/******/ (() => { // 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 "
\n

").concat(personalNoteLang, "

\n

").concat(personalNoteHintLang, "

\n\n \n\n ").concat(courseNotesShowAttachment ? "
\n \n\n
\n
\n \n
\n \n\n ").concat(item.personalNote && item.personalNote.attachment ? "
\n \n \n \n
") : '', "\n\n
\n
") : '', "\n\n
\n \n ").concat(item.personalNote && item.personalNote.note ? '' : '', "\n
\n
"); } return ''; } function handleDownloadCertificateHtml(result) { var title = downloadCertificateLang; var hint = enjoySharingYourCertificateWithOthersLang; var img = 'quiz.svg'; var otherHtml = ''; if (result && result !== '') { otherHtml = "\n ").concat(downloadLang, "\n "); } else { otherHtml = "\n \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 ").concat(showLang, "\n "); } else { otherHtml = "\n \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 += "
".concat(quiz.expire_time_message, "
"); } if (quiz.can_try) { otherHtml += "\n ").concat(quizPageLang, "\n "); } else { otherHtml += "\n \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 ").concat(coursePageLang, "\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
\n \n ").concat(coursePageLang, "\n
\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 += "
".concat(passwordLang, ": ").concat(session.password, "
"); } otherHtml += "\n
\n ").concat(joinTheClassLang, "\n ").concat(coursePageLang, "\n
\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 = "
"; html += ""); if (file.downloadable && file.downloadable !== '0') { html += "
\n ".concat(downloadTheFileLang, "\n ").concat(downloadLang, "\n
"); } html += "
"; html += handlePersonalNoteHtml(file); learningPageContent.html(html); } else if (file.downloadable && file.downloadable !== '0') { if (file.is_video) { var $html = "
"; $html += '
'; if (file.downloadable && file.downloadable !== '0') { $html += "
\n ".concat(downloadTheFileLang, "\n ").concat(downloadLang, "\n
"); } $html += "
"; $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 = "").concat(downloadLang, ""); 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 = '
'; _$html += handlePersonalNoteHtml(file); learningPageContent.html(_$html); var $videoCard1 = $('.js-other-content-video-player'); handleVideoByFileId(file.id, $videoCard1, function () {}); break; case 'secure_host': var $secureHosthtml = '
'; $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 = "").concat(showLang, ""); var _html2 = handleContentBoxHtml(_title, _hint, _img, _otherHtml); _html2 += handlePersonalNoteHtml(file); learningPageContent.html(_html2); break; } } feather.replace(); } function handleTextLessonHtml(textLesson) { var html = "
\n

".concat(textLesson.title, "

\n\n ").concat(textLesson.image ? "
\n \"").concat(textLesson.title,\n
") : '', "\n\n ").concat(textLesson.content, "\n
"); if (textLesson.attachments && Object.keys(textLesson.attachments).length) { html += "
\n

".concat(attachmentsLang, "

\n\n
\n "); Object.keys(textLesson.attachments).forEach(function (key) { var attachment = textLesson.attachments[key]; html += ""); }); html += "
\n
"; } 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 "
\n
\n
\n \"downloadable\n
\n\n

").concat(title, "

\n\n ").concat(hint, "\n\n ").concat(html !== null && html !== void 0 ? html : '', "\n
\n
"); } function addContentLoading() { var html = "
\n \"\"\n

".concat(pleaseWaitForTheContentLang, "

\n
"); learningPageContent.html(html); } function contentEmptyStateHtml() { var html = "
\n
\n \"\"\n
\n\n
\n

".concat(learningPageEmptyContentTitleLang, "

\n

").concat(learningPageEmptyContentHintLang, "

\n
\n
"); 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 = "
\n ".concat(path, "\n
"); $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 = ''; 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: '

' + sendAssignmentSuccessLang + '

', 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: '

' + saveAssignmentRateSuccessLang + '

', 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); /******/ })() ;