| @@ -1,33 +1,86 @@ | ||
| 1 | -/******/ (function() { // webpackBootstrap | |
| 1 | +/******/ (() => { // webpackBootstrap | |
| 2 | 2 | /******/ var __webpack_modules__ = ({ |
| 3 | 3 | |
| 4 | -/***/ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js": | |
| 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" | |
| 5 | 59 | /*!**********************************************************************!*\ |
| 6 | 60 | !*** ./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js ***! |
| 7 | 61 | \**********************************************************************/ |
| 8 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 62 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 9 | 63 | |
| 10 | 64 | "use strict"; |
| 11 | 65 | __webpack_require__.r(__webpack_exports__); |
| 66 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 67 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 68 | +/* harmony export */ }); | |
| 12 | 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"); |
| 13 | 70 | |
| 14 | 71 | const lpModalOverlayCompleteItem = { |
| 15 | 72 | elBtnFinishCourse: null, |
| 16 | 73 | elBtnCompleteItem: null, |
| 17 | - | |
| 18 | 74 | init() { |
| 19 | 75 | if (!_utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].init()) { |
| 20 | 76 | return; |
| 21 | 77 | } |
| 22 | - | |
| 23 | 78 | if (undefined === lpGlobalSettings || 'yes' !== lpGlobalSettings.option_enable_popup_confirm_finish) { |
| 24 | 79 | return; |
| 25 | 80 | } |
| 26 | - | |
| 27 | 81 | this.elBtnFinishCourse = document.querySelectorAll('.lp-btn-finish-course'); |
| 28 | 82 | this.elBtnCompleteItem = document.querySelector('.lp-btn-complete-item'); |
| 29 | - | |
| 30 | 83 | if (this.elBtnCompleteItem) { |
| 31 | 84 | this.elBtnCompleteItem.addEventListener('click', e => { |
| 32 | 85 | e.preventDefault(); |
| 33 | 86 | const form = e.target.closest('form'); |
| @@ -32,16 +85,19 @@ | ||
| 32 | 85 | e.preventDefault(); |
| 33 | 86 | const form = e.target.closest('form'); |
| 34 | 87 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show(); |
| 35 | 88 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title); |
| 36 | - _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + form.dataset.confirm + '</div>'); | |
| 37 | - | |
| 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>'); | |
| 38 | 95 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = () => { |
| 39 | 96 | form.submit(); |
| 40 | 97 | }; |
| 41 | 98 | }); |
| 42 | 99 | } |
| 43 | - | |
| 44 | 100 | if (this.elBtnFinishCourse) { |
| 45 | 101 | this.elBtnFinishCourse.forEach(element => element.addEventListener('click', e => { |
| 46 | 102 | e.preventDefault(); |
| 47 | 103 | const form = e.target.closest('form'); |
| @@ -47,9 +103,8 @@ | ||
| 47 | 103 | const form = e.target.closest('form'); |
| 48 | 104 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show(); |
| 49 | 105 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title); |
| 50 | 106 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + form.dataset.confirm + '</div>'); |
| 51 | - | |
| 52 | 107 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = () => { |
| 53 | 108 | form.submit(); |
| 54 | 109 | }; |
| 55 | 110 | })); |
| @@ -54,24 +109,23 @@ | ||
| 54 | 109 | }; |
| 55 | 110 | })); |
| 56 | 111 | } |
| 57 | 112 | } |
| 58 | - | |
| 59 | 113 | }; |
| 60 | -/* harmony default export */ __webpack_exports__["default"] = (lpModalOverlayCompleteItem); | |
| 114 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlayCompleteItem); | |
| 61 | 115 | |
| 62 | -/***/ }), | |
| 116 | +/***/ }, | |
| 63 | 117 | |
| 64 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/comment.js": | |
| 118 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/comment.js" | |
| 65 | 119 | /*!*****************************************************************************!*\ |
| 66 | 120 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/comment.js ***! |
| 67 | 121 | \*****************************************************************************/ |
| 68 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 122 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 69 | 123 | |
| 70 | 124 | "use strict"; |
| 71 | 125 | __webpack_require__.r(__webpack_exports__); |
| 72 | 126 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 73 | -/* harmony export */ "commentForm": function() { return /* binding */ commentForm; } | |
| 127 | +/* harmony export */ commentForm: () => (/* binding */ commentForm) | |
| 74 | 128 | /* harmony export */ }); |
| 75 | 129 | /** |
| 76 | 130 | * Toogle form Comment for Lesson. |
| 77 | 131 | * |
| @@ -76,23 +130,20 @@ | ||
| 76 | 130 | * Toogle form Comment for Lesson. |
| 77 | 131 | * |
| 78 | 132 | * @author Nhamdv. |
| 79 | 133 | */ |
| 134 | + | |
| 80 | 135 | const commentForm = () => { |
| 81 | 136 | const btn = document.querySelector('.lp-lesson-comment-btn'); |
| 82 | - | |
| 83 | 137 | if (!btn) { |
| 84 | 138 | return; |
| 85 | 139 | } |
| 86 | - | |
| 87 | 140 | const btnOpen = btn.textContent; |
| 88 | 141 | const btnClose = btn.dataset.close; |
| 89 | 142 | const hashComment = window.location.hash; |
| 90 | - | |
| 91 | 143 | if (hashComment.includes('comment')) { |
| 92 | 144 | btn.parentNode.classList.add('open-comments'); |
| 93 | 145 | } |
| 94 | - | |
| 95 | 146 | const toogleText = (btn, btnParent) => { |
| 96 | 147 | if (btnParent.classList.contains('open-comments')) { |
| 97 | 148 | btn.textContent = btnClose; |
| 98 | 149 | } else { |
| @@ -98,34 +149,38 @@ | ||
| 98 | 149 | } else { |
| 99 | 150 | btn.textContent = btnOpen; |
| 100 | 151 | } |
| 101 | 152 | }; |
| 102 | - | |
| 103 | 153 | toogleText(btn, btn.parentNode); |
| 104 | 154 | btn.addEventListener('click', e => { |
| 105 | 155 | e.preventDefault(); |
| 106 | 156 | btn.parentNode.classList.toggle('open-comments'); |
| 107 | 157 | toogleText(btn, btn.parentNode); |
| 108 | - }); // Use for Rest API. | |
| 158 | + }); | |
| 159 | + | |
| 160 | + // Use for Rest API. | |
| 109 | 161 | // const toogle = $( '#learn-press-item-comments-toggle' ); |
| 162 | + | |
| 110 | 163 | // toogle.on( 'change', async function() { |
| 111 | 164 | // if ( ! toogle[ 0 ].checked ) { |
| 112 | 165 | // return; |
| 113 | 166 | // } |
| 167 | + | |
| 114 | 168 | // const response = await wp.apiFetch( { |
| 115 | 169 | // path: 'lp/v1/courses/339/item-comments/50', |
| 116 | 170 | // } ); |
| 171 | + | |
| 117 | 172 | // $( '.learn-press-comments' ).html( response.comments ); |
| 118 | 173 | // } ); |
| 119 | 174 | }; |
| 120 | 175 | |
| 121 | -/***/ }), | |
| 176 | +/***/ }, | |
| 122 | 177 | |
| 123 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js": | |
| 178 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js" | |
| 124 | 179 | /*!********************************************************************************!*\ |
| 125 | 180 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/compatible.js ***! |
| 126 | 181 | \********************************************************************************/ |
| 127 | -/***/ (function() { | |
| 182 | +() { | |
| 128 | 183 | |
| 129 | 184 | /** |
| 130 | 185 | * Compatible with Page Builder. |
| 131 | 186 | * |
| @@ -130,45 +185,40 @@ | ||
| 130 | 185 | * Compatible with Page Builder. |
| 131 | 186 | * |
| 132 | 187 | * @author nhamdv |
| 133 | 188 | */ |
| 189 | + | |
| 134 | 190 | LP.Hook.addAction('lp-compatible-builder', () => { |
| 135 | 191 | LP.Hook.removeAction('lp-compatible-builder'); |
| 136 | - | |
| 137 | 192 | if (typeof elementorFrontend !== 'undefined') { |
| 138 | 193 | [...document.querySelectorAll('#popup-content')][0].addEventListener('scroll', () => { |
| 139 | - Waypoint.refreshAll(); | |
| 194 | + //Waypoint.refreshAll(); | |
| 140 | 195 | window.dispatchEvent(new Event('resize')); |
| 141 | 196 | }); |
| 142 | 197 | } |
| 143 | 198 | |
| 144 | - if (typeof vc_js !== 'undefined' && typeof VcWaypoint !== 'undefined') { | |
| 145 | - [...document.querySelectorAll('#popup-content')][0].addEventListener('scroll', () => { | |
| 146 | - VcWaypoint.refreshAll(); | |
| 147 | - }); | |
| 148 | - } | |
| 199 | + /*if ( typeof vc_js !== 'undefined' && typeof VcWaypoint !== 'undefined' ) { | |
| 200 | + [ ...document.querySelectorAll( '#popup-content' ) ][ 0 ].addEventListener( 'scroll', () => { | |
| 201 | + VcWaypoint.refreshAll(); | |
| 202 | + } ); | |
| 203 | + }*/ | |
| 149 | 204 | }); |
| 150 | 205 | LP.Hook.addAction('lp-quiz-compatible-builder', () => { |
| 151 | 206 | LP.Hook.removeAction('lp-quiz-compatible-builder'); |
| 152 | 207 | LP.Hook.doAction('lp-compatible-builder'); |
| 153 | - | |
| 154 | 208 | if (typeof elementorFrontend !== 'undefined') { |
| 155 | 209 | return window.elementorFrontend.init(); |
| 156 | 210 | } |
| 157 | - | |
| 158 | 211 | if (typeof vc_js !== 'undefined') { |
| 159 | 212 | if (typeof vc_round_charts !== 'undefined') { |
| 160 | 213 | vc_round_charts(); |
| 161 | 214 | } |
| 162 | - | |
| 163 | 215 | if (typeof vc_pieChart !== 'undefined') { |
| 164 | 216 | vc_pieChart(); |
| 165 | 217 | } |
| 166 | - | |
| 167 | 218 | if (typeof vc_line_charts !== 'undefined') { |
| 168 | 219 | vc_line_charts(); |
| 169 | 220 | } |
| 170 | - | |
| 171 | 221 | return window.vc_js(); |
| 172 | 222 | } |
| 173 | 223 | }); |
| 174 | 224 | LP.Hook.addAction('lp-question-compatible-builder', () => { |
| @@ -174,43 +224,38 @@ | ||
| 174 | 224 | LP.Hook.addAction('lp-question-compatible-builder', () => { |
| 175 | 225 | LP.Hook.removeAction('lp-question-compatible-builder'); |
| 176 | 226 | LP.Hook.removeAction('lp-quiz-compatible-builder'); |
| 177 | 227 | LP.Hook.doAction('lp-compatible-builder'); |
| 178 | - | |
| 179 | 228 | if (typeof elementorFrontend !== 'undefined') { |
| 180 | 229 | return window.elementorFrontend.init(); |
| 181 | 230 | } |
| 182 | - | |
| 183 | 231 | if (typeof vc_js !== 'undefined') { |
| 184 | 232 | if (typeof vc_round_charts !== 'undefined') { |
| 185 | 233 | vc_round_charts(); |
| 186 | 234 | } |
| 187 | - | |
| 188 | 235 | if (typeof vc_pieChart !== 'undefined') { |
| 189 | 236 | vc_pieChart(); |
| 190 | 237 | } |
| 191 | - | |
| 192 | 238 | if (typeof vc_line_charts !== 'undefined') { |
| 193 | 239 | vc_line_charts(); |
| 194 | 240 | } |
| 195 | - | |
| 196 | 241 | return window.vc_js(); |
| 197 | 242 | } |
| 198 | 243 | }); |
| 199 | 244 | |
| 200 | -/***/ }), | |
| 245 | +/***/ }, | |
| 201 | 246 | |
| 202 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js": | |
| 247 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js" | |
| 203 | 248 | /*!************************************************************************************!*\ |
| 204 | 249 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js ***! |
| 205 | 250 | \************************************************************************************/ |
| 206 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 251 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 207 | 252 | |
| 208 | 253 | "use strict"; |
| 209 | 254 | __webpack_require__.r(__webpack_exports__); |
| 210 | 255 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 211 | -/* harmony export */ "getResponse": function() { return /* binding */ getResponse; }, | |
| 212 | -/* harmony export */ "itemsProgress": function() { return /* binding */ itemsProgress; } | |
| 256 | +/* harmony export */ getResponse: () => (/* binding */ getResponse), | |
| 257 | +/* harmony export */ itemsProgress: () => (/* binding */ itemsProgress) | |
| 213 | 258 | /* harmony export */ }); |
| 214 | 259 | /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); |
| 215 | 260 | /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__); |
| 216 | 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"); |
| @@ -218,21 +263,21 @@ | ||
| 218 | 263 | |
| 219 | 264 | |
| 220 | 265 | const itemsProgress = () => { |
| 221 | 266 | const elements = document.querySelectorAll('.popup-header__inner'); |
| 222 | - | |
| 223 | 267 | if (!elements.length) { |
| 224 | 268 | return; |
| 225 | 269 | } |
| 226 | - | |
| 227 | 270 | if (document.querySelector('#learn-press-quiz-app div.quiz-result') !== null) { |
| 228 | 271 | return; |
| 229 | 272 | } |
| 230 | - | |
| 231 | 273 | if (elements[0].querySelectorAll('form.form-button-finish-course').length !== 0) { |
| 232 | 274 | return; |
| 233 | 275 | } |
| 234 | - | |
| 276 | + const user_id = lpGlobalSettings.user_id || 0; | |
| 277 | + if (user_id === 0) { | |
| 278 | + return; | |
| 279 | + } | |
| 235 | 280 | if ('IntersectionObserver' in window) { |
| 236 | 281 | const eleObserver = new IntersectionObserver((entries, observer) => { |
| 237 | 282 | entries.forEach(entry => { |
| 238 | 283 | if (entry.isIntersecting) { |
| @@ -256,23 +301,24 @@ | ||
| 256 | 301 | const { |
| 257 | 302 | data |
| 258 | 303 | } = response; |
| 259 | 304 | ele.innerHTML += data; |
| 305 | + ele.classList.add('can-finish-course'); | |
| 260 | 306 | _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init(); |
| 261 | 307 | }; |
| 262 | 308 | |
| 263 | -/***/ }), | |
| 309 | +/***/ }, | |
| 264 | 310 | |
| 265 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/progress.js": | |
| 311 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/progress.js" | |
| 266 | 312 | /*!******************************************************************************!*\ |
| 267 | 313 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/progress.js ***! |
| 268 | 314 | \******************************************************************************/ |
| 269 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 315 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 270 | 316 | |
| 271 | 317 | "use strict"; |
| 272 | 318 | __webpack_require__.r(__webpack_exports__); |
| 273 | 319 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 274 | -/* harmony export */ "progressBar": function() { return /* binding */ progressBar; } | |
| 320 | +/* harmony export */ progressBar: () => (/* binding */ progressBar) | |
| 275 | 321 | /* harmony export */ }); |
| 276 | 322 | const $ = jQuery; |
| 277 | 323 | const progressBar = () => { |
| 278 | 324 | $('.learn-press-progress').each(function () { |
| @@ -278,43 +324,38 @@ | ||
| 278 | 324 | $('.learn-press-progress').each(function () { |
| 279 | 325 | const $progress = $(this); |
| 280 | 326 | const $active = $progress.find('.learn-press-progress__active'); |
| 281 | 327 | const value = $active.data('value'); |
| 282 | - | |
| 283 | 328 | if (value === undefined) { |
| 284 | 329 | return; |
| 285 | 330 | } |
| 286 | - | |
| 287 | 331 | $active.css('left', -(100 - parseInt(value)) + '%'); |
| 288 | 332 | }); |
| 289 | 333 | }; |
| 290 | 334 | |
| 291 | -/***/ }), | |
| 335 | +/***/ }, | |
| 292 | 336 | |
| 293 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/search.js": | |
| 337 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/search.js" | |
| 294 | 338 | /*!****************************************************************************!*\ |
| 295 | 339 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/search.js ***! |
| 296 | 340 | \****************************************************************************/ |
| 297 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 341 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 298 | 342 | |
| 299 | 343 | "use strict"; |
| 300 | 344 | __webpack_require__.r(__webpack_exports__); |
| 301 | 345 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 302 | -/* harmony export */ "searchCourseContent": function() { return /* binding */ searchCourseContent; } | |
| 346 | +/* harmony export */ searchCourseContent: () => (/* binding */ searchCourseContent) | |
| 303 | 347 | /* harmony export */ }); |
| 304 | 348 | const searchCourseContent = () => { |
| 305 | 349 | const popup = document.querySelector('#popup-course'); |
| 306 | 350 | const list = document.querySelector('#learn-press-course-curriculum'); |
| 307 | - | |
| 308 | 351 | if (popup && list) { |
| 309 | 352 | const items = list.querySelector('.curriculum-sections'); |
| 310 | 353 | const form = popup.querySelector('.search-course'); |
| 311 | 354 | const search = popup.querySelector('.search-course input[type="text"]'); |
| 312 | - | |
| 313 | 355 | if (!search || !items || !form) { |
| 314 | 356 | return; |
| 315 | 357 | } |
| 316 | - | |
| 317 | 358 | const sections = items.querySelectorAll('li.section'); |
| 318 | 359 | const dataItems = items.querySelectorAll('li.course-item'); |
| 319 | 360 | const dataSearch = []; |
| 320 | 361 | dataItems.forEach(item => { |
| @@ -324,18 +365,15 @@ | ||
| 324 | 365 | id: itemID, |
| 325 | 366 | name: name ? name.textContent.toLowerCase() : '' |
| 326 | 367 | }); |
| 327 | 368 | }); |
| 328 | - | |
| 329 | 369 | const submit = event => { |
| 330 | 370 | event.preventDefault(); |
| 331 | 371 | const inputVal = search.value; |
| 332 | 372 | form.classList.add('searching'); |
| 333 | - | |
| 334 | 373 | if (!inputVal) { |
| 335 | 374 | form.classList.remove('searching'); |
| 336 | 375 | } |
| 337 | - | |
| 338 | 376 | const outputs = []; |
| 339 | 377 | dataSearch.forEach(i => { |
| 340 | 378 | if (!inputVal || i.name.match(inputVal.toLowerCase())) { |
| 341 | 379 | outputs.push(i.id); |
| @@ -355,9 +393,8 @@ | ||
| 355 | 393 | if (outputs.includes(a.dataset.id)) { |
| 356 | 394 | isTrue.push(a.dataset.id); |
| 357 | 395 | } |
| 358 | 396 | }); |
| 359 | - | |
| 360 | 397 | if (isTrue.length === 0) { |
| 361 | 398 | section.classList.add('hide-if-js'); |
| 362 | 399 | } else { |
| 363 | 400 | section.classList.remove('hide-if-js'); |
| @@ -363,11 +400,9 @@ | ||
| 363 | 400 | section.classList.remove('hide-if-js'); |
| 364 | 401 | } |
| 365 | 402 | }); |
| 366 | 403 | }; |
| 367 | - | |
| 368 | 404 | const clear = form.querySelector('.clear'); |
| 369 | - | |
| 370 | 405 | if (clear) { |
| 371 | 406 | clear.addEventListener('click', e => { |
| 372 | 407 | e.preventDefault(); |
| 373 | 408 | search.value = ''; |
| @@ -373,26 +408,25 @@ | ||
| 373 | 408 | search.value = ''; |
| 374 | 409 | submit(e); |
| 375 | 410 | }); |
| 376 | 411 | } |
| 377 | - | |
| 378 | 412 | form.addEventListener('submit', submit); |
| 379 | 413 | search.addEventListener('keyup', submit); |
| 380 | 414 | } |
| 381 | 415 | }; |
| 382 | 416 | |
| 383 | -/***/ }), | |
| 417 | +/***/ }, | |
| 384 | 418 | |
| 385 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js": | |
| 419 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js" | |
| 386 | 420 | /*!*****************************************************************************!*\ |
| 387 | 421 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js ***! |
| 388 | 422 | \*****************************************************************************/ |
| 389 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 423 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 390 | 424 | |
| 391 | 425 | "use strict"; |
| 392 | 426 | __webpack_require__.r(__webpack_exports__); |
| 393 | 427 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 394 | -/* harmony export */ "Sidebar": function() { return /* binding */ Sidebar; } | |
| 428 | +/* harmony export */ Sidebar: () => (/* binding */ Sidebar) | |
| 395 | 429 | /* harmony export */ }); |
| 396 | 430 | const $ = jQuery; |
| 397 | 431 | const { |
| 398 | 432 | throttle |
| @@ -398,22 +432,22 @@ | ||
| 398 | 432 | throttle |
| 399 | 433 | } = lodash; |
| 400 | 434 | const Sidebar = () => { |
| 401 | 435 | // Tungnx - Show/hide sidebar curriculumn |
| 402 | - const elSidebarToggle = document.querySelector('#sidebar-toggle'); // For style of theme | |
| 436 | + const elSidebarToggle = document.querySelector('#sidebar-toggle'); | |
| 403 | 437 | |
| 438 | + // For style of theme | |
| 404 | 439 | const toggleSidebar = toggle => { |
| 405 | 440 | $('body').removeClass('lp-sidebar-toggle__open'); |
| 406 | 441 | $('body').removeClass('lp-sidebar-toggle__close'); |
| 407 | - | |
| 408 | 442 | if (toggle) { |
| 409 | 443 | $('body').addClass('lp-sidebar-toggle__close'); |
| 410 | 444 | } else { |
| 411 | 445 | $('body').addClass('lp-sidebar-toggle__open'); |
| 412 | 446 | } |
| 413 | - }; // For lp and theme | |
| 447 | + }; | |
| 414 | 448 | |
| 415 | - | |
| 449 | + // For lp and theme | |
| 416 | 450 | if (elSidebarToggle) { |
| 417 | 451 | if ($(window).innerWidth() <= 768) { |
| 418 | 452 | elSidebarToggle.setAttribute('checked', 'checked'); |
| 419 | 453 | } else if (LP.Cookies.get('sidebar-toggle')) { |
| @@ -420,67 +454,73 @@ | ||
| 420 | 454 | elSidebarToggle.setAttribute('checked', 'checked'); |
| 421 | 455 | } else { |
| 422 | 456 | elSidebarToggle.removeAttribute('checked'); |
| 423 | 457 | } |
| 458 | + } | |
| 459 | + // End editor by tungnx | |
| 424 | 460 | |
| 425 | - document.querySelector('#popup-course').addEventListener('click', e => { | |
| 426 | - if (e.target.id === 'sidebar-toggle') { | |
| 427 | - LP.Cookies.set('sidebar-toggle', e.target.checked ? true : false); | |
| 428 | - toggleSidebar(LP.Cookies.get('sidebar-toggle')); | |
| 429 | - } | |
| 430 | - }); | |
| 431 | - } // End editor by tungnx | |
| 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 | + } );*/ | |
| 432 | 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 | + } );*/ | |
| 433 | 490 | |
| 434 | - const $curriculum = $('#learn-press-course-curriculum'); | |
| 435 | - $curriculum.find('.section-desc').each((i, el) => { | |
| 436 | - const a = $('<span class="show-desc"></span>').on('click', () => { | |
| 437 | - b.toggleClass('c'); | |
| 438 | - }); | |
| 439 | - const b = $(el).siblings('.section-title').append(a); | |
| 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 | + } | |
| 440 | 496 | }); |
| 441 | - $('.section').each(function () { | |
| 442 | - const $section = $(this), | |
| 443 | - $toggle = $section.find('.section-left'); | |
| 444 | - $toggle.on('click', function () { | |
| 445 | - const isClose = $section.toggleClass('closed').hasClass('closed'); | |
| 446 | - const sections = LP.Cookies.get('closed-section-' + lpGlobalSettings.post_id) || []; | |
| 447 | - const sectionId = parseInt($section.data('section-id')); | |
| 448 | - const at = sections.findIndex(id => { | |
| 449 | - return id == sectionId; | |
| 450 | - }); | |
| 451 | - | |
| 452 | - if (isClose) { | |
| 453 | - sections.push(parseInt($section.data('section-id'))); | |
| 454 | - } else { | |
| 455 | - sections.splice(at, 1); | |
| 456 | - } | |
| 457 | - | |
| 458 | - LP.Cookies.remove('closed-section-(.*)'); | |
| 459 | - LP.Cookies.set('closed-section-' + lpGlobalSettings.post_id, [...new Set(sections)]); | |
| 460 | - }); | |
| 461 | - }); | |
| 462 | 497 | }; |
| 463 | 498 | |
| 464 | -/***/ }), | |
| 499 | +/***/ }, | |
| 465 | 500 | |
| 466 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/index.js": | |
| 501 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/index.js" | |
| 467 | 502 | /*!****************************************************************!*\ |
| 468 | 503 | !*** ./assets/src/apps/js/frontend/single-curriculum/index.js ***! |
| 469 | 504 | \****************************************************************/ |
| 470 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 505 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 471 | 506 | |
| 472 | 507 | "use strict"; |
| 473 | 508 | __webpack_require__.r(__webpack_exports__); |
| 474 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 475 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 476 | -/* harmony import */ var _components_search__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/search */ "./assets/src/apps/js/frontend/single-curriculum/components/search.js"); | |
| 477 | -/* harmony import */ var _components_sidebar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/sidebar */ "./assets/src/apps/js/frontend/single-curriculum/components/sidebar.js"); | |
| 478 | -/* harmony import */ var _components_progress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/progress */ "./assets/src/apps/js/frontend/single-curriculum/components/progress.js"); | |
| 479 | -/* harmony import */ var _components_comment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/comment */ "./assets/src/apps/js/frontend/single-curriculum/components/comment.js"); | |
| 480 | -/* harmony import */ var _components_items_progress__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/items-progress */ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js"); | |
| 481 | -/* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./components/compatible */ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js"); | |
| 482 | -/* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_components_compatible__WEBPACK_IMPORTED_MODULE_6__); | |
| 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__); | |
| 483 | 523 | |
| 484 | 524 | const $ = jQuery; |
| 485 | 525 | |
| 486 | 526 | |
| @@ -488,13 +528,11 @@ | ||
| 488 | 528 | |
| 489 | 529 | |
| 490 | 530 | |
| 491 | 531 | |
| 492 | - | |
| 493 | -class SingleCurriculums extends _wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Component { | |
| 532 | +class SingleCurriculums extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component { | |
| 494 | 533 | checkCourseDurationExpire() { |
| 495 | 534 | const elCourseItemIsBlockeds = document.getElementsByName('lp-course-timestamp-remaining'); |
| 496 | - | |
| 497 | 535 | if (elCourseItemIsBlockeds.length) { |
| 498 | 536 | const elCourseItemIsBlocked = elCourseItemIsBlockeds[0]; |
| 499 | 537 | const timeDuration = elCourseItemIsBlocked.value; // value is second |
| 500 | 538 | |
| @@ -505,562 +543,642 @@ | ||
| 505 | 543 | }, timeDuration * 1000); |
| 506 | 544 | } |
| 507 | 545 | } |
| 508 | 546 | } |
| 509 | - | |
| 510 | 547 | render() { |
| 511 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null); | |
| 548 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null); | |
| 512 | 549 | } |
| 513 | - | |
| 514 | 550 | } |
| 515 | - | |
| 516 | -/* harmony default export */ __webpack_exports__["default"] = (SingleCurriculums); | |
| 551 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SingleCurriculums); | |
| 517 | 552 | document.addEventListener('DOMContentLoaded', () => { |
| 518 | 553 | LP.Hook.doAction('lp-compatible-builder'); |
| 519 | - (0,_components_search__WEBPACK_IMPORTED_MODULE_1__.searchCourseContent)(); | |
| 520 | - (0,_components_sidebar__WEBPACK_IMPORTED_MODULE_2__.Sidebar)(); | |
| 521 | - (0,_components_progress__WEBPACK_IMPORTED_MODULE_3__.progressBar)(); //commentForm(); | |
| 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)(); | |
| 522 | 559 | |
| 523 | - (0,_components_items_progress__WEBPACK_IMPORTED_MODULE_5__.itemsProgress)(); // Check duration expire of course | |
| 524 | - | |
| 560 | + // Check duration expire of course | |
| 525 | 561 | const singleCurriculums = new SingleCurriculums(); |
| 526 | 562 | singleCurriculums.checkCourseDurationExpire(); |
| 527 | 563 | }); |
| 528 | 564 | |
| 529 | -/***/ }), | |
| 565 | +/***/ }, | |
| 530 | 566 | |
| 531 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/scrolltoitem.js": | |
| 532 | -/*!***********************************************************************!*\ | |
| 533 | - !*** ./assets/src/apps/js/frontend/single-curriculum/scrolltoitem.js ***! | |
| 534 | - \***********************************************************************/ | |
| 535 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 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__) { | |
| 536 | 572 | |
| 537 | 573 | "use strict"; |
| 538 | 574 | __webpack_require__.r(__webpack_exports__); |
| 539 | -/* 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"); | |
| 540 | - | |
| 575 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 576 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 577 | +/* harmony export */ }); | |
| 541 | 578 | const $ = jQuery; |
| 542 | -const scrollToItemCurrent = { | |
| 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, | |
| 543 | 590 | init() { |
| 544 | - this.scrollToItemViewing = function () { | |
| 545 | - const elItemViewing = $('.viewing-course-item'); | |
| 546 | - | |
| 547 | - if (elItemViewing.length) { | |
| 548 | - const elCourseCurriculumn = $('#learn-press-course-curriculum'); | |
| 549 | - const heightCourseItemContentHeader = $('#popup-sidebar').outerHeight(); | |
| 550 | - const heightSectionTitle = $('.section-title').outerHeight(); | |
| 551 | - const heightSectionHeader = $('.section-header').outerHeight(); | |
| 552 | - const regex = new RegExp('^viewing-course-item-([0-9].*)'); | |
| 553 | - const classList = elItemViewing.attr('class'); | |
| 554 | - const classArr = classList.split(/\s+/); | |
| 555 | - let idItem = 0; | |
| 556 | - $.each(classArr, function (i, className) { | |
| 557 | - const compare = regex.exec(className); | |
| 558 | - | |
| 559 | - if (compare) { | |
| 560 | - idItem = compare[1]; | |
| 561 | - return false; | |
| 562 | - } | |
| 563 | - }); | |
| 564 | - | |
| 565 | - if (0 === idItem) { | |
| 566 | - return; | |
| 567 | - } | |
| 568 | - | |
| 569 | - const elItemCurrent = $('.course-item-' + idItem); | |
| 570 | - const offSetTop = elItemCurrent.offset().top; | |
| 571 | - const offset = elItemCurrent.offset().top - elCourseCurriculumn.offset().top + elCourseCurriculumn.scrollTop(); | |
| 572 | - elCourseCurriculumn.animate({ | |
| 573 | - scrollTop: LP.Hook.applyFilters('scroll-item-current', offset - heightSectionHeader) | |
| 574 | - }, 800); | |
| 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); | |
| 575 | 612 | } |
| 576 | - }; | |
| 577 | - | |
| 578 | - this.scrollToItemViewing(); | |
| 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); | |
| 579 | 628 | } |
| 580 | - | |
| 581 | 629 | }; |
| 582 | -/* harmony default export */ __webpack_exports__["default"] = (scrollToItemCurrent); | |
| 630 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlay); | |
| 583 | 631 | |
| 584 | -/***/ }), | |
| 632 | +/***/ }, | |
| 585 | 633 | |
| 586 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/skeleton.js": | |
| 587 | -/*!*******************************************************************!*\ | |
| 588 | - !*** ./assets/src/apps/js/frontend/single-curriculum/skeleton.js ***! | |
| 589 | - \*******************************************************************/ | |
| 590 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 634 | +/***/ "./assets/src/js/utils.js" | |
| 635 | +/*!********************************!*\ | |
| 636 | + !*** ./assets/src/js/utils.js ***! | |
| 637 | + \********************************/ | |
| 638 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 591 | 639 | |
| 592 | 640 | "use strict"; |
| 593 | 641 | __webpack_require__.r(__webpack_exports__); |
| 594 | 642 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 595 | -/* harmony export */ "default": function() { return /* binding */ courseCurriculumSkeleton; } | |
| 643 | +/* harmony export */ debounce: () => (/* binding */ debounce), | |
| 644 | +/* harmony export */ eventHandlers: () => (/* binding */ eventHandlers), | |
| 645 | +/* harmony export */ fullScreenView: () => (/* binding */ fullScreenView), | |
| 646 | +/* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm), | |
| 647 | +/* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm), | |
| 648 | +/* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated), | |
| 649 | +/* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed), | |
| 650 | +/* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs), | |
| 651 | +/* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld), | |
| 652 | +/* harmony export */ lpClassName: () => (/* binding */ lpClassName), | |
| 653 | +/* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI), | |
| 654 | +/* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam), | |
| 655 | +/* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady), | |
| 656 | +/* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl), | |
| 657 | +/* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl), | |
| 658 | +/* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm), | |
| 659 | +/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse), | |
| 660 | +/* harmony export */ toggleEnable: () => (/* binding */ toggleEnable) | |
| 596 | 661 | /* harmony export */ }); |
| 597 | -/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); | |
| 598 | -/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__); | |
| 599 | -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); | |
| 600 | -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__); | |
| 601 | -/* harmony import */ var _scrolltoitem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./scrolltoitem */ "./assets/src/apps/js/frontend/single-curriculum/scrolltoitem.js"); | |
| 602 | -/* harmony import */ var _components_search__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/search */ "./assets/src/apps/js/frontend/single-curriculum/components/search.js"); | |
| 603 | -// Rest API load content in Tab Curriculum - Nhamdv. | |
| 604 | - | |
| 605 | - | |
| 606 | - | |
| 607 | - | |
| 608 | -function courseCurriculumSkeleton() { | |
| 609 | - let courseID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | |
| 610 | - let isLoadingItems = false; | |
| 611 | - let isLoadingSections = false; | |
| 612 | - | |
| 613 | - const Sekeleton = () => { | |
| 614 | - const elementCurriculum = document.querySelector('.learnpress-course-curriculum'); | |
| 615 | - | |
| 616 | - if (!elementCurriculum) { | |
| 617 | - return; | |
| 662 | +/** | |
| 663 | + * Utils functions | |
| 664 | + * | |
| 665 | + * @param url | |
| 666 | + * @param data | |
| 667 | + * @param functions | |
| 668 | + * @since 4.2.5.1 | |
| 669 | + * @version 1.0.7 | |
| 670 | + */ | |
| 671 | +const lpClassName = { | |
| 672 | + hidden: 'lp-hidden', | |
| 673 | + loading: 'loading', | |
| 674 | + elCollapse: 'lp-collapse', | |
| 675 | + elSectionToggle: '.lp-section-toggle', | |
| 676 | + elTriggerToggle: '.lp-trigger-toggle', | |
| 677 | + elBtnFullScreen: '.lp-btn-full-screen-view', | |
| 678 | + elFullScreen: 'lp-full-screen-view', | |
| 679 | + elBtnFullScreenClose: 'lp-full-screen-view__close' | |
| 680 | +}; | |
| 681 | +const lpFetchAPI = (url, data = {}, functions = {}) => { | |
| 682 | + if ('function' === typeof functions.before) { | |
| 683 | + functions.before(); | |
| 684 | + } | |
| 685 | + fetch(url, { | |
| 686 | + method: 'GET', | |
| 687 | + ...data | |
| 688 | + }).then(response => response.json()).then(response => { | |
| 689 | + if ('function' === typeof functions.success) { | |
| 690 | + functions.success(response); | |
| 618 | 691 | } |
| 692 | + }).catch(err => { | |
| 693 | + if ('function' === typeof functions.error) { | |
| 694 | + functions.error(err); | |
| 695 | + } | |
| 696 | + }).finally(() => { | |
| 697 | + if ('function' === typeof functions.completed) { | |
| 698 | + functions.completed(); | |
| 699 | + } | |
| 700 | + }); | |
| 701 | +}; | |
| 619 | 702 | |
| 620 | - getResponse(elementCurriculum); | |
| 621 | - }; | |
| 703 | +/** | |
| 704 | + * Get current URL without params. | |
| 705 | + * | |
| 706 | + * @since 4.2.5.1 | |
| 707 | + */ | |
| 708 | +const lpGetCurrentURLNoParam = () => { | |
| 709 | + let currentUrl = window.location.href; | |
| 710 | + const hasParams = currentUrl.includes('?'); | |
| 711 | + if (hasParams) { | |
| 712 | + currentUrl = currentUrl.split('?')[0]; | |
| 713 | + } | |
| 714 | + return currentUrl; | |
| 715 | +}; | |
| 716 | +const lpAddQueryArgs = (endpoint, args) => { | |
| 717 | + const url = new URL(endpoint); | |
| 718 | + Object.keys(args).forEach(arg => { | |
| 719 | + url.searchParams.set(arg, args[arg]); | |
| 720 | + }); | |
| 721 | + return url; | |
| 722 | +}; | |
| 622 | 723 | |
| 623 | - const getResponse = async ele => { | |
| 624 | - const skeleton = ele.querySelector('.lp-skeleton-animation'); | |
| 625 | - const itemID = ele.dataset.id; | |
| 626 | - const sectionID = ele.dataset.section; | |
| 627 | - | |
| 628 | - try { | |
| 629 | - const page = 1; | |
| 630 | - const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({ | |
| 631 | - path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/lazy-load/course-curriculum', { | |
| 632 | - courseId: courseID || lpGlobalSettings.post_id || '', | |
| 633 | - page, | |
| 634 | - sectionID: sectionID || '' | |
| 635 | - }), | |
| 636 | - method: 'GET' | |
| 637 | - }); | |
| 638 | - const { | |
| 639 | - data, | |
| 640 | - status, | |
| 641 | - message | |
| 642 | - } = response; | |
| 643 | - let section_ids = data.section_ids; | |
| 644 | - | |
| 645 | - if (status === 'error') { | |
| 646 | - throw new Error(message || 'Error'); | |
| 724 | +/** | |
| 725 | + * Listen element viewed. | |
| 726 | + * | |
| 727 | + * @param el | |
| 728 | + * @param callback | |
| 729 | + * @since 4.2.5.8 | |
| 730 | + */ | |
| 731 | +const listenElementViewed = (el, callback) => { | |
| 732 | + const observerSeeItem = new IntersectionObserver(function (entries) { | |
| 733 | + for (const entry of entries) { | |
| 734 | + if (entry.isIntersecting) { | |
| 735 | + callback(entry); | |
| 647 | 736 | } |
| 737 | + } | |
| 738 | + }); | |
| 739 | + observerSeeItem.observe(el); | |
| 740 | +}; | |
| 648 | 741 | |
| 649 | - let returnData = data.content; | |
| 650 | - | |
| 651 | - if (undefined === returnData) { | |
| 652 | - // For old Eduma <= 4.6.0 | |
| 653 | - returnData = data; | |
| 654 | - section_ids = response.section_ids; | |
| 742 | +/** | |
| 743 | + * Listen element created. | |
| 744 | + * | |
| 745 | + * @param callback | |
| 746 | + * @since 4.2.5.8 | |
| 747 | + */ | |
| 748 | +const listenElementCreated = callback => { | |
| 749 | + const observerCreateItem = new MutationObserver(function (mutations) { | |
| 750 | + mutations.forEach(function (mutation) { | |
| 751 | + if (mutation.addedNodes) { | |
| 752 | + mutation.addedNodes.forEach(function (node) { | |
| 753 | + if (node.nodeType === 1) { | |
| 754 | + callback(node); | |
| 755 | + } | |
| 756 | + }); | |
| 655 | 757 | } |
| 758 | + }); | |
| 759 | + }); | |
| 760 | + observerCreateItem.observe(document, { | |
| 761 | + childList: true, | |
| 762 | + subtree: true | |
| 763 | + }); | |
| 764 | + // End. | |
| 765 | +}; | |
| 656 | 766 | |
| 657 | - if (sectionID) { | |
| 658 | - if (section_ids && !section_ids.includes(sectionID)) { | |
| 659 | - const response2 = await getResponsive('', page + 1, sectionID); | |
| 660 | - | |
| 661 | - if (response2) { | |
| 662 | - const { | |
| 663 | - data2, | |
| 664 | - pages2, | |
| 665 | - page2 | |
| 666 | - } = response2; | |
| 667 | - await parseContentItems({ | |
| 668 | - ele, | |
| 669 | - returnData, | |
| 670 | - sectionID, | |
| 671 | - itemID, | |
| 672 | - data2, | |
| 673 | - pages2, | |
| 674 | - page2 | |
| 675 | - }); | |
| 676 | - } | |
| 677 | - } else { | |
| 678 | - await parseContentItems({ | |
| 679 | - ele, | |
| 680 | - returnData, | |
| 681 | - sectionID, | |
| 682 | - itemID | |
| 683 | - }); | |
| 684 | - } | |
| 685 | - } else { | |
| 686 | - returnData && ele.insertAdjacentHTML('beforeend', returnData); | |
| 687 | - } | |
| 688 | - } catch (error) { | |
| 689 | - ele.insertAdjacentHTML('beforeend', `<div class="lp-ajax-message error" style="display:block">${error.message || 'Error: Query lp/v1/lazy-load/course-curriculum'}</div>`); | |
| 767 | +/** | |
| 768 | + * Listen element created. | |
| 769 | + * | |
| 770 | + * @param selector | |
| 771 | + * @param callback | |
| 772 | + * @since 4.2.7.1 | |
| 773 | + */ | |
| 774 | +const lpOnElementReady = (selector, callback) => { | |
| 775 | + const element = document.querySelector(selector); | |
| 776 | + if (element) { | |
| 777 | + callback(element); | |
| 778 | + return; | |
| 779 | + } | |
| 780 | + const observer = new MutationObserver((mutations, obs) => { | |
| 781 | + const element = document.querySelector(selector); | |
| 782 | + if (element) { | |
| 783 | + obs.disconnect(); | |
| 784 | + callback(element); | |
| 690 | 785 | } |
| 786 | + }); | |
| 787 | + observer.observe(document.documentElement, { | |
| 788 | + childList: true, | |
| 789 | + subtree: true | |
| 790 | + }); | |
| 791 | +}; | |
| 691 | 792 | |
| 692 | - skeleton && skeleton.remove(); | |
| 693 | - (0,_components_search__WEBPACK_IMPORTED_MODULE_3__.searchCourseContent)(); | |
| 694 | - }; | |
| 695 | - | |
| 696 | - const parseContentItems = async _ref => { | |
| 697 | - let { | |
| 698 | - ele, | |
| 699 | - returnData, | |
| 700 | - sectionID, | |
| 701 | - itemID, | |
| 702 | - data2, | |
| 703 | - pages2, | |
| 704 | - page2 | |
| 705 | - } = _ref; | |
| 706 | - const parser = new DOMParser(); | |
| 707 | - const doc = parser.parseFromString(returnData, 'text/html'); | |
| 708 | - | |
| 709 | - if (data2) { | |
| 710 | - const sections = doc.querySelector('.curriculum-sections'); | |
| 711 | - const loadMoreBtn = doc.querySelector('.curriculum-more__button'); | |
| 712 | - | |
| 713 | - if (loadMoreBtn) { | |
| 714 | - if (pages2 <= page2) { | |
| 715 | - loadMoreBtn.remove(); | |
| 716 | - } else { | |
| 717 | - loadMoreBtn.dataset.page = page2; | |
| 718 | - } | |
| 719 | - } | |
| 720 | - | |
| 721 | - sections.insertAdjacentHTML('beforeend', data2); | |
| 793 | +// Parse JSON from string with content include LP_AJAX_START. | |
| 794 | +const lpAjaxParseJsonOld = data => { | |
| 795 | + if (typeof data !== 'string') { | |
| 796 | + return data; | |
| 797 | + } | |
| 798 | + const m = String.raw({ | |
| 799 | + raw: data | |
| 800 | + }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s); | |
| 801 | + try { | |
| 802 | + if (m) { | |
| 803 | + data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, '')); | |
| 804 | + } else { | |
| 805 | + data = JSON.parse(data); | |
| 722 | 806 | } |
| 807 | + } catch (e) { | |
| 808 | + data = {}; | |
| 809 | + } | |
| 810 | + return data; | |
| 811 | +}; | |
| 723 | 812 | |
| 724 | - const section = doc.querySelector(`[data-section-id="${sectionID}"]`); | |
| 813 | +// status 0: hide, 1: show | |
| 814 | +const lpShowHideEl = (el, status = 0) => { | |
| 815 | + if (!el) { | |
| 816 | + return; | |
| 817 | + } | |
| 818 | + if (!status) { | |
| 819 | + el.classList.add(lpClassName.hidden); | |
| 820 | + } else { | |
| 821 | + el.classList.remove(lpClassName.hidden); | |
| 822 | + } | |
| 823 | +}; | |
| 725 | 824 | |
| 726 | - if (section) { | |
| 727 | - const items = section.querySelectorAll('.course-item'); | |
| 728 | - const item_ids = [...items].map(item => item.dataset.id); | |
| 729 | - const sectionContent = section.querySelector('.section-content'); | |
| 730 | - const itemLoadMore = section.querySelector('.section-item__loadmore'); | |
| 825 | +// status 0: hide, 1: show | |
| 826 | +const lpSetLoadingEl = (el, status) => { | |
| 827 | + if (!el) { | |
| 828 | + return; | |
| 829 | + } | |
| 830 | + if (!status) { | |
| 831 | + el.classList.remove(lpClassName.loading); | |
| 832 | + } else { | |
| 833 | + el.classList.add(lpClassName.loading); | |
| 834 | + } | |
| 835 | +}; | |
| 731 | 836 | |
| 732 | - if (itemID && !item_ids.includes(itemID)) { | |
| 733 | - const responseItem = await getResponsiveItem('', 2, sectionID, itemID); | |
| 734 | - const { | |
| 735 | - data3, | |
| 736 | - pages3, | |
| 737 | - paged3, | |
| 738 | - page | |
| 739 | - } = responseItem; | |
| 837 | +// Toggle collapse section | |
| 838 | +const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => { | |
| 839 | + if (!elTriggerClassName) { | |
| 840 | + elTriggerClassName = lpClassName.elTriggerToggle; | |
| 841 | + } | |
| 740 | 842 | |
| 741 | - if (pages3 <= paged3 || pages3 <= page) { | |
| 742 | - itemLoadMore.remove(); | |
| 743 | - } else { | |
| 744 | - itemLoadMore.dataset.page = page; | |
| 745 | - } | |
| 746 | - | |
| 747 | - if (data3 && sectionContent) { | |
| 748 | - sectionContent.insertAdjacentHTML('beforeend', data3); | |
| 749 | - } | |
| 843 | + // Exclude elements, which should not trigger the collapse toggle | |
| 844 | + if (elsExclude && elsExclude.length > 0) { | |
| 845 | + for (const elExclude of elsExclude) { | |
| 846 | + if (target.closest(elExclude)) { | |
| 847 | + return; | |
| 750 | 848 | } |
| 751 | 849 | } |
| 850 | + } | |
| 851 | + const elTrigger = target.closest(elTriggerClassName); | |
| 852 | + if (!elTrigger) { | |
| 853 | + return; | |
| 854 | + } | |
| 752 | 855 | |
| 753 | - ele.insertAdjacentHTML('beforeend', doc.body.innerHTML); | |
| 754 | - _scrolltoitem__WEBPACK_IMPORTED_MODULE_2__["default"].init(); | |
| 755 | - }; | |
| 856 | + //console.log( 'elTrigger', elTrigger ); | |
| 756 | 857 | |
| 757 | - const getResponsiveItem = async (returnData, paged, sectionID, itemID) => { | |
| 758 | - const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({ | |
| 759 | - path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/lazy-load/course-curriculum-items', { | |
| 760 | - sectionId: sectionID || '', | |
| 761 | - page: paged | |
| 762 | - }), | |
| 763 | - method: 'GET' | |
| 764 | - }); | |
| 765 | - const { | |
| 766 | - data, | |
| 767 | - status, | |
| 768 | - pages, | |
| 769 | - message | |
| 770 | - } = response; | |
| 771 | - const { | |
| 772 | - page | |
| 773 | - } = data; | |
| 774 | - let item_ids; | |
| 858 | + const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`); | |
| 859 | + if (!elSectionToggle) { | |
| 860 | + return; | |
| 861 | + } | |
| 862 | + elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`); | |
| 863 | + if ('function' === typeof callback) { | |
| 864 | + callback(elSectionToggle); | |
| 865 | + } | |
| 866 | +}; | |
| 775 | 867 | |
| 776 | - if (status === 'success') { | |
| 777 | - let dataTmp = data.content; | |
| 778 | - item_ids = data.item_ids; | |
| 779 | - | |
| 780 | - if (undefined === dataTmp) { | |
| 781 | - // For old Eduma <= 4.6.0 | |
| 782 | - dataTmp = data; | |
| 783 | - item_ids = response.item_ids; | |
| 784 | - } | |
| 785 | - | |
| 786 | - returnData += dataTmp; | |
| 787 | - | |
| 788 | - if (sectionID && item_ids && itemID && !item_ids.includes(itemID)) { | |
| 789 | - return getResponsiveItem(returnData, paged + 1, sectionID, itemID); | |
| 790 | - } | |
| 868 | +// Get data of form | |
| 869 | +const getDataOfForm = form => { | |
| 870 | + const dataSend = {}; | |
| 871 | + const formData = new FormData(form); | |
| 872 | + for (const pair of formData.entries()) { | |
| 873 | + const key = pair[0]; | |
| 874 | + const value = formData.getAll(key); | |
| 875 | + if (!dataSend.hasOwnProperty(key)) { | |
| 876 | + // Convert value array to string. | |
| 877 | + dataSend[key] = value.join(','); | |
| 791 | 878 | } |
| 879 | + } | |
| 880 | + return dataSend; | |
| 881 | +}; | |
| 792 | 882 | |
| 793 | - isLoadingItems = false; | |
| 794 | - return { | |
| 795 | - data3: returnData, | |
| 796 | - pages3: pages || data.pages, | |
| 797 | - status3: status, | |
| 798 | - message3: message, | |
| 799 | - page: page || 0 | |
| 800 | - }; | |
| 801 | - }; | |
| 802 | - | |
| 803 | - const getResponsive = async (returnData, page, sectionID) => { | |
| 804 | - const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({ | |
| 805 | - path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/lazy-load/course-curriculum', { | |
| 806 | - courseId: courseID || lpGlobalSettings.post_id || '', | |
| 807 | - page, | |
| 808 | - sectionID: sectionID || '', | |
| 809 | - loadMore: true | |
| 810 | - }), | |
| 811 | - method: 'GET' | |
| 812 | - }); | |
| 813 | - const { | |
| 814 | - data, | |
| 815 | - status, | |
| 816 | - message | |
| 817 | - } = response; | |
| 818 | - let returnDataTmp = data.content; | |
| 819 | - let section_ids = data.section_ids; | |
| 820 | - let pages = data.pages; | |
| 821 | - | |
| 822 | - if (undefined === returnDataTmp) { | |
| 823 | - // For old Eduma <= 4.6.0 | |
| 824 | - returnDataTmp = data; | |
| 825 | - section_ids = response.section_ids; | |
| 826 | - pages = response.pages; | |
| 883 | +// Get field keys of form | |
| 884 | +const getFieldKeysOfForm = form => { | |
| 885 | + const keys = []; | |
| 886 | + const elements = form.elements; | |
| 887 | + for (let i = 0; i < elements.length; i++) { | |
| 888 | + const name = elements[i].name; | |
| 889 | + if (name && !keys.includes(name)) { | |
| 890 | + keys.push(name); | |
| 827 | 891 | } |
| 892 | + } | |
| 893 | + return keys; | |
| 894 | +}; | |
| 828 | 895 | |
| 829 | - if (status === 'success') { | |
| 830 | - returnData += returnDataTmp; | |
| 831 | - | |
| 832 | - if (sectionID && section_ids && section_ids.length > 0 && !section_ids.includes(sectionID)) { | |
| 833 | - return getResponsive(returnData, page + 1, sectionID); | |
| 834 | - } | |
| 896 | +// Merge data handle with data form. | |
| 897 | +const mergeDataWithDatForm = (elForm, dataHandle) => { | |
| 898 | + const dataForm = getDataOfForm(elForm); | |
| 899 | + const keys = getFieldKeysOfForm(elForm); | |
| 900 | + keys.forEach(key => { | |
| 901 | + if (!dataForm.hasOwnProperty(key)) { | |
| 902 | + delete dataHandle[key]; | |
| 903 | + } else if (dataForm[key][0] === '') { | |
| 904 | + delete dataForm[key]; | |
| 905 | + delete dataHandle[key]; | |
| 835 | 906 | } |
| 907 | + }); | |
| 908 | + dataHandle = { | |
| 909 | + ...dataHandle, | |
| 910 | + ...dataForm | |
| 911 | + }; | |
| 912 | + return dataHandle; | |
| 913 | +}; | |
| 836 | 914 | |
| 837 | - isLoadingSections = false; | |
| 838 | - return { | |
| 839 | - data2: returnData, | |
| 840 | - pages2: pages || data.pages, | |
| 841 | - page2: page, | |
| 842 | - status2: status, | |
| 843 | - message2: message | |
| 915 | +/** | |
| 916 | + * Event trigger | |
| 917 | + * For each list of event handlers, listen event on document. | |
| 918 | + * | |
| 919 | + * eventName: 'click', 'change', ... | |
| 920 | + * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ] | |
| 921 | + * | |
| 922 | + * @param eventName | |
| 923 | + * @param eventHandlers | |
| 924 | + */ | |
| 925 | +const eventHandlers = (eventName, eventHandlers) => { | |
| 926 | + document.addEventListener(eventName, e => { | |
| 927 | + const target = e.target; | |
| 928 | + let args = { | |
| 929 | + e, | |
| 930 | + target | |
| 844 | 931 | }; |
| 845 | - }; | |
| 932 | + eventHandlers.forEach(eventHandler => { | |
| 933 | + args = { | |
| 934 | + ...args, | |
| 935 | + ...eventHandler | |
| 936 | + }; | |
| 846 | 937 | |
| 847 | - Sekeleton(); | |
| 848 | - document.addEventListener('click', e => { | |
| 849 | - const sectionBtns = document.querySelectorAll('.section-item__loadmore'); | |
| 850 | - [...sectionBtns].map(async sectionBtn => { | |
| 851 | - if (sectionBtn.contains(e.target) && !isLoadingItems) { | |
| 852 | - isLoadingItems = true; | |
| 853 | - const sectionItem = sectionBtn.parentNode; | |
| 854 | - const sectionId = sectionItem.getAttribute('data-section-id'); | |
| 855 | - const sectionContent = sectionItem.querySelector('.section-content'); | |
| 856 | - const paged = parseInt(sectionBtn.dataset.page); | |
| 857 | - sectionBtn.classList.add('loading'); | |
| 938 | + //console.log( args ); | |
| 858 | 939 | |
| 859 | - try { | |
| 860 | - const response = await getResponsiveItem('', paged + 1, sectionId, ''); | |
| 861 | - const { | |
| 862 | - data3, | |
| 863 | - pages3, | |
| 864 | - status3, | |
| 865 | - message3 | |
| 866 | - } = response; | |
| 867 | - | |
| 868 | - if (status3 === 'error') { | |
| 869 | - throw new Error(message3 || 'Error'); | |
| 870 | - } | |
| 871 | - | |
| 872 | - if (pages3 <= paged + 1) { | |
| 873 | - sectionBtn.remove(); | |
| 874 | - } else { | |
| 875 | - sectionBtn.dataset.page = paged + 1; | |
| 876 | - } | |
| 877 | - | |
| 878 | - sectionContent.insertAdjacentHTML('beforeend', data3); | |
| 879 | - } catch (e) { | |
| 880 | - sectionContent.insertAdjacentHTML('beforeend', `<div class="lp-ajax-message error" style="display:block">${e.message || 'Error: Query lp/v1/lazy-load/course-curriculum'}</div>`); | |
| 940 | + // Check condition before call back | |
| 941 | + if (eventHandler.conditionBeforeCallBack) { | |
| 942 | + if (eventHandler.conditionBeforeCallBack(args) !== true) { | |
| 943 | + return; | |
| 881 | 944 | } |
| 882 | - | |
| 883 | - sectionBtn.classList.remove('loading'); | |
| 884 | - (0,_components_search__WEBPACK_IMPORTED_MODULE_3__.searchCourseContent)(); | |
| 885 | 945 | } |
| 886 | - }); // Load more Sections | |
| 887 | 946 | |
| 888 | - const moreSections = document.querySelectorAll('.curriculum-more__button'); | |
| 889 | - [...moreSections].map(async moreSection => { | |
| 890 | - if (moreSection.contains(e.target) && !isLoadingSections) { | |
| 891 | - isLoadingSections = true; | |
| 892 | - const paged = parseInt(moreSection.dataset.page); | |
| 893 | - const sections = moreSection.parentNode.parentNode.querySelector('.curriculum-sections'); | |
| 894 | - | |
| 895 | - if (paged && sections) { | |
| 896 | - moreSection.classList.add('loading'); | |
| 897 | - | |
| 898 | - try { | |
| 899 | - const response2 = await getResponsive('', paged + 1, ''); | |
| 900 | - const { | |
| 901 | - data2, | |
| 902 | - pages2, | |
| 903 | - status2, | |
| 904 | - message2 | |
| 905 | - } = response2; | |
| 906 | - | |
| 907 | - if (status2 === 'error') { | |
| 908 | - throw new Error(message2 || 'Error'); | |
| 909 | - } | |
| 910 | - | |
| 911 | - if (pages2 <= paged + 1) { | |
| 912 | - moreSection.remove(); | |
| 913 | - } else { | |
| 914 | - moreSection.dataset.page = paged + 1; | |
| 915 | - } | |
| 916 | - | |
| 917 | - sections.insertAdjacentHTML('beforeend', data2); | |
| 918 | - } catch (e) { | |
| 919 | - sections.insertAdjacentHTML('beforeend', `<div class="lp-ajax-message error" style="display:block">${e.message || 'Error: Query lp/v1/lazy-load/course-curriculum'}</div>`); | |
| 920 | - } | |
| 921 | - | |
| 922 | - moreSection.classList.remove('loading'); | |
| 923 | - (0,_components_search__WEBPACK_IMPORTED_MODULE_3__.searchCourseContent)(); | |
| 947 | + // Special check for keydown event with checkIsEventEnter = true | |
| 948 | + if (eventName === 'keydown' && eventHandler.checkIsEventEnter) { | |
| 949 | + if (e.key !== 'Enter') { | |
| 950 | + return; | |
| 924 | 951 | } |
| 925 | 952 | } |
| 926 | - }); // Show/Hide accordion | |
| 927 | - | |
| 928 | - if (document.querySelector('.learnpress-course-curriculum')) { | |
| 929 | - const sections = document.querySelectorAll('.section'); | |
| 930 | - [...sections].map(section => { | |
| 931 | - if (section.contains(e.target)) { | |
| 932 | - const toggle = section.querySelector('.section-left'); | |
| 933 | - toggle.contains(e.target) && section.classList.toggle('closed'); | |
| 953 | + if (target.closest(eventHandler.selector)) { | |
| 954 | + if (eventHandler.class) { | |
| 955 | + // Call method of class, function callBack will understand exactly {this} is class object. | |
| 956 | + eventHandler.class[eventHandler.callBack](args); | |
| 957 | + } else { | |
| 958 | + // For send args is objected, {this} is eventHandler object, not class object. | |
| 959 | + eventHandler.callBack(args); | |
| 934 | 960 | } |
| 935 | - }); | |
| 936 | - } | |
| 961 | + } | |
| 962 | + }); | |
| 937 | 963 | }); |
| 938 | -} | |
| 964 | +}; | |
| 939 | 965 | |
| 940 | -/***/ }), | |
| 966 | +/** | |
| 967 | + * Debounce - delays function execution until after `wait` ms of inactivity. | |
| 968 | + * | |
| 969 | + * Each call resets the timer. Only the last call in a burst executes. | |
| 970 | + * | |
| 971 | + * USE CASES: | |
| 972 | + * - Search inputs, form validation, window resize | |
| 973 | + * - Multiple elements need independent timers | |
| 974 | + * - When you need to call with different arguments | |
| 975 | + * | |
| 976 | + * EXAMPLES: | |
| 977 | + * const debouncedSearch = debounce( (query) => fetchResults(query), 300 ); | |
| 978 | + * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value)); | |
| 979 | + * | |
| 980 | + * const debouncedResize = debounce( recalculateLayout, 250 ); | |
| 981 | + * window.addEventListener('resize', debouncedResize); | |
| 982 | + * | |
| 983 | + * ⚠️ Create ONCE outside event handlers, not inside. | |
| 984 | + * | |
| 985 | + * @param {Function} func - Function to debounce (can be anonymous) | |
| 986 | + * @param {number} wait - Milliseconds to wait (default: 500) | |
| 987 | + * @return {Function} Debounced wrapper function | |
| 988 | + * @since 4.3.7 | |
| 989 | + * @version 1.0.0 | |
| 990 | + */ | |
| 991 | +const debounce = (func, wait = 500) => { | |
| 992 | + let timer; | |
| 993 | + return args => { | |
| 994 | + clearTimeout(timer); | |
| 995 | + timer = setTimeout(() => func(args), wait); | |
| 996 | + }; | |
| 997 | +}; | |
| 941 | 998 | |
| 942 | -/***/ "./assets/src/apps/js/utils/lp-modal-overlay.js": | |
| 943 | -/*!******************************************************!*\ | |
| 944 | - !*** ./assets/src/apps/js/utils/lp-modal-overlay.js ***! | |
| 945 | - \******************************************************/ | |
| 946 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 999 | +/** | |
| 1000 | + * Initialize lp-toggle-enable components. | |
| 1001 | + * | |
| 1002 | + * Finds all `.lp-toggle-enable` elements and wires up toggle behavior. | |
| 1003 | + * Reads initial state from `data-enabled` attribute ("true"/"false"). | |
| 1004 | + * Calls `data-on-toggle` callback (if provided via options) on state change. | |
| 1005 | + * | |
| 1006 | + * HTML structure: | |
| 1007 | + * <label class="lp-toggle-enable" data-enabled="true"> | |
| 1008 | + * <input type="checkbox" class="lp-toggle-enable__input" /> | |
| 1009 | + * <span class="lp-toggle-enable__track"></span> | |
| 1010 | + * </label> | |
| 1011 | + * | |
| 1012 | + * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable') | |
| 1013 | + * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change | |
| 1014 | + * @since 4.4.5 | |
| 1015 | + * @version 1.0.0 | |
| 1016 | + */ | |
| 1017 | +window.lpToggleEnableInit = 0; | |
| 1018 | +const toggleEnable = (onToggle = null) => { | |
| 1019 | + if (window.lpToggleEnableInit) { | |
| 1020 | + return; | |
| 1021 | + } | |
| 1022 | + window.lpToggleEnableInit = 1; | |
| 1023 | + const selector = '.lp-toggle-enable'; | |
| 1024 | + const updateUI = (toggle, isEnabled) => { | |
| 1025 | + toggle.classList.toggle('is-enabled', isEnabled); | |
| 1026 | + const input = toggle.querySelector('.lp-toggle-enable__input'); | |
| 1027 | + if (input) { | |
| 1028 | + input.checked = isEnabled; | |
| 1029 | + input.value = isEnabled ? '1' : '0'; | |
| 1030 | + } | |
| 1031 | + }; | |
| 947 | 1032 | |
| 948 | -"use strict"; | |
| 949 | -__webpack_require__.r(__webpack_exports__); | |
| 950 | -const $ = jQuery; | |
| 951 | -let elLPOverlay = null; | |
| 952 | -const lpModalOverlay = { | |
| 953 | - elLPOverlay: null, | |
| 954 | - elMainContent: null, | |
| 955 | - elTitle: null, | |
| 956 | - elBtnYes: null, | |
| 957 | - elBtnNo: null, | |
| 958 | - elFooter: null, | |
| 959 | - elCalledModal: null, | |
| 960 | - callBackYes: null, | |
| 961 | - instance: null, | |
| 1033 | + // Delegate click handling via eventHandlers. | |
| 1034 | + eventHandlers('click', [{ | |
| 1035 | + selector, | |
| 1036 | + callBack: args => { | |
| 1037 | + const { | |
| 1038 | + e, | |
| 1039 | + target | |
| 1040 | + } = args; | |
| 1041 | + const toggle = target.closest(selector); | |
| 1042 | + if (!toggle || toggle.classList.contains('is-disabled')) { | |
| 1043 | + return; | |
| 1044 | + } | |
| 1045 | + e.preventDefault(); | |
| 1046 | + const isEnabled = !toggle.classList.contains('is-enabled'); | |
| 1047 | + updateUI(toggle, isEnabled); | |
| 1048 | + if ('function' === typeof onToggle) { | |
| 1049 | + onToggle(toggle, isEnabled); | |
| 1050 | + } | |
| 1051 | + } | |
| 1052 | + }]); | |
| 1053 | +}; | |
| 962 | 1054 | |
| 963 | - init() { | |
| 964 | - if (this.instance) { | |
| 965 | - return true; | |
| 1055 | +/** | |
| 1056 | + * Initialize custom fullscreen view buttons. | |
| 1057 | + * | |
| 1058 | + * Delegates clicks on `.lp-btn-full-screen-view` buttons to | |
| 1059 | + * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the | |
| 1060 | + * target element. Falls back to the button's parent element when | |
| 1061 | + * `data-target` is not provided. | |
| 1062 | + * | |
| 1063 | + * @since 4.4.5 | |
| 1064 | + * @version 1.0.0 | |
| 1065 | + */ | |
| 1066 | +window.lpFullScreenViewInit = 0; | |
| 1067 | +const fullScreenView = () => { | |
| 1068 | + if (window.lpFullScreenViewInit) { | |
| 1069 | + return; | |
| 1070 | + } | |
| 1071 | + window.lpFullScreenViewInit = 1; | |
| 1072 | + let lastScrollY = 0; | |
| 1073 | + const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => { | |
| 1074 | + const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen); | |
| 1075 | + if (isFullscreen) { | |
| 1076 | + elTarget.classList.remove(lpClassName.elFullScreen); | |
| 1077 | + document.documentElement.classList.remove('lp-full-screen-active'); | |
| 1078 | + window.scrollTo(0, lastScrollY); | |
| 1079 | + } else { | |
| 1080 | + lastScrollY = window.scrollY; | |
| 1081 | + elTarget.classList.add(lpClassName.elFullScreen); | |
| 1082 | + document.documentElement.classList.add('lp-full-screen-active'); | |
| 966 | 1083 | } |
| 967 | - | |
| 968 | - this.elLPOverlay = $('.lp-overlay'); | |
| 969 | - | |
| 970 | - if (!this.elLPOverlay.length) { | |
| 971 | - return false; | |
| 1084 | + if (!isFullscreen) { | |
| 1085 | + if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) { | |
| 1086 | + const closeButton = document.createElement('button'); | |
| 1087 | + closeButton.type = 'button'; | |
| 1088 | + closeButton.className = lpClassName.elBtnFullScreenClose; | |
| 1089 | + closeButton.setAttribute('aria-label', 'Close'); | |
| 1090 | + closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close ×'; | |
| 1091 | + closeButton.addEventListener('click', e => { | |
| 1092 | + e.preventDefault(); | |
| 1093 | + lpToggleFullscreenView(elTarget); | |
| 1094 | + }); | |
| 1095 | + elTarget.appendChild(closeButton); | |
| 1096 | + } | |
| 1097 | + } else { | |
| 1098 | + const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`); | |
| 1099 | + if (closeButton) { | |
| 1100 | + closeButton.remove(); | |
| 1101 | + } | |
| 972 | 1102 | } |
| 973 | - | |
| 974 | - elLPOverlay = this.elLPOverlay; | |
| 975 | - this.elMainContent = elLPOverlay.find('.main-content'); | |
| 976 | - this.elTitle = elLPOverlay.find('.modal-title'); | |
| 977 | - this.elBtnYes = elLPOverlay.find('.btn-yes'); | |
| 978 | - this.elBtnNo = elLPOverlay.find('.btn-no'); | |
| 979 | - this.elFooter = elLPOverlay.find('.lp-modal-footer'); | |
| 980 | - $(document).on('click', '.close, .btn-no', function () { | |
| 981 | - elLPOverlay.hide(); | |
| 982 | - }); | |
| 983 | - $(document).on('click', '.btn-yes', function (e) { | |
| 1103 | + }; | |
| 1104 | + eventHandlers('click', [{ | |
| 1105 | + selector: lpClassName.elBtnFullScreen, | |
| 1106 | + callBack: args => { | |
| 1107 | + const { | |
| 1108 | + e, | |
| 1109 | + target | |
| 1110 | + } = args; | |
| 1111 | + const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen); | |
| 1112 | + if (!elBtnFullScreen) { | |
| 1113 | + console.log('No full screen button found'); | |
| 1114 | + return; | |
| 1115 | + } | |
| 984 | 1116 | e.preventDefault(); |
| 985 | - e.stopPropagation(); | |
| 986 | - | |
| 987 | - if ('function' === typeof lpModalOverlay.callBackYes) { | |
| 988 | - lpModalOverlay.callBackYes(); | |
| 1117 | + let elTarget = null; | |
| 1118 | + const targetSelector = elBtnFullScreen.dataset.targetFullscreen; | |
| 1119 | + console.log(targetSelector); | |
| 1120 | + if (targetSelector) { | |
| 1121 | + elTarget = document.querySelector(targetSelector); | |
| 989 | 1122 | } |
| 990 | - }); | |
| 991 | - this.instance = this; | |
| 992 | - return true; | |
| 993 | - }, | |
| 994 | - | |
| 995 | - setElCalledModal(elCalledModal) { | |
| 996 | - this.elCalledModal = elCalledModal; | |
| 997 | - }, | |
| 998 | - | |
| 999 | - setContentModal(content, event) { | |
| 1000 | - this.elMainContent.html(content); | |
| 1001 | - | |
| 1002 | - if ('function' === typeof event) { | |
| 1003 | - event(); | |
| 1123 | + if (!elTarget) { | |
| 1124 | + console.log('No target element found'); | |
| 1125 | + return; | |
| 1126 | + } | |
| 1127 | + lpToggleFullscreenView(elTarget, elBtnFullScreen); | |
| 1004 | 1128 | } |
| 1005 | - }, | |
| 1006 | - | |
| 1007 | - setTitleModal(content) { | |
| 1008 | - this.elTitle.html(content); | |
| 1009 | - } | |
| 1010 | - | |
| 1129 | + }]); | |
| 1011 | 1130 | }; |
| 1012 | -/* harmony default export */ __webpack_exports__["default"] = (lpModalOverlay); | |
| 1013 | 1131 | |
| 1014 | -/***/ }), | |
| 1132 | +/***/ }, | |
| 1015 | 1133 | |
| 1016 | -/***/ "@wordpress/api-fetch": | |
| 1017 | -/*!**********************************!*\ | |
| 1018 | - !*** external ["wp","apiFetch"] ***! | |
| 1019 | - \**********************************/ | |
| 1020 | -/***/ (function(module) { | |
| 1134 | +/***/ "react" | |
| 1135 | +/*!************************!*\ | |
| 1136 | + !*** external "React" ***! | |
| 1137 | + \************************/ | |
| 1138 | +(module) { | |
| 1021 | 1139 | |
| 1022 | 1140 | "use strict"; |
| 1023 | -module.exports = window["wp"]["apiFetch"]; | |
| 1141 | +module.exports = window["React"]; | |
| 1024 | 1142 | |
| 1025 | -/***/ }), | |
| 1143 | +/***/ }, | |
| 1026 | 1144 | |
| 1027 | -/***/ "@wordpress/element": | |
| 1145 | +/***/ "@wordpress/element" | |
| 1028 | 1146 | /*!*********************************!*\ |
| 1029 | 1147 | !*** external ["wp","element"] ***! |
| 1030 | 1148 | \*********************************/ |
| 1031 | -/***/ (function(module) { | |
| 1149 | +(module) { | |
| 1032 | 1150 | |
| 1033 | 1151 | "use strict"; |
| 1034 | 1152 | module.exports = window["wp"]["element"]; |
| 1035 | 1153 | |
| 1036 | -/***/ }), | |
| 1154 | +/***/ }, | |
| 1037 | 1155 | |
| 1038 | -/***/ "@wordpress/url": | |
| 1156 | +/***/ "@wordpress/url" | |
| 1039 | 1157 | /*!*****************************!*\ |
| 1040 | 1158 | !*** external ["wp","url"] ***! |
| 1041 | 1159 | \*****************************/ |
| 1042 | -/***/ (function(module) { | |
| 1160 | +(module) { | |
| 1043 | 1161 | |
| 1044 | 1162 | "use strict"; |
| 1045 | 1163 | module.exports = window["wp"]["url"]; |
| 1046 | 1164 | |
| 1047 | -/***/ }) | |
| 1165 | +/***/ } | |
| 1048 | 1166 | |
| 1049 | 1167 | /******/ }); |
| 1050 | 1168 | /************************************************************************/ |
| 1051 | 1169 | /******/ // The module cache |
| 1052 | -/******/ var __webpack_module_cache__ = {}; | |
| 1170 | +/******/ const __webpack_module_cache__ = {}; | |
| 1053 | 1171 | /******/ |
| 1054 | 1172 | /******/ // The require function |
| 1055 | 1173 | /******/ function __webpack_require__(moduleId) { |
| 1056 | 1174 | /******/ // Check if module is in cache |
| 1057 | -/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 1175 | +/******/ const cachedModule = __webpack_module_cache__[moduleId]; | |
| 1058 | 1176 | /******/ if (cachedModule !== undefined) { |
| 1059 | 1177 | /******/ return cachedModule.exports; |
| 1060 | 1178 | /******/ } |
| 1061 | 1179 | /******/ // Create a new module (and put it into the cache) |
| 1062 | -/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 1180 | +/******/ const module = __webpack_module_cache__[moduleId] = { | |
| 1063 | 1181 | /******/ // no module.id needed |
| 1064 | 1182 | /******/ // no module.loaded needed |
| 1065 | 1183 | /******/ exports: {} |
| 1066 | 1184 | /******/ }; |
| @@ -1065,8 +1183,14 @@ | ||
| 1065 | 1183 | /******/ exports: {} |
| 1066 | 1184 | /******/ }; |
| 1067 | 1185 | /******/ |
| 1068 | 1186 | /******/ // Execute the module function |
| 1187 | +/******/ if (!(moduleId in __webpack_modules__)) { | |
| 1188 | +/******/ delete __webpack_module_cache__[moduleId]; | |
| 1189 | +/******/ const e = new Error("Cannot find module '" + moduleId + "'"); | |
| 1190 | +/******/ e.code = 'MODULE_NOT_FOUND'; | |
| 1191 | +/******/ throw e; | |
| 1192 | +/******/ } | |
| 1069 | 1193 | /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 1070 | 1194 | /******/ |
| 1071 | 1195 | /******/ // Return the exports of the module |
| 1072 | 1196 | /******/ return module.exports; |
| @@ -1073,51 +1197,66 @@ | ||
| 1073 | 1197 | /******/ } |
| 1074 | 1198 | /******/ |
| 1075 | 1199 | /************************************************************************/ |
| 1076 | 1200 | /******/ /* webpack/runtime/compat get default export */ |
| 1077 | -/******/ !function() { | |
| 1201 | +/******/ (() => { | |
| 1078 | 1202 | /******/ // getDefaultExport function for compatibility with non-harmony modules |
| 1079 | -/******/ __webpack_require__.n = function(module) { | |
| 1080 | -/******/ var getter = module && module.__esModule ? | |
| 1081 | -/******/ function() { return module['default']; } : | |
| 1082 | -/******/ function() { return module; }; | |
| 1203 | +/******/ __webpack_require__.n = (module) => { | |
| 1204 | +/******/ const getter = module && module.__esModule ? | |
| 1205 | +/******/ () => (module['default']) : | |
| 1206 | +/******/ () => (module); | |
| 1083 | 1207 | /******/ __webpack_require__.d(getter, { a: getter }); |
| 1084 | 1208 | /******/ return getter; |
| 1085 | 1209 | /******/ }; |
| 1086 | -/******/ }(); | |
| 1210 | +/******/ })(); | |
| 1087 | 1211 | /******/ |
| 1088 | 1212 | /******/ /* webpack/runtime/define property getters */ |
| 1089 | -/******/ !function() { | |
| 1090 | -/******/ // define getter functions for harmony exports | |
| 1091 | -/******/ __webpack_require__.d = function(exports, definition) { | |
| 1092 | -/******/ for(var key in definition) { | |
| 1093 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 1094 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 1213 | +/******/ (() => { | |
| 1214 | +/******/ // define getter/value functions for harmony exports | |
| 1215 | +/******/ __webpack_require__.d = (exports, definition) => { | |
| 1216 | +/******/ if(Array.isArray(definition)) { | |
| 1217 | +/******/ var i = 0; | |
| 1218 | +/******/ while(i < definition.length) { | |
| 1219 | +/******/ var key = definition[i++]; | |
| 1220 | +/******/ var binding = definition[i++]; | |
| 1221 | +/******/ if(!__webpack_require__.o(exports, key)) { | |
| 1222 | +/******/ if(binding === 0) { | |
| 1223 | +/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] }); | |
| 1224 | +/******/ } else { | |
| 1225 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding }); | |
| 1226 | +/******/ } | |
| 1227 | +/******/ } else if(binding === 0) { i++; } | |
| 1095 | 1228 | /******/ } |
| 1229 | +/******/ } else { | |
| 1230 | +/******/ for(var key in definition) { | |
| 1231 | +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 1232 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 1233 | +/******/ } | |
| 1234 | +/******/ } | |
| 1096 | 1235 | /******/ } |
| 1097 | 1236 | /******/ }; |
| 1098 | -/******/ }(); | |
| 1237 | +/******/ })(); | |
| 1099 | 1238 | /******/ |
| 1100 | 1239 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 1101 | -/******/ !function() { | |
| 1102 | -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } | |
| 1103 | -/******/ }(); | |
| 1240 | +/******/ (() => { | |
| 1241 | +/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop)) | |
| 1242 | +/******/ })(); | |
| 1104 | 1243 | /******/ |
| 1105 | 1244 | /******/ /* webpack/runtime/make namespace object */ |
| 1106 | -/******/ !function() { | |
| 1245 | +/******/ (() => { | |
| 1107 | 1246 | /******/ // define __esModule on exports |
| 1108 | -/******/ __webpack_require__.r = function(exports) { | |
| 1109 | -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 1247 | +/******/ __webpack_require__.r = (exports) => { | |
| 1248 | +/******/ if(Symbol.toStringTag) { | |
| 1110 | 1249 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 1111 | 1250 | /******/ } |
| 1112 | 1251 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 1113 | 1252 | /******/ }; |
| 1114 | -/******/ }(); | |
| 1253 | +/******/ })(); | |
| 1115 | 1254 | /******/ |
| 1116 | 1255 | /************************************************************************/ |
| 1117 | -var __webpack_exports__ = {}; | |
| 1118 | -// This entry need to be wrapped in an IIFE because it need to be in strict mode. | |
| 1119 | -!function() { | |
| 1256 | +let __webpack_exports__ = {}; | |
| 1257 | +// This entry needs to be wrapped in an IIFE because it needs to be in strict mode. | |
| 1258 | +(() => { | |
| 1120 | 1259 | "use strict"; |
| 1121 | 1260 | /*!**********************************************************!*\ |
| 1122 | 1261 | !*** ./assets/src/apps/js/frontend/single-curriculum.js ***! |
| 1123 | 1262 | \**********************************************************/ |
| @@ -1122,36 +1261,44 @@ | ||
| 1122 | 1261 | !*** ./assets/src/apps/js/frontend/single-curriculum.js ***! |
| 1123 | 1262 | \**********************************************************/ |
| 1124 | 1263 | __webpack_require__.r(__webpack_exports__); |
| 1125 | 1264 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1126 | -/* harmony export */ "init": function() { return /* binding */ init; } | |
| 1265 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 1127 | 1266 | /* harmony export */ }); |
| 1128 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1129 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 1130 | -/* harmony import */ var _single_curriculum_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./single-curriculum/index */ "./assets/src/apps/js/frontend/single-curriculum/index.js"); | |
| 1131 | -/* 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"); | |
| 1132 | -/* harmony import */ var _single_curriculum_skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./single-curriculum/skeleton */ "./assets/src/apps/js/frontend/single-curriculum/skeleton.js"); | |
| 1267 | +/* harmony import */ var _single_curriculum_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./single-curriculum/index */ "./assets/src/apps/js/frontend/single-curriculum/index.js"); | |
| 1268 | +/* 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"); | |
| 1269 | +/* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./material */ "./assets/src/apps/js/frontend/material.js"); | |
| 1133 | 1270 | |
| 1134 | 1271 | |
| 1272 | +//import courseCurriculumSkeleton from './single-curriculum/skeleton'; | |
| 1135 | 1273 | |
| 1274 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_single_curriculum_index__WEBPACK_IMPORTED_MODULE_0__["default"]); | |
| 1136 | 1275 | |
| 1137 | -/* harmony default export */ __webpack_exports__["default"] = (_single_curriculum_index__WEBPACK_IMPORTED_MODULE_1__["default"]); | |
| 1138 | -const init = () => { | |
| 1139 | - wp.element.render((0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_single_curriculum_index__WEBPACK_IMPORTED_MODULE_1__["default"], null), document.getElementById('learn-press-course-curriculum')); | |
| 1140 | -}; | |
| 1276 | +// Comment code use for old curriculum | |
| 1277 | +/*export const init = () => { | |
| 1278 | + wp.element.render( | |
| 1279 | + <SingleCurriculums />, | |
| 1280 | + document.getElementById( 'learn-press-course-curriculum' ) | |
| 1281 | + ); | |
| 1282 | +};*/ | |
| 1283 | + | |
| 1141 | 1284 | document.addEventListener('DOMContentLoaded', function (event) { |
| 1142 | - LP.Hook.doAction('course-ready'); | |
| 1143 | - _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_2__["default"].init(); //courseCurriculumSkeleton(); | |
| 1285 | + //LP.Hook.doAction( 'course-ready' ); | |
| 1286 | + _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init(); | |
| 1287 | + (0,_material__WEBPACK_IMPORTED_MODULE_2__["default"])(); | |
| 1288 | + //courseCurriculumSkeleton(); | |
| 1144 | 1289 | //init(); |
| 1145 | 1290 | }); |
| 1146 | -const detectedElCurriculum = setInterval(function () { | |
| 1147 | - const elementCurriculum = document.querySelector('.learnpress-course-curriculum'); | |
| 1148 | 1291 | |
| 1149 | - if (elementCurriculum) { | |
| 1150 | - (0,_single_curriculum_skeleton__WEBPACK_IMPORTED_MODULE_3__["default"])(); | |
| 1151 | - clearInterval(detectedElCurriculum); | |
| 1152 | - } | |
| 1153 | -}, 1); | |
| 1154 | -}(); | |
| 1292 | +// Comment code use for old curriculum | |
| 1293 | +/*const detectedElCurriculum = setInterval( function() { | |
| 1294 | + const elementCurriculum = document.querySelector( '.learnpress-course-curriculum' ); | |
| 1295 | + if ( elementCurriculum ) { | |
| 1296 | + courseCurriculumSkeleton(); | |
| 1297 | + clearInterval( detectedElCurriculum ); | |
| 1298 | + } | |
| 1299 | +}, 1 );*/ | |
| 1300 | +})(); | |
| 1301 | + | |
| 1155 | 1302 | /******/ })() |
| 1156 | 1303 | ; |
| 1157 | 1304 | //# sourceMappingURL=single-curriculum.js.map |