| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | /******/ (() => { // webpackBootstrap |
| 2 | 2 | /******/ "use strict"; |
| 3 | 3 | /******/ var __webpack_modules__ = ({ |
| 4 | 4 | |
| @@ -11,13 +11,13 @@ | ||
| 11 | 11 | __webpack_require__.r(__webpack_exports__); |
| 12 | 12 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 13 | 13 | /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) |
| 14 | 14 | /* harmony export */ }); |
| 15 | -/** | |
| 16 | - * List API on backend | |
| 17 | - * | |
| 18 | - * @since 4.2.6 | |
| 19 | - * @version 1.0.2 | |
| 15 | +/** | |
| 16 | + * List API on backend | |
| 17 | + * | |
| 18 | + * @since 4.2.6 | |
| 19 | + * @version 1.0.2 | |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | const lplistAPI = {}; |
| 23 | 23 | let lp_rest_url; |
| @@ -23,12 +23,9 @@ | ||
| 23 | 23 | let lp_rest_url; |
| 24 | 24 | if ('undefined' !== typeof lpDataAdmin) { |
| 25 | 25 | lp_rest_url = lpDataAdmin.lp_rest_url; |
| 26 | 26 | lplistAPI.admin = { |
| 27 | - apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices', | |
| 28 | - apiAddons: lp_rest_url + 'lp/v1/addon/all', | |
| 29 | - apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n', | |
| 30 | - apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase', | |
| 27 | + // apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices', | |
| 31 | 28 | apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course', |
| 32 | 29 | apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user', |
| 33 | 30 | apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course', |
| 34 | 31 | apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course' |
| @@ -63,8 +60,9 @@ | ||
| 63 | 60 | __webpack_require__.r(__webpack_exports__); |
| 64 | 61 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 65 | 62 | /* harmony export */ debounce: () => (/* binding */ debounce), |
| 66 | 63 | /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers), |
| 64 | +/* harmony export */ fullScreenView: () => (/* binding */ fullScreenView), | |
| 67 | 65 | /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm), |
| 68 | 66 | /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm), |
| 69 | 67 | /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated), |
| 70 | 68 | /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed), |
| @@ -76,18 +74,19 @@ | ||
| 76 | 74 | /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady), |
| 77 | 75 | /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl), |
| 78 | 76 | /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl), |
| 79 | 77 | /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm), |
| 80 | -/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse) | |
| 78 | +/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse), | |
| 79 | +/* harmony export */ toggleEnable: () => (/* binding */ toggleEnable) | |
| 81 | 80 | /* harmony export */ }); |
| 82 | -/** | |
| 83 | - * Utils functions | |
| 84 | - * | |
| 85 | - * @param url | |
| 86 | - * @param data | |
| 87 | - * @param functions | |
| 88 | - * @since 4.2.5.1 | |
| 89 | - * @version 1.0.6 | |
| 81 | +/** | |
| 82 | + * Utils functions | |
| 83 | + * | |
| 84 | + * @param url | |
| 85 | + * @param data | |
| 86 | + * @param functions | |
| 87 | + * @since 4.2.5.1 | |
| 88 | + * @version 1.0.7 | |
| 90 | 89 | */ |
| 91 | 90 | const lpClassName = { |
| 92 | 91 | hidden: 'lp-hidden', |
| 93 | 92 | loading: 'loading', |
| @@ -92,9 +91,12 @@ | ||
| 92 | 91 | hidden: 'lp-hidden', |
| 93 | 92 | loading: 'loading', |
| 94 | 93 | elCollapse: 'lp-collapse', |
| 95 | 94 | elSectionToggle: '.lp-section-toggle', |
| 96 | - elTriggerToggle: '.lp-trigger-toggle' | |
| 95 | + elTriggerToggle: '.lp-trigger-toggle', | |
| 96 | + elBtnFullScreen: '.lp-btn-full-screen-view', | |
| 97 | + elFullScreen: 'lp-full-screen-view', | |
| 98 | + elBtnFullScreenClose: 'lp-full-screen-view__close' | |
| 97 | 99 | }; |
| 98 | 100 | const lpFetchAPI = (url, data = {}, functions = {}) => { |
| 99 | 101 | if ('function' === typeof functions.before) { |
| 100 | 102 | functions.before(); |
| @@ -116,12 +118,12 @@ | ||
| 116 | 118 | } |
| 117 | 119 | }); |
| 118 | 120 | }; |
| 119 | 121 | |
| 120 | -/** | |
| 121 | - * Get current URL without params. | |
| 122 | - * | |
| 123 | - * @since 4.2.5.1 | |
| 122 | +/** | |
| 123 | + * Get current URL without params. | |
| 124 | + * | |
| 125 | + * @since 4.2.5.1 | |
| 124 | 126 | */ |
| 125 | 127 | const lpGetCurrentURLNoParam = () => { |
| 126 | 128 | let currentUrl = window.location.href; |
| 127 | 129 | const hasParams = currentUrl.includes('?'); |
| @@ -137,14 +139,14 @@ | ||
| 137 | 139 | }); |
| 138 | 140 | return url; |
| 139 | 141 | }; |
| 140 | 142 | |
| 141 | -/** | |
| 142 | - * Listen element viewed. | |
| 143 | - * | |
| 144 | - * @param el | |
| 145 | - * @param callback | |
| 146 | - * @since 4.2.5.8 | |
| 143 | +/** | |
| 144 | + * Listen element viewed. | |
| 145 | + * | |
| 146 | + * @param el | |
| 147 | + * @param callback | |
| 148 | + * @since 4.2.5.8 | |
| 147 | 149 | */ |
| 148 | 150 | const listenElementViewed = (el, callback) => { |
| 149 | 151 | const observerSeeItem = new IntersectionObserver(function (entries) { |
| 150 | 152 | for (const entry of entries) { |
| @@ -155,13 +157,13 @@ | ||
| 155 | 157 | }); |
| 156 | 158 | observerSeeItem.observe(el); |
| 157 | 159 | }; |
| 158 | 160 | |
| 159 | -/** | |
| 160 | - * Listen element created. | |
| 161 | - * | |
| 162 | - * @param callback | |
| 163 | - * @since 4.2.5.8 | |
| 161 | +/** | |
| 162 | + * Listen element created. | |
| 163 | + * | |
| 164 | + * @param callback | |
| 165 | + * @since 4.2.5.8 | |
| 164 | 166 | */ |
| 165 | 167 | const listenElementCreated = callback => { |
| 166 | 168 | const observerCreateItem = new MutationObserver(function (mutations) { |
| 167 | 169 | mutations.forEach(function (mutation) { |
| @@ -180,14 +182,14 @@ | ||
| 180 | 182 | }); |
| 181 | 183 | // End. |
| 182 | 184 | }; |
| 183 | 185 | |
| 184 | -/** | |
| 185 | - * Listen element created. | |
| 186 | - * | |
| 187 | - * @param selector | |
| 188 | - * @param callback | |
| 189 | - * @since 4.2.7.1 | |
| 186 | +/** | |
| 187 | + * Listen element created. | |
| 188 | + * | |
| 189 | + * @param selector | |
| 190 | + * @param callback | |
| 191 | + * @since 4.2.7.1 | |
| 190 | 192 | */ |
| 191 | 193 | const lpOnElementReady = (selector, callback) => { |
| 192 | 194 | const element = document.querySelector(selector); |
| 193 | 195 | if (element) { |
| @@ -328,17 +330,17 @@ | ||
| 328 | 330 | }; |
| 329 | 331 | return dataHandle; |
| 330 | 332 | }; |
| 331 | 333 | |
| 332 | -/** | |
| 333 | - * Event trigger | |
| 334 | - * For each list of event handlers, listen event on document. | |
| 335 | - * | |
| 336 | - * eventName: 'click', 'change', ... | |
| 337 | - * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ] | |
| 338 | - * | |
| 339 | - * @param eventName | |
| 340 | - * @param eventHandlers | |
| 334 | +/** | |
| 335 | + * Event trigger | |
| 336 | + * For each list of event handlers, listen event on document. | |
| 337 | + * | |
| 338 | + * eventName: 'click', 'change', ... | |
| 339 | + * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ] | |
| 340 | + * | |
| 341 | + * @param eventName | |
| 342 | + * @param eventHandlers | |
| 341 | 343 | */ |
| 342 | 344 | const eventHandlers = (eventName, eventHandlers) => { |
| 343 | 345 | document.addEventListener(eventName, e => { |
| 344 | 346 | const target = e.target; |
| @@ -379,32 +381,32 @@ | ||
| 379 | 381 | }); |
| 380 | 382 | }); |
| 381 | 383 | }; |
| 382 | 384 | |
| 383 | -/** | |
| 384 | - * Debounce - delays function execution until after `wait` ms of inactivity. | |
| 385 | - * | |
| 386 | - * Each call resets the timer. Only the last call in a burst executes. | |
| 387 | - * | |
| 388 | - * USE CASES: | |
| 389 | - * - Search inputs, form validation, window resize | |
| 390 | - * - Multiple elements need independent timers | |
| 391 | - * - When you need to call with different arguments | |
| 392 | - * | |
| 393 | - * EXAMPLES: | |
| 394 | - * const debouncedSearch = debounce( (query) => fetchResults(query), 300 ); | |
| 395 | - * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value)); | |
| 396 | - * | |
| 397 | - * const debouncedResize = debounce( recalculateLayout, 250 ); | |
| 398 | - * window.addEventListener('resize', debouncedResize); | |
| 399 | - * | |
| 400 | - * ⚠️ Create ONCE outside event handlers, not inside. | |
| 401 | - * | |
| 402 | - * @param {Function} func - Function to debounce (can be anonymous) | |
| 403 | - * @param {number} wait - Milliseconds to wait (default: 500) | |
| 404 | - * @return {Function} Debounced wrapper function | |
| 405 | - * @since 4.3.7 | |
| 406 | - * @version 1.0.0 | |
| 385 | +/** | |
| 386 | + * Debounce - delays function execution until after `wait` ms of inactivity. | |
| 387 | + * | |
| 388 | + * Each call resets the timer. Only the last call in a burst executes. | |
| 389 | + * | |
| 390 | + * USE CASES: | |
| 391 | + * - Search inputs, form validation, window resize | |
| 392 | + * - Multiple elements need independent timers | |
| 393 | + * - When you need to call with different arguments | |
| 394 | + * | |
| 395 | + * EXAMPLES: | |
| 396 | + * const debouncedSearch = debounce( (query) => fetchResults(query), 300 ); | |
| 397 | + * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value)); | |
| 398 | + * | |
| 399 | + * const debouncedResize = debounce( recalculateLayout, 250 ); | |
| 400 | + * window.addEventListener('resize', debouncedResize); | |
| 401 | + * | |
| 402 | + * ⚠️ Create ONCE outside event handlers, not inside. | |
| 403 | + * | |
| 404 | + * @param {Function} func - Function to debounce (can be anonymous) | |
| 405 | + * @param {number} wait - Milliseconds to wait (default: 500) | |
| 406 | + * @return {Function} Debounced wrapper function | |
| 407 | + * @since 4.3.7 | |
| 408 | + * @version 1.0.0 | |
| 407 | 409 | */ |
| 408 | 410 | const debounce = (func, wait = 500) => { |
| 409 | 411 | let timer; |
| 410 | 412 | return args => { |
| @@ -410,8 +412,141 @@ | ||
| 410 | 412 | return args => { |
| 411 | 413 | clearTimeout(timer); |
| 412 | 414 | timer = setTimeout(() => func(args), wait); |
| 413 | 415 | }; |
| 416 | +}; | |
| 417 | + | |
| 418 | +/** | |
| 419 | + * Initialize lp-toggle-enable components. | |
| 420 | + * | |
| 421 | + * Finds all `.lp-toggle-enable` elements and wires up toggle behavior. | |
| 422 | + * Reads initial state from `data-enabled` attribute ("true"/"false"). | |
| 423 | + * Calls `data-on-toggle` callback (if provided via options) on state change. | |
| 424 | + * | |
| 425 | + * HTML structure: | |
| 426 | + * <label class="lp-toggle-enable" data-enabled="true"> | |
| 427 | + * <input type="checkbox" class="lp-toggle-enable__input" /> | |
| 428 | + * <span class="lp-toggle-enable__track"></span> | |
| 429 | + * </label> | |
| 430 | + * | |
| 431 | + * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable') | |
| 432 | + * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change | |
| 433 | + * @since 4.4.5 | |
| 434 | + * @version 1.0.0 | |
| 435 | + */ | |
| 436 | +window.lpToggleEnableInit = 0; | |
| 437 | +const toggleEnable = (onToggle = null) => { | |
| 438 | + if (window.lpToggleEnableInit) { | |
| 439 | + return; | |
| 440 | + } | |
| 441 | + window.lpToggleEnableInit = 1; | |
| 442 | + const selector = '.lp-toggle-enable'; | |
| 443 | + const updateUI = (toggle, isEnabled) => { | |
| 444 | + toggle.classList.toggle('is-enabled', isEnabled); | |
| 445 | + const input = toggle.querySelector('.lp-toggle-enable__input'); | |
| 446 | + if (input) { | |
| 447 | + input.checked = isEnabled; | |
| 448 | + input.value = isEnabled ? '1' : '0'; | |
| 449 | + } | |
| 450 | + }; | |
| 451 | + | |
| 452 | + // Delegate click handling via eventHandlers. | |
| 453 | + eventHandlers('click', [{ | |
| 454 | + selector, | |
| 455 | + callBack: args => { | |
| 456 | + const { | |
| 457 | + e, | |
| 458 | + target | |
| 459 | + } = args; | |
| 460 | + const toggle = target.closest(selector); | |
| 461 | + if (!toggle || toggle.classList.contains('is-disabled')) { | |
| 462 | + return; | |
| 463 | + } | |
| 464 | + e.preventDefault(); | |
| 465 | + const isEnabled = !toggle.classList.contains('is-enabled'); | |
| 466 | + updateUI(toggle, isEnabled); | |
| 467 | + if ('function' === typeof onToggle) { | |
| 468 | + onToggle(toggle, isEnabled); | |
| 469 | + } | |
| 470 | + } | |
| 471 | + }]); | |
| 472 | +}; | |
| 473 | + | |
| 474 | +/** | |
| 475 | + * Initialize custom fullscreen view buttons. | |
| 476 | + * | |
| 477 | + * Delegates clicks on `.lp-btn-full-screen-view` buttons to | |
| 478 | + * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the | |
| 479 | + * target element. Falls back to the button's parent element when | |
| 480 | + * `data-target` is not provided. | |
| 481 | + * | |
| 482 | + * @since 4.4.5 | |
| 483 | + * @version 1.0.0 | |
| 484 | + */ | |
| 485 | +window.lpFullScreenViewInit = 0; | |
| 486 | +const fullScreenView = () => { | |
| 487 | + if (window.lpFullScreenViewInit) { | |
| 488 | + return; | |
| 489 | + } | |
| 490 | + window.lpFullScreenViewInit = 1; | |
| 491 | + let lastScrollY = 0; | |
| 492 | + const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => { | |
| 493 | + const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen); | |
| 494 | + if (isFullscreen) { | |
| 495 | + elTarget.classList.remove(lpClassName.elFullScreen); | |
| 496 | + document.documentElement.classList.remove('lp-full-screen-active'); | |
| 497 | + window.scrollTo(0, lastScrollY); | |
| 498 | + } else { | |
| 499 | + lastScrollY = window.scrollY; | |
| 500 | + elTarget.classList.add(lpClassName.elFullScreen); | |
| 501 | + document.documentElement.classList.add('lp-full-screen-active'); | |
| 502 | + } | |
| 503 | + if (!isFullscreen) { | |
| 504 | + if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) { | |
| 505 | + const closeButton = document.createElement('button'); | |
| 506 | + closeButton.type = 'button'; | |
| 507 | + closeButton.className = lpClassName.elBtnFullScreenClose; | |
| 508 | + closeButton.setAttribute('aria-label', 'Close'); | |
| 509 | + closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close ×'; | |
| 510 | + closeButton.addEventListener('click', e => { | |
| 511 | + e.preventDefault(); | |
| 512 | + lpToggleFullscreenView(elTarget); | |
| 513 | + }); | |
| 514 | + elTarget.appendChild(closeButton); | |
| 515 | + } | |
| 516 | + } else { | |
| 517 | + const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`); | |
| 518 | + if (closeButton) { | |
| 519 | + closeButton.remove(); | |
| 520 | + } | |
| 521 | + } | |
| 522 | + }; | |
| 523 | + eventHandlers('click', [{ | |
| 524 | + selector: lpClassName.elBtnFullScreen, | |
| 525 | + callBack: args => { | |
| 526 | + const { | |
| 527 | + e, | |
| 528 | + target | |
| 529 | + } = args; | |
| 530 | + const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen); | |
| 531 | + if (!elBtnFullScreen) { | |
| 532 | + console.log('No full screen button found'); | |
| 533 | + return; | |
| 534 | + } | |
| 535 | + e.preventDefault(); | |
| 536 | + let elTarget = null; | |
| 537 | + const targetSelector = elBtnFullScreen.dataset.targetFullscreen; | |
| 538 | + console.log(targetSelector); | |
| 539 | + if (targetSelector) { | |
| 540 | + elTarget = document.querySelector(targetSelector); | |
| 541 | + } | |
| 542 | + if (!elTarget) { | |
| 543 | + console.log('No target element found'); | |
| 544 | + return; | |
| 545 | + } | |
| 546 | + lpToggleFullscreenView(elTarget, elBtnFullScreen); | |
| 547 | + } | |
| 548 | + }]); | |
| 414 | 549 | }; |
| 415 | 550 | |
| 416 | 551 | /***/ } |
| 417 | 552 | |