????

Your IP : 3.135.249.190


Current Path : /home/thenclexdoctor.com/public_html/public/assets/learning_page/
Upload File :
Current File : /home/thenclexdoctor.com/public_html/public/assets/learning_page/scripts.min.js

/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!****************************************************!*\
  !*** ./resources/js/parts/learningPage/scripts.js ***!
  \****************************************************/
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
(function ($) {
  $('body').on('click', '.panel-file-manager', function (e) {
    e.preventDefault();
    $(this).filemanager('file', {
      prefix: '/laravel-filemanager'
    });
  });
  var learningPageContent = $('#learningPageContent');

  // disable right click
  document.addEventListener('contextmenu', function (event) {
    return event.preventDefault();
  }, false);
  $(document).ready(function () {
    var allItems = $('.tab-item');
    if (allItems && allItems.length && defaultItemType && defaultItemType !== '' && defaultItemId && defaultItemId !== '') {
      var _iterator = _createForOfIteratorHelper(allItems),
        _step;
      try {
        for (_iterator.s(); !(_step = _iterator.n()).done;) {
          var item = _step.value;
          var $item = $(item);
          var type = $item.attr('data-type');
          var id = $item.attr('data-id');
          if (type === defaultItemType && id === defaultItemId) {
            $item.trigger('click');
            var collapse = $item.closest('.collapse');
            if (collapse) {
              collapse.collapse('show');
            }
          }
        }
      } catch (err) {
        _iterator.e(err);
      } finally {
        _iterator.f();
      }
    } else if (allItems && loadFirstContent && loadFirstContent !== 'false') {
      if (allItems.length) {
        var _item = allItems[0];
        var _$item = $(_item);
        _$item.trigger('click');
        var _collapse = _$item.closest('.collapse');
        if (_collapse) {
          _collapse.collapse('show');
        }
      } else {
        contentEmptyStateHtml();
      }
    }
  });
  $('body').on('click', '#collapseBtn', function () {
    var $tabs = $('.learning-page-tabs');
    $tabs.toggleClass('show');
  });
  if ($(window).width() < 992) {
    $('.learning-page-tabs').removeClass('show');
  }
  $('body').on('click', '.nav-item a', function () {
    var $tabs = $('.learning-page-tabs');
    if (!$tabs.hasClass('show')) {
      $tabs.addClass('show');
    }
  });
  $('body').on('click', '.tab-item', function () {
    var $this = $(this);
    if (!$this.hasClass('active')) {
      var type = $this.attr('data-type');
      var id = $this.attr('data-id');

      //
      $('.tab-item-info').slideUp();
      $('.tab-item').removeClass('active');
      $('.certificate-item').removeClass('active');
      $this.addClass('active');
      $this.find('.tab-item-info').slideDown();
      if ($(window).width() < 992) {
        $('.learning-page-tabs').removeClass('show');
      }
      if (type !== 'assignment') {
        addContentLoading();
        handleContent(id, type);
      }
    }
  });
  $('body').on('click', '#checkAgainSession', function () {
    var $this = $(this);
    var type = $this.attr('data-type');
    var id = $this.attr('data-id');
    addContentLoading();
    handleContent(id, type);
  });
  $('body').on('click', '.certificate-item', function () {
    var $this = $(this);
    $('.course-certificate-item').removeClass('active');
    $('.certificate-item').removeClass('active');
    $('.tab-item').removeClass('active');
    $this.addClass('active');
    var result = $this.attr('data-result');
    handleDownloadCertificateHtml(result);
  });
  $('body').on('click', '.course-certificate-item', function () {
    var $this = $(this);
    $('.course-certificate-item').removeClass('active');
    $('.certificate-item').removeClass('active');
    $('.tab-item').removeClass('active');
    $this.addClass('active');
    var id = $this.attr('data-course-certificate');
    handleCourseCertificateHtml(id);
  });
  function handleContent(itemId, itemType) {
    var data = {
      type: itemType,
      id: itemId
    };
    $.post('/course/learning/itemInfo', data, function (result) {
      if (itemType === 'session') {
        var session = result.session;
        if (session) {
          if (session.is_finished) {
            handleLiveSessionFinishedHtml(session);
          } else if (session.is_started) {
            handleLiveSessionHtml(session);
          } else {
            handleLiveSessionNotStartedHtml(session);
          }
        }
      } else if (itemType === 'file') {
        handleFileHtml(result.file); // if file is downloadable
      } else if (itemType === 'text_lesson') {
        handleTextLessonHtml(result.textLesson);
      } else if (itemType === 'quiz') {
        handleQuizHtml(result.quiz);
      }
    });
  }
  function handlePersonalNoteHtml(item) {
    if (courseNotesStatus === '1') {
      return "<div class=\"js-personal-notes-form learning-page-personal-note bg-white mt-15 p-10 rounded-sm\" data-item-id=\"".concat(item.id, "\" data-item-type=\"").concat(item.modelName, "\" data-course-id=\"").concat(item.webinar_id, "\">\n                <h4 class=\"font-14 font-weight-bold text-secondary\">").concat(personalNoteLang, "</h4>\n                <p class=\"mt-5 font-12 text-gray\">").concat(personalNoteHintLang, "</p>\n\n                <textarea name=\"notes\" rows=\"5\" class=\"form-control mt-5\">").concat(item.personalNote && item.personalNote.note ? item.personalNote.note : '', "</textarea>\n\n                ").concat(courseNotesShowAttachment ? "<div class=\"form-group mt-15\">\n                            <label class=\"input-label\">".concat(attachmentLang, "</label>\n\n                            <div class=\"input-group mr-10\">\n                                <div class=\"input-group-prepend\">\n                                    <button type=\"button\" class=\"input-group-text panel-file-manager\" data-input=\"personalNotesAttachment\" data-preview=\"holder\">\n                                        <i data-feather=\"upload\" width=\"18\" height=\"18\" class=\"text-white\"></i>\n                                    </button>\n                                </div>\n                                <input type=\"text\" name=\"attach\" id=\"personalNotesAttachment\" value=\"").concat(item.personalNote && item.personalNote.attachment ? item.personalNote.attachment : '', "\" class=\"form-control\" placeholder=\"\"/>\n\n                                ").concat(item.personalNote && item.personalNote.attachment ? "<div class=\"input-group-append\">\n                                            <a href=\"/course/personal-notes/".concat(item.personalNote.id, "/download-attachment\" target=\"_blank\" class=\"input-group-text\">\n                                                <i data-feather=\"download\" width=\"18\" height=\"18\" class=\"text-white\"></i>\n                                            </a>\n                                        </div>") : '', "\n\n                            </div>\n                        </div>") : '', "\n\n                <div class=\"d-flex align-items-center mt-15\">\n                    <button type=\"button\" class=\"js-save-personal-note btn btn-sm btn-primary\">").concat(saveNoteLang, "</button>\n                    ").concat(item.personalNote && item.personalNote.note ? '<button type="button" class="js-clear-personal-note btn btn-sm btn-danger ml-2">' + clearNoteLang + '</button>' : '', "\n                </div>\n            </div>");
    }
    return '';
  }
  function handleDownloadCertificateHtml(result) {
    var title = downloadCertificateLang;
    var hint = enjoySharingYourCertificateWithOthersLang;
    var img = 'quiz.svg';
    var otherHtml = '';
    if (result && result !== '') {
      otherHtml = "\n                <a href=\"/panel/quizzes/results/".concat(result, "/showCertificate\" target=\"_blank\" class=\"btn btn-primary btn-sm mt-15\">").concat(downloadLang, "</a>\n            ");
    } else {
      otherHtml = "\n                <button type=\"button\" disabled class=\"btn btn-primary btn-sm mt-15\">".concat(downloadLang, "</button>\n            ");
    }
    var html = handleContentBoxHtml(title, hint, img, otherHtml);
    learningPageContent.html(html);
  }
  function handleCourseCertificateHtml(id) {
    var title = downloadCertificateLang;
    var hint = enjoySharingYourCertificateWithOthersLang;
    var img = 'quiz.svg';
    var otherHtml = '';
    if (id && id !== '') {
      otherHtml = "\n                <a href=\"/panel/certificates/webinars/".concat(id, "/show\" target=\"_blank\" class=\"btn btn-primary btn-sm mt-15\">").concat(showLang, "</a>\n            ");
    } else {
      otherHtml = "\n                <button type=\"button\" disabled class=\"btn btn-primary btn-sm mt-15\">".concat(showLang, "</button>\n            ");
    }
    var html = handleContentBoxHtml(title, hint, img, otherHtml);
    learningPageContent.html(html);
  }
  function handleQuizHtml(quiz) {
    var title = quiz.title;
    var hint = goToTheQuizPageForMoreInformationLang;
    var img = 'quiz.svg';
    var otherHtml = '';
    if (quiz.has_expired) {
      title = expiredQuizLang;
      hint = quiz.expired_message;
    } else {
      if (quiz.expire_time_message && quiz.expire_time_message !== "null") {
        otherHtml += "<div class=\"mt-10 font-14 text-gray\">".concat(quiz.expire_time_message, "</div>");
      }
      if (quiz.can_try) {
        otherHtml += "\n                <a href=\"/panel/quizzes/".concat(quiz.id, "/start\" target=\"_blank\" class=\"btn btn-primary btn-sm mt-15\">").concat(quizPageLang, "</a>\n            ");
      } else {
        otherHtml += "\n                <button type=\"button\" class=\"js-cant-start-quiz-toast btn btn-primary btn-sm mt-15 disabled\">".concat(quizPageLang, "</button>\n            ");
      }
    }
    var html = handleContentBoxHtml(title, hint, img, otherHtml);
    html += handlePersonalNoteHtml(quiz);
    learningPageContent.html(html);
    feather.replace();
  }
  function handleLiveSessionFinishedHtml(session) {
    var title = sessionIsFinishedLang;
    var hint = sessionIsFinishedHintLang;
    var img = 'live_session.svg';
    var otherHtml = "\n                <a href=\"".concat(courseUrl, "\" class=\"btn btn-white btn-sm mt-15\">").concat(coursePageLang, "</a>\n        ");
    var html = handleContentBoxHtml(title, hint, img, otherHtml, 'mt-10');
    html += handlePersonalNoteHtml(session);
    learningPageContent.html(html);
    feather.replace();
  }
  function handleLiveSessionNotStartedHtml(session) {
    var title = sessionIsNotStartedYetLang;
    var hint = thisSessionWillBeStartedOnLang + ' ' + session.start_data;
    var img = 'live_session.svg';
    var otherHtml = "\n            <div class=\"d-flex align-items-center mt-15\">\n                <button type=\"button\" id=\"checkAgainSession\" data-type=\"session\" data-id=\"".concat(session.id, "\" class=\"btn btn-primary btn-sm \">").concat(checkAgainLang, "</button>\n                <a href=\"").concat(courseUrl, "\" class=\"btn btn-white btn-sm ml-10\">").concat(coursePageLang, "</a>\n            </div>\n        ");
    var html = handleContentBoxHtml(title, hint, img, otherHtml, 'mt-10');
    html += handlePersonalNoteHtml(session);
    learningPageContent.html(html);
    feather.replace();
  }
  function handleLiveSessionHtml(session) {
    var title = sessionIsLiveLang;
    var hint = youCanJoinTheLiveNowLang;
    var img = 'live_session.svg';
    var otherHtml = "";
    if (session.password) {
      otherHtml += "<div class=\"font-14 font-weight-500 text-gray mt-5\">".concat(passwordLang, ": ").concat(session.password, "</div>");
    }
    otherHtml += "\n            <div class=\"d-flex align-items-center mt-15\">\n                <a href=\"".concat(session.join_url, "\" target=\"_blank\" class=\"btn btn-primary btn-sm \">").concat(joinTheClassLang, "</a>\n                <a href=\"").concat(courseUrl, "\" class=\"btn btn-white btn-sm ml-10\">").concat(coursePageLang, "</a>\n            </div>\n        ");
    var html = handleContentBoxHtml(title, hint, img, otherHtml, 'mt-10');
    html += handlePersonalNoteHtml(session);
    learningPageContent.html(html);
    feather.replace();
  }
  function handleFileHtml(file) {
    if (file.online_viewer && file.online_viewer !== '0' || file.downloadable && file.downloadable !== '0') {
      if (file.online_viewer && file.online_viewer !== '0') {
        var html = "<div class=\"d-flex flex-column p-10 h-100\">";
        html += "<iframe src=\"/ViewerJS/index.html#".concat(file.file_path, "\" class=\"file-online-viewer rounded-sm ").concat(file.downloadable && file.downloadable !== '0' ? 'has-download-card' : '', "\" frameborder=\"0\" allowfullscreen></iframe>");
        if (file.downloadable && file.downloadable !== '0') {
          html += "<div class=\"d-flex align-items-center justify-content-between rounded-sm mt-15 p-15 border-dashed-gray300\">\n                                <span class=\"font-weight-bold text-dark\">".concat(downloadTheFileLang, "</span>\n                                <a href=\"").concat(courseUrl, "/file/").concat(file.id, "/download\" class=\"btn btn-primary btn-sm\" target=\"_blank\">").concat(downloadLang, "</a>\n                            </div>");
        }
        html += "</div>";
        html += handlePersonalNoteHtml(file);
        learningPageContent.html(html);
      } else if (file.downloadable && file.downloadable !== '0') {
        if (file.is_video) {
          var $html = "<div class=\"js-video-and-download d-flex flex-column p-10 h-100\">";
          $html += '<div class="learning-content-video-player w-100"></div>';
          if (file.downloadable && file.downloadable !== '0') {
            $html += "<div class=\"d-flex align-items-center justify-content-between rounded-sm mt-15 p-15 border-dashed-gray300\">\n                                <span class=\"font-weight-bold text-dark\">".concat(downloadTheFileLang, "</span>\n                                <a href=\"").concat(courseUrl, "/file/").concat(file.id, "/download\" class=\"btn btn-primary btn-sm\" target=\"_blank\">").concat(downloadLang, "</a>\n                            </div>");
          }
          $html += "</div>";
          $html += handlePersonalNoteHtml(file);
          learningPageContent.html($html);
          var $videoCard = $('.js-video-and-download .learning-content-video-player');
          handleVideoByFileId(file.id, $videoCard, function () {});
        } else {
          var title = downloadTheFileLang;
          var hint = file.title;
          var img = 'download.svg';
          var otherHtml = "<a href=\"".concat(courseUrl, "/file/").concat(file.id, "/download\" class=\"btn btn-primary btn-sm mt-15\" target=\"_blank\">").concat(downloadLang, "</a>");
          var _html = handleContentBoxHtml(title, hint, img, otherHtml);
          _html += handlePersonalNoteHtml(file);
          learningPageContent.html(_html);
        }
      }
    } else {
      switch (file.storage) {
        case 'upload':
        case 'youtube':
        case 'vimeo':
        case 'external_link':
        case 's3':
          var _$html = '<div class="js-other-content-video-player learning-content-video-player w-100"></div>';
          _$html += handlePersonalNoteHtml(file);
          learningPageContent.html(_$html);
          var $videoCard1 = $('.js-other-content-video-player');
          handleVideoByFileId(file.id, $videoCard1, function () {});
          break;
        case 'secure_host':
          var $secureHosthtml = '<div class="js-secure-host-video-player learning-content-video-player w-100"></div>';
          $secureHosthtml += handlePersonalNoteHtml(file);
          learningPageContent.html($secureHosthtml);
          var $videoCard2 = $('.js-secure-host-video-player');
          handleVideoByFileId(file.id, $videoCard2, function () {});
          break;
        case 'google_drive':
        case 'iframe':
          handleFileIframe(file);
          break;
        case 'upload_archive':
          var _title = showHtmlFileLang;
          var _hint = file.title;
          var _img = 'download.svg';
          var _otherHtml = "<a href=\"".concat(courseUrl, "/file/").concat(file.id, "/showHtml\" target=\"_blank\" class=\"btn btn-primary btn-sm mt-15\">").concat(showLang, "</a>");
          var _html2 = handleContentBoxHtml(_title, _hint, _img, _otherHtml);
          _html2 += handlePersonalNoteHtml(file);
          learningPageContent.html(_html2);
          break;
      }
    }
    feather.replace();
  }
  function handleTextLessonHtml(textLesson) {
    var html = "<div class=\"text-lesson-content p-15 p-lg-30\">\n                    <h4 class=\"font-16 font-weight-bold text-dark\">".concat(textLesson.title, "</h4>\n\n                    ").concat(textLesson.image ? "<div class=\"pb-5 mt-15 main-image rounded-lg w-100\">\n                                <img src=\"".concat(textLesson.image, "\" class=\"bg-gray200\" alt=\"").concat(textLesson.title, "\"/>\n                            </div>") : '', "\n\n                    ").concat(textLesson.content, "\n                </div>");
    if (textLesson.attachments && Object.keys(textLesson.attachments).length) {
      html += "<div class=\"shadow-sm rounded-lg bg-white px-15 px-md-25 py-20 mt-20\">\n                    <h3 class=\" font-16 font-weight-bold text-dark-blue\">".concat(attachmentsLang, "</h3>\n\n                    <div class=\"row mt-10\">\n                    ");
      Object.keys(textLesson.attachments).forEach(function (key) {
        var attachment = textLesson.attachments[key];
        html += "<div class=\"col-12 col-lg-3 mt-10 mt-lg-0\">\n                            <a href=\"".concat(courseUrl, "/file/").concat(attachment.file.id, "/download\" class=\"d-flex align-items-center p-10 border border-gray200 rounded-sm\">\n                                <span class=\"chapter-icon bg-gray300 mr-10\">\n                                    <i data-feather=\"download-cloud\" class=\"text-gray\" width=\"16\" height=\"16\"></i>\n                                </span>\n\n                                <div class=\"\">\n                                    <span class=\"font-weight-500 font-14 text-dark-blue d-block\">").concat(attachment.file.title, "</span>\n                                    <span class=\"font-12 text-gray d-block\">").concat(attachment.file.file_type, " | ").concat(attachment.file.volume, "</span>\n                                </div>\n                            </a>\n                    </div>");
      });
      html += "</div>\n                </div>";
    }
    html += handlePersonalNoteHtml(textLesson);
    learningPageContent.html(html);
    feather.replace();
  }
  function handleContentBoxHtml(title, hint, img) {
    var html = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
    var titleClassName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
    return "<div class=\"d-flex align-items-center justify-content-center w-100 h-100\">\n                    <div class=\"learning-content-box d-flex align-items-center justify-content-center flex-column p-15 p-lg-30 rounded-lg\">\n                        <div class=\"learning-content-box-icon\">\n                            <img src=\"/assets/default/img/learning/".concat(img, "\" alt=\"downloadable icon\">\n                        </div>\n\n                        <h4 class=\"font-16 font-weight-bold text-dark ").concat(titleClassName !== null && titleClassName !== void 0 ? titleClassName : '', "\">").concat(title, "</h4>\n\n                        <span class=\"font-14 font-weight-500 text-gray mt-5\">").concat(hint, "</span>\n\n                        ").concat(html !== null && html !== void 0 ? html : '', "\n                    </div>\n                </div>");
  }
  function addContentLoading() {
    var html = "<div class=\"learning-content-loading d-flex align-items-center justify-content-center flex-column w-100 h-100\">\n            <img src=\"/assets/default/img/loading.gif\" alt=\"\">\n            <p class=\"mt-10\">".concat(pleaseWaitForTheContentLang, "</p>\n        </div>");
    learningPageContent.html(html);
  }
  function contentEmptyStateHtml() {
    var html = "<div class=\"learning-page-forum-empty d-flex align-items-center justify-content-center flex-column\">\n            <div class=\"learning-page-forum-empty-icon d-flex align-items-center justify-content-center\">\n                <img src=\"/assets/default/img/learning/content-empty.svg\" class=\"img-fluid\" alt=\"\">\n            </div>\n\n            <div class=\"d-flex align-items-center flex-column mt-10 text-center\">\n                <h3 class=\"font-20 font-weight-bold text-dark-blue text-center\">".concat(learningPageEmptyContentTitleLang, "</h3>\n                <p class=\"font-14 font-weight-500 text-gray mt-5 text-center\">").concat(learningPageEmptyContentHintLang, "</p>\n            </div>\n        </div>");
    learningPageContent.html(html);
  }
  function handleFileIframe(file) {
    $.post('/course/getFilePath', {
      file_id: file.id
    }, function (result) {
      if (result && result.code === 200) {
        var storage = result.storage,
          path = result.path;
        var $iframeHtml = "<div class=\"learning-content-iframe\">\n                            ".concat(path, "\n                        </div>");
        $iframeHtml += handlePersonalNoteHtml(file);
        learningPageContent.html($iframeHtml);
        feather.replace();
      } else {
        $.toast({
          heading: notAccessToastTitleLang,
          text: notAccessToastMsgLang,
          bgColor: '#f63c3c',
          textColor: 'white',
          hideAfter: 10000,
          position: 'bottom-right',
          icon: 'error'
        });
      }
    }).fail(function (err) {
      $.toast({
        heading: notAccessToastTitleLang,
        text: notAccessToastMsgLang,
        bgColor: '#f63c3c',
        textColor: 'white',
        hideAfter: 10000,
        position: 'bottom-right',
        icon: 'error'
      });
    });
  }
  $('body').on('change', '.js-passed-lesson-toggle', function (e) {
    var $this = $(this);
    var course_id = $this.val();
    var item = $this.attr('data-item');
    var item_id = $this.attr('data-item-id');
    var status = this.checked;
    var data = {
      item: item,
      item_id: item_id,
      status: status
    };
    $.post('/course/' + course_id + '/learningStatus', data, function (result) {
      $.toast({
        heading: '',
        text: learningToggleLangSuccess,
        bgColor: '#43d477',
        textColor: 'white',
        hideAfter: 10000,
        position: 'bottom-right',
        icon: 'success'
      });

      /*setTimeout(() => {
          window.location.reload();
      }, 500);*/
    }).fail(function (err) {
      $this.prop('checked', !status);
      $.toast({
        heading: '',
        text: learningToggleLangError,
        bgColor: '#f63c3c',
        textColor: 'white',
        hideAfter: 10000,
        position: 'bottom-right',
        icon: 'error'
      });
    });
  });
  $('body').on('click', '.js-sequence-content-error-modal', function (e) {
    e.preventDefault();
    var passedError = $(this).attr('data-passed-error');
    var accessDaysError = $(this).attr('data-access-days-error');
    var html = '<ul class="list-group-custom">\n';
    if (passedError) {
      html += '<li class="font-14 mb-10">' + passedError + '</li>\n';
    }
    if (accessDaysError) {
      html += '<li class="font-14">' + accessDaysError + '</li>\n';
    }
    html += '</ul>';
    Swal.fire({
      icon: 'error',
      title: sequenceContentErrorModalTitle,
      html: html,
      showCancelButton: false,
      showConfirmButton: false,
      customClass: {
        content: 'p-0 text-left'
      },
      width: '30rem'
    });
  });
  $('body').on('click', '.js-save-history-message', function () {
    var $this = $(this);
    var $form = $this.closest('form');
    var action = $form.attr('action');
    var data = $form.serializeObject();
    $this.addClass('loadingbar primary').prop('disabled', true);
    $form.find('.invalid-feedback').text('');
    $form.find('.is-invalid').removeClass('is-invalid');
    $.post(action, data, function (result) {
      if (result && result.code === 200) {
        Swal.fire({
          icon: 'success',
          html: '<h3 class="font-20 text-center text-dark-blue">' + sendAssignmentSuccessLang + '</h3>',
          showConfirmButton: false
        });
        setTimeout(function () {
          window.location.reload();
        }, 500);
      } else if (result && result.code === 401) {
        $.toast({
          heading: result.errors.title,
          text: result.errors.msg,
          bgColor: '#f63c3c',
          textColor: 'white',
          hideAfter: 10000,
          position: 'bottom-right',
          icon: 'error'
        });
        $this.removeClass('loadingbar primary').prop('disabled', false);
      }
    }).fail(function (err) {
      $this.removeClass('loadingbar primary').prop('disabled', false);
      var errors = err.responseJSON;
      if (errors && errors.errors) {
        Object.keys(errors.errors).forEach(function (key) {
          var error = errors.errors[key];
          var element = $form.find('[name="' + key + '"]');
          element.addClass('is-invalid');
          element.parent().find('.invalid-feedback').text(error[0]);
        });
      }
    });
  });
  $('body').on('click', '.js-save-history-rate', function () {
    var $this = $(this);
    var $form = $this.closest('form');
    var action = $form.attr('action');
    var data = $form.serializeObject();
    $this.addClass('loadingbar primary').prop('disabled', true);
    $form.find('.invalid-feedback').text('');
    $form.find('.is-invalid').removeClass('is-invalid');
    $.post(action, data, function (result) {
      if (result && result.code === 200) {
        Swal.fire({
          icon: 'success',
          html: '<h3 class="font-20 text-center text-dark-blue">' + saveAssignmentRateSuccessLang + '</h3>',
          showConfirmButton: false
        });
        setTimeout(function () {
          window.location.reload();
        }, 500);
      } else if (result && result.code === 401) {
        $.toast({
          heading: result.errors.title,
          text: result.errors.msg,
          bgColor: '#f63c3c',
          textColor: 'white',
          hideAfter: 10000,
          position: 'bottom-right',
          icon: 'error'
        });
        $this.removeClass('loadingbar primary').prop('disabled', false);
      }
    }).fail(function (err) {
      $this.removeClass('loadingbar primary').prop('disabled', false);
      var errors = err.responseJSON;
      if (errors && errors.errors) {
        Object.keys(errors.errors).forEach(function (key) {
          var error = errors.errors[key];
          var element = $form.find('[name="' + key + '"]');
          element.addClass('is-invalid');
          element.parent().find('.invalid-feedback').text(error[0]);
        });
      }
    });
  });
  function errorToast(heading, text) {
    $.toast({
      heading: heading,
      text: text,
      bgColor: '#f63c3c',
      textColor: 'white',
      hideAfter: 10000,
      position: 'bottom-right',
      icon: 'error'
    });
  }
  $('body').on('click', '.js-not-access-toast', function (e) {
    e.preventDefault();
    if (notAccessToastTitleLang && notAccessToastMsgLang) {
      errorToast(notAccessToastTitleLang, notAccessToastMsgLang);
    }
  });
  $('body').on('click', '.js-cant-start-quiz-toast', function (e) {
    e.preventDefault();
    if (cantStartQuizToastTitleLang && cantStartQuizToastMsgLang) {
      errorToast(cantStartQuizToastTitleLang, cantStartQuizToastMsgLang);
    }
  });
  $('body').on('click', '.js-save-personal-note', function (e) {
    e.preventDefault();
    var $this = $(this);
    var $form = $this.closest('.js-personal-notes-form');
    var courseId = $form.attr('data-course-id');
    var itemId = $form.attr('data-item-id');
    var itemType = $form.attr('data-item-type');
    var data = {
      course_id: courseId,
      item_id: itemId,
      item_type: itemType,
      note: $form.find('textarea[name="notes"]').val(),
      attachment: $form.find('input[name="attach"]').val()
    };
    $this.addClass('loadingbar primary').prop('disabled', true);
    $.post('/course/learning/personalNotes', data, function (result) {
      if (result && result.code === 200) {
        $.toast({
          heading: personalNoteLang,
          text: personalNoteStoredSuccessfullyLang,
          bgColor: '#43d477',
          textColor: 'white',
          hideAfter: 10000,
          position: 'bottom-right',
          icon: 'success'
        });
      }
      $this.removeClass('loadingbar primary').prop('disabled', false);
    }).fail(function () {
      $.toast({
        heading: oopsLang,
        text: somethingWentWrongLang,
        bgColor: '#f63c3c',
        textColor: 'white',
        hideAfter: 10000,
        position: 'bottom-right',
        icon: 'error'
      });
      $this.removeClass('loadingbar primary').prop('disabled', false);
    });
  });
  $('body').on('click', '.js-clear-personal-note', function (e) {
    e.preventDefault();
    var $this = $(this);
    var $form = $this.closest('.js-personal-notes-form');
    $form.find('textarea[name="notes"]').val('');
    $form.find('input[name="attach"]').val('');
  });
})(jQuery);
/******/ })()
;

Page not found | The NCLEX Doctor

Page not found!

Sorry, this page is not available...