| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | /******/ (() => { // webpackBootstrap |
| 2 | 2 | /******/ "use strict"; |
| 3 | 3 | /******/ var __webpack_modules__ = ({ |
| 4 | 4 | |
| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | __webpack_require__.r(__webpack_exports__); |
| 12 | 12 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 13 | 13 | /* harmony export */ debounce: () => (/* binding */ debounce), |
| 14 | 14 | /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers), |
| 15 | +/* harmony export */ fullScreenView: () => (/* binding */ fullScreenView), | |
| 15 | 16 | /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm), |
| 16 | 17 | /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm), |
| 17 | 18 | /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated), |
| 18 | 19 | /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed), |
| @@ -24,18 +25,19 @@ | ||
| 24 | 25 | /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady), |
| 25 | 26 | /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl), |
| 26 | 27 | /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl), |
| 27 | 28 | /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm), |
| 28 | -/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse) | |
| 29 | +/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse), | |
| 30 | +/* harmony export */ toggleEnable: () => (/* binding */ toggleEnable) | |
| 29 | 31 | /* harmony export */ }); |
| 30 | -/** | |
| 31 | - * Utils functions | |
| 32 | - * | |
| 33 | - * @param url | |
| 34 | - * @param data | |
| 35 | - * @param functions | |
| 36 | - * @since 4.2.5.1 | |
| 37 | - * @version 1.0.6 | |
| 32 | +/** | |
| 33 | + * Utils functions | |
| 34 | + * | |
| 35 | + * @param url | |
| 36 | + * @param data | |
| 37 | + * @param functions | |
| 38 | + * @since 4.2.5.1 | |
| 39 | + * @version 1.0.7 | |
| 38 | 40 | */ |
| 39 | 41 | const lpClassName = { |
| 40 | 42 | hidden: 'lp-hidden', |
| 41 | 43 | loading: 'loading', |
| @@ -40,9 +42,12 @@ | ||
| 40 | 42 | hidden: 'lp-hidden', |
| 41 | 43 | loading: 'loading', |
| 42 | 44 | elCollapse: 'lp-collapse', |
| 43 | 45 | elSectionToggle: '.lp-section-toggle', |
| 44 | - elTriggerToggle: '.lp-trigger-toggle' | |
| 46 | + elTriggerToggle: '.lp-trigger-toggle', | |
| 47 | + elBtnFullScreen: '.lp-btn-full-screen-view', | |
| 48 | + elFullScreen: 'lp-full-screen-view', | |
| 49 | + elBtnFullScreenClose: 'lp-full-screen-view__close' | |
| 45 | 50 | }; |
| 46 | 51 | const lpFetchAPI = (url, data = {}, functions = {}) => { |
| 47 | 52 | if ('function' === typeof functions.before) { |
| 48 | 53 | functions.before(); |
| @@ -64,12 +69,12 @@ | ||
| 64 | 69 | } |
| 65 | 70 | }); |
| 66 | 71 | }; |
| 67 | 72 | |
| 68 | -/** | |
| 69 | - * Get current URL without params. | |
| 70 | - * | |
| 71 | - * @since 4.2.5.1 | |
| 73 | +/** | |
| 74 | + * Get current URL without params. | |
| 75 | + * | |
| 76 | + * @since 4.2.5.1 | |
| 72 | 77 | */ |
| 73 | 78 | const lpGetCurrentURLNoParam = () => { |
| 74 | 79 | let currentUrl = window.location.href; |
| 75 | 80 | const hasParams = currentUrl.includes('?'); |
| @@ -85,14 +90,14 @@ | ||
| 85 | 90 | }); |
| 86 | 91 | return url; |
| 87 | 92 | }; |
| 88 | 93 | |
| 89 | -/** | |
| 90 | - * Listen element viewed. | |
| 91 | - * | |
| 92 | - * @param el | |
| 93 | - * @param callback | |
| 94 | - * @since 4.2.5.8 | |
| 94 | +/** | |
| 95 | + * Listen element viewed. | |
| 96 | + * | |
| 97 | + * @param el | |
| 98 | + * @param callback | |
| 99 | + * @since 4.2.5.8 | |
| 95 | 100 | */ |
| 96 | 101 | const listenElementViewed = (el, callback) => { |
| 97 | 102 | const observerSeeItem = new IntersectionObserver(function (entries) { |
| 98 | 103 | for (const entry of entries) { |
| @@ -103,13 +108,13 @@ | ||
| 103 | 108 | }); |
| 104 | 109 | observerSeeItem.observe(el); |
| 105 | 110 | }; |
| 106 | 111 | |
| 107 | -/** | |
| 108 | - * Listen element created. | |
| 109 | - * | |
| 110 | - * @param callback | |
| 111 | - * @since 4.2.5.8 | |
| 112 | +/** | |
| 113 | + * Listen element created. | |
| 114 | + * | |
| 115 | + * @param callback | |
| 116 | + * @since 4.2.5.8 | |
| 112 | 117 | */ |
| 113 | 118 | const listenElementCreated = callback => { |
| 114 | 119 | const observerCreateItem = new MutationObserver(function (mutations) { |
| 115 | 120 | mutations.forEach(function (mutation) { |
| @@ -128,14 +133,14 @@ | ||
| 128 | 133 | }); |
| 129 | 134 | // End. |
| 130 | 135 | }; |
| 131 | 136 | |
| 132 | -/** | |
| 133 | - * Listen element created. | |
| 134 | - * | |
| 135 | - * @param selector | |
| 136 | - * @param callback | |
| 137 | - * @since 4.2.7.1 | |
| 137 | +/** | |
| 138 | + * Listen element created. | |
| 139 | + * | |
| 140 | + * @param selector | |
| 141 | + * @param callback | |
| 142 | + * @since 4.2.7.1 | |
| 138 | 143 | */ |
| 139 | 144 | const lpOnElementReady = (selector, callback) => { |
| 140 | 145 | const element = document.querySelector(selector); |
| 141 | 146 | if (element) { |
| @@ -276,17 +281,17 @@ | ||
| 276 | 281 | }; |
| 277 | 282 | return dataHandle; |
| 278 | 283 | }; |
| 279 | 284 | |
| 280 | -/** | |
| 281 | - * Event trigger | |
| 282 | - * For each list of event handlers, listen event on document. | |
| 283 | - * | |
| 284 | - * eventName: 'click', 'change', ... | |
| 285 | - * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ] | |
| 286 | - * | |
| 287 | - * @param eventName | |
| 288 | - * @param eventHandlers | |
| 285 | +/** | |
| 286 | + * Event trigger | |
| 287 | + * For each list of event handlers, listen event on document. | |
| 288 | + * | |
| 289 | + * eventName: 'click', 'change', ... | |
| 290 | + * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ] | |
| 291 | + * | |
| 292 | + * @param eventName | |
| 293 | + * @param eventHandlers | |
| 289 | 294 | */ |
| 290 | 295 | const eventHandlers = (eventName, eventHandlers) => { |
| 291 | 296 | document.addEventListener(eventName, e => { |
| 292 | 297 | const target = e.target; |
| @@ -327,32 +332,32 @@ | ||
| 327 | 332 | }); |
| 328 | 333 | }); |
| 329 | 334 | }; |
| 330 | 335 | |
| 331 | -/** | |
| 332 | - * Debounce - delays function execution until after `wait` ms of inactivity. | |
| 333 | - * | |
| 334 | - * Each call resets the timer. Only the last call in a burst executes. | |
| 335 | - * | |
| 336 | - * USE CASES: | |
| 337 | - * - Search inputs, form validation, window resize | |
| 338 | - * - Multiple elements need independent timers | |
| 339 | - * - When you need to call with different arguments | |
| 340 | - * | |
| 341 | - * EXAMPLES: | |
| 342 | - * const debouncedSearch = debounce( (query) => fetchResults(query), 300 ); | |
| 343 | - * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value)); | |
| 344 | - * | |
| 345 | - * const debouncedResize = debounce( recalculateLayout, 250 ); | |
| 346 | - * window.addEventListener('resize', debouncedResize); | |
| 347 | - * | |
| 348 | - * ⚠️ Create ONCE outside event handlers, not inside. | |
| 349 | - * | |
| 350 | - * @param {Function} func - Function to debounce (can be anonymous) | |
| 351 | - * @param {number} wait - Milliseconds to wait (default: 500) | |
| 352 | - * @return {Function} Debounced wrapper function | |
| 353 | - * @since 4.3.7 | |
| 354 | - * @version 1.0.0 | |
| 336 | +/** | |
| 337 | + * Debounce - delays function execution until after `wait` ms of inactivity. | |
| 338 | + * | |
| 339 | + * Each call resets the timer. Only the last call in a burst executes. | |
| 340 | + * | |
| 341 | + * USE CASES: | |
| 342 | + * - Search inputs, form validation, window resize | |
| 343 | + * - Multiple elements need independent timers | |
| 344 | + * - When you need to call with different arguments | |
| 345 | + * | |
| 346 | + * EXAMPLES: | |
| 347 | + * const debouncedSearch = debounce( (query) => fetchResults(query), 300 ); | |
| 348 | + * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value)); | |
| 349 | + * | |
| 350 | + * const debouncedResize = debounce( recalculateLayout, 250 ); | |
| 351 | + * window.addEventListener('resize', debouncedResize); | |
| 352 | + * | |
| 353 | + * ⚠️ Create ONCE outside event handlers, not inside. | |
| 354 | + * | |
| 355 | + * @param {Function} func - Function to debounce (can be anonymous) | |
| 356 | + * @param {number} wait - Milliseconds to wait (default: 500) | |
| 357 | + * @return {Function} Debounced wrapper function | |
| 358 | + * @since 4.3.7 | |
| 359 | + * @version 1.0.0 | |
| 355 | 360 | */ |
| 356 | 361 | const debounce = (func, wait = 500) => { |
| 357 | 362 | let timer; |
| 358 | 363 | return args => { |
| @@ -360,8 +365,141 @@ | ||
| 360 | 365 | timer = setTimeout(() => func(args), wait); |
| 361 | 366 | }; |
| 362 | 367 | }; |
| 363 | 368 | |
| 369 | +/** | |
| 370 | + * Initialize lp-toggle-enable components. | |
| 371 | + * | |
| 372 | + * Finds all `.lp-toggle-enable` elements and wires up toggle behavior. | |
| 373 | + * Reads initial state from `data-enabled` attribute ("true"/"false"). | |
| 374 | + * Calls `data-on-toggle` callback (if provided via options) on state change. | |
| 375 | + * | |
| 376 | + * HTML structure: | |
| 377 | + * <label class="lp-toggle-enable" data-enabled="true"> | |
| 378 | + * <input type="checkbox" class="lp-toggle-enable__input" /> | |
| 379 | + * <span class="lp-toggle-enable__track"></span> | |
| 380 | + * </label> | |
| 381 | + * | |
| 382 | + * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable') | |
| 383 | + * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change | |
| 384 | + * @since 4.4.5 | |
| 385 | + * @version 1.0.0 | |
| 386 | + */ | |
| 387 | +window.lpToggleEnableInit = 0; | |
| 388 | +const toggleEnable = (onToggle = null) => { | |
| 389 | + if (window.lpToggleEnableInit) { | |
| 390 | + return; | |
| 391 | + } | |
| 392 | + window.lpToggleEnableInit = 1; | |
| 393 | + const selector = '.lp-toggle-enable'; | |
| 394 | + const updateUI = (toggle, isEnabled) => { | |
| 395 | + toggle.classList.toggle('is-enabled', isEnabled); | |
| 396 | + const input = toggle.querySelector('.lp-toggle-enable__input'); | |
| 397 | + if (input) { | |
| 398 | + input.checked = isEnabled; | |
| 399 | + input.value = isEnabled ? '1' : '0'; | |
| 400 | + } | |
| 401 | + }; | |
| 402 | + | |
| 403 | + // Delegate click handling via eventHandlers. | |
| 404 | + eventHandlers('click', [{ | |
| 405 | + selector, | |
| 406 | + callBack: args => { | |
| 407 | + const { | |
| 408 | + e, | |
| 409 | + target | |
| 410 | + } = args; | |
| 411 | + const toggle = target.closest(selector); | |
| 412 | + if (!toggle || toggle.classList.contains('is-disabled')) { | |
| 413 | + return; | |
| 414 | + } | |
| 415 | + e.preventDefault(); | |
| 416 | + const isEnabled = !toggle.classList.contains('is-enabled'); | |
| 417 | + updateUI(toggle, isEnabled); | |
| 418 | + if ('function' === typeof onToggle) { | |
| 419 | + onToggle(toggle, isEnabled); | |
| 420 | + } | |
| 421 | + } | |
| 422 | + }]); | |
| 423 | +}; | |
| 424 | + | |
| 425 | +/** | |
| 426 | + * Initialize custom fullscreen view buttons. | |
| 427 | + * | |
| 428 | + * Delegates clicks on `.lp-btn-full-screen-view` buttons to | |
| 429 | + * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the | |
| 430 | + * target element. Falls back to the button's parent element when | |
| 431 | + * `data-target` is not provided. | |
| 432 | + * | |
| 433 | + * @since 4.4.5 | |
| 434 | + * @version 1.0.0 | |
| 435 | + */ | |
| 436 | +window.lpFullScreenViewInit = 0; | |
| 437 | +const fullScreenView = () => { | |
| 438 | + if (window.lpFullScreenViewInit) { | |
| 439 | + return; | |
| 440 | + } | |
| 441 | + window.lpFullScreenViewInit = 1; | |
| 442 | + let lastScrollY = 0; | |
| 443 | + const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => { | |
| 444 | + const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen); | |
| 445 | + if (isFullscreen) { | |
| 446 | + elTarget.classList.remove(lpClassName.elFullScreen); | |
| 447 | + document.documentElement.classList.remove('lp-full-screen-active'); | |
| 448 | + window.scrollTo(0, lastScrollY); | |
| 449 | + } else { | |
| 450 | + lastScrollY = window.scrollY; | |
| 451 | + elTarget.classList.add(lpClassName.elFullScreen); | |
| 452 | + document.documentElement.classList.add('lp-full-screen-active'); | |
| 453 | + } | |
| 454 | + if (!isFullscreen) { | |
| 455 | + if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) { | |
| 456 | + const closeButton = document.createElement('button'); | |
| 457 | + closeButton.type = 'button'; | |
| 458 | + closeButton.className = lpClassName.elBtnFullScreenClose; | |
| 459 | + closeButton.setAttribute('aria-label', 'Close'); | |
| 460 | + closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close ×'; | |
| 461 | + closeButton.addEventListener('click', e => { | |
| 462 | + e.preventDefault(); | |
| 463 | + lpToggleFullscreenView(elTarget); | |
| 464 | + }); | |
| 465 | + elTarget.appendChild(closeButton); | |
| 466 | + } | |
| 467 | + } else { | |
| 468 | + const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`); | |
| 469 | + if (closeButton) { | |
| 470 | + closeButton.remove(); | |
| 471 | + } | |
| 472 | + } | |
| 473 | + }; | |
| 474 | + eventHandlers('click', [{ | |
| 475 | + selector: lpClassName.elBtnFullScreen, | |
| 476 | + callBack: args => { | |
| 477 | + const { | |
| 478 | + e, | |
| 479 | + target | |
| 480 | + } = args; | |
| 481 | + const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen); | |
| 482 | + if (!elBtnFullScreen) { | |
| 483 | + console.log('No full screen button found'); | |
| 484 | + return; | |
| 485 | + } | |
| 486 | + e.preventDefault(); | |
| 487 | + let elTarget = null; | |
| 488 | + const targetSelector = elBtnFullScreen.dataset.targetFullscreen; | |
| 489 | + console.log(targetSelector); | |
| 490 | + if (targetSelector) { | |
| 491 | + elTarget = document.querySelector(targetSelector); | |
| 492 | + } | |
| 493 | + if (!elTarget) { | |
| 494 | + console.log('No target element found'); | |
| 495 | + return; | |
| 496 | + } | |
| 497 | + lpToggleFullscreenView(elTarget, elBtnFullScreen); | |
| 498 | + } | |
| 499 | + }]); | |
| 500 | +}; | |
| 501 | + | |
| 364 | 502 | /***/ } |
| 365 | 503 | |
| 366 | 504 | /******/ }); |
| 367 | 505 | /************************************************************************/ |
| @@ -434,14 +572,14 @@ | ||
| 434 | 572 | __webpack_require__.r(__webpack_exports__); |
| 435 | 573 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 436 | 574 | /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) |
| 437 | 575 | /* harmony export */ }); |
| 438 | -/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./assets/src/js/utils.js"); | |
| 439 | -/** | |
| 440 | - * Load all you need via AJAX | |
| 441 | - * | |
| 442 | - * @since 4.2.5.7 | |
| 443 | - * @version 1.1.0 | |
| 576 | +/* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js"); | |
| 577 | +/** | |
| 578 | + * Load all you need via AJAX | |
| 579 | + * | |
| 580 | + * @since 4.2.5.7 | |
| 581 | + * @version 1.1.1 | |
| 444 | 582 | */ |
| 445 | 583 | |
| 446 | 584 | |
| 447 | 585 | |
| @@ -455,9 +593,9 @@ | ||
| 455 | 593 | // End Handle general parameter in the Frontend and Backend |
| 456 | 594 | |
| 457 | 595 | const lpAJAX = () => { |
| 458 | 596 | const classLPTarget = '.lp-target'; |
| 459 | - const urlCurrent = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpGetCurrentURLNoParam)(); | |
| 597 | + const urlCurrent = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpGetCurrentURLNoParam(); | |
| 460 | 598 | return { |
| 461 | 599 | autoLoadAPIs: () => { |
| 462 | 600 | console.log('autoLoadAPIs'); |
| 463 | 601 | }, |
| @@ -481,11 +619,11 @@ | ||
| 481 | 619 | option.headers['Content-Type'] = 'application/json'; |
| 482 | 620 | } else { |
| 483 | 621 | params.args = JSON.stringify(params.args); |
| 484 | 622 | params.callback = JSON.stringify(params.callback); |
| 485 | - url = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(url, params); | |
| 623 | + url = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs(url, params); | |
| 486 | 624 | } |
| 487 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI)(url, option, callBack); | |
| 625 | + lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, option, callBack); | |
| 488 | 626 | }, |
| 489 | 627 | fetchAJAX: (params, callBack) => { |
| 490 | 628 | let urlAjax = lpSettings.lpAjaxUrl; |
| 491 | 629 | |
| @@ -490,36 +628,55 @@ | ||
| 490 | 628 | let urlAjax = lpSettings.lpAjaxUrl; |
| 491 | 629 | |
| 492 | 630 | // Set param id_url for identify. |
| 493 | 631 | if (params.hasOwnProperty('args') && params.args.hasOwnProperty('id_url')) { |
| 494 | - urlAjax = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(urlAjax, { | |
| 632 | + urlAjax = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs(urlAjax, { | |
| 495 | 633 | id_url: params.args.id_url |
| 496 | 634 | }); |
| 497 | 635 | } else if (params.hasOwnProperty('id_url')) { |
| 498 | - urlAjax = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(urlAjax, { | |
| 636 | + urlAjax = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs(urlAjax, { | |
| 499 | 637 | id_url: params.id_url |
| 500 | 638 | }); |
| 501 | 639 | } |
| 502 | 640 | // Set param lang here if exits, for detect translate |
| 503 | 641 | if (lpSettings.urlParams.hasOwnProperty('lang')) { |
| 504 | - urlAjax = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(urlAjax, { | |
| 642 | + urlAjax = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs(urlAjax, { | |
| 505 | 643 | lang: lpSettings.urlParams.lang |
| 506 | 644 | }); |
| 507 | 645 | } |
| 508 | - const formData = new FormData(); | |
| 509 | 646 | const action = params.hasOwnProperty('action') ? params.action : 'load_content_via_ajax'; |
| 510 | - formData.append('nonce', lpSettings.nonce); | |
| 511 | - formData.append('lp-load-ajax', action); | |
| 512 | - formData.append('data', JSON.stringify(params)); | |
| 513 | - const dataSend = { | |
| 514 | - method: 'POST', | |
| 515 | - headers: {}, | |
| 516 | - body: formData | |
| 517 | - }; | |
| 647 | + const isGet = params.hasOwnProperty('method_request') && 'GET' === String(params.method_request).toUpperCase(); | |
| 648 | + let dataSend; | |
| 649 | + if (isGet) { | |
| 650 | + // Don't send method_request back to server; keep URL shorter. | |
| 651 | + const paramsForSend = { | |
| 652 | + ...params | |
| 653 | + }; | |
| 654 | + delete paramsForSend.method_request; | |
| 655 | + urlAjax = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs(urlAjax, { | |
| 656 | + nonce: lpSettings.nonce, | |
| 657 | + 'lp-load-ajax': action, | |
| 658 | + data: JSON.stringify(paramsForSend) | |
| 659 | + }); | |
| 660 | + dataSend = { | |
| 661 | + method: 'GET', | |
| 662 | + headers: {} | |
| 663 | + }; | |
| 664 | + } else { | |
| 665 | + const formData = new FormData(); | |
| 666 | + formData.append('nonce', lpSettings.nonce); | |
| 667 | + formData.append('lp-load-ajax', action); | |
| 668 | + formData.append('data', JSON.stringify(params)); | |
| 669 | + dataSend = { | |
| 670 | + method: 'POST', | |
| 671 | + headers: {}, | |
| 672 | + body: formData | |
| 673 | + }; | |
| 674 | + } | |
| 518 | 675 | if (0 !== parseInt(lpSettings.user_id)) { |
| 519 | 676 | dataSend.headers['X-WP-Nonce'] = lpSettings.nonce; |
| 520 | 677 | } |
| 521 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI)(urlAjax, dataSend, callBack); | |
| 678 | + lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(urlAjax, dataSend, callBack); | |
| 522 | 679 | }, |
| 523 | 680 | getElements: () => { |
| 524 | 681 | // Finds all elements with the class '.lp-load-ajax-element' |
| 525 | 682 | const elements = document.querySelectorAll('.lp-load-ajax-element:not(.loaded)'); |
| @@ -574,8 +731,13 @@ | ||
| 574 | 731 | const btnNumber = target.closest('.page-numbers:not(.disabled)'); |
| 575 | 732 | if (!btnNumber) { |
| 576 | 733 | return; |
| 577 | 734 | } |
| 735 | + | |
| 736 | + // Check btnNumber is tag a | |
| 737 | + if (btnNumber.tagName.toLowerCase() !== 'a') { | |
| 738 | + return; | |
| 739 | + } | |
| 578 | 740 | const elLPTarget = btnNumber.closest(`${classLPTarget}`); |
| 579 | 741 | if (!elLPTarget) { |
| 580 | 742 | return; |
| 581 | 743 | } |
| @@ -602,9 +764,9 @@ | ||
| 602 | 764 | |
| 603 | 765 | // Set url params to reload page. |
| 604 | 766 | if (!dataSend.args.hasOwnProperty('enableUpdateParamsUrl') || dataSend.args.enableUpdateParamsUrl) { |
| 605 | 767 | lpSettings.urlParams.paged = dataSend.args.paged; |
| 606 | - window.history.pushState({}, '', (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(urlCurrent, lpSettings.urlParams)); | |
| 768 | + window.history.pushState({}, '', lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs(urlCurrent, lpSettings.urlParams)); | |
| 607 | 769 | } |
| 608 | 770 | // End. |
| 609 | 771 | |
| 610 | 772 | // Show loading |
| @@ -646,9 +808,9 @@ | ||
| 646 | 808 | }, |
| 647 | 809 | showHideLoading: (elLPTarget, status) => { |
| 648 | 810 | const elLoading = elLPTarget.nextElementSibling?.querySelector('.lp-loading-change'); |
| 649 | 811 | if (elLoading) { |
| 650 | - (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl)(elLoading, status); | |
| 812 | + lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elLoading, status); | |
| 651 | 813 | } |
| 652 | 814 | } |
| 653 | 815 | }; |
| 654 | 816 | }; |
| @@ -661,9 +823,9 @@ | ||
| 661 | 823 | window.lpAJAXG.clickNumberPage(e, target); |
| 662 | 824 | }); |
| 663 | 825 | |
| 664 | 826 | // Listen element created |
| 665 | -(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.listenElementCreated)(node => { | |
| 827 | +lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.listenElementCreated(node => { | |
| 666 | 828 | if (node.classList.contains('lp-load-ajax-element')) { |
| 667 | 829 | //console.log( 'Element created', node ); |
| 668 | 830 | window.lpAJAXG.getElements(); |
| 669 | 831 | } |
| @@ -669,9 +831,9 @@ | ||
| 669 | 831 | } |
| 670 | 832 | }); |
| 671 | 833 | |
| 672 | 834 | // Listen element ready |
| 673 | -(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady)('.lp-load-ajax-element', element => { | |
| 835 | +lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady('.lp-load-ajax-element', element => { | |
| 674 | 836 | //console.log( 'Element ready', element ); |
| 675 | 837 | window.lpAJAXG.getElements(); |
| 676 | 838 | }); |
| 677 | 839 | |