| @@ -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,9 +74,10 @@ | ||
| 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 | 81 | /** |
| 83 | 82 | * Utils functions |
| 84 | 83 | * |
| @@ -85,9 +84,9 @@ | ||
| 85 | 84 | * @param url |
| 86 | 85 | * @param data |
| 87 | 86 | * @param functions |
| 88 | 87 | * @since 4.2.5.1 |
| 89 | - * @version 1.0.6 | |
| 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(); |
| @@ -412,24 +414,157 @@ | ||
| 412 | 414 | timer = setTimeout(() => func(args), wait); |
| 413 | 415 | }; |
| 414 | 416 | }; |
| 415 | 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 | + }]); | |
| 549 | +}; | |
| 550 | + | |
| 416 | 551 | /***/ } |
| 417 | 552 | |
| 418 | 553 | /******/ }); |
| 419 | 554 | /************************************************************************/ |
| 420 | 555 | /******/ // The module cache |
| 421 | -/******/ const __webpack_module_cache__ = {}; | |
| 556 | +/******/ var __webpack_module_cache__ = {}; | |
| 422 | 557 | /******/ |
| 423 | 558 | /******/ // The require function |
| 424 | 559 | /******/ function __webpack_require__(moduleId) { |
| 425 | 560 | /******/ // Check if module is in cache |
| 426 | -/******/ const cachedModule = __webpack_module_cache__[moduleId]; | |
| 561 | +/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 427 | 562 | /******/ if (cachedModule !== undefined) { |
| 428 | 563 | /******/ return cachedModule.exports; |
| 429 | 564 | /******/ } |
| 430 | 565 | /******/ // Create a new module (and put it into the cache) |
| 431 | -/******/ const module = __webpack_module_cache__[moduleId] = { | |
| 566 | +/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 432 | 567 | /******/ // no module.id needed |
| 433 | 568 | /******/ // no module.loaded needed |
| 434 | 569 | /******/ exports: {} |
| 435 | 570 | /******/ }; |
| @@ -436,9 +571,9 @@ | ||
| 436 | 571 | /******/ |
| 437 | 572 | /******/ // Execute the module function |
| 438 | 573 | /******/ if (!(moduleId in __webpack_modules__)) { |
| 439 | 574 | /******/ delete __webpack_module_cache__[moduleId]; |
| 440 | -/******/ const e = new Error("Cannot find module '" + moduleId + "'"); | |
| 575 | +/******/ var e = new Error("Cannot find module '" + moduleId + "'"); | |
| 441 | 576 | /******/ e.code = 'MODULE_NOT_FOUND'; |
| 442 | 577 | /******/ throw e; |
| 443 | 578 | /******/ } |
| 444 | 579 | /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| @@ -449,29 +584,14 @@ | ||
| 449 | 584 | /******/ |
| 450 | 585 | /************************************************************************/ |
| 451 | 586 | /******/ /* webpack/runtime/define property getters */ |
| 452 | 587 | /******/ (() => { |
| 453 | -/******/ // define getter/value functions for harmony exports | |
| 588 | +/******/ // define getter functions for harmony exports | |
| 454 | 589 | /******/ __webpack_require__.d = (exports, definition) => { |
| 455 | -/******/ if(Array.isArray(definition)) { | |
| 456 | -/******/ var i = 0; | |
| 457 | -/******/ while(i < definition.length) { | |
| 458 | -/******/ var key = definition[i++]; | |
| 459 | -/******/ var binding = definition[i++]; | |
| 460 | -/******/ if(!__webpack_require__.o(exports, key)) { | |
| 461 | -/******/ if(binding === 0) { | |
| 462 | -/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] }); | |
| 463 | -/******/ } else { | |
| 464 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding }); | |
| 465 | -/******/ } | |
| 466 | -/******/ } else if(binding === 0) { i++; } | |
| 590 | +/******/ for(var key in definition) { | |
| 591 | +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 592 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 467 | 593 | /******/ } |
| 468 | -/******/ } else { | |
| 469 | -/******/ for(var key in definition) { | |
| 470 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 471 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 472 | -/******/ } | |
| 473 | -/******/ } | |
| 474 | 594 | /******/ } |
| 475 | 595 | /******/ }; |
| 476 | 596 | /******/ })(); |
| 477 | 597 | /******/ |
| @@ -476,9 +596,9 @@ | ||
| 476 | 596 | /******/ })(); |
| 477 | 597 | /******/ |
| 478 | 598 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 479 | 599 | /******/ (() => { |
| 480 | -/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop)) | |
| 600 | +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | |
| 481 | 601 | /******/ })(); |
| 482 | 602 | /******/ |
| 483 | 603 | /******/ /* webpack/runtime/make namespace object */ |
| 484 | 604 | /******/ (() => { |
| @@ -483,9 +603,9 @@ | ||
| 483 | 603 | /******/ /* webpack/runtime/make namespace object */ |
| 484 | 604 | /******/ (() => { |
| 485 | 605 | /******/ // define __esModule on exports |
| 486 | 606 | /******/ __webpack_require__.r = (exports) => { |
| 487 | -/******/ if(Symbol.toStringTag) { | |
| 607 | +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 488 | 608 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 489 | 609 | /******/ } |
| 490 | 610 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 491 | 611 | /******/ }; |
| @@ -491,9 +611,9 @@ | ||
| 491 | 611 | /******/ }; |
| 492 | 612 | /******/ })(); |
| 493 | 613 | /******/ |
| 494 | 614 | /************************************************************************/ |
| 495 | -let __webpack_exports__ = {}; | |
| 615 | +var __webpack_exports__ = {}; | |
| 496 | 616 | // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. |
| 497 | 617 | (() => { |
| 498 | 618 | /*!*******************************************!*\ |
| 499 | 619 | !*** ./assets/src/js/frontend/widgets.js ***! |