| @@ -204,28 +204,12 @@ | ||
| 204 | 204 | this.reInitTinymce(idTextarea); |
| 205 | 205 | }); |
| 206 | 206 | } |
| 207 | 207 | reInitTinymce(id) { |
| 208 | - if (!window.tinymce || !id) { | |
| 209 | - return; | |
| 210 | - } | |
| 211 | - const elTextarea = document.getElementById(id); | |
| 212 | - if (!elTextarea) { | |
| 213 | - return; | |
| 214 | - } | |
| 215 | - this.reInitQuicktags(id); | |
| 216 | - const editor = window.tinymce.get(id); | |
| 217 | - const editorContainer = editor?.getContainer?.(); | |
| 218 | - const isEditorAttached = editor && (editor.targetElm === elTextarea || editor.getElement?.() === elTextarea || editorContainer?.contains(elTextarea)); | |
| 219 | - if (isEditorAttached) { | |
| 220 | - this.setDefaultEditorTab(id); | |
| 221 | - return; | |
| 222 | - } | |
| 223 | 208 | window.tinymce.execCommand('mceRemoveEditor', true, id); |
| 224 | 209 | window.tinymce.execCommand('mceAddEditor', true, id); |
| 225 | - this.setDefaultEditorTab(id); | |
| 226 | 210 | } |
| 227 | - reInitQuicktags(id) { | |
| 211 | + reInitQuickTags(id) { | |
| 228 | 212 | const toolbar = document.getElementById(`qt_${id}_toolbar`); |
| 229 | 213 | if (!toolbar || toolbar.children.length || !window.quicktags) { |
| 230 | 214 | return; |
| 231 | 215 | } |
| @@ -243,8 +227,12 @@ | ||
| 243 | 227 | return; |
| 244 | 228 | } |
| 245 | 229 | if (wrapEditor.classList.contains('html-active') && window.switchEditors?.go) { |
| 246 | 230 | window.switchEditors.go(id, 'tmce'); |
| 231 | + const elTextarea = document.getElementById(id); | |
| 232 | + if (elTextarea) { | |
| 233 | + elTextarea.style.visibility = ''; | |
| 234 | + } | |
| 247 | 235 | } |
| 248 | 236 | wrapEditor.classList.add('tmce-active'); |
| 249 | 237 | wrapEditor.classList.remove('html-active'); |
| 250 | 238 | const visualTab = document.getElementById(`${id}-tmce`); |
| @@ -263,9 +251,8 @@ | ||
| 263 | 251 | } |
| 264 | 252 | if (id === 'content') { |
| 265 | 253 | return; |
| 266 | 254 | } |
| 267 | - this.setDefaultEditorTab(id); | |
| 268 | 255 | const elTextarea = document.getElementById(id); |
| 269 | 256 | if (!elTextarea) { |
| 270 | 257 | return; |
| 271 | 258 | } |
| @@ -286,8 +273,11 @@ | ||
| 286 | 273 | editor.settings.convert_urls = true; |
| 287 | 274 | editor.settings.document_base_url = lpData.site_url; |
| 288 | 275 | // End config use absolute url |
| 289 | 276 | |
| 277 | + // Add quick tags | |
| 278 | + this.reInitQuickTags(id); | |
| 279 | + | |
| 290 | 280 | // Events focus in TinyMCE editor |
| 291 | 281 | editor.on('change keyup', e => { |
| 292 | 282 | // Auto save if it has class lp-auto-save |
| 293 | 283 | elTextarea.value = editor.getContent(); |
| @@ -309,9 +299,12 @@ | ||
| 309 | 299 | .${EditQuestion.selectors.elQuestionFibInput} { |
| 310 | 300 | border: 1px dashed rebeccapurple; |
| 311 | 301 | padding: 5px; |
| 312 | 302 | } |
| 313 | - `); | |
| 303 | + `); | |
| 304 | + | |
| 305 | + // Set default tab visual | |
| 306 | + this.setDefaultEditorTab(id); | |
| 314 | 307 | }); |
| 315 | 308 | editor.on('setcontent', e => { |
| 316 | 309 | const uniquid = this.randomString(); |
| 317 | 310 | const elementg = editor.dom.select(`.${EditQuestion.selectors.elQuestionFibInput}[data-id="${uniquid}"]`); |
| @@ -1340,9 +1333,9 @@ | ||
| 1340 | 1333 | sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({ |
| 1341 | 1334 | html: modalTemplate.innerHTML, |
| 1342 | 1335 | showConfirmButton: false, |
| 1343 | 1336 | showCloseButton: true, |
| 1344 | - width: '60%', | |
| 1337 | + width: 'max(350px, 65vw)', | |
| 1345 | 1338 | customClass: { |
| 1346 | 1339 | popup: 'lp-select-items-popup', |
| 1347 | 1340 | htmlContainer: 'lp-select-items-html-container', |
| 1348 | 1341 | container: 'lp-select-items-container' |
| @@ -1349,25 +1342,33 @@ | ||
| 1349 | 1342 | }, |
| 1350 | 1343 | willOpen: () => { |
| 1351 | 1344 | elPopup = sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().getPopup(); |
| 1352 | 1345 | const elLPTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`); |
| 1353 | - if (elLPTarget) { | |
| 1354 | - const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget); | |
| 1355 | - dataSend.args.paged = 1; | |
| 1356 | - dataSend.args.item_selecting = itemsSelectedData || []; | |
| 1357 | - window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend); | |
| 1358 | - window.lpAJAXG.fetchAJAX(dataSend, { | |
| 1359 | - success: response => { | |
| 1360 | - const { | |
| 1361 | - data | |
| 1362 | - } = response; | |
| 1363 | - const elSkeleton = elPopup.querySelector('.lp-skeleton-animation'); | |
| 1364 | - elSkeleton.remove(); | |
| 1365 | - elLPTarget.innerHTML = data.content || ''; | |
| 1366 | - this.watchItemsSelectedDataChange(); | |
| 1367 | - } | |
| 1368 | - }); | |
| 1369 | - } | |
| 1346 | + | |
| 1347 | + // Avoid duplicate AJAX: loadAJAX.js handles fresh elements; skip if already loaded. Set timeout to ensure DOM is ready handle. | |
| 1348 | + setTimeout(() => { | |
| 1349 | + const elLoadAjaxElement = elLPTarget.closest('.lp-load-ajax-element:not(.loaded)'); | |
| 1350 | + if (!elLoadAjaxElement) { | |
| 1351 | + return; | |
| 1352 | + } | |
| 1353 | + if (elLPTarget) { | |
| 1354 | + const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget); | |
| 1355 | + dataSend.args.paged = 1; | |
| 1356 | + dataSend.args.item_selecting = itemsSelectedData || []; | |
| 1357 | + window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend); | |
| 1358 | + window.lpAJAXG.fetchAJAX(dataSend, { | |
| 1359 | + success: response => { | |
| 1360 | + const { | |
| 1361 | + data | |
| 1362 | + } = response; | |
| 1363 | + const elSkeleton = elPopup.querySelector('.lp-skeleton-animation'); | |
| 1364 | + elSkeleton.remove(); | |
| 1365 | + elLPTarget.innerHTML = data.content || ''; | |
| 1366 | + this.watchItemsSelectedDataChange(); | |
| 1367 | + } | |
| 1368 | + }); | |
| 1369 | + } | |
| 1370 | + }, 1); | |
| 1370 | 1371 | } |
| 1371 | 1372 | }).then(result => { |
| 1372 | 1373 | if (result.isDismissed) {} |
| 1373 | 1374 | }); |
| @@ -1703,8 +1704,9 @@ | ||
| 1703 | 1704 | __webpack_require__.r(__webpack_exports__); |
| 1704 | 1705 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 1705 | 1706 | /* harmony export */ debounce: () => (/* binding */ debounce), |
| 1706 | 1707 | /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers), |
| 1708 | +/* harmony export */ fullScreenView: () => (/* binding */ fullScreenView), | |
| 1707 | 1709 | /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm), |
| 1708 | 1710 | /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm), |
| 1709 | 1711 | /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated), |
| 1710 | 1712 | /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed), |
| @@ -1716,9 +1718,10 @@ | ||
| 1716 | 1718 | /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady), |
| 1717 | 1719 | /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl), |
| 1718 | 1720 | /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl), |
| 1719 | 1721 | /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm), |
| 1720 | -/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse) | |
| 1722 | +/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse), | |
| 1723 | +/* harmony export */ toggleEnable: () => (/* binding */ toggleEnable) | |
| 1721 | 1724 | /* harmony export */ }); |
| 1722 | 1725 | /** |
| 1723 | 1726 | * Utils functions |
| 1724 | 1727 | * |
| @@ -1725,9 +1728,9 @@ | ||
| 1725 | 1728 | * @param url |
| 1726 | 1729 | * @param data |
| 1727 | 1730 | * @param functions |
| 1728 | 1731 | * @since 4.2.5.1 |
| 1729 | - * @version 1.0.6 | |
| 1732 | + * @version 1.0.7 | |
| 1730 | 1733 | */ |
| 1731 | 1734 | const lpClassName = { |
| 1732 | 1735 | hidden: 'lp-hidden', |
| 1733 | 1736 | loading: 'loading', |
| @@ -1732,9 +1735,12 @@ | ||
| 1732 | 1735 | hidden: 'lp-hidden', |
| 1733 | 1736 | loading: 'loading', |
| 1734 | 1737 | elCollapse: 'lp-collapse', |
| 1735 | 1738 | elSectionToggle: '.lp-section-toggle', |
| 1736 | - elTriggerToggle: '.lp-trigger-toggle' | |
| 1739 | + elTriggerToggle: '.lp-trigger-toggle', | |
| 1740 | + elBtnFullScreen: '.lp-btn-full-screen-view', | |
| 1741 | + elFullScreen: 'lp-full-screen-view', | |
| 1742 | + elBtnFullScreenClose: 'lp-full-screen-view__close' | |
| 1737 | 1743 | }; |
| 1738 | 1744 | const lpFetchAPI = (url, data = {}, functions = {}) => { |
| 1739 | 1745 | if ('function' === typeof functions.before) { |
| 1740 | 1746 | functions.before(); |
| @@ -2050,8 +2056,141 @@ | ||
| 2050 | 2056 | return args => { |
| 2051 | 2057 | clearTimeout(timer); |
| 2052 | 2058 | timer = setTimeout(() => func(args), wait); |
| 2053 | 2059 | }; |
| 2060 | +}; | |
| 2061 | + | |
| 2062 | +/** | |
| 2063 | + * Initialize lp-toggle-enable components. | |
| 2064 | + * | |
| 2065 | + * Finds all `.lp-toggle-enable` elements and wires up toggle behavior. | |
| 2066 | + * Reads initial state from `data-enabled` attribute ("true"/"false"). | |
| 2067 | + * Calls `data-on-toggle` callback (if provided via options) on state change. | |
| 2068 | + * | |
| 2069 | + * HTML structure: | |
| 2070 | + * <label class="lp-toggle-enable" data-enabled="true"> | |
| 2071 | + * <input type="checkbox" class="lp-toggle-enable__input" /> | |
| 2072 | + * <span class="lp-toggle-enable__track"></span> | |
| 2073 | + * </label> | |
| 2074 | + * | |
| 2075 | + * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable') | |
| 2076 | + * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change | |
| 2077 | + * @since 4.4.5 | |
| 2078 | + * @version 1.0.0 | |
| 2079 | + */ | |
| 2080 | +window.lpToggleEnableInit = 0; | |
| 2081 | +const toggleEnable = (onToggle = null) => { | |
| 2082 | + if (window.lpToggleEnableInit) { | |
| 2083 | + return; | |
| 2084 | + } | |
| 2085 | + window.lpToggleEnableInit = 1; | |
| 2086 | + const selector = '.lp-toggle-enable'; | |
| 2087 | + const updateUI = (toggle, isEnabled) => { | |
| 2088 | + toggle.classList.toggle('is-enabled', isEnabled); | |
| 2089 | + const input = toggle.querySelector('.lp-toggle-enable__input'); | |
| 2090 | + if (input) { | |
| 2091 | + input.checked = isEnabled; | |
| 2092 | + input.value = isEnabled ? '1' : '0'; | |
| 2093 | + } | |
| 2094 | + }; | |
| 2095 | + | |
| 2096 | + // Delegate click handling via eventHandlers. | |
| 2097 | + eventHandlers('click', [{ | |
| 2098 | + selector, | |
| 2099 | + callBack: args => { | |
| 2100 | + const { | |
| 2101 | + e, | |
| 2102 | + target | |
| 2103 | + } = args; | |
| 2104 | + const toggle = target.closest(selector); | |
| 2105 | + if (!toggle || toggle.classList.contains('is-disabled')) { | |
| 2106 | + return; | |
| 2107 | + } | |
| 2108 | + e.preventDefault(); | |
| 2109 | + const isEnabled = !toggle.classList.contains('is-enabled'); | |
| 2110 | + updateUI(toggle, isEnabled); | |
| 2111 | + if ('function' === typeof onToggle) { | |
| 2112 | + onToggle(toggle, isEnabled); | |
| 2113 | + } | |
| 2114 | + } | |
| 2115 | + }]); | |
| 2116 | +}; | |
| 2117 | + | |
| 2118 | +/** | |
| 2119 | + * Initialize custom fullscreen view buttons. | |
| 2120 | + * | |
| 2121 | + * Delegates clicks on `.lp-btn-full-screen-view` buttons to | |
| 2122 | + * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the | |
| 2123 | + * target element. Falls back to the button's parent element when | |
| 2124 | + * `data-target` is not provided. | |
| 2125 | + * | |
| 2126 | + * @since 4.4.5 | |
| 2127 | + * @version 1.0.0 | |
| 2128 | + */ | |
| 2129 | +window.lpFullScreenViewInit = 0; | |
| 2130 | +const fullScreenView = () => { | |
| 2131 | + if (window.lpFullScreenViewInit) { | |
| 2132 | + return; | |
| 2133 | + } | |
| 2134 | + window.lpFullScreenViewInit = 1; | |
| 2135 | + let lastScrollY = 0; | |
| 2136 | + const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => { | |
| 2137 | + const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen); | |
| 2138 | + if (isFullscreen) { | |
| 2139 | + elTarget.classList.remove(lpClassName.elFullScreen); | |
| 2140 | + document.documentElement.classList.remove('lp-full-screen-active'); | |
| 2141 | + window.scrollTo(0, lastScrollY); | |
| 2142 | + } else { | |
| 2143 | + lastScrollY = window.scrollY; | |
| 2144 | + elTarget.classList.add(lpClassName.elFullScreen); | |
| 2145 | + document.documentElement.classList.add('lp-full-screen-active'); | |
| 2146 | + } | |
| 2147 | + if (!isFullscreen) { | |
| 2148 | + if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) { | |
| 2149 | + const closeButton = document.createElement('button'); | |
| 2150 | + closeButton.type = 'button'; | |
| 2151 | + closeButton.className = lpClassName.elBtnFullScreenClose; | |
| 2152 | + closeButton.setAttribute('aria-label', 'Close'); | |
| 2153 | + closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close ×'; | |
| 2154 | + closeButton.addEventListener('click', e => { | |
| 2155 | + e.preventDefault(); | |
| 2156 | + lpToggleFullscreenView(elTarget); | |
| 2157 | + }); | |
| 2158 | + elTarget.appendChild(closeButton); | |
| 2159 | + } | |
| 2160 | + } else { | |
| 2161 | + const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`); | |
| 2162 | + if (closeButton) { | |
| 2163 | + closeButton.remove(); | |
| 2164 | + } | |
| 2165 | + } | |
| 2166 | + }; | |
| 2167 | + eventHandlers('click', [{ | |
| 2168 | + selector: lpClassName.elBtnFullScreen, | |
| 2169 | + callBack: args => { | |
| 2170 | + const { | |
| 2171 | + e, | |
| 2172 | + target | |
| 2173 | + } = args; | |
| 2174 | + const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen); | |
| 2175 | + if (!elBtnFullScreen) { | |
| 2176 | + console.log('No full screen button found'); | |
| 2177 | + return; | |
| 2178 | + } | |
| 2179 | + e.preventDefault(); | |
| 2180 | + let elTarget = null; | |
| 2181 | + const targetSelector = elBtnFullScreen.dataset.targetFullscreen; | |
| 2182 | + console.log(targetSelector); | |
| 2183 | + if (targetSelector) { | |
| 2184 | + elTarget = document.querySelector(targetSelector); | |
| 2185 | + } | |
| 2186 | + if (!elTarget) { | |
| 2187 | + console.log('No target element found'); | |
| 2188 | + return; | |
| 2189 | + } | |
| 2190 | + lpToggleFullscreenView(elTarget, elBtnFullScreen); | |
| 2191 | + } | |
| 2192 | + }]); | |
| 2054 | 2193 | }; |
| 2055 | 2194 | |
| 2056 | 2195 | /***/ }, |
| 2057 | 2196 | |