PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.3
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-curriculum.js

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

1,151 lines 38.5 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 $toggle.on( 'click', function() {
475 const isClose = $section.toggleClass( 'closed' ).hasClass( 'closed' );
476 const sections = LP.Cookies.get( 'closed-section-' + lpGlobalSettings.post_id ) || [];
477 const sectionId = parseInt( $section.data( 'section-id' ) );
478 const at = sections.findIndex( ( id ) => {
479 return id == sectionId;
480 } );
481 if ( isClose ) {
482 sections.push( parseInt( $section.data( 'section-id' ) ) );
483 } else {
484 sections.splice( at, 1 );
485 }
486 LP.Cookies.remove( 'closed-section-(.*)' );
487 LP.Cookies.set( 'closed-section-' + lpGlobalSettings.post_id, [ ...new Set( sections ) ] );
488 } );
489 } );*/
490
491 document.addEventListener('click', e => {
492 if (e.target.id === 'sidebar-toggle') {
493 LP.Cookies.set('sidebar-toggle', e.target.checked ? true : false);
494 toggleSidebar(LP.Cookies.get('sidebar-toggle'));
495 }
496 });
497 };
498
499 /***/ },
500
501 /***/ "./assets/src/apps/js/frontend/single-curriculum/index.js"
502 /*!****************************************************************!*\
503 !*** ./assets/src/apps/js/frontend/single-curriculum/index.js ***!
504 \****************************************************************/
505 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
506
507 "use strict";
508 __webpack_require__.r(__webpack_exports__);
509 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
510 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
511 /* harmony export */ });
512 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
513 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
514 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
515 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__);
516 /* harmony import */ var _components_search__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/search */ "./assets/src/apps/js/frontend/single-curriculum/components/search.js");
517 /* harmony import */ var _components_sidebar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/sidebar */ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js");
518 /* harmony import */ var _components_progress__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/progress */ "./assets/src/apps/js/frontend/single-curriculum/components/progress.js");
519 /* harmony import */ var _components_comment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/comment */ "./assets/src/apps/js/frontend/single-curriculum/components/comment.js");
520 /* 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");
521 /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/compatible */ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js");
522 /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_components_compatible__WEBPACK_IMPORTED_MODULE_7__);
523
524 const $ = jQuery;
525
526
527
528
529
530
531
532 class SingleCurriculums extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component {
533 checkCourseDurationExpire() {
534 const elCourseItemIsBlockeds = document.getElementsByName('lp-course-timestamp-remaining');
535 if (elCourseItemIsBlockeds.length) {
536 const elCourseItemIsBlocked = elCourseItemIsBlockeds[0];
537 const timeDuration = elCourseItemIsBlocked.value; // value is second
538
539 if (timeDuration < 60 * 60 * 24) {
540 // compare with 1 day
541 setTimeout(function () {
542 window.location.reload(true);
543 }, timeDuration * 1000);
544 }
545 }
546 }
547 render() {
548 return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null);
549 }
550 }
551 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SingleCurriculums);
552 document.addEventListener('DOMContentLoaded', () => {
553 LP.Hook.doAction('lp-compatible-builder');
554 (0,_components_search__WEBPACK_IMPORTED_MODULE_2__.searchCourseContent)();
555 (0,_components_sidebar__WEBPACK_IMPORTED_MODULE_3__.Sidebar)();
556 (0,_components_progress__WEBPACK_IMPORTED_MODULE_4__.progressBar)();
557 //commentForm();
558 (0,_components_items_progress__WEBPACK_IMPORTED_MODULE_6__.itemsProgress)();
559
560 // Check duration expire of course
561 const singleCurriculums = new SingleCurriculums();
562 singleCurriculums.checkCourseDurationExpire();
563 });
564
565 /***/ },
566
567 /***/ "./assets/src/apps/js/utils/lp-modal-overlay.js"
568 /*!******************************************************!*\
569 !*** ./assets/src/apps/js/utils/lp-modal-overlay.js ***!
570 \******************************************************/
571 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
572
573 "use strict";
574 __webpack_require__.r(__webpack_exports__);
575 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
576 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
577 /* harmony export */ });
578 const $ = jQuery;
579 let elLPOverlay = null;
580 const lpModalOverlay = {
581 elLPOverlay: null,
582 elMainContent: null,
583 elTitle: null,
584 elBtnYes: null,
585 elBtnNo: null,
586 elFooter: null,
587 elCalledModal: null,
588 callBackYes: null,
589 instance: null,
590 init() {
591 if (this.instance) {
592 return true;
593 }
594 this.elLPOverlay = $('.lp-overlay');
595 if (!this.elLPOverlay.length) {
596 return false;
597 }
598 elLPOverlay = this.elLPOverlay;
599 this.elMainContent = elLPOverlay.find('.main-content');
600 this.elTitle = elLPOverlay.find('.modal-title');
601 this.elBtnYes = elLPOverlay.find('.btn-yes');
602 this.elBtnNo = elLPOverlay.find('.btn-no');
603 this.elFooter = elLPOverlay.find('.lp-modal-footer');
604 $(document).on('click', '.close, .btn-no', function () {
605 elLPOverlay.hide();
606 });
607 $(document).on('click', '.btn-yes', function (e) {
608 e.preventDefault();
609 e.stopPropagation();
610 if ('function' === typeof lpModalOverlay.callBackYes) {
611 lpModalOverlay.callBackYes(e);
612 }
613 });
614 this.instance = this;
615 return true;
616 },
617 setElCalledModal(elCalledModal) {
618 this.elCalledModal = elCalledModal;
619 },
620 setContentModal(content, event) {
621 this.elMainContent.html(content);
622 if ('function' === typeof event) {
623 event();
624 }
625 },
626 setTitleModal(content) {
627 this.elTitle.html(content);
628 }
629 };
630 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlay);
631
632 /***/ },
633
634 /***/ "./assets/src/js/utils.js"
635 /*!********************************!*\
636 !*** ./assets/src/js/utils.js ***!
637 \********************************/
638 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
639
640 "use strict";
641 __webpack_require__.r(__webpack_exports__);
642 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
643 /* harmony export */ debounce: () => (/* binding */ debounce),
644 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
645 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
646 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
647 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
648 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
649 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
650 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
651 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
652 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
653 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
654 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
655 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
656 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
657 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
658 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
659 /* harmony export */ });
660 /**
661 * Utils functions
662 *
663 * @param url
664 * @param data
665 * @param functions
666 * @since 4.2.5.1
667 * @version 1.0.6
668 */
669 const lpClassName = {
670 hidden: 'lp-hidden',
671 loading: 'loading',
672 elCollapse: 'lp-collapse',
673 elSectionToggle: '.lp-section-toggle',
674 elTriggerToggle: '.lp-trigger-toggle'
675 };
676 const lpFetchAPI = (url, data = {}, functions = {}) => {
677 if ('function' === typeof functions.before) {
678 functions.before();
679 }
680 fetch(url, {
681 method: 'GET',
682 ...data
683 }).then(response => response.json()).then(response => {
684 if ('function' === typeof functions.success) {
685 functions.success(response);
686 }
687 }).catch(err => {
688 if ('function' === typeof functions.error) {
689 functions.error(err);
690 }
691 }).finally(() => {
692 if ('function' === typeof functions.completed) {
693 functions.completed();
694 }
695 });
696 };
697
698 /**
699 * Get current URL without params.
700 *
701 * @since 4.2.5.1
702 */
703 const lpGetCurrentURLNoParam = () => {
704 let currentUrl = window.location.href;
705 const hasParams = currentUrl.includes('?');
706 if (hasParams) {
707 currentUrl = currentUrl.split('?')[0];
708 }
709 return currentUrl;
710 };
711 const lpAddQueryArgs = (endpoint, args) => {
712 const url = new URL(endpoint);
713 Object.keys(args).forEach(arg => {
714 url.searchParams.set(arg, args[arg]);
715 });
716 return url;
717 };
718
719 /**
720 * Listen element viewed.
721 *
722 * @param el
723 * @param callback
724 * @since 4.2.5.8
725 */
726 const listenElementViewed = (el, callback) => {
727 const observerSeeItem = new IntersectionObserver(function (entries) {
728 for (const entry of entries) {
729 if (entry.isIntersecting) {
730 callback(entry);
731 }
732 }
733 });
734 observerSeeItem.observe(el);
735 };
736
737 /**
738 * Listen element created.
739 *
740 * @param callback
741 * @since 4.2.5.8
742 */
743 const listenElementCreated = callback => {
744 const observerCreateItem = new MutationObserver(function (mutations) {
745 mutations.forEach(function (mutation) {
746 if (mutation.addedNodes) {
747 mutation.addedNodes.forEach(function (node) {
748 if (node.nodeType === 1) {
749 callback(node);
750 }
751 });
752 }
753 });
754 });
755 observerCreateItem.observe(document, {
756 childList: true,
757 subtree: true
758 });
759 // End.
760 };
761
762 /**
763 * Listen element created.
764 *
765 * @param selector
766 * @param callback
767 * @since 4.2.7.1
768 */
769 const lpOnElementReady = (selector, callback) => {
770 const element = document.querySelector(selector);
771 if (element) {
772 callback(element);
773 return;
774 }
775 const observer = new MutationObserver((mutations, obs) => {
776 const element = document.querySelector(selector);
777 if (element) {
778 obs.disconnect();
779 callback(element);
780 }
781 });
782 observer.observe(document.documentElement, {
783 childList: true,
784 subtree: true
785 });
786 };
787
788 // Parse JSON from string with content include LP_AJAX_START.
789 const lpAjaxParseJsonOld = data => {
790 if (typeof data !== 'string') {
791 return data;
792 }
793 const m = String.raw({
794 raw: data
795 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
796 try {
797 if (m) {
798 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
799 } else {
800 data = JSON.parse(data);
801 }
802 } catch (e) {
803 data = {};
804 }
805 return data;
806 };
807
808 // status 0: hide, 1: show
809 const lpShowHideEl = (el, status = 0) => {
810 if (!el) {
811 return;
812 }
813 if (!status) {
814 el.classList.add(lpClassName.hidden);
815 } else {
816 el.classList.remove(lpClassName.hidden);
817 }
818 };
819
820 // status 0: hide, 1: show
821 const lpSetLoadingEl = (el, status) => {
822 if (!el) {
823 return;
824 }
825 if (!status) {
826 el.classList.remove(lpClassName.loading);
827 } else {
828 el.classList.add(lpClassName.loading);
829 }
830 };
831
832 // Toggle collapse section
833 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
834 if (!elTriggerClassName) {
835 elTriggerClassName = lpClassName.elTriggerToggle;
836 }
837
838 // Exclude elements, which should not trigger the collapse toggle
839 if (elsExclude && elsExclude.length > 0) {
840 for (const elExclude of elsExclude) {
841 if (target.closest(elExclude)) {
842 return;
843 }
844 }
845 }
846 const elTrigger = target.closest(elTriggerClassName);
847 if (!elTrigger) {
848 return;
849 }
850
851 //console.log( 'elTrigger', elTrigger );
852
853 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
854 if (!elSectionToggle) {
855 return;
856 }
857 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
858 if ('function' === typeof callback) {
859 callback(elSectionToggle);
860 }
861 };
862
863 // Get data of form
864 const getDataOfForm = form => {
865 const dataSend = {};
866 const formData = new FormData(form);
867 for (const pair of formData.entries()) {
868 const key = pair[0];
869 const value = formData.getAll(key);
870 if (!dataSend.hasOwnProperty(key)) {
871 // Convert value array to string.
872 dataSend[key] = value.join(',');
873 }
874 }
875 return dataSend;
876 };
877
878 // Get field keys of form
879 const getFieldKeysOfForm = form => {
880 const keys = [];
881 const elements = form.elements;
882 for (let i = 0; i < elements.length; i++) {
883 const name = elements[i].name;
884 if (name && !keys.includes(name)) {
885 keys.push(name);
886 }
887 }
888 return keys;
889 };
890
891 // Merge data handle with data form.
892 const mergeDataWithDatForm = (elForm, dataHandle) => {
893 const dataForm = getDataOfForm(elForm);
894 const keys = getFieldKeysOfForm(elForm);
895 keys.forEach(key => {
896 if (!dataForm.hasOwnProperty(key)) {
897 delete dataHandle[key];
898 } else if (dataForm[key][0] === '') {
899 delete dataForm[key];
900 delete dataHandle[key];
901 }
902 });
903 dataHandle = {
904 ...dataHandle,
905 ...dataForm
906 };
907 return dataHandle;
908 };
909
910 /**
911 * Event trigger
912 * For each list of event handlers, listen event on document.
913 *
914 * eventName: 'click', 'change', ...
915 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
916 *
917 * @param eventName
918 * @param eventHandlers
919 */
920 const eventHandlers = (eventName, eventHandlers) => {
921 document.addEventListener(eventName, e => {
922 const target = e.target;
923 let args = {
924 e,
925 target
926 };
927 eventHandlers.forEach(eventHandler => {
928 args = {
929 ...args,
930 ...eventHandler
931 };
932
933 //console.log( args );
934
935 // Check condition before call back
936 if (eventHandler.conditionBeforeCallBack) {
937 if (eventHandler.conditionBeforeCallBack(args) !== true) {
938 return;
939 }
940 }
941
942 // Special check for keydown event with checkIsEventEnter = true
943 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
944 if (e.key !== 'Enter') {
945 return;
946 }
947 }
948 if (target.closest(eventHandler.selector)) {
949 if (eventHandler.class) {
950 // Call method of class, function callBack will understand exactly {this} is class object.
951 eventHandler.class[eventHandler.callBack](args);
952 } else {
953 // For send args is objected, {this} is eventHandler object, not class object.
954 eventHandler.callBack(args);
955 }
956 }
957 });
958 });
959 };
960
961 /**
962 * Debounce - delays function execution until after `wait` ms of inactivity.
963 *
964 * Each call resets the timer. Only the last call in a burst executes.
965 *
966 * USE CASES:
967 * - Search inputs, form validation, window resize
968 * - Multiple elements need independent timers
969 * - When you need to call with different arguments
970 *
971 * EXAMPLES:
972 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
973 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
974 *
975 * const debouncedResize = debounce( recalculateLayout, 250 );
976 * window.addEventListener('resize', debouncedResize);
977 *
978 * ⚠️ Create ONCE outside event handlers, not inside.
979 *
980 * @param {Function} func - Function to debounce (can be anonymous)
981 * @param {number} wait - Milliseconds to wait (default: 500)
982 * @return {Function} Debounced wrapper function
983 * @since 4.3.7
984 * @version 1.0.0
985 */
986 const debounce = (func, wait = 500) => {
987 let timer;
988 return args => {
989 clearTimeout(timer);
990 timer = setTimeout(() => func(args), wait);
991 };
992 };
993
994 /***/ },
995
996 /***/ "react"
997 /*!************************!*\
998 !*** external "React" ***!
999 \************************/
1000 (module) {
1001
1002 "use strict";
1003 module.exports = window["React"];
1004
1005 /***/ },
1006
1007 /***/ "@wordpress/element"
1008 /*!*********************************!*\
1009 !*** external ["wp","element"] ***!
1010 \*********************************/
1011 (module) {
1012
1013 "use strict";
1014 module.exports = window["wp"]["element"];
1015
1016 /***/ },
1017
1018 /***/ "@wordpress/url"
1019 /*!*****************************!*\
1020 !*** external ["wp","url"] ***!
1021 \*****************************/
1022 (module) {
1023
1024 "use strict";
1025 module.exports = window["wp"]["url"];
1026
1027 /***/ }
1028
1029 /******/ });
1030 /************************************************************************/
1031 /******/ // The module cache
1032 /******/ var __webpack_module_cache__ = {};
1033 /******/
1034 /******/ // The require function
1035 /******/ function __webpack_require__(moduleId) {
1036 /******/ // Check if module is in cache
1037 /******/ var cachedModule = __webpack_module_cache__[moduleId];
1038 /******/ if (cachedModule !== undefined) {
1039 /******/ return cachedModule.exports;
1040 /******/ }
1041 /******/ // Create a new module (and put it into the cache)
1042 /******/ var module = __webpack_module_cache__[moduleId] = {
1043 /******/ // no module.id needed
1044 /******/ // no module.loaded needed
1045 /******/ exports: {}
1046 /******/ };
1047 /******/
1048 /******/ // Execute the module function
1049 /******/ if (!(moduleId in __webpack_modules__)) {
1050 /******/ delete __webpack_module_cache__[moduleId];
1051 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
1052 /******/ e.code = 'MODULE_NOT_FOUND';
1053 /******/ throw e;
1054 /******/ }
1055 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1056 /******/
1057 /******/ // Return the exports of the module
1058 /******/ return module.exports;
1059 /******/ }
1060 /******/
1061 /************************************************************************/
1062 /******/ /* webpack/runtime/compat get default export */
1063 /******/ (() => {
1064 /******/ // getDefaultExport function for compatibility with non-harmony modules
1065 /******/ __webpack_require__.n = (module) => {
1066 /******/ var getter = module && module.__esModule ?
1067 /******/ () => (module['default']) :
1068 /******/ () => (module);
1069 /******/ __webpack_require__.d(getter, { a: getter });
1070 /******/ return getter;
1071 /******/ };
1072 /******/ })();
1073 /******/
1074 /******/ /* webpack/runtime/define property getters */
1075 /******/ (() => {
1076 /******/ // define getter functions for harmony exports
1077 /******/ __webpack_require__.d = (exports, definition) => {
1078 /******/ for(var key in definition) {
1079 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1080 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1081 /******/ }
1082 /******/ }
1083 /******/ };
1084 /******/ })();
1085 /******/
1086 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1087 /******/ (() => {
1088 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1089 /******/ })();
1090 /******/
1091 /******/ /* webpack/runtime/make namespace object */
1092 /******/ (() => {
1093 /******/ // define __esModule on exports
1094 /******/ __webpack_require__.r = (exports) => {
1095 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1096 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1097 /******/ }
1098 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1099 /******/ };
1100 /******/ })();
1101 /******/
1102 /************************************************************************/
1103 var __webpack_exports__ = {};
1104 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
1105 (() => {
1106 "use strict";
1107 /*!**********************************************************!*\
1108 !*** ./assets/src/apps/js/frontend/single-curriculum.js ***!
1109 \**********************************************************/
1110 __webpack_require__.r(__webpack_exports__);
1111 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1112 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1113 /* harmony export */ });
1114 /* harmony import */ var _single_curriculum_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./single-curriculum/index */ "./assets/src/apps/js/frontend/single-curriculum/index.js");
1115 /* 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");
1116 /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./material */ "./assets/src/apps/js/frontend/material.js");
1117
1118
1119 //import courseCurriculumSkeleton from './single-curriculum/skeleton';
1120
1121 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_single_curriculum_index__WEBPACK_IMPORTED_MODULE_0__["default"]);
1122
1123 // Comment code use for old curriculum
1124 /*export const init = () => {
1125 wp.element.render(
1126 <SingleCurriculums />,
1127 document.getElementById( 'learn-press-course-curriculum' )
1128 );
1129 };*/
1130
1131 document.addEventListener('DOMContentLoaded', function (event) {
1132 //LP.Hook.doAction( 'course-ready' );
1133 _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init();
1134 (0,_material__WEBPACK_IMPORTED_MODULE_2__["default"])();
1135 //courseCurriculumSkeleton();
1136 //init();
1137 });
1138
1139 // Comment code use for old curriculum
1140 /*const detectedElCurriculum = setInterval( function() {
1141 const elementCurriculum = document.querySelector( '.learnpress-course-curriculum' );
1142 if ( elementCurriculum ) {
1143 courseCurriculumSkeleton();
1144 clearInterval( detectedElCurriculum );
1145 }
1146 }, 1 );*/
1147 })();
1148
1149 /******/ })()
1150 ;
1151 //# sourceMappingURL=single-curriculum.js.map