| @@ -418,9 +418,8 @@ | ||
| 418 | 418 | if (!btn) { |
| 419 | 419 | return; |
| 420 | 420 | } |
| 421 | 421 | lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(btn, isLoading ? 1 : 0); |
| 422 | - btn.disabled = !!isLoading; | |
| 423 | 422 | } |
| 424 | 423 | init() { |
| 425 | 424 | if (ViewStudentsModal._loadedEvents) { |
| 426 | 425 | return; |
| @@ -456,9 +455,9 @@ | ||
| 456 | 455 | }]); |
| 457 | 456 | } |
| 458 | 457 | handleOpenModal(args) { |
| 459 | 458 | const btn = args?.target?.closest(ViewStudentsModal.selectors.courseTrigger); |
| 460 | - if (!btn || this.isRequesting || btn.classList.contains('loading') || btn.disabled) { | |
| 459 | + if (!btn || this.isRequesting || btn.classList.contains('loading')) { | |
| 461 | 460 | return; |
| 462 | 461 | } |
| 463 | 462 | const courseId = parseInt(btn.dataset.courseId, 10) || 0; |
| 464 | 463 | if (!courseId) { |
| @@ -508,9 +507,9 @@ | ||
| 508 | 507 | } |
| 509 | 508 | if (args?.e) { |
| 510 | 509 | args.e.preventDefault(); |
| 511 | 510 | } |
| 512 | - if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) { | |
| 511 | + if (this.isRequesting || btn.classList.contains('loading')) { | |
| 513 | 512 | return; |
| 514 | 513 | } |
| 515 | 514 | form.reset(); |
| 516 | 515 | this.setButtonLoadingState(btn, true); |
| @@ -713,8 +712,9 @@ | ||
| 713 | 712 | __webpack_require__.r(__webpack_exports__); |
| 714 | 713 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 715 | 714 | /* harmony export */ debounce: () => (/* binding */ debounce), |
| 716 | 715 | /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers), |
| 716 | +/* harmony export */ fullScreenView: () => (/* binding */ fullScreenView), | |
| 717 | 717 | /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm), |
| 718 | 718 | /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm), |
| 719 | 719 | /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated), |
| 720 | 720 | /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed), |
| @@ -726,9 +726,10 @@ | ||
| 726 | 726 | /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady), |
| 727 | 727 | /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl), |
| 728 | 728 | /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl), |
| 729 | 729 | /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm), |
| 730 | -/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse) | |
| 730 | +/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse), | |
| 731 | +/* harmony export */ toggleEnable: () => (/* binding */ toggleEnable) | |
| 731 | 732 | /* harmony export */ }); |
| 732 | 733 | /** |
| 733 | 734 | * Utils functions |
| 734 | 735 | * |
| @@ -735,9 +736,9 @@ | ||
| 735 | 736 | * @param url |
| 736 | 737 | * @param data |
| 737 | 738 | * @param functions |
| 738 | 739 | * @since 4.2.5.1 |
| 739 | - * @version 1.0.6 | |
| 740 | + * @version 1.0.7 | |
| 740 | 741 | */ |
| 741 | 742 | const lpClassName = { |
| 742 | 743 | hidden: 'lp-hidden', |
| 743 | 744 | loading: 'loading', |
| @@ -742,9 +743,12 @@ | ||
| 742 | 743 | hidden: 'lp-hidden', |
| 743 | 744 | loading: 'loading', |
| 744 | 745 | elCollapse: 'lp-collapse', |
| 745 | 746 | elSectionToggle: '.lp-section-toggle', |
| 746 | - elTriggerToggle: '.lp-trigger-toggle' | |
| 747 | + elTriggerToggle: '.lp-trigger-toggle', | |
| 748 | + elBtnFullScreen: '.lp-btn-full-screen-view', | |
| 749 | + elFullScreen: 'lp-full-screen-view', | |
| 750 | + elBtnFullScreenClose: 'lp-full-screen-view__close' | |
| 747 | 751 | }; |
| 748 | 752 | const lpFetchAPI = (url, data = {}, functions = {}) => { |
| 749 | 753 | if ('function' === typeof functions.before) { |
| 750 | 754 | functions.before(); |
| @@ -1060,8 +1064,141 @@ | ||
| 1060 | 1064 | return args => { |
| 1061 | 1065 | clearTimeout(timer); |
| 1062 | 1066 | timer = setTimeout(() => func(args), wait); |
| 1063 | 1067 | }; |
| 1068 | +}; | |
| 1069 | + | |
| 1070 | +/** | |
| 1071 | + * Initialize lp-toggle-enable components. | |
| 1072 | + * | |
| 1073 | + * Finds all `.lp-toggle-enable` elements and wires up toggle behavior. | |
| 1074 | + * Reads initial state from `data-enabled` attribute ("true"/"false"). | |
| 1075 | + * Calls `data-on-toggle` callback (if provided via options) on state change. | |
| 1076 | + * | |
| 1077 | + * HTML structure: | |
| 1078 | + * <label class="lp-toggle-enable" data-enabled="true"> | |
| 1079 | + * <input type="checkbox" class="lp-toggle-enable__input" /> | |
| 1080 | + * <span class="lp-toggle-enable__track"></span> | |
| 1081 | + * </label> | |
| 1082 | + * | |
| 1083 | + * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable') | |
| 1084 | + * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change | |
| 1085 | + * @since 4.4.5 | |
| 1086 | + * @version 1.0.0 | |
| 1087 | + */ | |
| 1088 | +window.lpToggleEnableInit = 0; | |
| 1089 | +const toggleEnable = (onToggle = null) => { | |
| 1090 | + if (window.lpToggleEnableInit) { | |
| 1091 | + return; | |
| 1092 | + } | |
| 1093 | + window.lpToggleEnableInit = 1; | |
| 1094 | + const selector = '.lp-toggle-enable'; | |
| 1095 | + const updateUI = (toggle, isEnabled) => { | |
| 1096 | + toggle.classList.toggle('is-enabled', isEnabled); | |
| 1097 | + const input = toggle.querySelector('.lp-toggle-enable__input'); | |
| 1098 | + if (input) { | |
| 1099 | + input.checked = isEnabled; | |
| 1100 | + input.value = isEnabled ? '1' : '0'; | |
| 1101 | + } | |
| 1102 | + }; | |
| 1103 | + | |
| 1104 | + // Delegate click handling via eventHandlers. | |
| 1105 | + eventHandlers('click', [{ | |
| 1106 | + selector, | |
| 1107 | + callBack: args => { | |
| 1108 | + const { | |
| 1109 | + e, | |
| 1110 | + target | |
| 1111 | + } = args; | |
| 1112 | + const toggle = target.closest(selector); | |
| 1113 | + if (!toggle || toggle.classList.contains('is-disabled')) { | |
| 1114 | + return; | |
| 1115 | + } | |
| 1116 | + e.preventDefault(); | |
| 1117 | + const isEnabled = !toggle.classList.contains('is-enabled'); | |
| 1118 | + updateUI(toggle, isEnabled); | |
| 1119 | + if ('function' === typeof onToggle) { | |
| 1120 | + onToggle(toggle, isEnabled); | |
| 1121 | + } | |
| 1122 | + } | |
| 1123 | + }]); | |
| 1124 | +}; | |
| 1125 | + | |
| 1126 | +/** | |
| 1127 | + * Initialize custom fullscreen view buttons. | |
| 1128 | + * | |
| 1129 | + * Delegates clicks on `.lp-btn-full-screen-view` buttons to | |
| 1130 | + * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the | |
| 1131 | + * target element. Falls back to the button's parent element when | |
| 1132 | + * `data-target` is not provided. | |
| 1133 | + * | |
| 1134 | + * @since 4.4.5 | |
| 1135 | + * @version 1.0.0 | |
| 1136 | + */ | |
| 1137 | +window.lpFullScreenViewInit = 0; | |
| 1138 | +const fullScreenView = () => { | |
| 1139 | + if (window.lpFullScreenViewInit) { | |
| 1140 | + return; | |
| 1141 | + } | |
| 1142 | + window.lpFullScreenViewInit = 1; | |
| 1143 | + let lastScrollY = 0; | |
| 1144 | + const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => { | |
| 1145 | + const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen); | |
| 1146 | + if (isFullscreen) { | |
| 1147 | + elTarget.classList.remove(lpClassName.elFullScreen); | |
| 1148 | + document.documentElement.classList.remove('lp-full-screen-active'); | |
| 1149 | + window.scrollTo(0, lastScrollY); | |
| 1150 | + } else { | |
| 1151 | + lastScrollY = window.scrollY; | |
| 1152 | + elTarget.classList.add(lpClassName.elFullScreen); | |
| 1153 | + document.documentElement.classList.add('lp-full-screen-active'); | |
| 1154 | + } | |
| 1155 | + if (!isFullscreen) { | |
| 1156 | + if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) { | |
| 1157 | + const closeButton = document.createElement('button'); | |
| 1158 | + closeButton.type = 'button'; | |
| 1159 | + closeButton.className = lpClassName.elBtnFullScreenClose; | |
| 1160 | + closeButton.setAttribute('aria-label', 'Close'); | |
| 1161 | + closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close ×'; | |
| 1162 | + closeButton.addEventListener('click', e => { | |
| 1163 | + e.preventDefault(); | |
| 1164 | + lpToggleFullscreenView(elTarget); | |
| 1165 | + }); | |
| 1166 | + elTarget.appendChild(closeButton); | |
| 1167 | + } | |
| 1168 | + } else { | |
| 1169 | + const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`); | |
| 1170 | + if (closeButton) { | |
| 1171 | + closeButton.remove(); | |
| 1172 | + } | |
| 1173 | + } | |
| 1174 | + }; | |
| 1175 | + eventHandlers('click', [{ | |
| 1176 | + selector: lpClassName.elBtnFullScreen, | |
| 1177 | + callBack: args => { | |
| 1178 | + const { | |
| 1179 | + e, | |
| 1180 | + target | |
| 1181 | + } = args; | |
| 1182 | + const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen); | |
| 1183 | + if (!elBtnFullScreen) { | |
| 1184 | + console.log('No full screen button found'); | |
| 1185 | + return; | |
| 1186 | + } | |
| 1187 | + e.preventDefault(); | |
| 1188 | + let elTarget = null; | |
| 1189 | + const targetSelector = elBtnFullScreen.dataset.targetFullscreen; | |
| 1190 | + console.log(targetSelector); | |
| 1191 | + if (targetSelector) { | |
| 1192 | + elTarget = document.querySelector(targetSelector); | |
| 1193 | + } | |
| 1194 | + if (!elTarget) { | |
| 1195 | + console.log('No target element found'); | |
| 1196 | + return; | |
| 1197 | + } | |
| 1198 | + lpToggleFullscreenView(elTarget, elBtnFullScreen); | |
| 1199 | + } | |
| 1200 | + }]); | |
| 1064 | 1201 | }; |
| 1065 | 1202 | |
| 1066 | 1203 | /***/ }, |
| 1067 | 1204 | |