PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / js / dist / frontend / single-course.js

single-course.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at assets/js/dist/frontend/single-course.js

3,025 lines 104.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/apps/js/frontend/material.js"
5 /*!*************************************************!*\
6 !*** ./assets/src/apps/js/frontend/material.js ***!
7 \*************************************************/
8 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ "default": () => (/* binding */ lpMaterialsLoad)
14 /* harmony export */ });
15 /* harmony import */ var _js_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../js/utils.js */ "./assets/src/js/utils.js");
16
17 function lpMaterialsLoad() {
18 document.addEventListener('click', function (e) {
19 const target = e.target;
20 if (target.classList.contains('lp-loadmore-material')) {
21 const loadMoreButton = target;
22 const lpTarget = target.closest('.lp-target');
23 const dataSend = window.lpAJAXG.getDataSetCurrent(lpTarget);
24 dataSend.args.paged++;
25 _js_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(loadMoreButton, 1);
26 const callBack = {
27 success: response => {
28 const {
29 status,
30 message,
31 data
32 } = response;
33 if (status === 'success') {
34 const tableBody = lpTarget.querySelector('table.course-material-table tbody');
35 tableBody.insertAdjacentHTML('beforeend', data.content);
36 if (data.paged === data.total_pages) {
37 loadMoreButton.remove();
38 }
39 window.lpAJAXG.setDataSetCurrent(lpTarget, dataSend);
40 } else {
41 console.error(message);
42 }
43 },
44 error: error => {
45 console.error(error);
46 },
47 completed: () => {
48 _js_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(loadMoreButton, 0);
49 }
50 };
51 window.lpAJAXG.fetchAJAX(dataSend, callBack);
52 }
53 });
54 }
55
56 /***/ },
57
58 /***/ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js"
59 /*!**********************************************************************!*\
60 !*** ./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js ***!
61 \**********************************************************************/
62 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
63
64 "use strict";
65 __webpack_require__.r(__webpack_exports__);
66 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
67 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
68 /* harmony export */ });
69 /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/lp-modal-overlay */ "./assets/src/apps/js/utils/lp-modal-overlay.js");
70
71 const lpModalOverlayCompleteItem = {
72 elBtnFinishCourse: null,
73 elBtnCompleteItem: null,
74 init() {
75 if (!_utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].init()) {
76 return;
77 }
78 if (undefined === lpGlobalSettings || 'yes' !== lpGlobalSettings.option_enable_popup_confirm_finish) {
79 return;
80 }
81 this.elBtnFinishCourse = document.querySelectorAll('.lp-btn-finish-course');
82 this.elBtnCompleteItem = document.querySelector('.lp-btn-complete-item');
83 if (this.elBtnCompleteItem) {
84 this.elBtnCompleteItem.addEventListener('click', e => {
85 e.preventDefault();
86 const form = e.target.closest('form');
87 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show();
88 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title);
89 // ESC html
90 const div = document.createElement('div');
91 div.appendChild(document.createTextNode(form.dataset.confirm));
92 const contentModal = div.innerHTML;
93 // End ESC html
94 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + contentModal + '</div>');
95 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = () => {
96 form.submit();
97 };
98 });
99 }
100 if (this.elBtnFinishCourse) {
101 this.elBtnFinishCourse.forEach(element => element.addEventListener('click', e => {
102 e.preventDefault();
103 const form = e.target.closest('form');
104 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show();
105 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title);
106 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + form.dataset.confirm + '</div>');
107 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = () => {
108 form.submit();
109 };
110 }));
111 }
112 }
113 };
114 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlayCompleteItem);
115
116 /***/ },
117
118 /***/ "./assets/src/apps/js/frontend/single-course/index.js"
119 /*!************************************************************!*\
120 !*** ./assets/src/apps/js/frontend/single-course/index.js ***!
121 \************************************************************/
122 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
123
124 "use strict";
125 __webpack_require__.r(__webpack_exports__);
126 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
127 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
128 /* harmony export */ });
129 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
130 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
131 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
132 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__);
133 /* harmony import */ var _learnpress_quiz__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @learnpress/quiz */ "@learnpress/quiz");
134 /* harmony import */ var _learnpress_quiz__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_learnpress_quiz__WEBPACK_IMPORTED_MODULE_2__);
135 /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./store */ "./assets/src/apps/js/frontend/single-course/store/index.js");
136 /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_store__WEBPACK_IMPORTED_MODULE_3__);
137 /* harmony import */ var _single_curriculum_components_sidebar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../single-curriculum/components/sidebar */ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js");
138
139
140
141
142 // Use toggle in Curriculum tab.
143
144 class SingleCourse extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component {
145 render() {
146 return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null);
147 }
148 }
149 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SingleCourse);
150 function run() {
151 (0,_single_curriculum_components_sidebar__WEBPACK_IMPORTED_MODULE_4__.Sidebar)();
152 }
153 document.addEventListener('DOMContentLoaded', () => {
154 run();
155 });
156
157 /***/ },
158
159 /***/ "./assets/src/apps/js/frontend/single-course/store/index.js"
160 /*!******************************************************************!*\
161 !*** ./assets/src/apps/js/frontend/single-course/store/index.js ***!
162 \******************************************************************/
163 () {
164
165 /**
166 * Created by tu on 9/19/19.
167 */
168
169 /***/ },
170
171 /***/ "./assets/src/apps/js/frontend/single-curriculum/components/search.js"
172 /*!****************************************************************************!*\
173 !*** ./assets/src/apps/js/frontend/single-curriculum/components/search.js ***!
174 \****************************************************************************/
175 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
176
177 "use strict";
178 __webpack_require__.r(__webpack_exports__);
179 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
180 /* harmony export */ searchCourseContent: () => (/* binding */ searchCourseContent)
181 /* harmony export */ });
182 const searchCourseContent = () => {
183 const popup = document.querySelector('#popup-course');
184 const list = document.querySelector('#learn-press-course-curriculum');
185 if (popup && list) {
186 const items = list.querySelector('.curriculum-sections');
187 const form = popup.querySelector('.search-course');
188 const search = popup.querySelector('.search-course input[type="text"]');
189 if (!search || !items || !form) {
190 return;
191 }
192 const sections = items.querySelectorAll('li.section');
193 const dataItems = items.querySelectorAll('li.course-item');
194 const dataSearch = [];
195 dataItems.forEach(item => {
196 const itemID = item.dataset.id;
197 const name = item.querySelector('.item-name');
198 dataSearch.push({
199 id: itemID,
200 name: name ? name.textContent.toLowerCase() : ''
201 });
202 });
203 const submit = event => {
204 event.preventDefault();
205 const inputVal = search.value;
206 form.classList.add('searching');
207 if (!inputVal) {
208 form.classList.remove('searching');
209 }
210 const outputs = [];
211 dataSearch.forEach(i => {
212 if (!inputVal || i.name.match(inputVal.toLowerCase())) {
213 outputs.push(i.id);
214 dataItems.forEach(c => {
215 if (outputs.indexOf(c.dataset.id) !== -1) {
216 c.classList.remove('hide-if-js');
217 } else {
218 c.classList.add('hide-if-js');
219 }
220 });
221 }
222 });
223 sections.forEach(section => {
224 const listItem = section.querySelectorAll('.course-item');
225 const isTrue = [];
226 listItem.forEach(a => {
227 if (outputs.includes(a.dataset.id)) {
228 isTrue.push(a.dataset.id);
229 }
230 });
231 if (isTrue.length === 0) {
232 section.classList.add('hide-if-js');
233 } else {
234 section.classList.remove('hide-if-js');
235 }
236 });
237 };
238 const clear = form.querySelector('.clear');
239 if (clear) {
240 clear.addEventListener('click', e => {
241 e.preventDefault();
242 search.value = '';
243 submit(e);
244 });
245 }
246 form.addEventListener('submit', submit);
247 search.addEventListener('keyup', submit);
248 }
249 };
250
251 /***/ },
252
253 /***/ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js"
254 /*!*****************************************************************************!*\
255 !*** ./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js ***!
256 \*****************************************************************************/
257 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
258
259 "use strict";
260 __webpack_require__.r(__webpack_exports__);
261 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
262 /* harmony export */ Sidebar: () => (/* binding */ Sidebar)
263 /* harmony export */ });
264 const $ = jQuery;
265 const {
266 throttle
267 } = lodash;
268 const Sidebar = () => {
269 // Tungnx - Show/hide sidebar curriculumn
270 const elSidebarToggle = document.querySelector('#sidebar-toggle');
271
272 // For style of theme
273 const toggleSidebar = toggle => {
274 $('body').removeClass('lp-sidebar-toggle__open');
275 $('body').removeClass('lp-sidebar-toggle__close');
276 if (toggle) {
277 $('body').addClass('lp-sidebar-toggle__close');
278 } else {
279 $('body').addClass('lp-sidebar-toggle__open');
280 }
281 };
282
283 // For lp and theme
284 if (elSidebarToggle) {
285 if ($(window).innerWidth() <= 768) {
286 elSidebarToggle.setAttribute('checked', 'checked');
287 } else if (LP.Cookies.get('sidebar-toggle')) {
288 elSidebarToggle.setAttribute('checked', 'checked');
289 } else {
290 elSidebarToggle.removeAttribute('checked');
291 }
292 }
293 // End editor by tungnx
294
295 // Code for old curriculum
296 /*const $curriculum = $( '#learn-press-course-curriculum' );
297 $curriculum.find( '.section-desc' ).each( ( i, el ) => {
298 const a = $( '<span class="show-desc"></span>' ).on( 'click', () => {
299 b.toggleClass( 'c' );
300 } );
301 const b = $( el ).siblings( '.section-title' ).append( a );
302 } );*/
303
304 // Code for old curriculum
305 /*$( '.section' ).each( function() {
306 const $section = $( this ),
307 $toggle = $section.find( '.section-left' );
308 $toggle.on( 'click', function() {
309 const isClose = $section.toggleClass( 'closed' ).hasClass( 'closed' );
310 const sections = LP.Cookies.get( 'closed-section-' + lpGlobalSettings.post_id ) || [];
311 const sectionId = parseInt( $section.data( 'section-id' ) );
312 const at = sections.findIndex( ( id ) => {
313 return id == sectionId;
314 } );
315 if ( isClose ) {
316 sections.push( parseInt( $section.data( 'section-id' ) ) );
317 } else {
318 sections.splice( at, 1 );
319 }
320 LP.Cookies.remove( 'closed-section-(.*)' );
321 LP.Cookies.set( 'closed-section-' + lpGlobalSettings.post_id, [ ...new Set( sections ) ] );
322 } );
323 } );*/
324
325 document.addEventListener('click', e => {
326 if (e.target.id === 'sidebar-toggle') {
327 LP.Cookies.set('sidebar-toggle', e.target.checked ? true : false);
328 toggleSidebar(LP.Cookies.get('sidebar-toggle'));
329 }
330 });
331 };
332
333 /***/ },
334
335 /***/ "./assets/src/apps/js/frontend/single-curriculum/scrolltoitem.js"
336 /*!***********************************************************************!*\
337 !*** ./assets/src/apps/js/frontend/single-curriculum/scrolltoitem.js ***!
338 \***********************************************************************/
339 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
340
341 "use strict";
342 __webpack_require__.r(__webpack_exports__);
343 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
344 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
345 /* harmony export */ });
346 /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils/lp-modal-overlay */ "./assets/src/apps/js/utils/lp-modal-overlay.js");
347
348 const $ = jQuery;
349 const scrollToItemCurrent = {
350 init() {
351 this.scrollToItemViewing = function () {
352 const elItemViewing = $('.viewing-course-item');
353 if (elItemViewing.length) {
354 const elCourseCurriculumn = $('#learn-press-course-curriculum');
355 const heightCourseItemContentHeader = $('#popup-sidebar').outerHeight();
356 const heightSectionTitle = $('.section-title').outerHeight();
357 const heightSectionHeader = $('.section-header').outerHeight();
358 const regex = new RegExp('^viewing-course-item-([0-9].*)');
359 const classList = elItemViewing.attr('class');
360 const classArr = classList.split(/\s+/);
361 let idItem = 0;
362 $.each(classArr, function (i, className) {
363 const compare = regex.exec(className);
364 if (compare) {
365 idItem = compare[1];
366 return false;
367 }
368 });
369 if (0 === idItem) {
370 return;
371 }
372 const elItemCurrent = $('.course-item-' + idItem);
373 elItemCurrent.addClass('current');
374 const offSetTop = elItemCurrent.offset().top;
375 const offset = elItemCurrent.offset().top - elCourseCurriculumn.offset().top + elCourseCurriculumn.scrollTop();
376 elCourseCurriculumn.animate({
377 scrollTop: LP.Hook.applyFilters('scroll-item-current', offset - heightSectionHeader)
378 }, 800);
379 }
380 };
381 this.scrollToItemViewing();
382 }
383 };
384 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (scrollToItemCurrent);
385
386 /***/ },
387
388 /***/ "./assets/src/apps/js/frontend/single-curriculum/skeleton.js"
389 /*!*******************************************************************!*\
390 !*** ./assets/src/apps/js/frontend/single-curriculum/skeleton.js ***!
391 \*******************************************************************/
392 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
393
394 "use strict";
395 __webpack_require__.r(__webpack_exports__);
396 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
397 /* harmony export */ "default": () => (/* binding */ courseCurriculumSkeleton)
398 /* harmony export */ });
399 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
400 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
401 /* harmony import */ var _scrolltoitem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./scrolltoitem */ "./assets/src/apps/js/frontend/single-curriculum/scrolltoitem.js");
402 /* harmony import */ var _components_search__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/search */ "./assets/src/apps/js/frontend/single-curriculum/components/search.js");
403 // Rest API load content in Tab Curriculum - Nhamdv.
404
405 //import apiFetch from '@wordpress/api-fetch';
406
407
408 function courseCurriculumSkeleton(courseID = '') {
409 let idItemViewing = 0;
410 const elItemViewing = document.querySelector('.viewing-course-item');
411 if (elItemViewing) {
412 const regex = new RegExp('^viewing-course-item-([0-9].*)');
413 const classList = elItemViewing.classList;
414 classList.forEach(function (className) {
415 const compare = regex.exec(className);
416 if (compare) {
417 idItemViewing = compare[1];
418 return false;
419 }
420 });
421 }
422 let isLoadingItems = false;
423 let isLoadingSections = false;
424 const Sekeleton = () => {
425 const elementCurriculum = document.querySelector('.learnpress-course-curriculum');
426 if (!elementCurriculum) {
427 return;
428 }
429 getResponse(elementCurriculum);
430 };
431 const getResponse = async ele => {
432 const skeleton = ele.querySelector('.lp-skeleton-animation');
433 const itemID = ele.dataset.id;
434 const sectionID = ele.dataset.section;
435 try {
436 const page = 1;
437 let url = lpData.lp_rest_url + 'lp/v1/lazy-load/course-curriculum/';
438 url = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)(url, {
439 courseId: courseID || lpGlobalSettings.post_id || '',
440 page,
441 sectionID: sectionID || '',
442 idItemViewing
443 });
444 let paramsFetch = {};
445 if (0 !== parseInt(lpData.user_id)) {
446 paramsFetch = {
447 headers: {
448 'X-WP-Nonce': lpData.nonce
449 }
450 };
451 }
452 let response = await fetch(url, {
453 method: 'GET',
454 ...paramsFetch
455 });
456 response = await response.json();
457 const {
458 data,
459 status,
460 message
461 } = response;
462 const section_ids = data.section_ids;
463 if (status === 'error') {
464 throw new Error(message || 'Error');
465 }
466 const returnData = data.content;
467 if (sectionID) {
468 if (section_ids && !section_ids.includes(sectionID)) {
469 const response2 = await getResponsive('', page + 1, sectionID);
470 if (response2) {
471 const {
472 data2,
473 pages2,
474 page2
475 } = response2;
476 await parseContentItems({
477 ele,
478 returnData,
479 sectionID,
480 itemID,
481 data2,
482 pages2,
483 page2
484 });
485 }
486 } else {
487 await parseContentItems({
488 ele,
489 returnData,
490 sectionID,
491 itemID
492 });
493 }
494 } else {
495 returnData && ele.insertAdjacentHTML('beforeend', returnData);
496 }
497 } catch (error) {
498 ele.insertAdjacentHTML('beforeend', `<div class="lp-ajax-message error" style="display:block">${error.message || 'Error: Query lp/v1/lazy-load/course-curriculum'}</div>`);
499 }
500 skeleton && skeleton.remove();
501 (0,_components_search__WEBPACK_IMPORTED_MODULE_2__.searchCourseContent)();
502 };
503 const parseContentItems = async ({
504 ele,
505 returnData,
506 sectionID,
507 itemID,
508 data2,
509 pages2,
510 page2
511 }) => {
512 const parser = new DOMParser();
513 const doc = parser.parseFromString(returnData, 'text/html');
514 if (data2) {
515 const sections = doc.querySelector('.curriculum-sections');
516 const loadMoreBtn = doc.querySelector('.curriculum-more__button');
517 if (loadMoreBtn) {
518 if (pages2 <= page2) {
519 loadMoreBtn.remove();
520 } else {
521 loadMoreBtn.dataset.page = page2;
522 }
523 }
524 sections.insertAdjacentHTML('beforeend', data2);
525 }
526 const section = doc.querySelector(`[data-section-id="${sectionID}"]`);
527 if (section) {
528 const items = section.querySelectorAll('.course-item');
529 const item_ids = [...items].map(item => item.dataset.id);
530 const sectionContent = section.querySelector('.section-content');
531 const itemLoadMore = section.querySelector('.section-item__loadmore');
532 if (itemID && !item_ids.includes(itemID)) {
533 const responseItem = await getResponsiveItem('', 2, sectionID, itemID);
534 const {
535 data3,
536 pages3,
537 paged3,
538 page
539 } = responseItem;
540 if (pages3 <= paged3 || pages3 <= page) {
541 itemLoadMore.remove();
542 } else {
543 itemLoadMore.dataset.page = page;
544 }
545 if (data3 && sectionContent) {
546 sectionContent.insertAdjacentHTML('beforeend', data3);
547 }
548 }
549 }
550 ele.insertAdjacentHTML('beforeend', doc.body.innerHTML);
551 _scrolltoitem__WEBPACK_IMPORTED_MODULE_1__["default"].init();
552 };
553 const getResponsiveItem = async (returnData, paged, sectionID, itemID) => {
554 let url = lpData.lp_rest_url + 'lp/v1/lazy-load/course-curriculum-items/';
555 url = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)(url, {
556 sectionId: sectionID || '',
557 page: paged
558 });
559 let paramsFetch = {};
560 if (0 !== parseInt(lpData.user_id)) {
561 paramsFetch = {
562 headers: {
563 'X-WP-Nonce': lpData.nonce
564 }
565 };
566 }
567 let response = await fetch(url, {
568 method: 'GET',
569 ...paramsFetch
570 });
571 response = await response.json();
572 const {
573 data,
574 status,
575 pages,
576 message
577 } = response;
578 const {
579 page
580 } = data;
581 let item_ids;
582 if (status === 'success') {
583 const dataTmp = data.content;
584 item_ids = data.item_ids;
585 returnData += dataTmp;
586 if (sectionID && item_ids && itemID && !item_ids.includes(itemID)) {
587 return getResponsiveItem(returnData, paged + 1, sectionID, itemID);
588 }
589 }
590 isLoadingItems = false;
591 return {
592 data3: returnData,
593 pages3: pages || data.pages,
594 status3: status,
595 message3: message,
596 page: page || 0
597 };
598 };
599 const getResponsive = async (returnData, page, sectionID) => {
600 let url = lpData.lp_rest_url + 'lp/v1/lazy-load/course-curriculum/';
601 url = (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)(url, {
602 courseId: courseID || lpGlobalSettings.post_id || '',
603 page,
604 sectionID: sectionID || '',
605 loadMore: true
606 });
607 let paramsFetch = {};
608 if (0 !== parseInt(lpData.user_id)) {
609 paramsFetch = {
610 headers: {
611 'X-WP-Nonce': lpData.nonce
612 }
613 };
614 }
615 let response = await fetch(url, {
616 method: 'GET',
617 ...paramsFetch
618 });
619 response = await response.json();
620 const {
621 data,
622 status,
623 message
624 } = response;
625 const returnDataTmp = data.content;
626 const section_ids = data.section_ids;
627 const pages = data.pages;
628 if (status === 'success') {
629 returnData += returnDataTmp;
630 if (sectionID && section_ids && section_ids.length > 0 && !section_ids.includes(sectionID)) {
631 return getResponsive(returnData, page + 1, sectionID);
632 }
633 }
634 isLoadingSections = false;
635 return {
636 data2: returnData,
637 pages2: pages || data.pages,
638 page2: page,
639 status2: status,
640 message2: message
641 };
642 };
643 Sekeleton();
644 document.addEventListener('click', e => {
645 const sectionBtns = document.querySelectorAll('.section-item__loadmore');
646 [...sectionBtns].map(async sectionBtn => {
647 if (sectionBtn.contains(e.target) && !isLoadingItems) {
648 isLoadingItems = true;
649 const sectionItem = sectionBtn.parentNode;
650 const sectionId = sectionItem.getAttribute('data-section-id');
651 const sectionContent = sectionItem.querySelector('.section-content');
652 const paged = parseInt(sectionBtn.dataset.page);
653 sectionBtn.classList.add('loading');
654 try {
655 const response = await getResponsiveItem('', paged + 1, sectionId, '');
656 const {
657 data3,
658 pages3,
659 status3,
660 message3
661 } = response;
662 if (status3 === 'error') {
663 throw new Error(message3 || 'Error');
664 }
665 if (pages3 <= paged + 1) {
666 sectionBtn.remove();
667 } else {
668 sectionBtn.dataset.page = paged + 1;
669 }
670 sectionContent.insertAdjacentHTML('beforeend', data3);
671 } catch (e) {
672 sectionContent.insertAdjacentHTML('beforeend', `<div class="lp-ajax-message error" style="display:block">${e.message || 'Error: Query lp/v1/lazy-load/course-curriculum'}</div>`);
673 }
674 sectionBtn.classList.remove('loading');
675 (0,_components_search__WEBPACK_IMPORTED_MODULE_2__.searchCourseContent)();
676 }
677 });
678
679 // Load more Sections
680 const moreSections = document.querySelectorAll('.curriculum-more__button');
681 [...moreSections].map(async moreSection => {
682 if (moreSection.contains(e.target) && !isLoadingSections) {
683 isLoadingSections = true;
684 const paged = parseInt(moreSection.dataset.page);
685 const sections = moreSection.parentNode.parentNode.querySelector('.curriculum-sections');
686 if (paged && sections) {
687 moreSection.classList.add('loading');
688 try {
689 const response2 = await getResponsive('', paged + 1, '');
690 const {
691 data2,
692 pages2,
693 status2,
694 message2
695 } = response2;
696 if (status2 === 'error') {
697 throw new Error(message2 || 'Error');
698 }
699 if (pages2 <= paged + 1) {
700 moreSection.remove();
701 } else {
702 moreSection.dataset.page = paged + 1;
703 }
704 sections.insertAdjacentHTML('beforeend', data2);
705 } catch (e) {
706 sections.insertAdjacentHTML('beforeend', `<div class="lp-ajax-message error" style="display:block">${e.message || 'Error: Query lp/v1/lazy-load/course-curriculum'}</div>`);
707 }
708 moreSection.classList.remove('loading');
709 (0,_components_search__WEBPACK_IMPORTED_MODULE_2__.searchCourseContent)();
710 }
711 }
712 });
713
714 // Show/Hide accordion
715 if (document.querySelector('.learnpress-course-curriculum')) {
716 const sections = document.querySelectorAll('.section');
717 [...sections].map(section => {
718 if (section.contains(e.target)) {
719 const toggle = section.querySelector('.section-left');
720 toggle.contains(e.target) && section.classList.toggle('closed');
721 }
722 });
723 }
724 });
725 }
726
727 /***/ },
728
729 /***/ "./assets/src/apps/js/frontend/tabs-scroll.js"
730 /*!****************************************************!*\
731 !*** ./assets/src/apps/js/frontend/tabs-scroll.js ***!
732 \****************************************************/
733 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
734
735 "use strict";
736 __webpack_require__.r(__webpack_exports__);
737 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
738 /* harmony export */ "default": () => (/* binding */ TabsDragScroll)
739 /* harmony export */ });
740 function TabsDragScroll() {
741 // Selectors and DOM elements
742 const TabsDragScroll = document.querySelector('.TabsDragScroll');
743 if (!TabsDragScroll) return;
744 const tabMenu = TabsDragScroll.querySelector('ul');
745
746 // Dragging functionality
747 let activeDrag = false;
748 tabMenu.addEventListener('mousemove', event => {
749 if (!activeDrag) return;
750 tabMenu.scrollLeft -= event.movementX;
751 // iconVisibility();
752 tabMenu.classList.add('dragging');
753 });
754 document.addEventListener('mouseup', () => {
755 activeDrag = false;
756 tabMenu.classList.remove('dragging');
757 });
758 tabMenu.addEventListener('mousedown', () => {
759 activeDrag = true;
760 });
761
762 // Scroll to <li> on click
763 const scrollToLi = li => {
764 const liLeft = li.offsetLeft;
765 const liWidth = li.offsetWidth;
766 const tabCenter = tabMenu.clientWidth / 2 - liWidth / 2;
767 tabMenu.scrollTo({
768 left: liLeft - tabCenter,
769 behavior: 'smooth'
770 });
771 };
772
773 // Add click event listeners to all <li> elements
774 tabMenu.querySelectorAll('li').forEach(li => {
775 li.addEventListener('click', () => scrollToLi(li));
776 });
777 }
778
779 /***/ },
780
781 /***/ "./assets/src/apps/js/utils/lp-modal-overlay.js"
782 /*!******************************************************!*\
783 !*** ./assets/src/apps/js/utils/lp-modal-overlay.js ***!
784 \******************************************************/
785 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
786
787 "use strict";
788 __webpack_require__.r(__webpack_exports__);
789 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
790 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
791 /* harmony export */ });
792 const $ = jQuery;
793 let elLPOverlay = null;
794 const lpModalOverlay = {
795 elLPOverlay: null,
796 elMainContent: null,
797 elTitle: null,
798 elBtnYes: null,
799 elBtnNo: null,
800 elFooter: null,
801 elCalledModal: null,
802 callBackYes: null,
803 instance: null,
804 init() {
805 if (this.instance) {
806 return true;
807 }
808 this.elLPOverlay = $('.lp-overlay');
809 if (!this.elLPOverlay.length) {
810 return false;
811 }
812 elLPOverlay = this.elLPOverlay;
813 this.elMainContent = elLPOverlay.find('.main-content');
814 this.elTitle = elLPOverlay.find('.modal-title');
815 this.elBtnYes = elLPOverlay.find('.btn-yes');
816 this.elBtnNo = elLPOverlay.find('.btn-no');
817 this.elFooter = elLPOverlay.find('.lp-modal-footer');
818 $(document).on('click', '.close, .btn-no', function () {
819 elLPOverlay.hide();
820 });
821 $(document).on('click', '.btn-yes', function (e) {
822 e.preventDefault();
823 e.stopPropagation();
824 if ('function' === typeof lpModalOverlay.callBackYes) {
825 lpModalOverlay.callBackYes(e);
826 }
827 });
828 this.instance = this;
829 return true;
830 },
831 setElCalledModal(elCalledModal) {
832 this.elCalledModal = elCalledModal;
833 },
834 setContentModal(content, event) {
835 this.elMainContent.html(content);
836 if ('function' === typeof event) {
837 event();
838 }
839 },
840 setTitleModal(content) {
841 this.elTitle.html(content);
842 }
843 };
844 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlay);
845
846 /***/ },
847
848 /***/ "./assets/src/js/frontend/copy-to-clipboard.js"
849 /*!*****************************************************!*\
850 !*** ./assets/src/js/frontend/copy-to-clipboard.js ***!
851 \*****************************************************/
852 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
853
854 "use strict";
855 __webpack_require__.r(__webpack_exports__);
856 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
857 /* harmony export */ "default": () => (/* binding */ CopyToClipboard)
858 /* harmony export */ });
859 function LPClick(element, iconBtn, inner) {
860 const wrappers = document.querySelectorAll(element);
861 if (!wrappers.length) {
862 return;
863 }
864 wrappers.forEach(wrapper => {
865 const clickBtn = wrapper.querySelector(iconBtn);
866 const class_open = element.replace('.', '') + '__open';
867 const closeElement = wrapper.querySelector(element + '__close');
868 const isOpenElement = () => wrapper.classList.contains(class_open);
869 const showElement = () => {
870 if (!isOpenElement()) {
871 wrapper.classList.add(class_open);
872 }
873 };
874 const hideElement = () => {
875 if (isOpenElement()) {
876 wrapper.classList.remove(class_open);
877 }
878 };
879 const toggleElement = () => {
880 if (isOpenElement()) {
881 hideElement();
882 } else {
883 showElement();
884 }
885 };
886 const onKeyDown = e => {
887 if (e.keyCode === 27) {
888 hideElement();
889 }
890 };
891 if (clickBtn) {
892 clickBtn.onclick = function (e) {
893 e.preventDefault();
894 toggleElement();
895 };
896 }
897 document.addEventListener('click', e => {
898 if (!isOpenElement()) {
899 return;
900 }
901 const target = e.target;
902 if (target.closest(inner) || target.closest(iconBtn)) {
903 return;
904 }
905 hideElement();
906 });
907 if (closeElement) {
908 closeElement.addEventListener('click', e => {
909 e.preventDefault();
910 hideElement();
911 });
912 }
913 document.addEventListener('keydown', onKeyDown, false);
914 });
915 }
916 function CopyToClipboard() {
917 LPClick('.social-share-toggle', '.share-toggle-icon', '.content-widget-social-share');
918 var copyTextareaBtn = document.querySelector('.btn-clipboard');
919 if (copyTextareaBtn) {
920 copyTextareaBtn.addEventListener('click', function (event) {
921 var copyTextarea = document.querySelector('.clipboard-value');
922 copyTextarea.focus();
923 copyTextarea.select();
924 try {
925 var successful = document.execCommand('copy');
926 var msg = copyTextareaBtn.getAttribute('data-copied');
927 copyTextareaBtn.innerHTML = msg + '<span class="tooltip">' + msg + '</span>';
928 } catch (err) {}
929 });
930 }
931 }
932
933 /***/ },
934
935 /***/ "./assets/src/js/utils.js"
936 /*!********************************!*\
937 !*** ./assets/src/js/utils.js ***!
938 \********************************/
939 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
940
941 "use strict";
942 __webpack_require__.r(__webpack_exports__);
943 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
944 /* harmony export */ debounce: () => (/* binding */ debounce),
945 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
946 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
947 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
948 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
949 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
950 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
951 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
952 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
953 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
954 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
955 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
956 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
957 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
958 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
959 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
960 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
961 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
962 /* harmony export */ });
963 /**
964 * Utils functions
965 *
966 * @param url
967 * @param data
968 * @param functions
969 * @since 4.2.5.1
970 * @version 1.0.7
971 */
972 const lpClassName = {
973 hidden: 'lp-hidden',
974 loading: 'loading',
975 elCollapse: 'lp-collapse',
976 elSectionToggle: '.lp-section-toggle',
977 elTriggerToggle: '.lp-trigger-toggle',
978 elBtnFullScreen: '.lp-btn-full-screen-view',
979 elFullScreen: 'lp-full-screen-view',
980 elBtnFullScreenClose: 'lp-full-screen-view__close'
981 };
982 const lpFetchAPI = (url, data = {}, functions = {}) => {
983 if ('function' === typeof functions.before) {
984 functions.before();
985 }
986 fetch(url, {
987 method: 'GET',
988 ...data
989 }).then(response => response.json()).then(response => {
990 if ('function' === typeof functions.success) {
991 functions.success(response);
992 }
993 }).catch(err => {
994 if ('function' === typeof functions.error) {
995 functions.error(err);
996 }
997 }).finally(() => {
998 if ('function' === typeof functions.completed) {
999 functions.completed();
1000 }
1001 });
1002 };
1003
1004 /**
1005 * Get current URL without params.
1006 *
1007 * @since 4.2.5.1
1008 */
1009 const lpGetCurrentURLNoParam = () => {
1010 let currentUrl = window.location.href;
1011 const hasParams = currentUrl.includes('?');
1012 if (hasParams) {
1013 currentUrl = currentUrl.split('?')[0];
1014 }
1015 return currentUrl;
1016 };
1017 const lpAddQueryArgs = (endpoint, args) => {
1018 const url = new URL(endpoint);
1019 Object.keys(args).forEach(arg => {
1020 url.searchParams.set(arg, args[arg]);
1021 });
1022 return url;
1023 };
1024
1025 /**
1026 * Listen element viewed.
1027 *
1028 * @param el
1029 * @param callback
1030 * @since 4.2.5.8
1031 */
1032 const listenElementViewed = (el, callback) => {
1033 const observerSeeItem = new IntersectionObserver(function (entries) {
1034 for (const entry of entries) {
1035 if (entry.isIntersecting) {
1036 callback(entry);
1037 }
1038 }
1039 });
1040 observerSeeItem.observe(el);
1041 };
1042
1043 /**
1044 * Listen element created.
1045 *
1046 * @param callback
1047 * @since 4.2.5.8
1048 */
1049 const listenElementCreated = callback => {
1050 const observerCreateItem = new MutationObserver(function (mutations) {
1051 mutations.forEach(function (mutation) {
1052 if (mutation.addedNodes) {
1053 mutation.addedNodes.forEach(function (node) {
1054 if (node.nodeType === 1) {
1055 callback(node);
1056 }
1057 });
1058 }
1059 });
1060 });
1061 observerCreateItem.observe(document, {
1062 childList: true,
1063 subtree: true
1064 });
1065 // End.
1066 };
1067
1068 /**
1069 * Listen element created.
1070 *
1071 * @param selector
1072 * @param callback
1073 * @since 4.2.7.1
1074 */
1075 const lpOnElementReady = (selector, callback) => {
1076 const element = document.querySelector(selector);
1077 if (element) {
1078 callback(element);
1079 return;
1080 }
1081 const observer = new MutationObserver((mutations, obs) => {
1082 const element = document.querySelector(selector);
1083 if (element) {
1084 obs.disconnect();
1085 callback(element);
1086 }
1087 });
1088 observer.observe(document.documentElement, {
1089 childList: true,
1090 subtree: true
1091 });
1092 };
1093
1094 // Parse JSON from string with content include LP_AJAX_START.
1095 const lpAjaxParseJsonOld = data => {
1096 if (typeof data !== 'string') {
1097 return data;
1098 }
1099 const m = String.raw({
1100 raw: data
1101 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1102 try {
1103 if (m) {
1104 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1105 } else {
1106 data = JSON.parse(data);
1107 }
1108 } catch (e) {
1109 data = {};
1110 }
1111 return data;
1112 };
1113
1114 // status 0: hide, 1: show
1115 const lpShowHideEl = (el, status = 0) => {
1116 if (!el) {
1117 return;
1118 }
1119 if (!status) {
1120 el.classList.add(lpClassName.hidden);
1121 } else {
1122 el.classList.remove(lpClassName.hidden);
1123 }
1124 };
1125
1126 // status 0: hide, 1: show
1127 const lpSetLoadingEl = (el, status) => {
1128 if (!el) {
1129 return;
1130 }
1131 if (!status) {
1132 el.classList.remove(lpClassName.loading);
1133 } else {
1134 el.classList.add(lpClassName.loading);
1135 }
1136 };
1137
1138 // Toggle collapse section
1139 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1140 if (!elTriggerClassName) {
1141 elTriggerClassName = lpClassName.elTriggerToggle;
1142 }
1143
1144 // Exclude elements, which should not trigger the collapse toggle
1145 if (elsExclude && elsExclude.length > 0) {
1146 for (const elExclude of elsExclude) {
1147 if (target.closest(elExclude)) {
1148 return;
1149 }
1150 }
1151 }
1152 const elTrigger = target.closest(elTriggerClassName);
1153 if (!elTrigger) {
1154 return;
1155 }
1156
1157 //console.log( 'elTrigger', elTrigger );
1158
1159 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1160 if (!elSectionToggle) {
1161 return;
1162 }
1163 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1164 if ('function' === typeof callback) {
1165 callback(elSectionToggle);
1166 }
1167 };
1168
1169 // Get data of form
1170 const getDataOfForm = form => {
1171 const dataSend = {};
1172 const formData = new FormData(form);
1173 for (const pair of formData.entries()) {
1174 const key = pair[0];
1175 const value = formData.getAll(key);
1176 if (!dataSend.hasOwnProperty(key)) {
1177 // Convert value array to string.
1178 dataSend[key] = value.join(',');
1179 }
1180 }
1181 return dataSend;
1182 };
1183
1184 // Get field keys of form
1185 const getFieldKeysOfForm = form => {
1186 const keys = [];
1187 const elements = form.elements;
1188 for (let i = 0; i < elements.length; i++) {
1189 const name = elements[i].name;
1190 if (name && !keys.includes(name)) {
1191 keys.push(name);
1192 }
1193 }
1194 return keys;
1195 };
1196
1197 // Merge data handle with data form.
1198 const mergeDataWithDatForm = (elForm, dataHandle) => {
1199 const dataForm = getDataOfForm(elForm);
1200 const keys = getFieldKeysOfForm(elForm);
1201 keys.forEach(key => {
1202 if (!dataForm.hasOwnProperty(key)) {
1203 delete dataHandle[key];
1204 } else if (dataForm[key][0] === '') {
1205 delete dataForm[key];
1206 delete dataHandle[key];
1207 }
1208 });
1209 dataHandle = {
1210 ...dataHandle,
1211 ...dataForm
1212 };
1213 return dataHandle;
1214 };
1215
1216 /**
1217 * Event trigger
1218 * For each list of event handlers, listen event on document.
1219 *
1220 * eventName: 'click', 'change', ...
1221 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1222 *
1223 * @param eventName
1224 * @param eventHandlers
1225 */
1226 const eventHandlers = (eventName, eventHandlers) => {
1227 document.addEventListener(eventName, e => {
1228 const target = e.target;
1229 let args = {
1230 e,
1231 target
1232 };
1233 eventHandlers.forEach(eventHandler => {
1234 args = {
1235 ...args,
1236 ...eventHandler
1237 };
1238
1239 //console.log( args );
1240
1241 // Check condition before call back
1242 if (eventHandler.conditionBeforeCallBack) {
1243 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1244 return;
1245 }
1246 }
1247
1248 // Special check for keydown event with checkIsEventEnter = true
1249 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1250 if (e.key !== 'Enter') {
1251 return;
1252 }
1253 }
1254 if (target.closest(eventHandler.selector)) {
1255 if (eventHandler.class) {
1256 // Call method of class, function callBack will understand exactly {this} is class object.
1257 eventHandler.class[eventHandler.callBack](args);
1258 } else {
1259 // For send args is objected, {this} is eventHandler object, not class object.
1260 eventHandler.callBack(args);
1261 }
1262 }
1263 });
1264 });
1265 };
1266
1267 /**
1268 * Debounce - delays function execution until after `wait` ms of inactivity.
1269 *
1270 * Each call resets the timer. Only the last call in a burst executes.
1271 *
1272 * USE CASES:
1273 * - Search inputs, form validation, window resize
1274 * - Multiple elements need independent timers
1275 * - When you need to call with different arguments
1276 *
1277 * EXAMPLES:
1278 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1279 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1280 *
1281 * const debouncedResize = debounce( recalculateLayout, 250 );
1282 * window.addEventListener('resize', debouncedResize);
1283 *
1284 * ⚠️ Create ONCE outside event handlers, not inside.
1285 *
1286 * @param {Function} func - Function to debounce (can be anonymous)
1287 * @param {number} wait - Milliseconds to wait (default: 500)
1288 * @return {Function} Debounced wrapper function
1289 * @since 4.3.7
1290 * @version 1.0.0
1291 */
1292 const debounce = (func, wait = 500) => {
1293 let timer;
1294 return args => {
1295 clearTimeout(timer);
1296 timer = setTimeout(() => func(args), wait);
1297 };
1298 };
1299
1300 /**
1301 * Initialize lp-toggle-enable components.
1302 *
1303 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1304 * Reads initial state from `data-enabled` attribute ("true"/"false").
1305 * Calls `data-on-toggle` callback (if provided via options) on state change.
1306 *
1307 * HTML structure:
1308 * <label class="lp-toggle-enable" data-enabled="true">
1309 * <input type="checkbox" class="lp-toggle-enable__input" />
1310 * <span class="lp-toggle-enable__track"></span>
1311 * </label>
1312 *
1313 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1314 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1315 * @since 4.4.5
1316 * @version 1.0.0
1317 */
1318 window.lpToggleEnableInit = 0;
1319 const toggleEnable = (onToggle = null) => {
1320 if (window.lpToggleEnableInit) {
1321 return;
1322 }
1323 window.lpToggleEnableInit = 1;
1324 const selector = '.lp-toggle-enable';
1325 const updateUI = (toggle, isEnabled) => {
1326 toggle.classList.toggle('is-enabled', isEnabled);
1327 const input = toggle.querySelector('.lp-toggle-enable__input');
1328 if (input) {
1329 input.checked = isEnabled;
1330 input.value = isEnabled ? '1' : '0';
1331 }
1332 };
1333
1334 // Delegate click handling via eventHandlers.
1335 eventHandlers('click', [{
1336 selector,
1337 callBack: args => {
1338 const {
1339 e,
1340 target
1341 } = args;
1342 const toggle = target.closest(selector);
1343 if (!toggle || toggle.classList.contains('is-disabled')) {
1344 return;
1345 }
1346 e.preventDefault();
1347 const isEnabled = !toggle.classList.contains('is-enabled');
1348 updateUI(toggle, isEnabled);
1349 if ('function' === typeof onToggle) {
1350 onToggle(toggle, isEnabled);
1351 }
1352 }
1353 }]);
1354 };
1355
1356 /**
1357 * Initialize custom fullscreen view buttons.
1358 *
1359 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1360 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1361 * target element. Falls back to the button's parent element when
1362 * `data-target` is not provided.
1363 *
1364 * @since 4.4.5
1365 * @version 1.0.0
1366 */
1367 window.lpFullScreenViewInit = 0;
1368 const fullScreenView = () => {
1369 if (window.lpFullScreenViewInit) {
1370 return;
1371 }
1372 window.lpFullScreenViewInit = 1;
1373 let lastScrollY = 0;
1374 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1375 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1376 if (isFullscreen) {
1377 elTarget.classList.remove(lpClassName.elFullScreen);
1378 document.documentElement.classList.remove('lp-full-screen-active');
1379 window.scrollTo(0, lastScrollY);
1380 } else {
1381 lastScrollY = window.scrollY;
1382 elTarget.classList.add(lpClassName.elFullScreen);
1383 document.documentElement.classList.add('lp-full-screen-active');
1384 }
1385 if (!isFullscreen) {
1386 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1387 const closeButton = document.createElement('button');
1388 closeButton.type = 'button';
1389 closeButton.className = lpClassName.elBtnFullScreenClose;
1390 closeButton.setAttribute('aria-label', 'Close');
1391 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1392 closeButton.addEventListener('click', e => {
1393 e.preventDefault();
1394 lpToggleFullscreenView(elTarget);
1395 });
1396 elTarget.appendChild(closeButton);
1397 }
1398 } else {
1399 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1400 if (closeButton) {
1401 closeButton.remove();
1402 }
1403 }
1404 };
1405 eventHandlers('click', [{
1406 selector: lpClassName.elBtnFullScreen,
1407 callBack: args => {
1408 const {
1409 e,
1410 target
1411 } = args;
1412 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1413 if (!elBtnFullScreen) {
1414 console.log('No full screen button found');
1415 return;
1416 }
1417 e.preventDefault();
1418 let elTarget = null;
1419 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
1420 console.log(targetSelector);
1421 if (targetSelector) {
1422 elTarget = document.querySelector(targetSelector);
1423 }
1424 if (!elTarget) {
1425 console.log('No target element found');
1426 return;
1427 }
1428 lpToggleFullscreenView(elTarget, elBtnFullScreen);
1429 }
1430 }]);
1431 };
1432
1433 /***/ },
1434
1435 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1436 /*!*****************************************************************************************!*\
1437 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1438 \*****************************************************************************************/
1439 (module, __webpack_exports__, __webpack_require__) {
1440
1441 "use strict";
1442 __webpack_require__.r(__webpack_exports__);
1443 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1444 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1445 /* harmony export */ });
1446 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css-loader/dist/runtime/sourceMaps.js */ "./node_modules/css-loader/dist/runtime/sourceMaps.js");
1447 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
1448 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
1449 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
1450 // Imports
1451
1452
1453 var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
1454 // Module
1455 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1456 * Toastify js 1.12.0
1457 * https://github.com/apvarun/toastify-js
1458 * @license MIT licensed
1459 *
1460 * Copyright (C) 2018 Varun A P
1461 */
1462
1463 .toastify {
1464 padding: 12px 20px;
1465 color: #ffffff;
1466 display: inline-block;
1467 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1468 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1469 background: linear-gradient(135deg, #73a5ff, #5477f5);
1470 position: fixed;
1471 opacity: 0;
1472 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1473 border-radius: 2px;
1474 cursor: pointer;
1475 text-decoration: none;
1476 max-width: calc(50% - 20px);
1477 z-index: 2147483647;
1478 }
1479
1480 .toastify.on {
1481 opacity: 1;
1482 }
1483
1484 .toast-close {
1485 background: transparent;
1486 border: 0;
1487 color: white;
1488 cursor: pointer;
1489 font-family: inherit;
1490 font-size: 1em;
1491 opacity: 0.4;
1492 padding: 0 5px;
1493 }
1494
1495 .toastify-right {
1496 right: 15px;
1497 }
1498
1499 .toastify-left {
1500 left: 15px;
1501 }
1502
1503 .toastify-top {
1504 top: -150px;
1505 }
1506
1507 .toastify-bottom {
1508 bottom: -150px;
1509 }
1510
1511 .toastify-rounded {
1512 border-radius: 25px;
1513 }
1514
1515 .toastify-avatar {
1516 width: 1.5em;
1517 height: 1.5em;
1518 margin: -7px 5px;
1519 border-radius: 2px;
1520 }
1521
1522 .toastify-center {
1523 margin-left: auto;
1524 margin-right: auto;
1525 left: 0;
1526 right: 0;
1527 max-width: fit-content;
1528 max-width: -moz-fit-content;
1529 }
1530
1531 @media only screen and (max-width: 360px) {
1532 .toastify-right, .toastify-left {
1533 margin-left: auto;
1534 margin-right: auto;
1535 left: 0;
1536 right: 0;
1537 max-width: fit-content;
1538 }
1539 }
1540 `, "",{"version":3,"sources":["webpack://./node_modules/toastify-js/src/toastify.css"],"names":[],"mappings":"AAAA;;;;;;EAME;;AAEF;IACI,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,uFAAuF;IACvF,6DAA6D;IAC7D,qDAAqD;IACrD,eAAe;IACf,UAAU;IACV,wDAAwD;IACxD,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,2BAA2B;IAC3B,mBAAmB;AACvB;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,uBAAuB;IACvB,SAAS;IACT,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,cAAc;AAClB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,iBAAiB;IACjB,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,sBAAsB;IACtB,2BAA2B;AAC/B;;AAEA;IACI;QACI,iBAAiB;QACjB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,sBAAsB;IAC1B;AACJ","sourcesContent":["/*!\n * Toastify js 1.12.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n.toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n}\n\n.toastify.on {\n opacity: 1;\n}\n\n.toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n}\n\n.toastify-right {\n right: 15px;\n}\n\n.toastify-left {\n left: 15px;\n}\n\n.toastify-top {\n top: -150px;\n}\n\n.toastify-bottom {\n bottom: -150px;\n}\n\n.toastify-rounded {\n border-radius: 25px;\n}\n\n.toastify-avatar {\n width: 1.5em;\n height: 1.5em;\n margin: -7px 5px;\n border-radius: 2px;\n}\n\n.toastify-center {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n max-width: -moz-fit-content;\n}\n\n@media only screen and (max-width: 360px) {\n .toastify-right, .toastify-left {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n }\n}\n"],"sourceRoot":""}]);
1541 // Exports
1542 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1543
1544
1545 /***/ },
1546
1547 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1548 /*!*****************************************************!*\
1549 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1550 \*****************************************************/
1551 (module) {
1552
1553 "use strict";
1554
1555
1556 /*
1557 MIT License http://www.opensource.org/licenses/mit-license.php
1558 Author Tobias Koppers @sokra
1559 */
1560 module.exports = function (cssWithMappingToString) {
1561 var list = [];
1562
1563 // return the list of modules as css string
1564 list.toString = function toString() {
1565 return this.map(function (item) {
1566 var content = "";
1567 var needLayer = typeof item[5] !== "undefined";
1568 if (item[4]) {
1569 content += "@supports (".concat(item[4], ") {");
1570 }
1571 if (item[2]) {
1572 content += "@media ".concat(item[2], " {");
1573 }
1574 if (needLayer) {
1575 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1576 }
1577 content += cssWithMappingToString(item);
1578 if (needLayer) {
1579 content += "}";
1580 }
1581 if (item[2]) {
1582 content += "}";
1583 }
1584 if (item[4]) {
1585 content += "}";
1586 }
1587 return content;
1588 }).join("");
1589 };
1590
1591 // import a list of modules into the list
1592 list.i = function i(modules, media, dedupe, supports, layer) {
1593 if (typeof modules === "string") {
1594 modules = [[null, modules, undefined]];
1595 }
1596 var alreadyImportedModules = {};
1597 if (dedupe) {
1598 for (var k = 0; k < this.length; k++) {
1599 var id = this[k][0];
1600 if (id != null) {
1601 alreadyImportedModules[id] = true;
1602 }
1603 }
1604 }
1605 for (var _k = 0; _k < modules.length; _k++) {
1606 var item = [].concat(modules[_k]);
1607 if (dedupe && alreadyImportedModules[item[0]]) {
1608 continue;
1609 }
1610 if (typeof layer !== "undefined") {
1611 if (typeof item[5] === "undefined") {
1612 item[5] = layer;
1613 } else {
1614 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1615 item[5] = layer;
1616 }
1617 }
1618 if (media) {
1619 if (!item[2]) {
1620 item[2] = media;
1621 } else {
1622 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1623 item[2] = media;
1624 }
1625 }
1626 if (supports) {
1627 if (!item[4]) {
1628 item[4] = "".concat(supports);
1629 } else {
1630 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1631 item[4] = supports;
1632 }
1633 }
1634 list.push(item);
1635 }
1636 };
1637 return list;
1638 };
1639
1640 /***/ },
1641
1642 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1643 /*!************************************************************!*\
1644 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1645 \************************************************************/
1646 (module) {
1647
1648 "use strict";
1649
1650
1651 module.exports = function (item) {
1652 var content = item[1];
1653 var cssMapping = item[3];
1654 if (!cssMapping) {
1655 return content;
1656 }
1657 if (typeof btoa === "function") {
1658 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1659 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1660 var sourceMapping = "/*# ".concat(data, " */");
1661 return [content].concat([sourceMapping]).join("\n");
1662 }
1663 return [content].join("\n");
1664 };
1665
1666 /***/ },
1667
1668 /***/ "./node_modules/toastify-js/src/toastify.css"
1669 /*!***************************************************!*\
1670 !*** ./node_modules/toastify-js/src/toastify.css ***!
1671 \***************************************************/
1672 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1673
1674 "use strict";
1675 __webpack_require__.r(__webpack_exports__);
1676 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1677 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1678 /* harmony export */ });
1679 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
1680 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
1681 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleDomAPI.js */ "./node_modules/style-loader/dist/runtime/styleDomAPI.js");
1682 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);
1683 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertBySelector.js */ "./node_modules/style-loader/dist/runtime/insertBySelector.js");
1684 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);
1685 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../style-loader/dist/runtime/setAttributesWithoutAttributes.js */ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js");
1686 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);
1687 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertStyleElement.js */ "./node_modules/style-loader/dist/runtime/insertStyleElement.js");
1688 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);
1689 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleTagTransform.js */ "./node_modules/style-loader/dist/runtime/styleTagTransform.js");
1690 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);
1691 /* harmony import */ var _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../css-loader/dist/cjs.js!./toastify.css */ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css");
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703 var options = {};
1704
1705 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1706 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1707
1708 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1709
1710 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1711 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1712
1713 var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);
1714
1715
1716
1717
1718 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);
1719
1720
1721 /***/ },
1722
1723 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1724 /*!****************************************************************************!*\
1725 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1726 \****************************************************************************/
1727 (module) {
1728
1729 "use strict";
1730
1731
1732 var stylesInDOM = [];
1733 function getIndexByIdentifier(identifier) {
1734 var result = -1;
1735 for (var i = 0; i < stylesInDOM.length; i++) {
1736 if (stylesInDOM[i].identifier === identifier) {
1737 result = i;
1738 break;
1739 }
1740 }
1741 return result;
1742 }
1743 function modulesToDom(list, options) {
1744 var idCountMap = {};
1745 var identifiers = [];
1746 for (var i = 0; i < list.length; i++) {
1747 var item = list[i];
1748 var id = options.base ? item[0] + options.base : item[0];
1749 var count = idCountMap[id] || 0;
1750 var identifier = "".concat(id, " ").concat(count);
1751 idCountMap[id] = count + 1;
1752 var indexByIdentifier = getIndexByIdentifier(identifier);
1753 var obj = {
1754 css: item[1],
1755 media: item[2],
1756 sourceMap: item[3],
1757 supports: item[4],
1758 layer: item[5]
1759 };
1760 if (indexByIdentifier !== -1) {
1761 stylesInDOM[indexByIdentifier].references++;
1762 stylesInDOM[indexByIdentifier].updater(obj);
1763 } else {
1764 var updater = addElementStyle(obj, options);
1765 options.byIndex = i;
1766 stylesInDOM.splice(i, 0, {
1767 identifier: identifier,
1768 updater: updater,
1769 references: 1
1770 });
1771 }
1772 identifiers.push(identifier);
1773 }
1774 return identifiers;
1775 }
1776 function addElementStyle(obj, options) {
1777 var api = options.domAPI(options);
1778 api.update(obj);
1779 var updater = function updater(newObj) {
1780 if (newObj) {
1781 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1782 return;
1783 }
1784 api.update(obj = newObj);
1785 } else {
1786 api.remove();
1787 }
1788 };
1789 return updater;
1790 }
1791 module.exports = function (list, options) {
1792 options = options || {};
1793 list = list || [];
1794 var lastIdentifiers = modulesToDom(list, options);
1795 return function update(newList) {
1796 newList = newList || [];
1797 for (var i = 0; i < lastIdentifiers.length; i++) {
1798 var identifier = lastIdentifiers[i];
1799 var index = getIndexByIdentifier(identifier);
1800 stylesInDOM[index].references--;
1801 }
1802 var newLastIdentifiers = modulesToDom(newList, options);
1803 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1804 var _identifier = lastIdentifiers[_i];
1805 var _index = getIndexByIdentifier(_identifier);
1806 if (stylesInDOM[_index].references === 0) {
1807 stylesInDOM[_index].updater();
1808 stylesInDOM.splice(_index, 1);
1809 }
1810 }
1811 lastIdentifiers = newLastIdentifiers;
1812 };
1813 };
1814
1815 /***/ },
1816
1817 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1818 /*!********************************************************************!*\
1819 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1820 \********************************************************************/
1821 (module) {
1822
1823 "use strict";
1824
1825
1826 var memo = {};
1827
1828 /* istanbul ignore next */
1829 function getTarget(target) {
1830 if (typeof memo[target] === "undefined") {
1831 var styleTarget = document.querySelector(target);
1832
1833 // Special case to return head of iframe instead of iframe itself
1834 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1835 try {
1836 // This will throw an exception if access to iframe is blocked
1837 // due to cross-origin restrictions
1838 styleTarget = styleTarget.contentDocument.head;
1839 } catch (e) {
1840 // istanbul ignore next
1841 styleTarget = null;
1842 }
1843 }
1844 memo[target] = styleTarget;
1845 }
1846 return memo[target];
1847 }
1848
1849 /* istanbul ignore next */
1850 function insertBySelector(insert, style) {
1851 var target = getTarget(insert);
1852 if (!target) {
1853 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1854 }
1855 target.appendChild(style);
1856 }
1857 module.exports = insertBySelector;
1858
1859 /***/ },
1860
1861 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1862 /*!**********************************************************************!*\
1863 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1864 \**********************************************************************/
1865 (module) {
1866
1867 "use strict";
1868
1869
1870 /* istanbul ignore next */
1871 function insertStyleElement(options) {
1872 var element = document.createElement("style");
1873 options.setAttributes(element, options.attributes);
1874 options.insert(element, options.options);
1875 return element;
1876 }
1877 module.exports = insertStyleElement;
1878
1879 /***/ },
1880
1881 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1882 /*!**********************************************************************************!*\
1883 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1884 \**********************************************************************************/
1885 (module, __unused_webpack_exports, __webpack_require__) {
1886
1887 "use strict";
1888
1889
1890 /* istanbul ignore next */
1891 function setAttributesWithoutAttributes(styleElement) {
1892 var nonce = true ? __webpack_require__.nc : 0;
1893 if (nonce) {
1894 styleElement.setAttribute("nonce", nonce);
1895 }
1896 }
1897 module.exports = setAttributesWithoutAttributes;
1898
1899 /***/ },
1900
1901 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1902 /*!***************************************************************!*\
1903 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1904 \***************************************************************/
1905 (module) {
1906
1907 "use strict";
1908
1909
1910 /* istanbul ignore next */
1911 function apply(styleElement, options, obj) {
1912 var css = "";
1913 if (obj.supports) {
1914 css += "@supports (".concat(obj.supports, ") {");
1915 }
1916 if (obj.media) {
1917 css += "@media ".concat(obj.media, " {");
1918 }
1919 var needLayer = typeof obj.layer !== "undefined";
1920 if (needLayer) {
1921 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1922 }
1923 css += obj.css;
1924 if (needLayer) {
1925 css += "}";
1926 }
1927 if (obj.media) {
1928 css += "}";
1929 }
1930 if (obj.supports) {
1931 css += "}";
1932 }
1933 var sourceMap = obj.sourceMap;
1934 if (sourceMap && typeof btoa !== "undefined") {
1935 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1936 }
1937
1938 // For old IE
1939 /* istanbul ignore if */
1940 options.styleTagTransform(css, styleElement, options.options);
1941 }
1942 function removeStyleElement(styleElement) {
1943 // istanbul ignore if
1944 if (styleElement.parentNode === null) {
1945 return false;
1946 }
1947 styleElement.parentNode.removeChild(styleElement);
1948 }
1949
1950 /* istanbul ignore next */
1951 function domAPI(options) {
1952 if (typeof document === "undefined") {
1953 return {
1954 update: function update() {},
1955 remove: function remove() {}
1956 };
1957 }
1958 var styleElement = options.insertStyleElement(options);
1959 return {
1960 update: function update(obj) {
1961 apply(styleElement, options, obj);
1962 },
1963 remove: function remove() {
1964 removeStyleElement(styleElement);
1965 }
1966 };
1967 }
1968 module.exports = domAPI;
1969
1970 /***/ },
1971
1972 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
1973 /*!*********************************************************************!*\
1974 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
1975 \*********************************************************************/
1976 (module) {
1977
1978 "use strict";
1979
1980
1981 /* istanbul ignore next */
1982 function styleTagTransform(css, styleElement) {
1983 if (styleElement.styleSheet) {
1984 styleElement.styleSheet.cssText = css;
1985 } else {
1986 while (styleElement.firstChild) {
1987 styleElement.removeChild(styleElement.firstChild);
1988 }
1989 styleElement.appendChild(document.createTextNode(css));
1990 }
1991 }
1992 module.exports = styleTagTransform;
1993
1994 /***/ },
1995
1996 /***/ "./node_modules/toastify-js/src/toastify.js"
1997 /*!**************************************************!*\
1998 !*** ./node_modules/toastify-js/src/toastify.js ***!
1999 \**************************************************/
2000 (module) {
2001
2002 /*!
2003 * Toastify js 1.12.0
2004 * https://github.com/apvarun/toastify-js
2005 * @license MIT licensed
2006 *
2007 * Copyright (C) 2018 Varun A P
2008 */
2009 (function(root, factory) {
2010 if ( true && module.exports) {
2011 module.exports = factory();
2012 } else {
2013 root.Toastify = factory();
2014 }
2015 })(this, function(global) {
2016 // Object initialization
2017 var Toastify = function(options) {
2018 // Returning a new init object
2019 return new Toastify.lib.init(options);
2020 },
2021 // Library version
2022 version = "1.12.0";
2023
2024 // Set the default global options
2025 Toastify.defaults = {
2026 oldestFirst: true,
2027 text: "Toastify is awesome!",
2028 node: undefined,
2029 duration: 3000,
2030 selector: undefined,
2031 callback: function () {
2032 },
2033 destination: undefined,
2034 newWindow: false,
2035 close: false,
2036 gravity: "toastify-top",
2037 positionLeft: false,
2038 position: '',
2039 backgroundColor: '',
2040 avatar: "",
2041 className: "",
2042 stopOnFocus: true,
2043 onClick: function () {
2044 },
2045 offset: {x: 0, y: 0},
2046 escapeMarkup: true,
2047 ariaLive: 'polite',
2048 style: {background: ''}
2049 };
2050
2051 // Defining the prototype of the object
2052 Toastify.lib = Toastify.prototype = {
2053 toastify: version,
2054
2055 constructor: Toastify,
2056
2057 // Initializing the object with required parameters
2058 init: function(options) {
2059 // Verifying and validating the input object
2060 if (!options) {
2061 options = {};
2062 }
2063
2064 // Creating the options object
2065 this.options = {};
2066
2067 this.toastElement = null;
2068
2069 // Validating the options
2070 this.options.text = options.text || Toastify.defaults.text; // Display message
2071 this.options.node = options.node || Toastify.defaults.node; // Display content as node
2072 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
2073 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
2074 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
2075 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
2076 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
2077 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
2078 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
2079 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
2080 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
2081 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
2082 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
2083 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
2084 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
2085 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
2086 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
2087 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
2088 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
2089 this.options.style = options.style || Toastify.defaults.style;
2090 if(options.backgroundColor) {
2091 this.options.style.background = options.backgroundColor;
2092 }
2093
2094 // Returning the current object for chaining functions
2095 return this;
2096 },
2097
2098 // Building the DOM element
2099 buildToast: function() {
2100 // Validating if the options are defined
2101 if (!this.options) {
2102 throw "Toastify is not initialized";
2103 }
2104
2105 // Creating the DOM object
2106 var divElement = document.createElement("div");
2107 divElement.className = "toastify on " + this.options.className;
2108
2109 // Positioning toast to left or right or center
2110 if (!!this.options.position) {
2111 divElement.className += " toastify-" + this.options.position;
2112 } else {
2113 // To be depreciated in further versions
2114 if (this.options.positionLeft === true) {
2115 divElement.className += " toastify-left";
2116 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
2117 } else {
2118 // Default position
2119 divElement.className += " toastify-right";
2120 }
2121 }
2122
2123 // Assigning gravity of element
2124 divElement.className += " " + this.options.gravity;
2125
2126 if (this.options.backgroundColor) {
2127 // This is being deprecated in favor of using the style HTML DOM property
2128 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
2129 }
2130
2131 // Loop through our style object and apply styles to divElement
2132 for (var property in this.options.style) {
2133 divElement.style[property] = this.options.style[property];
2134 }
2135
2136 // Announce the toast to screen readers
2137 if (this.options.ariaLive) {
2138 divElement.setAttribute('aria-live', this.options.ariaLive)
2139 }
2140
2141 // Adding the toast message/node
2142 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
2143 // If we have a valid node, we insert it
2144 divElement.appendChild(this.options.node)
2145 } else {
2146 if (this.options.escapeMarkup) {
2147 divElement.innerText = this.options.text;
2148 } else {
2149 divElement.innerHTML = this.options.text;
2150 }
2151
2152 if (this.options.avatar !== "") {
2153 var avatarElement = document.createElement("img");
2154 avatarElement.src = this.options.avatar;
2155
2156 avatarElement.className = "toastify-avatar";
2157
2158 if (this.options.position == "left" || this.options.positionLeft === true) {
2159 // Adding close icon on the left of content
2160 divElement.appendChild(avatarElement);
2161 } else {
2162 // Adding close icon on the right of content
2163 divElement.insertAdjacentElement("afterbegin", avatarElement);
2164 }
2165 }
2166 }
2167
2168 // Adding a close icon to the toast
2169 if (this.options.close === true) {
2170 // Create a span for close element
2171 var closeElement = document.createElement("button");
2172 closeElement.type = "button";
2173 closeElement.setAttribute("aria-label", "Close");
2174 closeElement.className = "toast-close";
2175 closeElement.innerHTML = "&#10006;";
2176
2177 // Triggering the removal of toast from DOM on close click
2178 closeElement.addEventListener(
2179 "click",
2180 function(event) {
2181 event.stopPropagation();
2182 this.removeElement(this.toastElement);
2183 window.clearTimeout(this.toastElement.timeOutValue);
2184 }.bind(this)
2185 );
2186
2187 //Calculating screen width
2188 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
2189
2190 // Adding the close icon to the toast element
2191 // Display on the right if screen width is less than or equal to 360px
2192 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
2193 // Adding close icon on the left of content
2194 divElement.insertAdjacentElement("afterbegin", closeElement);
2195 } else {
2196 // Adding close icon on the right of content
2197 divElement.appendChild(closeElement);
2198 }
2199 }
2200
2201 // Clear timeout while toast is focused
2202 if (this.options.stopOnFocus && this.options.duration > 0) {
2203 var self = this;
2204 // stop countdown
2205 divElement.addEventListener(
2206 "mouseover",
2207 function(event) {
2208 window.clearTimeout(divElement.timeOutValue);
2209 }
2210 )
2211 // add back the timeout
2212 divElement.addEventListener(
2213 "mouseleave",
2214 function() {
2215 divElement.timeOutValue = window.setTimeout(
2216 function() {
2217 // Remove the toast from DOM
2218 self.removeElement(divElement);
2219 },
2220 self.options.duration
2221 )
2222 }
2223 )
2224 }
2225
2226 // Adding an on-click destination path
2227 if (typeof this.options.destination !== "undefined") {
2228 divElement.addEventListener(
2229 "click",
2230 function(event) {
2231 event.stopPropagation();
2232 if (this.options.newWindow === true) {
2233 window.open(this.options.destination, "_blank");
2234 } else {
2235 window.location = this.options.destination;
2236 }
2237 }.bind(this)
2238 );
2239 }
2240
2241 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
2242 divElement.addEventListener(
2243 "click",
2244 function(event) {
2245 event.stopPropagation();
2246 this.options.onClick();
2247 }.bind(this)
2248 );
2249 }
2250
2251 // Adding offset
2252 if(typeof this.options.offset === "object") {
2253
2254 var x = getAxisOffsetAValue("x", this.options);
2255 var y = getAxisOffsetAValue("y", this.options);
2256
2257 var xOffset = this.options.position == "left" ? x : "-" + x;
2258 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
2259
2260 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
2261
2262 }
2263
2264 // Returning the generated element
2265 return divElement;
2266 },
2267
2268 // Displaying the toast
2269 showToast: function() {
2270 // Creating the DOM object for the toast
2271 this.toastElement = this.buildToast();
2272
2273 // Getting the root element to with the toast needs to be added
2274 var rootElement;
2275 if (typeof this.options.selector === "string") {
2276 rootElement = document.getElementById(this.options.selector);
2277 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
2278 rootElement = this.options.selector;
2279 } else {
2280 rootElement = document.body;
2281 }
2282
2283 // Validating if root element is present in DOM
2284 if (!rootElement) {
2285 throw "Root element is not defined";
2286 }
2287
2288 // Adding the DOM element
2289 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
2290 rootElement.insertBefore(this.toastElement, elementToInsert);
2291
2292 // Repositioning the toasts in case multiple toasts are present
2293 Toastify.reposition();
2294
2295 if (this.options.duration > 0) {
2296 this.toastElement.timeOutValue = window.setTimeout(
2297 function() {
2298 // Remove the toast from DOM
2299 this.removeElement(this.toastElement);
2300 }.bind(this),
2301 this.options.duration
2302 ); // Binding `this` for function invocation
2303 }
2304
2305 // Supporting function chaining
2306 return this;
2307 },
2308
2309 hideToast: function() {
2310 if (this.toastElement.timeOutValue) {
2311 clearTimeout(this.toastElement.timeOutValue);
2312 }
2313 this.removeElement(this.toastElement);
2314 },
2315
2316 // Removing the element from the DOM
2317 removeElement: function(toastElement) {
2318 // Hiding the element
2319 // toastElement.classList.remove("on");
2320 toastElement.className = toastElement.className.replace(" on", "");
2321
2322 // Removing the element from DOM after transition end
2323 window.setTimeout(
2324 function() {
2325 // remove options node if any
2326 if (this.options.node && this.options.node.parentNode) {
2327 this.options.node.parentNode.removeChild(this.options.node);
2328 }
2329
2330 // Remove the element from the DOM, only when the parent node was not removed before.
2331 if (toastElement.parentNode) {
2332 toastElement.parentNode.removeChild(toastElement);
2333 }
2334
2335 // Calling the callback function
2336 this.options.callback.call(toastElement);
2337
2338 // Repositioning the toasts again
2339 Toastify.reposition();
2340 }.bind(this),
2341 400
2342 ); // Binding `this` for function invocation
2343 },
2344 };
2345
2346 // Positioning the toasts on the DOM
2347 Toastify.reposition = function() {
2348
2349 // Top margins with gravity
2350 var topLeftOffsetSize = {
2351 top: 15,
2352 bottom: 15,
2353 };
2354 var topRightOffsetSize = {
2355 top: 15,
2356 bottom: 15,
2357 };
2358 var offsetSize = {
2359 top: 15,
2360 bottom: 15,
2361 };
2362
2363 // Get all toast messages on the DOM
2364 var allToasts = document.getElementsByClassName("toastify");
2365
2366 var classUsed;
2367
2368 // Modifying the position of each toast element
2369 for (var i = 0; i < allToasts.length; i++) {
2370 // Getting the applied gravity
2371 if (containsClass(allToasts[i], "toastify-top") === true) {
2372 classUsed = "toastify-top";
2373 } else {
2374 classUsed = "toastify-bottom";
2375 }
2376
2377 var height = allToasts[i].offsetHeight;
2378 classUsed = classUsed.substr(9, classUsed.length-1)
2379 // Spacing between toasts
2380 var offset = 15;
2381
2382 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
2383
2384 // Show toast in center if screen with less than or equal to 360px
2385 if (width <= 360) {
2386 // Setting the position
2387 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
2388
2389 offsetSize[classUsed] += height + offset;
2390 } else {
2391 if (containsClass(allToasts[i], "toastify-left") === true) {
2392 // Setting the position
2393 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
2394
2395 topLeftOffsetSize[classUsed] += height + offset;
2396 } else {
2397 // Setting the position
2398 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
2399
2400 topRightOffsetSize[classUsed] += height + offset;
2401 }
2402 }
2403 }
2404
2405 // Supporting function chaining
2406 return this;
2407 };
2408
2409 // Helper function to get offset.
2410 function getAxisOffsetAValue(axis, options) {
2411
2412 if(options.offset[axis]) {
2413 if(isNaN(options.offset[axis])) {
2414 return options.offset[axis];
2415 }
2416 else {
2417 return options.offset[axis] + 'px';
2418 }
2419 }
2420
2421 return '0px';
2422
2423 }
2424
2425 function containsClass(elem, yourClass) {
2426 if (!elem || typeof yourClass !== "string") {
2427 return false;
2428 } else if (
2429 elem.className &&
2430 elem.className
2431 .trim()
2432 .split(/\s+/gi)
2433 .indexOf(yourClass) > -1
2434 ) {
2435 return true;
2436 } else {
2437 return false;
2438 }
2439 }
2440
2441 // Setting up the prototype for the init object
2442 Toastify.lib.init.prototype = Toastify.lib;
2443
2444 // Returning the Toastify function to be assigned to the window object/module
2445 return Toastify;
2446 });
2447
2448
2449 /***/ },
2450
2451 /***/ "react"
2452 /*!************************!*\
2453 !*** external "React" ***!
2454 \************************/
2455 (module) {
2456
2457 "use strict";
2458 module.exports = window["React"];
2459
2460 /***/ },
2461
2462 /***/ "@learnpress/quiz"
2463 /*!******************************!*\
2464 !*** external ["LP","quiz"] ***!
2465 \******************************/
2466 (module) {
2467
2468 "use strict";
2469 module.exports = window["LP"]["quiz"];
2470
2471 /***/ },
2472
2473 /***/ "@wordpress/element"
2474 /*!*********************************!*\
2475 !*** external ["wp","element"] ***!
2476 \*********************************/
2477 (module) {
2478
2479 "use strict";
2480 module.exports = window["wp"]["element"];
2481
2482 /***/ },
2483
2484 /***/ "@wordpress/url"
2485 /*!*****************************!*\
2486 !*** external ["wp","url"] ***!
2487 \*****************************/
2488 (module) {
2489
2490 "use strict";
2491 module.exports = window["wp"]["url"];
2492
2493 /***/ }
2494
2495 /******/ });
2496 /************************************************************************/
2497 /******/ // The module cache
2498 /******/ const __webpack_module_cache__ = {};
2499 /******/
2500 /******/ // The require function
2501 /******/ function __webpack_require__(moduleId) {
2502 /******/ // Check if module is in cache
2503 /******/ const cachedModule = __webpack_module_cache__[moduleId];
2504 /******/ if (cachedModule !== undefined) {
2505 /******/ return cachedModule.exports;
2506 /******/ }
2507 /******/ // Create a new module (and put it into the cache)
2508 /******/ const module = __webpack_module_cache__[moduleId] = {
2509 /******/ id: moduleId,
2510 /******/ // no module.loaded needed
2511 /******/ exports: {}
2512 /******/ };
2513 /******/
2514 /******/ // Execute the module function
2515 /******/ if (!(moduleId in __webpack_modules__)) {
2516 /******/ delete __webpack_module_cache__[moduleId];
2517 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
2518 /******/ e.code = 'MODULE_NOT_FOUND';
2519 /******/ throw e;
2520 /******/ }
2521 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
2522 /******/
2523 /******/ // Return the exports of the module
2524 /******/ return module.exports;
2525 /******/ }
2526 /******/
2527 /************************************************************************/
2528 /******/ /* webpack/runtime/compat get default export */
2529 /******/ (() => {
2530 /******/ // getDefaultExport function for compatibility with non-harmony modules
2531 /******/ __webpack_require__.n = (module) => {
2532 /******/ const getter = module && module.__esModule ?
2533 /******/ () => (module['default']) :
2534 /******/ () => (module);
2535 /******/ __webpack_require__.d(getter, { a: getter });
2536 /******/ return getter;
2537 /******/ };
2538 /******/ })();
2539 /******/
2540 /******/ /* webpack/runtime/define property getters */
2541 /******/ (() => {
2542 /******/ // define getter/value functions for harmony exports
2543 /******/ __webpack_require__.d = (exports, definition) => {
2544 /******/ if(Array.isArray(definition)) {
2545 /******/ var i = 0;
2546 /******/ while(i < definition.length) {
2547 /******/ var key = definition[i++];
2548 /******/ var binding = definition[i++];
2549 /******/ if(!__webpack_require__.o(exports, key)) {
2550 /******/ if(binding === 0) {
2551 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
2552 /******/ } else {
2553 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
2554 /******/ }
2555 /******/ } else if(binding === 0) { i++; }
2556 /******/ }
2557 /******/ } else {
2558 /******/ for(var key in definition) {
2559 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
2560 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
2561 /******/ }
2562 /******/ }
2563 /******/ }
2564 /******/ };
2565 /******/ })();
2566 /******/
2567 /******/ /* webpack/runtime/hasOwnProperty shorthand */
2568 /******/ (() => {
2569 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
2570 /******/ })();
2571 /******/
2572 /******/ /* webpack/runtime/make namespace object */
2573 /******/ (() => {
2574 /******/ // define __esModule on exports
2575 /******/ __webpack_require__.r = (exports) => {
2576 /******/ if(Symbol.toStringTag) {
2577 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2578 /******/ }
2579 /******/ Object.defineProperty(exports, '__esModule', { value: true });
2580 /******/ };
2581 /******/ })();
2582 /******/
2583 /******/ /* webpack/runtime/nonce */
2584 /******/ (() => {
2585 /******/ __webpack_require__.nc = undefined;
2586 /******/ })();
2587 /******/
2588 /************************************************************************/
2589 let __webpack_exports__ = {};
2590 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
2591 (() => {
2592 "use strict";
2593 /*!******************************************************!*\
2594 !*** ./assets/src/apps/js/frontend/single-course.js ***!
2595 \******************************************************/
2596 __webpack_require__.r(__webpack_exports__);
2597 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2598 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
2599 /* harmony export */ enrollCourse: () => (/* binding */ enrollCourse),
2600 /* harmony export */ init: () => (/* binding */ init),
2601 /* harmony export */ initCourseSidebar: () => (/* binding */ initCourseSidebar),
2602 /* harmony export */ initCourseTabs: () => (/* binding */ initCourseTabs)
2603 /* harmony export */ });
2604 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
2605 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
2606 /* harmony import */ var _single_course_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./single-course/index */ "./assets/src/apps/js/frontend/single-course/index.js");
2607 /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./show-lp-overlay-complete-item */ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js");
2608 /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/lp-modal-overlay */ "./assets/src/apps/js/utils/lp-modal-overlay.js");
2609 /* harmony import */ var _single_curriculum_skeleton__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./single-curriculum/skeleton */ "./assets/src/apps/js/frontend/single-curriculum/skeleton.js");
2610 /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./assets/src/apps/js/frontend/material.js");
2611 /* harmony import */ var _tabs_scroll__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./tabs-scroll */ "./assets/src/apps/js/frontend/tabs-scroll.js");
2612 /* harmony import */ var _js_utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../js/utils.js */ "./assets/src/js/utils.js");
2613 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
2614 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_8__);
2615 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
2616 /* harmony import */ var _js_frontend_copy_to_clipboard_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../js/frontend/copy-to-clipboard.js */ "./assets/src/js/frontend/copy-to-clipboard.js");
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_single_course_index__WEBPACK_IMPORTED_MODULE_1__["default"]);
2629 const init = () => {
2630 wp.element.render((0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_single_course_index__WEBPACK_IMPORTED_MODULE_1__["default"], null));
2631 };
2632 const $ = jQuery;
2633 const initCourseTabs = function () {
2634 $('#learn-press-course-tabs').on('change', 'input[name="learn-press-course-tab-radio"]', function (e) {
2635 const selectedTab = $('input[name="learn-press-course-tab-radio"]:checked').val();
2636 LP.Cookies.set('course-tab', selectedTab);
2637 $('label[for="' + $(e.target).attr('id') + '"]').closest('li').addClass('active').siblings().removeClass('active');
2638 });
2639 };
2640 const initCourseSidebar = function initCourseSidebar() {
2641 const $sidebar = $('.course-summary-sidebar');
2642 if (!$sidebar.length) {
2643 return;
2644 }
2645 const $window = $(window);
2646 const $scrollable = $sidebar.children();
2647 const offset = $sidebar.offset();
2648 let scrollTop = 0;
2649 const maxHeight = $sidebar.height();
2650 const scrollHeight = $scrollable.height();
2651 const options = {
2652 offsetTop: 32
2653 };
2654 const onScroll = function () {
2655 scrollTop = $window.scrollTop();
2656 const top = scrollTop - offset.top + options.offsetTop;
2657 if (top < 0) {
2658 $sidebar.removeClass('slide-top slide-down');
2659 $scrollable.css('top', '');
2660 return;
2661 }
2662 if (top > maxHeight - scrollHeight) {
2663 $sidebar.removeClass('slide-down').addClass('slide-top');
2664 $scrollable.css('top', maxHeight - scrollHeight);
2665 } else {
2666 $sidebar.removeClass('slide-top').addClass('slide-down');
2667 $scrollable.css('top', options.offsetTop);
2668 }
2669 };
2670 $window.on('scroll.fixed-course-sidebar', onScroll).trigger('scroll.fixed-course-sidebar');
2671 };
2672
2673 // Rest API Enroll course - Nhamdv.
2674 const enrollCourse = () => {
2675 const formEnrolls = document.querySelectorAll('form.enroll-course');
2676 if (formEnrolls.length > 0) {
2677 formEnrolls.forEach(formEnroll => {
2678 const submit = async (id, btnEnroll) => {
2679 const status = 'error';
2680 try {
2681 const response = await wp.apiFetch({
2682 path: 'lp/v1/courses/enroll-course',
2683 method: 'POST',
2684 data: {
2685 id
2686 }
2687 });
2688 const {
2689 status,
2690 data: {
2691 redirect
2692 },
2693 message
2694 } = response;
2695 if (status === 'success') {
2696 btnEnroll.remove();
2697 } else {
2698 (0,_js_utils_js__WEBPACK_IMPORTED_MODULE_7__.lpSetLoadingEl)(btnEnroll, 0);
2699 throw new Error(message);
2700 }
2701 if (message && status) {
2702 formEnroll.innerHTML += `<div class="learn-press-message ${status}">${message}</div>`;
2703 if (redirect) {
2704 window.location.href = redirect;
2705 }
2706 }
2707 } catch (error) {
2708 toastify_js__WEBPACK_IMPORTED_MODULE_8___default()({
2709 text: error.message,
2710 gravity: lpData.toast.gravity,
2711 // `top` or `bottom`
2712 position: lpData.toast.position,
2713 // `left`, `center` or `right`
2714 className: `${lpData.toast.classPrefix} ${status}`,
2715 close: lpData.toast.close == 1,
2716 stopOnFocus: lpData.toast.stopOnFocus == 1,
2717 duration: lpData.toast.duration
2718 }).showToast();
2719 }
2720 };
2721 formEnroll.addEventListener('submit', event => {
2722 event.preventDefault();
2723 const id = formEnroll.querySelector('input[name=enroll-course]').value;
2724 const btnEnroll = formEnroll.querySelector('button.button-enroll-course');
2725 (0,_js_utils_js__WEBPACK_IMPORTED_MODULE_7__.lpSetLoadingEl)(btnEnroll, 1);
2726 submit(id, btnEnroll);
2727 });
2728 });
2729 }
2730
2731 // Reload when press back button in chrome.
2732 if (document.querySelector('.course-detail-info') !== null) {
2733 window.addEventListener('pageshow', event => {
2734 const hasCache = event.persisted || typeof window.performance != 'undefined' && String(window.performance.getEntriesByType('navigation')[0].type) == 'back_forward';
2735 if (hasCache) {
2736 location.reload();
2737 }
2738 });
2739 }
2740 };
2741
2742 // Rest API purchase course - Nhamdv.
2743 const purchaseCourse = () => {
2744 const forms = document.querySelectorAll('form.purchase-course');
2745 if (forms.length > 0) {
2746 forms.forEach(form => {
2747 // Allow Repurchase.
2748 const allowRepurchase = () => {
2749 const continueRepurchases = document.querySelectorAll('.lp_allow_repurchase_select');
2750 continueRepurchases.forEach(repurchase => {
2751 const radios = repurchase.querySelectorAll('[name=_lp_allow_repurchase_type]');
2752 for (let i = 0, length = radios.length; i < length; i++) {
2753 if (radios[i].checked) {
2754 const repurchaseType = radios[i].value;
2755 const id = form.querySelector('input[name=purchase-course]').value;
2756 const btnBuyNow = form.querySelector('button.button-purchase-course');
2757 (0,_js_utils_js__WEBPACK_IMPORTED_MODULE_7__.lpSetLoadingEl)(btnBuyNow, 1);
2758 submit(id, btnBuyNow, repurchaseType);
2759 break;
2760 }
2761 }
2762 });
2763 };
2764 const submit = async (id, btn, repurchaseType = false) => {
2765 const status = 'error';
2766 try {
2767 const formData = new FormData(form);
2768 const dataSend = Object.fromEntries(Array.from(formData.keys(), key => {
2769 const val = formData.getAll(key);
2770 return [key, val.length > 1 ? val : val.pop()];
2771 }));
2772 dataSend.id = id;
2773 dataSend.repurchaseType = repurchaseType;
2774 const response = await wp.apiFetch({
2775 path: 'lp/v1/courses/purchase-course',
2776 method: 'POST',
2777 data: dataSend
2778 });
2779 const {
2780 status,
2781 data: {
2782 redirect,
2783 type,
2784 html,
2785 titlePopup
2786 },
2787 message
2788 } = response;
2789 if (status === 'success') {
2790 if (type === 'allow_repurchase') {
2791 (0,_js_utils_js__WEBPACK_IMPORTED_MODULE_7__.lpSetLoadingEl)(btn, 0);
2792 } else {
2793 btn.remove();
2794 }
2795 } else {
2796 (0,_js_utils_js__WEBPACK_IMPORTED_MODULE_7__.lpSetLoadingEl)(btn, 0);
2797 throw new Error(message);
2798 }
2799 if (type === 'allow_repurchase' && status === 'success') {
2800 if (!form.querySelector('.lp_allow_repurchase_select')) {
2801 if (!_utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].init()) {
2802 return;
2803 }
2804 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].elLPOverlay.show();
2805 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].setTitleModal(titlePopup || '');
2806 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].setContentModal(html);
2807 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].callBackYes = () => {
2808 _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].elLPOverlay.hide();
2809 allowRepurchase();
2810 };
2811 }
2812 } else if (message && status) {
2813 form.innerHTML += `<div class="learn-press-message ${status}">${message}</div>`;
2814 if ('success' === status && redirect) {
2815 window.location.href = redirect;
2816 }
2817 }
2818 } catch (error) {
2819 toastify_js__WEBPACK_IMPORTED_MODULE_8___default()({
2820 text: error.message,
2821 gravity: lpData.toast.gravity,
2822 // `top` or `bottom`
2823 position: lpData.toast.position,
2824 // `left`, `center` or `right`
2825 className: `${lpData.toast.classPrefix} ${status}`,
2826 close: lpData.toast.close == 1,
2827 stopOnFocus: lpData.toast.stopOnFocus == 1,
2828 duration: lpData.toast.duration
2829 }).showToast();
2830 }
2831 };
2832 form.addEventListener('submit', event => {
2833 event.preventDefault();
2834 const id = form.querySelector('input[name=purchase-course]').value;
2835 const btn = form.querySelector('button.button-purchase-course');
2836 (0,_js_utils_js__WEBPACK_IMPORTED_MODULE_7__.lpSetLoadingEl)(btn, 1);
2837 submit(id, btn);
2838 });
2839 });
2840 }
2841 };
2842 const retakeCourse = () => {
2843 const elFormRetakeCourses = document.querySelectorAll('.lp-form-retake-course');
2844 if (!elFormRetakeCourses.length) {
2845 return;
2846 }
2847 elFormRetakeCourses.forEach(elFormRetakeCourse => {
2848 const elButtonRetakeCourses = elFormRetakeCourse.querySelector('.button-retake-course');
2849 const elCourseId = elFormRetakeCourse.querySelector('[name=retake-course]').value;
2850 const elAjaxMessage = elFormRetakeCourse.querySelector('.lp-ajax-message');
2851 const submit = elButtonRetakeCourse => {
2852 wp.apiFetch({
2853 path: '/lp/v1/courses/retake-course',
2854 method: 'POST',
2855 data: {
2856 id: elCourseId
2857 }
2858 }).then(res => {
2859 const {
2860 status,
2861 message,
2862 data
2863 } = res;
2864 elAjaxMessage.innerHTML = message;
2865 if (undefined != status && status === 'success') {
2866 elButtonRetakeCourse.style.display = 'none';
2867 setTimeout(() => {
2868 window.location.replace(data.url_redirect);
2869 }, 1000);
2870 } else {
2871 elAjaxMessage.classList.add('error');
2872 }
2873 }).catch(err => {
2874 elAjaxMessage.classList.add('error');
2875 elAjaxMessage.innerHTML = 'error: ' + err.message;
2876 }).then(() => {
2877 elButtonRetakeCourse.classList.remove('loading');
2878 elButtonRetakeCourse.disabled = false;
2879 elAjaxMessage.style.display = 'block';
2880 });
2881 };
2882 elFormRetakeCourse.addEventListener('submit', e => {
2883 e.preventDefault();
2884 });
2885 elButtonRetakeCourses.addEventListener('click', e => {
2886 e.preventDefault();
2887 elButtonRetakeCourses.classList.add('loading');
2888 elButtonRetakeCourses.disabled = true;
2889 submit(elButtonRetakeCourses);
2890 });
2891 });
2892 };
2893
2894 // Rest API load content course progress - Nhamdv.
2895 /*const courseProgress = () => {
2896 const elements = document.querySelectorAll( '.lp-course-progress-wrapper' );
2897
2898 if ( ! elements.length ) {
2899 return;
2900 }
2901
2902 if ( 'IntersectionObserver' in window ) {
2903 const eleObserver = new IntersectionObserver( ( entries, observer ) => {
2904 entries.forEach( ( entry ) => {
2905 if ( entry.isIntersecting ) {
2906 const ele = entry.target;
2907
2908 setTimeout( function() {
2909 getResponse( ele );
2910 }, 600 );
2911
2912 eleObserver.unobserve( ele );
2913 }
2914 } );
2915 } );
2916
2917 [ ...elements ].map( ( ele ) => eleObserver.observe( ele ) );
2918 }
2919
2920 const getResponse = async ( ele ) => {
2921 let url = 'lp/v1/lazy-load/course-progress';
2922 if ( lpData.urlParams.hasOwnProperty( 'lang' ) ) {
2923 url += '?lang=' + lpData.urlParams.lang;
2924 }
2925
2926 const response = await wp.apiFetch( {
2927 path: url,
2928 method: 'POST',
2929 data: {
2930 courseId: lpGlobalSettings.post_id || '',
2931 userId: lpData.user_id || '',
2932 },
2933 } );
2934
2935 const { data } = response;
2936
2937 ele.innerHTML = data;
2938 };
2939 };*/
2940
2941 const accordionExtraTab = () => {
2942 const elements = document.querySelectorAll('.course-extra-box');
2943 [...elements].map(ele => {
2944 const title = ele.querySelector('.course-extra-box__title');
2945 ele.classList.remove('active');
2946 const content = ele.querySelector('.course-extra-box__content');
2947 content.style.height = '0';
2948 title.addEventListener('click', () => {
2949 const isActive = ele.classList.contains('active');
2950 [...elements].forEach(otherEle => {
2951 if (otherEle !== ele) {
2952 otherEle.classList.remove('active');
2953 otherEle.querySelector('.course-extra-box__content').style.height = '0';
2954 }
2955 });
2956 if (isActive) {
2957 ele.classList.remove('active');
2958 content.style.height = '0';
2959 } else {
2960 ele.classList.add('active');
2961 content.style.height = content.scrollHeight + 'px';
2962 }
2963 });
2964 });
2965 };
2966 const courseContinue = () => {
2967 const formContinue = document.querySelectorAll('form.continue-course');
2968 if (formContinue.length && lpData.user_id > 0) {
2969 const getResponse = async ele => {
2970 const response = await wp.apiFetch({
2971 path: 'lp/v1/courses/continue-course',
2972 method: 'POST',
2973 data: {
2974 courseId: lpGlobalSettings.post_id || '',
2975 userId: lpGlobalSettings.user_id || ''
2976 }
2977 });
2978 return response;
2979 };
2980 getResponse(formContinue).then(function (result) {
2981 if (result.status === 'success') {
2982 formContinue.forEach(form => {
2983 form.style.display = 'inline-block';
2984 form.action = result.data;
2985 });
2986 }
2987 });
2988 }
2989 };
2990
2991 document.addEventListener('DOMContentLoaded', function () {
2992 const $popup = $('#popup-course');
2993 let timerClearScroll;
2994 const $curriculum = $('#learn-press-course-curriculum');
2995 accordionExtraTab();
2996 initCourseTabs();
2997 initCourseSidebar();
2998 enrollCourse();
2999 purchaseCourse();
3000 retakeCourse();
3001 //courseProgress();
3002 courseContinue();
3003 _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_2__["default"].init();
3004 (0,_material__WEBPACK_IMPORTED_MODULE_5__["default"])();
3005 //courseCurriculumSkeleton();
3006 (0,_tabs_scroll__WEBPACK_IMPORTED_MODULE_6__["default"])();
3007 (0,_js_frontend_copy_to_clipboard_js__WEBPACK_IMPORTED_MODULE_10__["default"])();
3008 });
3009 const detectedElCurriculum = setInterval(function () {
3010 const elementCurriculum = document.querySelector('.learnpress-course-curriculum');
3011 if (elementCurriculum) {
3012 (0,_single_curriculum_skeleton__WEBPACK_IMPORTED_MODULE_4__["default"])();
3013 clearInterval(detectedElCurriculum);
3014 }
3015 }, 1);
3016
3017 // Add callback for Thimkits
3018 LP.Hook.addAction('lp_course_curriculum_skeleton', function (id) {
3019 (0,_single_curriculum_skeleton__WEBPACK_IMPORTED_MODULE_4__["default"])(id);
3020 });
3021 })();
3022
3023 /******/ })()
3024 ;
3025 //# sourceMappingURL=single-course.js.map