PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.8
4.4.9 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 All 140 releases
learnpress / assets / js / dist / frontend / single-curriculum.js

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

1,154 lines 38.7 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-curriculum/components/comment.js"
119 /*!*****************************************************************************!*\
120 !*** ./assets/src/apps/js/frontend/single-curriculum/components/comment.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 */ commentForm: () => (/* binding */ commentForm)
128 /* harmony export */ });
129 /**
130 * Toogle form Comment for Lesson.
131 *
132 * @author Nhamdv.
133 */
134
135 const commentForm = () => {
136 const btn = document.querySelector('.lp-lesson-comment-btn');
137 if (!btn) {
138 return;
139 }
140 const btnOpen = btn.textContent;
141 const btnClose = btn.dataset.close;
142 const hashComment = window.location.hash;
143 if (hashComment.includes('comment')) {
144 btn.parentNode.classList.add('open-comments');
145 }
146 const toogleText = (btn, btnParent) => {
147 if (btnParent.classList.contains('open-comments')) {
148 btn.textContent = btnClose;
149 } else {
150 btn.textContent = btnOpen;
151 }
152 };
153 toogleText(btn, btn.parentNode);
154 btn.addEventListener('click', e => {
155 e.preventDefault();
156 btn.parentNode.classList.toggle('open-comments');
157 toogleText(btn, btn.parentNode);
158 });
159
160 // Use for Rest API.
161 // const toogle = $( '#learn-press-item-comments-toggle' );
162
163 // toogle.on( 'change', async function() {
164 // if ( ! toogle[ 0 ].checked ) {
165 // return;
166 // }
167
168 // const response = await wp.apiFetch( {
169 // path: 'lp/v1/courses/339/item-comments/50',
170 // } );
171
172 // $( '.learn-press-comments' ).html( response.comments );
173 // } );
174 };
175
176 /***/ },
177
178 /***/ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js"
179 /*!********************************************************************************!*\
180 !*** ./assets/src/apps/js/frontend/single-curriculum/components/compatible.js ***!
181 \********************************************************************************/
182 () {
183
184 /**
185 * Compatible with Page Builder.
186 *
187 * @author nhamdv
188 */
189
190 LP.Hook.addAction('lp-compatible-builder', () => {
191 LP.Hook.removeAction('lp-compatible-builder');
192 if (typeof elementorFrontend !== 'undefined') {
193 [...document.querySelectorAll('#popup-content')][0].addEventListener('scroll', () => {
194 //Waypoint.refreshAll();
195 window.dispatchEvent(new Event('resize'));
196 });
197 }
198
199 /*if ( typeof vc_js !== 'undefined' && typeof VcWaypoint !== 'undefined' ) {
200 [ ...document.querySelectorAll( '#popup-content' ) ][ 0 ].addEventListener( 'scroll', () => {
201 VcWaypoint.refreshAll();
202 } );
203 }*/
204 });
205 LP.Hook.addAction('lp-quiz-compatible-builder', () => {
206 LP.Hook.removeAction('lp-quiz-compatible-builder');
207 LP.Hook.doAction('lp-compatible-builder');
208 if (typeof elementorFrontend !== 'undefined') {
209 return window.elementorFrontend.init();
210 }
211 if (typeof vc_js !== 'undefined') {
212 if (typeof vc_round_charts !== 'undefined') {
213 vc_round_charts();
214 }
215 if (typeof vc_pieChart !== 'undefined') {
216 vc_pieChart();
217 }
218 if (typeof vc_line_charts !== 'undefined') {
219 vc_line_charts();
220 }
221 return window.vc_js();
222 }
223 });
224 LP.Hook.addAction('lp-question-compatible-builder', () => {
225 LP.Hook.removeAction('lp-question-compatible-builder');
226 LP.Hook.removeAction('lp-quiz-compatible-builder');
227 LP.Hook.doAction('lp-compatible-builder');
228 if (typeof elementorFrontend !== 'undefined') {
229 return window.elementorFrontend.init();
230 }
231 if (typeof vc_js !== 'undefined') {
232 if (typeof vc_round_charts !== 'undefined') {
233 vc_round_charts();
234 }
235 if (typeof vc_pieChart !== 'undefined') {
236 vc_pieChart();
237 }
238 if (typeof vc_line_charts !== 'undefined') {
239 vc_line_charts();
240 }
241 return window.vc_js();
242 }
243 });
244
245 /***/ },
246
247 /***/ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js"
248 /*!************************************************************************************!*\
249 !*** ./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js ***!
250 \************************************************************************************/
251 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
252
253 "use strict";
254 __webpack_require__.r(__webpack_exports__);
255 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
256 /* harmony export */ getResponse: () => (/* binding */ getResponse),
257 /* harmony export */ itemsProgress: () => (/* binding */ itemsProgress)
258 /* harmony export */ });
259 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
260 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
261 /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../show-lp-overlay-complete-item */ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js");
262 // Rest API load content course progress - Nhamdv.
263
264
265 const itemsProgress = () => {
266 const elements = document.querySelectorAll('.popup-header__inner');
267 if (!elements.length) {
268 return;
269 }
270 if (document.querySelector('#learn-press-quiz-app div.quiz-result') !== null) {
271 return;
272 }
273 if (elements[0].querySelectorAll('form.form-button-finish-course').length !== 0) {
274 return;
275 }
276 const user_id = lpGlobalSettings.user_id || 0;
277 if (user_id === 0) {
278 return;
279 }
280 if ('IntersectionObserver' in window) {
281 const eleObserver = new IntersectionObserver((entries, observer) => {
282 entries.forEach(entry => {
283 if (entry.isIntersecting) {
284 const ele = entry.target;
285 getResponse(ele);
286 eleObserver.unobserve(ele);
287 }
288 });
289 });
290 [...elements].map(ele => eleObserver.observe(ele));
291 }
292 };
293 const getResponse = async ele => {
294 const response = await wp.apiFetch({
295 path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/lazy-load/items-progress', {
296 courseId: lpGlobalSettings.post_id || '',
297 userId: lpGlobalSettings.user_id || ''
298 }),
299 method: 'GET'
300 });
301 const {
302 data
303 } = response;
304 ele.innerHTML += data;
305 ele.classList.add('can-finish-course');
306 _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init();
307 };
308
309 /***/ },
310
311 /***/ "./assets/src/apps/js/frontend/single-curriculum/components/progress.js"
312 /*!******************************************************************************!*\
313 !*** ./assets/src/apps/js/frontend/single-curriculum/components/progress.js ***!
314 \******************************************************************************/
315 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
316
317 "use strict";
318 __webpack_require__.r(__webpack_exports__);
319 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
320 /* harmony export */ progressBar: () => (/* binding */ progressBar)
321 /* harmony export */ });
322 const $ = jQuery;
323 const progressBar = () => {
324 $('.learn-press-progress').each(function () {
325 const $progress = $(this);
326 const $active = $progress.find('.learn-press-progress__active');
327 const value = $active.data('value');
328 if (value === undefined) {
329 return;
330 }
331 $active.css('left', -(100 - parseInt(value)) + '%');
332 });
333 };
334
335 /***/ },
336
337 /***/ "./assets/src/apps/js/frontend/single-curriculum/components/search.js"
338 /*!****************************************************************************!*\
339 !*** ./assets/src/apps/js/frontend/single-curriculum/components/search.js ***!
340 \****************************************************************************/
341 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
342
343 "use strict";
344 __webpack_require__.r(__webpack_exports__);
345 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
346 /* harmony export */ searchCourseContent: () => (/* binding */ searchCourseContent)
347 /* harmony export */ });
348 const searchCourseContent = () => {
349 const popup = document.querySelector('#popup-course');
350 const list = document.querySelector('#learn-press-course-curriculum');
351 if (popup && list) {
352 const items = list.querySelector('.curriculum-sections');
353 const form = popup.querySelector('.search-course');
354 const search = popup.querySelector('.search-course input[type="text"]');
355 if (!search || !items || !form) {
356 return;
357 }
358 const sections = items.querySelectorAll('li.section');
359 const dataItems = items.querySelectorAll('li.course-item');
360 const dataSearch = [];
361 dataItems.forEach(item => {
362 const itemID = item.dataset.id;
363 const name = item.querySelector('.item-name');
364 dataSearch.push({
365 id: itemID,
366 name: name ? name.textContent.toLowerCase() : ''
367 });
368 });
369 const submit = event => {
370 event.preventDefault();
371 const inputVal = search.value;
372 form.classList.add('searching');
373 if (!inputVal) {
374 form.classList.remove('searching');
375 }
376 const outputs = [];
377 dataSearch.forEach(i => {
378 if (!inputVal || i.name.match(inputVal.toLowerCase())) {
379 outputs.push(i.id);
380 dataItems.forEach(c => {
381 if (outputs.indexOf(c.dataset.id) !== -1) {
382 c.classList.remove('hide-if-js');
383 } else {
384 c.classList.add('hide-if-js');
385 }
386 });
387 }
388 });
389 sections.forEach(section => {
390 const listItem = section.querySelectorAll('.course-item');
391 const isTrue = [];
392 listItem.forEach(a => {
393 if (outputs.includes(a.dataset.id)) {
394 isTrue.push(a.dataset.id);
395 }
396 });
397 if (isTrue.length === 0) {
398 section.classList.add('hide-if-js');
399 } else {
400 section.classList.remove('hide-if-js');
401 }
402 });
403 };
404 const clear = form.querySelector('.clear');
405 if (clear) {
406 clear.addEventListener('click', e => {
407 e.preventDefault();
408 search.value = '';
409 submit(e);
410 });
411 }
412 form.addEventListener('submit', submit);
413 search.addEventListener('keyup', submit);
414 }
415 };
416
417 /***/ },
418
419 /***/ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js"
420 /*!*****************************************************************************!*\
421 !*** ./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js ***!
422 \*****************************************************************************/
423 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
424
425 "use strict";
426 __webpack_require__.r(__webpack_exports__);
427 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
428 /* harmony export */ Sidebar: () => (/* binding */ Sidebar)
429 /* harmony export */ });
430 const $ = jQuery;
431 const {
432 throttle
433 } = lodash;
434 const Sidebar = () => {
435 // Tungnx - Show/hide sidebar curriculumn
436 const elSidebarToggle = document.querySelector('#sidebar-toggle');
437
438 // For style of theme
439 const toggleSidebar = toggle => {
440 $('body').removeClass('lp-sidebar-toggle__open');
441 $('body').removeClass('lp-sidebar-toggle__close');
442 if (toggle) {
443 $('body').addClass('lp-sidebar-toggle__close');
444 } else {
445 $('body').addClass('lp-sidebar-toggle__open');
446 }
447 };
448
449 // For lp and theme
450 if (elSidebarToggle) {
451 if ($(window).innerWidth() <= 768) {
452 elSidebarToggle.setAttribute('checked', 'checked');
453 } else if (LP.Cookies.get('sidebar-toggle')) {
454 elSidebarToggle.setAttribute('checked', 'checked');
455 } else {
456 elSidebarToggle.removeAttribute('checked');
457 }
458 }
459 // End editor by tungnx
460
461 // Code for old curriculum
462 /*const $curriculum = $( '#learn-press-course-curriculum' );
463 $curriculum.find( '.section-desc' ).each( ( i, el ) => {
464 const a = $( '<span class="show-desc"></span>' ).on( 'click', () => {
465 b.toggleClass( 'c' );
466 } );
467 const b = $( el ).siblings( '.section-title' ).append( a );
468 } );*/
469
470 // Code for old curriculum
471 /*$( '.section' ).each( function() {
472 const $section = $( this ),
473 $toggle = $section.find( '.section-left' );
474
475 $toggle.on( 'click', function() {
476 const isClose = $section.toggleClass( 'closed' ).hasClass( 'closed' );
477 const sections = LP.Cookies.get( 'closed-section-' + lpGlobalSettings.post_id ) || [];
478 const sectionId = parseInt( $section.data( 'section-id' ) );
479 const at = sections.findIndex( ( id ) => {
480 return id == sectionId;
481 } );
482
483 if ( isClose ) {
484 sections.push( parseInt( $section.data( 'section-id' ) ) );
485 } else {
486 sections.splice( at, 1 );
487 }
488
489 LP.Cookies.remove( 'closed-section-(.*)' );
490 LP.Cookies.set( 'closed-section-' + lpGlobalSettings.post_id, [ ...new Set( sections ) ] );
491 } );
492 } );*/
493
494 document.addEventListener('click', e => {
495 if (e.target.id === 'sidebar-toggle') {
496 LP.Cookies.set('sidebar-toggle', e.target.checked ? true : false);
497 toggleSidebar(LP.Cookies.get('sidebar-toggle'));
498 }
499 });
500 };
501
502 /***/ },
503
504 /***/ "./assets/src/apps/js/frontend/single-curriculum/index.js"
505 /*!****************************************************************!*\
506 !*** ./assets/src/apps/js/frontend/single-curriculum/index.js ***!
507 \****************************************************************/
508 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
509
510 "use strict";
511 __webpack_require__.r(__webpack_exports__);
512 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
513 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
514 /* harmony export */ });
515 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
516 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
517 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
518 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__);
519 /* harmony import */ var _components_search__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/search */ "./assets/src/apps/js/frontend/single-curriculum/components/search.js");
520 /* harmony import */ var _components_sidebar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/sidebar */ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js");
521 /* harmony import */ var _components_progress__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/progress */ "./assets/src/apps/js/frontend/single-curriculum/components/progress.js");
522 /* harmony import */ var _components_comment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/comment */ "./assets/src/apps/js/frontend/single-curriculum/components/comment.js");
523 /* harmony import */ var _components_items_progress__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./components/items-progress */ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js");
524 /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/compatible */ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js");
525 /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_components_compatible__WEBPACK_IMPORTED_MODULE_7__);
526
527 const $ = jQuery;
528
529
530
531
532
533
534
535 class SingleCurriculums extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component {
536 checkCourseDurationExpire() {
537 const elCourseItemIsBlockeds = document.getElementsByName('lp-course-timestamp-remaining');
538 if (elCourseItemIsBlockeds.length) {
539 const elCourseItemIsBlocked = elCourseItemIsBlockeds[0];
540 const timeDuration = elCourseItemIsBlocked.value; // value is second
541
542 if (timeDuration < 60 * 60 * 24) {
543 // compare with 1 day
544 setTimeout(function () {
545 window.location.reload(true);
546 }, timeDuration * 1000);
547 }
548 }
549 }
550 render() {
551 return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null);
552 }
553 }
554 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SingleCurriculums);
555 document.addEventListener('DOMContentLoaded', () => {
556 LP.Hook.doAction('lp-compatible-builder');
557 (0,_components_search__WEBPACK_IMPORTED_MODULE_2__.searchCourseContent)();
558 (0,_components_sidebar__WEBPACK_IMPORTED_MODULE_3__.Sidebar)();
559 (0,_components_progress__WEBPACK_IMPORTED_MODULE_4__.progressBar)();
560 //commentForm();
561 (0,_components_items_progress__WEBPACK_IMPORTED_MODULE_6__.itemsProgress)();
562
563 // Check duration expire of course
564 const singleCurriculums = new SingleCurriculums();
565 singleCurriculums.checkCourseDurationExpire();
566 });
567
568 /***/ },
569
570 /***/ "./assets/src/apps/js/utils/lp-modal-overlay.js"
571 /*!******************************************************!*\
572 !*** ./assets/src/apps/js/utils/lp-modal-overlay.js ***!
573 \******************************************************/
574 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
575
576 "use strict";
577 __webpack_require__.r(__webpack_exports__);
578 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
579 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
580 /* harmony export */ });
581 const $ = jQuery;
582 let elLPOverlay = null;
583 const lpModalOverlay = {
584 elLPOverlay: null,
585 elMainContent: null,
586 elTitle: null,
587 elBtnYes: null,
588 elBtnNo: null,
589 elFooter: null,
590 elCalledModal: null,
591 callBackYes: null,
592 instance: null,
593 init() {
594 if (this.instance) {
595 return true;
596 }
597 this.elLPOverlay = $('.lp-overlay');
598 if (!this.elLPOverlay.length) {
599 return false;
600 }
601 elLPOverlay = this.elLPOverlay;
602 this.elMainContent = elLPOverlay.find('.main-content');
603 this.elTitle = elLPOverlay.find('.modal-title');
604 this.elBtnYes = elLPOverlay.find('.btn-yes');
605 this.elBtnNo = elLPOverlay.find('.btn-no');
606 this.elFooter = elLPOverlay.find('.lp-modal-footer');
607 $(document).on('click', '.close, .btn-no', function () {
608 elLPOverlay.hide();
609 });
610 $(document).on('click', '.btn-yes', function (e) {
611 e.preventDefault();
612 e.stopPropagation();
613 if ('function' === typeof lpModalOverlay.callBackYes) {
614 lpModalOverlay.callBackYes(e);
615 }
616 });
617 this.instance = this;
618 return true;
619 },
620 setElCalledModal(elCalledModal) {
621 this.elCalledModal = elCalledModal;
622 },
623 setContentModal(content, event) {
624 this.elMainContent.html(content);
625 if ('function' === typeof event) {
626 event();
627 }
628 },
629 setTitleModal(content) {
630 this.elTitle.html(content);
631 }
632 };
633 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlay);
634
635 /***/ },
636
637 /***/ "./assets/src/js/utils.js"
638 /*!********************************!*\
639 !*** ./assets/src/js/utils.js ***!
640 \********************************/
641 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
642
643 "use strict";
644 __webpack_require__.r(__webpack_exports__);
645 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
646 /* harmony export */ debounce: () => (/* binding */ debounce),
647 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
648 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
649 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
650 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
651 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
652 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
653 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
654 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
655 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
656 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
657 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
658 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
659 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
660 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
661 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
662 /* harmony export */ });
663 /**
664 * Utils functions
665 *
666 * @param url
667 * @param data
668 * @param functions
669 * @since 4.2.5.1
670 * @version 1.0.6
671 */
672 const lpClassName = {
673 hidden: 'lp-hidden',
674 loading: 'loading',
675 elCollapse: 'lp-collapse',
676 elSectionToggle: '.lp-section-toggle',
677 elTriggerToggle: '.lp-trigger-toggle'
678 };
679 const lpFetchAPI = (url, data = {}, functions = {}) => {
680 if ('function' === typeof functions.before) {
681 functions.before();
682 }
683 fetch(url, {
684 method: 'GET',
685 ...data
686 }).then(response => response.json()).then(response => {
687 if ('function' === typeof functions.success) {
688 functions.success(response);
689 }
690 }).catch(err => {
691 if ('function' === typeof functions.error) {
692 functions.error(err);
693 }
694 }).finally(() => {
695 if ('function' === typeof functions.completed) {
696 functions.completed();
697 }
698 });
699 };
700
701 /**
702 * Get current URL without params.
703 *
704 * @since 4.2.5.1
705 */
706 const lpGetCurrentURLNoParam = () => {
707 let currentUrl = window.location.href;
708 const hasParams = currentUrl.includes('?');
709 if (hasParams) {
710 currentUrl = currentUrl.split('?')[0];
711 }
712 return currentUrl;
713 };
714 const lpAddQueryArgs = (endpoint, args) => {
715 const url = new URL(endpoint);
716 Object.keys(args).forEach(arg => {
717 url.searchParams.set(arg, args[arg]);
718 });
719 return url;
720 };
721
722 /**
723 * Listen element viewed.
724 *
725 * @param el
726 * @param callback
727 * @since 4.2.5.8
728 */
729 const listenElementViewed = (el, callback) => {
730 const observerSeeItem = new IntersectionObserver(function (entries) {
731 for (const entry of entries) {
732 if (entry.isIntersecting) {
733 callback(entry);
734 }
735 }
736 });
737 observerSeeItem.observe(el);
738 };
739
740 /**
741 * Listen element created.
742 *
743 * @param callback
744 * @since 4.2.5.8
745 */
746 const listenElementCreated = callback => {
747 const observerCreateItem = new MutationObserver(function (mutations) {
748 mutations.forEach(function (mutation) {
749 if (mutation.addedNodes) {
750 mutation.addedNodes.forEach(function (node) {
751 if (node.nodeType === 1) {
752 callback(node);
753 }
754 });
755 }
756 });
757 });
758 observerCreateItem.observe(document, {
759 childList: true,
760 subtree: true
761 });
762 // End.
763 };
764
765 /**
766 * Listen element created.
767 *
768 * @param selector
769 * @param callback
770 * @since 4.2.7.1
771 */
772 const lpOnElementReady = (selector, callback) => {
773 const element = document.querySelector(selector);
774 if (element) {
775 callback(element);
776 return;
777 }
778 const observer = new MutationObserver((mutations, obs) => {
779 const element = document.querySelector(selector);
780 if (element) {
781 obs.disconnect();
782 callback(element);
783 }
784 });
785 observer.observe(document.documentElement, {
786 childList: true,
787 subtree: true
788 });
789 };
790
791 // Parse JSON from string with content include LP_AJAX_START.
792 const lpAjaxParseJsonOld = data => {
793 if (typeof data !== 'string') {
794 return data;
795 }
796 const m = String.raw({
797 raw: data
798 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
799 try {
800 if (m) {
801 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
802 } else {
803 data = JSON.parse(data);
804 }
805 } catch (e) {
806 data = {};
807 }
808 return data;
809 };
810
811 // status 0: hide, 1: show
812 const lpShowHideEl = (el, status = 0) => {
813 if (!el) {
814 return;
815 }
816 if (!status) {
817 el.classList.add(lpClassName.hidden);
818 } else {
819 el.classList.remove(lpClassName.hidden);
820 }
821 };
822
823 // status 0: hide, 1: show
824 const lpSetLoadingEl = (el, status) => {
825 if (!el) {
826 return;
827 }
828 if (!status) {
829 el.classList.remove(lpClassName.loading);
830 } else {
831 el.classList.add(lpClassName.loading);
832 }
833 };
834
835 // Toggle collapse section
836 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
837 if (!elTriggerClassName) {
838 elTriggerClassName = lpClassName.elTriggerToggle;
839 }
840
841 // Exclude elements, which should not trigger the collapse toggle
842 if (elsExclude && elsExclude.length > 0) {
843 for (const elExclude of elsExclude) {
844 if (target.closest(elExclude)) {
845 return;
846 }
847 }
848 }
849 const elTrigger = target.closest(elTriggerClassName);
850 if (!elTrigger) {
851 return;
852 }
853
854 //console.log( 'elTrigger', elTrigger );
855
856 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
857 if (!elSectionToggle) {
858 return;
859 }
860 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
861 if ('function' === typeof callback) {
862 callback(elSectionToggle);
863 }
864 };
865
866 // Get data of form
867 const getDataOfForm = form => {
868 const dataSend = {};
869 const formData = new FormData(form);
870 for (const pair of formData.entries()) {
871 const key = pair[0];
872 const value = formData.getAll(key);
873 if (!dataSend.hasOwnProperty(key)) {
874 // Convert value array to string.
875 dataSend[key] = value.join(',');
876 }
877 }
878 return dataSend;
879 };
880
881 // Get field keys of form
882 const getFieldKeysOfForm = form => {
883 const keys = [];
884 const elements = form.elements;
885 for (let i = 0; i < elements.length; i++) {
886 const name = elements[i].name;
887 if (name && !keys.includes(name)) {
888 keys.push(name);
889 }
890 }
891 return keys;
892 };
893
894 // Merge data handle with data form.
895 const mergeDataWithDatForm = (elForm, dataHandle) => {
896 const dataForm = getDataOfForm(elForm);
897 const keys = getFieldKeysOfForm(elForm);
898 keys.forEach(key => {
899 if (!dataForm.hasOwnProperty(key)) {
900 delete dataHandle[key];
901 } else if (dataForm[key][0] === '') {
902 delete dataForm[key];
903 delete dataHandle[key];
904 }
905 });
906 dataHandle = {
907 ...dataHandle,
908 ...dataForm
909 };
910 return dataHandle;
911 };
912
913 /**
914 * Event trigger
915 * For each list of event handlers, listen event on document.
916 *
917 * eventName: 'click', 'change', ...
918 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
919 *
920 * @param eventName
921 * @param eventHandlers
922 */
923 const eventHandlers = (eventName, eventHandlers) => {
924 document.addEventListener(eventName, e => {
925 const target = e.target;
926 let args = {
927 e,
928 target
929 };
930 eventHandlers.forEach(eventHandler => {
931 args = {
932 ...args,
933 ...eventHandler
934 };
935
936 //console.log( args );
937
938 // Check condition before call back
939 if (eventHandler.conditionBeforeCallBack) {
940 if (eventHandler.conditionBeforeCallBack(args) !== true) {
941 return;
942 }
943 }
944
945 // Special check for keydown event with checkIsEventEnter = true
946 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
947 if (e.key !== 'Enter') {
948 return;
949 }
950 }
951 if (target.closest(eventHandler.selector)) {
952 if (eventHandler.class) {
953 // Call method of class, function callBack will understand exactly {this} is class object.
954 eventHandler.class[eventHandler.callBack](args);
955 } else {
956 // For send args is objected, {this} is eventHandler object, not class object.
957 eventHandler.callBack(args);
958 }
959 }
960 });
961 });
962 };
963
964 /**
965 * Debounce - delays function execution until after `wait` ms of inactivity.
966 *
967 * Each call resets the timer. Only the last call in a burst executes.
968 *
969 * USE CASES:
970 * - Search inputs, form validation, window resize
971 * - Multiple elements need independent timers
972 * - When you need to call with different arguments
973 *
974 * EXAMPLES:
975 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
976 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
977 *
978 * const debouncedResize = debounce( recalculateLayout, 250 );
979 * window.addEventListener('resize', debouncedResize);
980 *
981 * ⚠️ Create ONCE outside event handlers, not inside.
982 *
983 * @param {Function} func - Function to debounce (can be anonymous)
984 * @param {number} wait - Milliseconds to wait (default: 500)
985 * @return {Function} Debounced wrapper function
986 * @since 4.3.7
987 * @version 1.0.0
988 */
989 const debounce = (func, wait = 500) => {
990 let timer;
991 return args => {
992 clearTimeout(timer);
993 timer = setTimeout(() => func(args), wait);
994 };
995 };
996
997 /***/ },
998
999 /***/ "react"
1000 /*!************************!*\
1001 !*** external "React" ***!
1002 \************************/
1003 (module) {
1004
1005 "use strict";
1006 module.exports = window["React"];
1007
1008 /***/ },
1009
1010 /***/ "@wordpress/element"
1011 /*!*********************************!*\
1012 !*** external ["wp","element"] ***!
1013 \*********************************/
1014 (module) {
1015
1016 "use strict";
1017 module.exports = window["wp"]["element"];
1018
1019 /***/ },
1020
1021 /***/ "@wordpress/url"
1022 /*!*****************************!*\
1023 !*** external ["wp","url"] ***!
1024 \*****************************/
1025 (module) {
1026
1027 "use strict";
1028 module.exports = window["wp"]["url"];
1029
1030 /***/ }
1031
1032 /******/ });
1033 /************************************************************************/
1034 /******/ // The module cache
1035 /******/ var __webpack_module_cache__ = {};
1036 /******/
1037 /******/ // The require function
1038 /******/ function __webpack_require__(moduleId) {
1039 /******/ // Check if module is in cache
1040 /******/ var cachedModule = __webpack_module_cache__[moduleId];
1041 /******/ if (cachedModule !== undefined) {
1042 /******/ return cachedModule.exports;
1043 /******/ }
1044 /******/ // Create a new module (and put it into the cache)
1045 /******/ var module = __webpack_module_cache__[moduleId] = {
1046 /******/ // no module.id needed
1047 /******/ // no module.loaded needed
1048 /******/ exports: {}
1049 /******/ };
1050 /******/
1051 /******/ // Execute the module function
1052 /******/ if (!(moduleId in __webpack_modules__)) {
1053 /******/ delete __webpack_module_cache__[moduleId];
1054 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
1055 /******/ e.code = 'MODULE_NOT_FOUND';
1056 /******/ throw e;
1057 /******/ }
1058 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1059 /******/
1060 /******/ // Return the exports of the module
1061 /******/ return module.exports;
1062 /******/ }
1063 /******/
1064 /************************************************************************/
1065 /******/ /* webpack/runtime/compat get default export */
1066 /******/ (() => {
1067 /******/ // getDefaultExport function for compatibility with non-harmony modules
1068 /******/ __webpack_require__.n = (module) => {
1069 /******/ var getter = module && module.__esModule ?
1070 /******/ () => (module['default']) :
1071 /******/ () => (module);
1072 /******/ __webpack_require__.d(getter, { a: getter });
1073 /******/ return getter;
1074 /******/ };
1075 /******/ })();
1076 /******/
1077 /******/ /* webpack/runtime/define property getters */
1078 /******/ (() => {
1079 /******/ // define getter functions for harmony exports
1080 /******/ __webpack_require__.d = (exports, definition) => {
1081 /******/ for(var key in definition) {
1082 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1083 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1084 /******/ }
1085 /******/ }
1086 /******/ };
1087 /******/ })();
1088 /******/
1089 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1090 /******/ (() => {
1091 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1092 /******/ })();
1093 /******/
1094 /******/ /* webpack/runtime/make namespace object */
1095 /******/ (() => {
1096 /******/ // define __esModule on exports
1097 /******/ __webpack_require__.r = (exports) => {
1098 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1099 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1100 /******/ }
1101 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1102 /******/ };
1103 /******/ })();
1104 /******/
1105 /************************************************************************/
1106 var __webpack_exports__ = {};
1107 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
1108 (() => {
1109 "use strict";
1110 /*!**********************************************************!*\
1111 !*** ./assets/src/apps/js/frontend/single-curriculum.js ***!
1112 \**********************************************************/
1113 __webpack_require__.r(__webpack_exports__);
1114 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1115 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1116 /* harmony export */ });
1117 /* harmony import */ var _single_curriculum_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./single-curriculum/index */ "./assets/src/apps/js/frontend/single-curriculum/index.js");
1118 /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./show-lp-overlay-complete-item */ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js");
1119 /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./material */ "./assets/src/apps/js/frontend/material.js");
1120
1121
1122 //import courseCurriculumSkeleton from './single-curriculum/skeleton';
1123
1124 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_single_curriculum_index__WEBPACK_IMPORTED_MODULE_0__["default"]);
1125
1126 // Comment code use for old curriculum
1127 /*export const init = () => {
1128 wp.element.render(
1129 <SingleCurriculums />,
1130 document.getElementById( 'learn-press-course-curriculum' )
1131 );
1132 };*/
1133
1134 document.addEventListener('DOMContentLoaded', function (event) {
1135 //LP.Hook.doAction( 'course-ready' );
1136 _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init();
1137 (0,_material__WEBPACK_IMPORTED_MODULE_2__["default"])();
1138 //courseCurriculumSkeleton();
1139 //init();
1140 });
1141
1142 // Comment code use for old curriculum
1143 /*const detectedElCurriculum = setInterval( function() {
1144 const elementCurriculum = document.querySelector( '.learnpress-course-curriculum' );
1145 if ( elementCurriculum ) {
1146 courseCurriculumSkeleton();
1147 clearInterval( detectedElCurriculum );
1148 }
1149 }, 1 );*/
1150 })();
1151
1152 /******/ })()
1153 ;
1154 //# sourceMappingURL=single-curriculum.js.map