From bdfbe4da7c320668432cdb14e111c2be4b170c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Ste=CC=A8pien=CC=81?= Date: Tue, 24 Oct 2023 00:03:48 +0200 Subject: [PATCH 1/9] Code structure refactorization part 1 --- .../core/checkout/checkoutController.js | 2 +- .../components/useCheckoutStepsController.js | 2 +- .../handler/address/changeAddressHandler.js | 4 ++-- .../handler/address/editAddressHandler.js | 0 .../address/showAddressErrorMessageHandler.js | 4 ++-- .../delivery/changeDeliveryMethodHandler.js | 5 ++-- .../delivery/editDeliveryStepHandler.js | 0 .../handler/payment/confirmOrderHandler.js | 2 +- .../payment/orderConfirmationErrorsHandler.js | 0 .../payment/toggleOrderButtonStateHandler.js | 4 ++-- .../payment/togglePaymentOptionsHandler.js | 4 ++-- .../process/checkoutFormSubmitHandler.js | 2 +- .../process/checkoutStepChangeHandler.js | 0 .../core/checkout/index.js | 2 +- .../request/checkCartStillOrderableRequest.js | 2 +- .../request/selectDeliveryMethodRequest.js | 2 +- .../checkout/utils/areConditionsAccepted.js | 2 +- .../core/checkout/utils/canProceedOrder.js | 0 .../utils/collapseAllPaymentOptions.js | 4 ++-- .../core/checkout/utils/getEditAddress.js | 0 .../utils/getSelectedPaymentOption.js | 0 .../checkout/utils/refreshCheckoutPage.js | 0 .../switchConfirmAddressesButtonState.js | 2 +- .../utils/switchEditAddressButtonColor.js | 2 +- .../toggleOrderConfirmationButtonState.js | 0 _dev/js/checkout/index.js | 9 ++++--- _dev/js/listing/components/filters/Filters.js | 2 +- .../components/filters/FiltersRangeSliders.js | 2 +- .../listing/components/filters/RangeSlider.js | 2 +- _dev/js/listing/index.js | 6 ++--- _dev/js/product/index.js | 2 +- _dev/js/theme/components/customer/index.js | 2 +- .../dynamic-bootstrap-components.js | 4 ++-- _dev/js/theme/components/header/index.js | 2 +- _dev/js/theme/components/header/useTopMenu.js | 2 +- _dev/js/theme/components/product.js | 4 +--- _dev/js/theme/components/quickview.js | 3 +-- _dev/js/theme/components/responsive.js | 2 +- _dev/js/theme/components/sliders/index.js | 2 +- _dev/js/theme/components/useAlertToast.js | 2 +- _dev/js/theme/components/usePageLoader.js | 12 +++++++--- _dev/js/theme/components/useStickyElement.js | 2 +- _dev/js/theme/components/useThemeForm.js | 2 +- .../theme/core/address/addressController.js | 2 +- .../handler/changeAddressCountryHandler.js | 2 +- _dev/js/theme/core/address/index.js | 2 +- .../address/request/updateAddressRequest.js | 8 +++---- _dev/js/theme/core/cart/cartController.js | 2 +- .../cart/handler/cart/addToCartHandler.js | 2 +- .../cart/handler/cart/updateCartHandler.js | 2 +- .../handler/voucher/submitVoucherHandler.js | 2 +- _dev/js/theme/core/cart/index.js | 2 +- .../cart/request/cart/addToCartRequest.js | 4 ++-- .../request/cart/deleteFromCartRequest.js | 4 ++-- .../request/cart/quantityChangeRequest.js | 4 ++-- .../request/cart/updateCartContentRequest.js | 2 +- .../voucher/addVoucherToCartRequest.js | 4 ++-- .../voucher/deleteVoucherFromCartRequest.js | 4 ++-- _dev/js/theme/core/index.js | 3 +-- _dev/js/theme/core/listing/index.js | 2 +- .../request/updateListingFacetsRequest.js | 6 ++--- .../updateProductDOMElementsHandler.js | 3 +-- .../handler/product/updateProductHandler.js | 2 +- _dev/js/theme/core/product/index.js | 2 +- .../persister/productFormDataPersister.js | 2 +- .../theme/core/product/productController.js | 2 +- .../request/product/updateProductRequest.js | 8 +++---- .../request/quickView/quickViewRequest.js | 4 ++-- _dev/js/theme/core/selectors.js | 2 +- .../handler/error/httpRequestErrorHandler.js | 2 +- _dev/js/theme/index.js | 4 +--- _dev/js/theme/utils/DOMReady.js | 13 ---------- _dev/js/theme/utils/parseToHtml.js | 13 ---------- .../{theme/utils => utils/DOM}/DOMHelpers.js | 24 +++++++++++++++++++ .../utils => utils/DOM}/DOMSelectorsHelper.js | 0 _dev/js/{theme => }/utils/debounce.js | 0 .../display/useToggleDisplay.js | 0 .../dynamicImports/componentProxyFactory.js | 0 .../useBootstrapComponentDynamicImport.js | 0 .../useDynamicImportEventsHandler.js | 2 +- .../dynamicImports/useFunctionCallstackMap.js | 0 .../utils/dynamicImports/useInstanceMap.js | 0 .../components => utils}/event/useEvent.js | 0 _dev/js/{theme => }/utils/formSerialize.js | 0 _dev/js/{theme => }/utils/getUniqueId.js | 0 .../http/error/GenericHttpRequestError.js | 0 .../http/useDefaultHttpRequest.js | 0 .../http/useHttpController.js | 2 +- .../http/useHttpPayloadDefinition.js | 0 .../http/useHttpRequest.js | 0 _dev/js/{theme => }/utils/sprintf.js | 0 _dev/webpack/webpack.parts.js | 5 ++++ config/assets.yml | 9 ++++--- 93 files changed, 132 insertions(+), 131 deletions(-) rename _dev/js/{theme => checkout}/core/checkout/checkoutController.js (97%) rename _dev/js/{theme => checkout}/core/checkout/components/useCheckoutStepsController.js (98%) rename _dev/js/{theme => checkout}/core/checkout/handler/address/changeAddressHandler.js (92%) rename _dev/js/{theme => checkout}/core/checkout/handler/address/editAddressHandler.js (100%) rename _dev/js/{theme => checkout}/core/checkout/handler/address/showAddressErrorMessageHandler.js (90%) rename _dev/js/{theme => checkout}/core/checkout/handler/delivery/changeDeliveryMethodHandler.js (93%) rename _dev/js/{theme => checkout}/core/checkout/handler/delivery/editDeliveryStepHandler.js (100%) rename _dev/js/{theme => checkout}/core/checkout/handler/payment/confirmOrderHandler.js (96%) rename _dev/js/{theme => checkout}/core/checkout/handler/payment/orderConfirmationErrorsHandler.js (100%) rename _dev/js/{theme => checkout}/core/checkout/handler/payment/toggleOrderButtonStateHandler.js (85%) rename _dev/js/{theme => checkout}/core/checkout/handler/payment/togglePaymentOptionsHandler.js (87%) rename _dev/js/{theme => checkout}/core/checkout/handler/process/checkoutFormSubmitHandler.js (90%) rename _dev/js/{theme => checkout}/core/checkout/handler/process/checkoutStepChangeHandler.js (100%) rename _dev/js/{theme => checkout}/core/checkout/index.js (94%) rename _dev/js/{theme => checkout}/core/checkout/request/checkCartStillOrderableRequest.js (91%) rename _dev/js/{theme => checkout}/core/checkout/request/selectDeliveryMethodRequest.js (94%) rename _dev/js/{theme => checkout}/core/checkout/utils/areConditionsAccepted.js (95%) rename _dev/js/{theme => checkout}/core/checkout/utils/canProceedOrder.js (100%) rename _dev/js/{theme => checkout}/core/checkout/utils/collapseAllPaymentOptions.js (88%) rename _dev/js/{theme => checkout}/core/checkout/utils/getEditAddress.js (100%) rename _dev/js/{theme => checkout}/core/checkout/utils/getSelectedPaymentOption.js (100%) rename _dev/js/{theme => checkout}/core/checkout/utils/refreshCheckoutPage.js (100%) rename _dev/js/{theme => checkout}/core/checkout/utils/switchConfirmAddressesButtonState.js (86%) rename _dev/js/{theme => checkout}/core/checkout/utils/switchEditAddressButtonColor.js (93%) rename _dev/js/{theme => checkout}/core/checkout/utils/toggleOrderConfirmationButtonState.js (100%) delete mode 100644 _dev/js/theme/utils/DOMReady.js delete mode 100644 _dev/js/theme/utils/parseToHtml.js rename _dev/js/{theme/utils => utils/DOM}/DOMHelpers.js (52%) rename _dev/js/{theme/utils => utils/DOM}/DOMSelectorsHelper.js (100%) rename _dev/js/{theme => }/utils/debounce.js (100%) rename _dev/js/{theme/components => utils}/display/useToggleDisplay.js (100%) rename _dev/js/{theme => }/utils/dynamicImports/componentProxyFactory.js (100%) rename _dev/js/{theme => }/utils/dynamicImports/useBootstrapComponentDynamicImport.js (100%) rename _dev/js/{theme => }/utils/dynamicImports/useDynamicImportEventsHandler.js (95%) rename _dev/js/{theme => }/utils/dynamicImports/useFunctionCallstackMap.js (100%) rename _dev/js/{theme => }/utils/dynamicImports/useInstanceMap.js (100%) rename _dev/js/{theme/components => utils}/event/useEvent.js (100%) rename _dev/js/{theme => }/utils/formSerialize.js (100%) rename _dev/js/{theme => }/utils/getUniqueId.js (100%) rename _dev/js/{theme/components => utils}/http/error/GenericHttpRequestError.js (100%) rename _dev/js/{theme/components => utils}/http/useDefaultHttpRequest.js (100%) rename _dev/js/{theme/components => utils}/http/useHttpController.js (97%) rename _dev/js/{theme/components => utils}/http/useHttpPayloadDefinition.js (100%) rename _dev/js/{theme/components => utils}/http/useHttpRequest.js (100%) rename _dev/js/{theme => }/utils/sprintf.js (100%) diff --git a/_dev/js/theme/core/checkout/checkoutController.js b/_dev/js/checkout/core/checkout/checkoutController.js similarity index 97% rename from _dev/js/theme/core/checkout/checkoutController.js rename to _dev/js/checkout/core/checkout/checkoutController.js index 050ed0b1..de582227 100644 --- a/_dev/js/theme/core/checkout/checkoutController.js +++ b/_dev/js/checkout/core/checkout/checkoutController.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import useEvent from '../../components/event/useEvent'; +import useEvent from '../../../utils/event/useEvent'; import editAddressHandler from './handler/address/editAddressHandler'; import changeAddressHandler from './handler/address/changeAddressHandler'; import changeDeliveryMethodHandler from './handler/delivery/changeDeliveryMethodHandler'; diff --git a/_dev/js/theme/core/checkout/components/useCheckoutStepsController.js b/_dev/js/checkout/core/checkout/components/useCheckoutStepsController.js similarity index 98% rename from _dev/js/theme/core/checkout/components/useCheckoutStepsController.js rename to _dev/js/checkout/core/checkout/components/useCheckoutStepsController.js index 20eaea41..10bc49fc 100644 --- a/_dev/js/theme/core/checkout/components/useCheckoutStepsController.js +++ b/_dev/js/checkout/core/checkout/components/useCheckoutStepsController.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import { getAllSiblingsBeforeElement, getAllSiblingsAfterElement } from '../../../utils/DOMSelectorsHelper'; +import { getAllSiblingsBeforeElement, getAllSiblingsAfterElement } from '../../../../utils/DOM/DOMSelectorsHelper'; /** * A utility function to control checkout steps in Prestashop. diff --git a/_dev/js/theme/core/checkout/handler/address/changeAddressHandler.js b/_dev/js/checkout/core/checkout/handler/address/changeAddressHandler.js similarity index 92% rename from _dev/js/theme/core/checkout/handler/address/changeAddressHandler.js rename to _dev/js/checkout/core/checkout/handler/address/changeAddressHandler.js index d634dd2b..174e3632 100644 --- a/_dev/js/theme/core/checkout/handler/address/changeAddressHandler.js +++ b/_dev/js/checkout/core/checkout/handler/address/changeAddressHandler.js @@ -1,9 +1,9 @@ import prestashop from 'prestashop'; -import useToggleDisplay from '../../../../components/display/useToggleDisplay'; +import useToggleDisplay from '../../../../../utils/display/useToggleDisplay'; import switchEditAddressButtonColor from '../../utils/switchEditAddressButtonColor'; import getEditAddress from '../../utils/getEditAddress'; import switchConfirmAddressesButtonState from '../../utils/switchConfirmAddressesButtonState'; -import { isElementVisible, each } from '../../../../utils/DOMHelpers'; +import { isElementVisible, each } from '../../../../../utils/DOM/DOMHelpers'; /** * Handles the change event for address selection in the Prestashop checkout process. diff --git a/_dev/js/theme/core/checkout/handler/address/editAddressHandler.js b/_dev/js/checkout/core/checkout/handler/address/editAddressHandler.js similarity index 100% rename from _dev/js/theme/core/checkout/handler/address/editAddressHandler.js rename to _dev/js/checkout/core/checkout/handler/address/editAddressHandler.js diff --git a/_dev/js/theme/core/checkout/handler/address/showAddressErrorMessageHandler.js b/_dev/js/checkout/core/checkout/handler/address/showAddressErrorMessageHandler.js similarity index 90% rename from _dev/js/theme/core/checkout/handler/address/showAddressErrorMessageHandler.js rename to _dev/js/checkout/core/checkout/handler/address/showAddressErrorMessageHandler.js index 12d65f4c..b6377b6b 100644 --- a/_dev/js/theme/core/checkout/handler/address/showAddressErrorMessageHandler.js +++ b/_dev/js/checkout/core/checkout/handler/address/showAddressErrorMessageHandler.js @@ -1,8 +1,8 @@ import prestashop from 'prestashop'; -import useToggleDisplay from '../../../../components/display/useToggleDisplay'; +import useToggleDisplay from '../../../../../utils/display/useToggleDisplay'; import switchConfirmAddressesButtonState from '../../utils/switchConfirmAddressesButtonState'; import switchEditAddressButtonColor from '../../utils/switchEditAddressButtonColor'; -import { isElementVisible } from '../../../../utils/DOMHelpers'; +import { isElementVisible } from '../../../../../utils/DOM/DOMHelpers'; import getEditAddress from '../../utils/getEditAddress'; /** diff --git a/_dev/js/theme/core/checkout/handler/delivery/changeDeliveryMethodHandler.js b/_dev/js/checkout/core/checkout/handler/delivery/changeDeliveryMethodHandler.js similarity index 93% rename from _dev/js/theme/core/checkout/handler/delivery/changeDeliveryMethodHandler.js rename to _dev/js/checkout/core/checkout/handler/delivery/changeDeliveryMethodHandler.js index 0e6d2cea..8a4d7991 100644 --- a/_dev/js/theme/core/checkout/handler/delivery/changeDeliveryMethodHandler.js +++ b/_dev/js/checkout/core/checkout/handler/delivery/changeDeliveryMethodHandler.js @@ -1,9 +1,8 @@ import prestashop from 'prestashop'; -import { formSerializeArray, fromSerializeObject } from '../../../../utils/formSerialize'; +import { formSerializeArray, fromSerializeObject } from '../../../../../utils/formSerialize'; import selectDeliveryMethodRequest from '../../request/selectDeliveryMethodRequest'; -import parseToHtml from '../../../../utils/parseToHtml'; import refreshCheckoutPage from '../../utils/refreshCheckoutPage'; -import { each } from '../../../../utils/DOMHelpers'; +import { each, parseToHtml } from '../../../../../utils/DOM/DOMHelpers'; /** * Handles the change of delivery method in the Prestashop checkout process. diff --git a/_dev/js/theme/core/checkout/handler/delivery/editDeliveryStepHandler.js b/_dev/js/checkout/core/checkout/handler/delivery/editDeliveryStepHandler.js similarity index 100% rename from _dev/js/theme/core/checkout/handler/delivery/editDeliveryStepHandler.js rename to _dev/js/checkout/core/checkout/handler/delivery/editDeliveryStepHandler.js diff --git a/_dev/js/theme/core/checkout/handler/payment/confirmOrderHandler.js b/_dev/js/checkout/core/checkout/handler/payment/confirmOrderHandler.js similarity index 96% rename from _dev/js/theme/core/checkout/handler/payment/confirmOrderHandler.js rename to _dev/js/checkout/core/checkout/handler/payment/confirmOrderHandler.js index 6a3c77f0..36bcffd8 100644 --- a/_dev/js/theme/core/checkout/handler/payment/confirmOrderHandler.js +++ b/_dev/js/checkout/core/checkout/handler/payment/confirmOrderHandler.js @@ -3,7 +3,7 @@ import getSelectedPaymentOption from '../../utils/getSelectedPaymentOption'; import canProceedOrder from '../../utils/canProceedOrder'; import checkCartStillOrderableRequest from '../../request/checkCartStillOrderableRequest'; import toggleOrderConfirmationButtonState from '../../utils/toggleOrderConfirmationButtonState'; -import { each } from '../../../../utils/DOMHelpers'; +import { each } from '../../../../../utils/DOM/DOMHelpers'; const showNativeFormErrors = () => { const { termsCheckboxSelector } = prestashop.selectors.checkout; diff --git a/_dev/js/theme/core/checkout/handler/payment/orderConfirmationErrorsHandler.js b/_dev/js/checkout/core/checkout/handler/payment/orderConfirmationErrorsHandler.js similarity index 100% rename from _dev/js/theme/core/checkout/handler/payment/orderConfirmationErrorsHandler.js rename to _dev/js/checkout/core/checkout/handler/payment/orderConfirmationErrorsHandler.js diff --git a/_dev/js/theme/core/checkout/handler/payment/toggleOrderButtonStateHandler.js b/_dev/js/checkout/core/checkout/handler/payment/toggleOrderButtonStateHandler.js similarity index 85% rename from _dev/js/theme/core/checkout/handler/payment/toggleOrderButtonStateHandler.js rename to _dev/js/checkout/core/checkout/handler/payment/toggleOrderButtonStateHandler.js index 5cd6c560..7db34285 100644 --- a/_dev/js/theme/core/checkout/handler/payment/toggleOrderButtonStateHandler.js +++ b/_dev/js/checkout/core/checkout/handler/payment/toggleOrderButtonStateHandler.js @@ -1,8 +1,8 @@ import prestashop from 'prestashop'; -import useToggleDisplay from '../../../../components/display/useToggleDisplay'; +import useToggleDisplay from '../../../../../utils/display/useToggleDisplay'; import canProceedOrder from '../../utils/canProceedOrder'; import toggleOrderConfirmationButtonState from '../../utils/toggleOrderConfirmationButtonState'; -import { each } from '../../../../utils/DOMHelpers'; +import { each } from '../../../../../utils/DOM/DOMHelpers'; const { toggle } = useToggleDisplay(); diff --git a/_dev/js/theme/core/checkout/handler/payment/togglePaymentOptionsHandler.js b/_dev/js/checkout/core/checkout/handler/payment/togglePaymentOptionsHandler.js similarity index 87% rename from _dev/js/theme/core/checkout/handler/payment/togglePaymentOptionsHandler.js rename to _dev/js/checkout/core/checkout/handler/payment/togglePaymentOptionsHandler.js index 17200098..81f68f01 100644 --- a/_dev/js/theme/core/checkout/handler/payment/togglePaymentOptionsHandler.js +++ b/_dev/js/checkout/core/checkout/handler/payment/togglePaymentOptionsHandler.js @@ -1,9 +1,9 @@ import collapseAllPaymentOptions from '../../utils/collapseAllPaymentOptions'; import getSelectedPaymentOption from '../../utils/getSelectedPaymentOption'; -import useToggleDisplay from '../../../../components/display/useToggleDisplay'; +import useToggleDisplay from '../../../../../utils/display/useToggleDisplay'; import canProceedOrder from '../../utils/canProceedOrder'; import toggleOrderConfirmationButtonState from '../../utils/toggleOrderConfirmationButtonState'; -import { each } from '../../../../utils/DOMHelpers'; +import { each } from '../../../../../utils/DOM/DOMHelpers'; const { show } = useToggleDisplay(); diff --git a/_dev/js/theme/core/checkout/handler/process/checkoutFormSubmitHandler.js b/_dev/js/checkout/core/checkout/handler/process/checkoutFormSubmitHandler.js similarity index 90% rename from _dev/js/theme/core/checkout/handler/process/checkoutFormSubmitHandler.js rename to _dev/js/checkout/core/checkout/handler/process/checkoutFormSubmitHandler.js index 9df23b9e..51b21845 100644 --- a/_dev/js/theme/core/checkout/handler/process/checkoutFormSubmitHandler.js +++ b/_dev/js/checkout/core/checkout/handler/process/checkoutFormSubmitHandler.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import { each } from '../../../../utils/DOMHelpers'; +import { each } from '../../../../../utils/DOM/DOMHelpers'; /** * Handles the submission of the checkout form, disables submit buttons, and emits a 'submitCheckoutForm' event. diff --git a/_dev/js/theme/core/checkout/handler/process/checkoutStepChangeHandler.js b/_dev/js/checkout/core/checkout/handler/process/checkoutStepChangeHandler.js similarity index 100% rename from _dev/js/theme/core/checkout/handler/process/checkoutStepChangeHandler.js rename to _dev/js/checkout/core/checkout/handler/process/checkoutStepChangeHandler.js diff --git a/_dev/js/theme/core/checkout/index.js b/_dev/js/checkout/core/checkout/index.js similarity index 94% rename from _dev/js/theme/core/checkout/index.js rename to _dev/js/checkout/core/checkout/index.js index ffa7b897..eb52d287 100644 --- a/_dev/js/theme/core/checkout/index.js +++ b/_dev/js/checkout/core/checkout/index.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import DOMReady from '../../utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; import checkoutController from './checkoutController'; diff --git a/_dev/js/theme/core/checkout/request/checkCartStillOrderableRequest.js b/_dev/js/checkout/core/checkout/request/checkCartStillOrderableRequest.js similarity index 91% rename from _dev/js/theme/core/checkout/request/checkCartStillOrderableRequest.js rename to _dev/js/checkout/core/checkout/request/checkCartStillOrderableRequest.js index 660644eb..e4236778 100644 --- a/_dev/js/theme/core/checkout/request/checkCartStillOrderableRequest.js +++ b/_dev/js/checkout/core/checkout/request/checkCartStillOrderableRequest.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../components/http/useDefaultHttpRequest'; +import useDefaultHttpRequest from '../../../../utils/http/useDefaultHttpRequest'; /** * Represents the server response from a check cart still orderable request. diff --git a/_dev/js/theme/core/checkout/request/selectDeliveryMethodRequest.js b/_dev/js/checkout/core/checkout/request/selectDeliveryMethodRequest.js similarity index 94% rename from _dev/js/theme/core/checkout/request/selectDeliveryMethodRequest.js rename to _dev/js/checkout/core/checkout/request/selectDeliveryMethodRequest.js index 8198eed5..2371449b 100644 --- a/_dev/js/theme/core/checkout/request/selectDeliveryMethodRequest.js +++ b/_dev/js/checkout/core/checkout/request/selectDeliveryMethodRequest.js @@ -1,4 +1,4 @@ -import useDefaultHttpRequest from '../../../components/http/useDefaultHttpRequest'; +import useDefaultHttpRequest from '../../../../utils/http/useDefaultHttpRequest'; /** * Represents the server response from a select delivery method request. diff --git a/_dev/js/theme/core/checkout/utils/areConditionsAccepted.js b/_dev/js/checkout/core/checkout/utils/areConditionsAccepted.js similarity index 95% rename from _dev/js/theme/core/checkout/utils/areConditionsAccepted.js rename to _dev/js/checkout/core/checkout/utils/areConditionsAccepted.js index 93d037cb..32f1817b 100644 --- a/_dev/js/theme/core/checkout/utils/areConditionsAccepted.js +++ b/_dev/js/checkout/core/checkout/utils/areConditionsAccepted.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import { each } from '../../../utils/DOMHelpers'; +import { each } from '../../../../utils/DOM/DOMHelpers'; /** * Checks if all conditions are accepted. diff --git a/_dev/js/theme/core/checkout/utils/canProceedOrder.js b/_dev/js/checkout/core/checkout/utils/canProceedOrder.js similarity index 100% rename from _dev/js/theme/core/checkout/utils/canProceedOrder.js rename to _dev/js/checkout/core/checkout/utils/canProceedOrder.js diff --git a/_dev/js/theme/core/checkout/utils/collapseAllPaymentOptions.js b/_dev/js/checkout/core/checkout/utils/collapseAllPaymentOptions.js similarity index 88% rename from _dev/js/theme/core/checkout/utils/collapseAllPaymentOptions.js rename to _dev/js/checkout/core/checkout/utils/collapseAllPaymentOptions.js index 76a5ea78..a4726490 100644 --- a/_dev/js/theme/core/checkout/utils/collapseAllPaymentOptions.js +++ b/_dev/js/checkout/core/checkout/utils/collapseAllPaymentOptions.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; -import { each } from '../../../utils/DOMHelpers'; -import useToggleDisplay from '../../../components/display/useToggleDisplay'; +import { each } from '../../../../utils/DOM/DOMHelpers'; +import useToggleDisplay from '../../../../utils/display/useToggleDisplay'; /** * Collapses all payment options' additional information blocks and options forms. diff --git a/_dev/js/theme/core/checkout/utils/getEditAddress.js b/_dev/js/checkout/core/checkout/utils/getEditAddress.js similarity index 100% rename from _dev/js/theme/core/checkout/utils/getEditAddress.js rename to _dev/js/checkout/core/checkout/utils/getEditAddress.js diff --git a/_dev/js/theme/core/checkout/utils/getSelectedPaymentOption.js b/_dev/js/checkout/core/checkout/utils/getSelectedPaymentOption.js similarity index 100% rename from _dev/js/theme/core/checkout/utils/getSelectedPaymentOption.js rename to _dev/js/checkout/core/checkout/utils/getSelectedPaymentOption.js diff --git a/_dev/js/theme/core/checkout/utils/refreshCheckoutPage.js b/_dev/js/checkout/core/checkout/utils/refreshCheckoutPage.js similarity index 100% rename from _dev/js/theme/core/checkout/utils/refreshCheckoutPage.js rename to _dev/js/checkout/core/checkout/utils/refreshCheckoutPage.js diff --git a/_dev/js/theme/core/checkout/utils/switchConfirmAddressesButtonState.js b/_dev/js/checkout/core/checkout/utils/switchConfirmAddressesButtonState.js similarity index 86% rename from _dev/js/theme/core/checkout/utils/switchConfirmAddressesButtonState.js rename to _dev/js/checkout/core/checkout/utils/switchConfirmAddressesButtonState.js index 3869f540..3475b5aa 100644 --- a/_dev/js/theme/core/checkout/utils/switchConfirmAddressesButtonState.js +++ b/_dev/js/checkout/core/checkout/utils/switchConfirmAddressesButtonState.js @@ -1,4 +1,4 @@ -import { each } from '../../../utils/DOMHelpers'; +import { each } from '../../../../utils/DOM/DOMHelpers'; /** * Switches the state of the confirm addresses button. diff --git a/_dev/js/theme/core/checkout/utils/switchEditAddressButtonColor.js b/_dev/js/checkout/core/checkout/utils/switchEditAddressButtonColor.js similarity index 93% rename from _dev/js/theme/core/checkout/utils/switchEditAddressButtonColor.js rename to _dev/js/checkout/core/checkout/utils/switchEditAddressButtonColor.js index 9e2a9cd2..c44e8c53 100644 --- a/_dev/js/theme/core/checkout/utils/switchEditAddressButtonColor.js +++ b/_dev/js/checkout/core/checkout/utils/switchEditAddressButtonColor.js @@ -1,4 +1,4 @@ -import { each } from '../../../utils/DOMHelpers'; +import { each } from '../../../../utils/DOM/DOMHelpers'; /** * Changes the color of the edit button for the wrong address. diff --git a/_dev/js/theme/core/checkout/utils/toggleOrderConfirmationButtonState.js b/_dev/js/checkout/core/checkout/utils/toggleOrderConfirmationButtonState.js similarity index 100% rename from _dev/js/theme/core/checkout/utils/toggleOrderConfirmationButtonState.js rename to _dev/js/checkout/core/checkout/utils/toggleOrderConfirmationButtonState.js diff --git a/_dev/js/checkout/index.js b/_dev/js/checkout/index.js index 38d57f4f..e06ad0ce 100644 --- a/_dev/js/checkout/index.js +++ b/_dev/js/checkout/index.js @@ -1,9 +1,8 @@ import prestashop from 'prestashop'; -import useEvent from '../theme/components/event/useEvent'; -import parseToHtml from '../theme/utils/parseToHtml'; -import useHttpRequest from '../theme/components/http/useHttpRequest'; -import { each } from '../theme/utils/DOMHelpers'; -import DOMReady from '../theme/utils/DOMReady'; +import useEvent from '../utils/event/useEvent'; +import { parseToHtml, each, DOMReady } from '../utils/DOM/DOMHelpers'; +import useHttpRequest from '../utils/http/useHttpRequest'; +import './core/checkout/index'; const { on } = useEvent(); diff --git a/_dev/js/listing/components/filters/Filters.js b/_dev/js/listing/components/filters/Filters.js index 2178b3a4..1682b587 100644 --- a/_dev/js/listing/components/filters/Filters.js +++ b/_dev/js/listing/components/filters/Filters.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; import FiltersRangeSliders from './FiltersRangeSliders'; -import useEvent from '../../../theme/components/event/useEvent'; +import useEvent from '../../../utils/event/useEvent'; class Filters { constructor() { diff --git a/_dev/js/listing/components/filters/FiltersRangeSliders.js b/_dev/js/listing/components/filters/FiltersRangeSliders.js index bee2e052..91a7becf 100644 --- a/_dev/js/listing/components/filters/FiltersRangeSliders.js +++ b/_dev/js/listing/components/filters/FiltersRangeSliders.js @@ -1,5 +1,5 @@ import RangeSlider from './RangeSlider'; -import { each } from '../../../theme/utils/DOMHelpers'; +import { each } from '../../../utils/DOM/DOMHelpers'; class FiltersRangeSliders { static init() { diff --git a/_dev/js/listing/components/filters/RangeSlider.js b/_dev/js/listing/components/filters/RangeSlider.js index 5eae465a..cc9a1739 100644 --- a/_dev/js/listing/components/filters/RangeSlider.js +++ b/_dev/js/listing/components/filters/RangeSlider.js @@ -2,7 +2,7 @@ import prestashop from 'prestashop'; import noUiSlider from 'nouislider'; import wNumb from 'wnumb'; import FiltersUrlHandler from './FiltersUrlHandler'; -import useEvent from '../../../theme/components/event/useEvent'; +import useEvent from '../../../utils/event/useEvent'; class RangeSlider { constructor(element) { diff --git a/_dev/js/listing/index.js b/_dev/js/listing/index.js index 705c8f27..28e5e92c 100644 --- a/_dev/js/listing/index.js +++ b/_dev/js/listing/index.js @@ -1,8 +1,6 @@ import prestashop from 'prestashop'; -import Filters from '@js/listing/components/filters/Filters'; -import parseToHtml from '../theme/utils/parseToHtml'; -import { each } from '../theme/utils/DOMHelpers'; -import DOMReady from '../theme/utils/DOMReady'; +import Filters from './components/filters/Filters'; +import { each, parseToHtml, DOMReady } from '../utils/DOM/DOMHelpers'; function updateProductListDOM(data) { each(prestashop.selectors.listing.searchFilters, (el) => { diff --git a/_dev/js/product/index.js b/_dev/js/product/index.js index d8d0af7a..e58cbe80 100644 --- a/_dev/js/product/index.js +++ b/_dev/js/product/index.js @@ -1,5 +1,5 @@ import ProductGallery from './components/ProductGallery'; -import DOMReady from '../theme/utils/DOMReady'; +import { DOMReady } from '../utils/DOM/DOMHelpers'; DOMReady(() => { const gallery = new ProductGallery(); diff --git a/_dev/js/theme/components/customer/index.js b/_dev/js/theme/components/customer/index.js index 16f745b3..fbfb62b8 100644 --- a/_dev/js/theme/components/customer/index.js +++ b/_dev/js/theme/components/customer/index.js @@ -1,4 +1,4 @@ -import DOMReady from '../../utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; const initCustomerLinksTriggerActive = () => { const url = window.location.pathname; diff --git a/_dev/js/theme/components/dynamic-bootstrap-components.js b/_dev/js/theme/components/dynamic-bootstrap-components.js index 71dba35e..3410af63 100644 --- a/_dev/js/theme/components/dynamic-bootstrap-components.js +++ b/_dev/js/theme/components/dynamic-bootstrap-components.js @@ -1,5 +1,5 @@ -import DOMReady from '../utils/DOMReady'; -import useBootstrapComponentDynamicImport from '../utils/dynamicImports/useBootstrapComponentDynamicImport'; +import { DOMReady } from '../../utils/DOM/DOMHelpers'; +import useBootstrapComponentDynamicImport from '../../utils/dynamicImports/useBootstrapComponentDynamicImport'; DOMReady(() => { const { init: initDynamicImportForModal } = useBootstrapComponentDynamicImport( diff --git a/_dev/js/theme/components/header/index.js b/_dev/js/theme/components/header/index.js index 47e25dd9..0893c440 100644 --- a/_dev/js/theme/components/header/index.js +++ b/_dev/js/theme/components/header/index.js @@ -1,4 +1,4 @@ -import DOMReady from '../../utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; import useTopMenu from './useTopMenu'; import useStickyElement from '../useStickyElement'; diff --git a/_dev/js/theme/components/header/useTopMenu.js b/_dev/js/theme/components/header/useTopMenu.js index e8556369..10cab9a9 100644 --- a/_dev/js/theme/components/header/useTopMenu.js +++ b/_dev/js/theme/components/header/useTopMenu.js @@ -1,4 +1,4 @@ -import useEvent from '../event/useEvent'; +import useEvent from '../../../utils/event/useEvent'; const useTopMenu = (selector) => { const { on, off } = useEvent(); diff --git a/_dev/js/theme/components/product.js b/_dev/js/theme/components/product.js index 23242ff8..d0509a03 100644 --- a/_dev/js/theme/components/product.js +++ b/_dev/js/theme/components/product.js @@ -1,8 +1,6 @@ import prestashop from 'prestashop'; import useCustomQuantityInput from './useCustomQuantityInput'; -import { each } from '../utils/DOMHelpers'; -import parseToHtml from '../utils/parseToHtml'; -import DOMReady from '../utils/DOMReady'; +import { each, parseToHtml, DOMReady } from '../../utils/DOM/DOMHelpers'; import productEventContextSelector from '../core/product/utils/productEventContextSelector'; DOMReady(() => { diff --git a/_dev/js/theme/components/quickview.js b/_dev/js/theme/components/quickview.js index 9b87d747..3aeeba7d 100644 --- a/_dev/js/theme/components/quickview.js +++ b/_dev/js/theme/components/quickview.js @@ -1,6 +1,5 @@ import prestashop from 'prestashop'; -import DOMReady from '../utils/DOMReady'; -import parseToHtml from '../utils/parseToHtml'; +import { DOMReady, parseToHtml } from '../../utils/DOM/DOMHelpers'; /** * Handle open quick view diff --git a/_dev/js/theme/components/responsive.js b/_dev/js/theme/components/responsive.js index fe4eff35..b28f7288 100644 --- a/_dev/js/theme/components/responsive.js +++ b/_dev/js/theme/components/responsive.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import DOMReady from '../utils/DOMReady'; +import { DOMReady } from '../../utils/DOM/DOMHelpers'; function isMobile() { return prestashop.responsive.current_width < prestashop.responsive.min_width; diff --git a/_dev/js/theme/components/sliders/index.js b/_dev/js/theme/components/sliders/index.js index ad4c1230..031caf65 100644 --- a/_dev/js/theme/components/sliders/index.js +++ b/_dev/js/theme/components/sliders/index.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import DOMReady from '../../utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; import PageSlider from './PageSlider'; import SwiperSlider from './SwiperSlider'; diff --git a/_dev/js/theme/components/useAlertToast.js b/_dev/js/theme/components/useAlertToast.js index 0896d0f5..b1cced31 100644 --- a/_dev/js/theme/components/useAlertToast.js +++ b/_dev/js/theme/components/useAlertToast.js @@ -1,4 +1,4 @@ -import parseToHtml from '@js/theme/utils/parseToHtml'; +import { parseToHtml } from '../../utils/DOM/DOMHelpers'; let id = 0; diff --git a/_dev/js/theme/components/usePageLoader.js b/_dev/js/theme/components/usePageLoader.js index 72eb2ddb..f1037d8e 100644 --- a/_dev/js/theme/components/usePageLoader.js +++ b/_dev/js/theme/components/usePageLoader.js @@ -1,8 +1,12 @@ /** * A utility module for managing the page loader state. * - * @return {showLoader, hideLoader} + * @module usePageLoader + * @returns {Object} An object with methods to show and hide the page loader. + * @property {Function} showLoader - Displays the page loader. + * @property {Function} hideLoader - Hides the page loader. * @example + * // Usage example: * const pageLoader = usePageLoader(); * pageLoader.showLoader(); // Display the page loader * pageLoader.hideLoader(); // Hide the page loader @@ -14,7 +18,8 @@ const usePageLoader = () => { /** * Show the page loader. * - * @method showLoader + * @function + * @name showLoader * @returns {void} */ const showLoader = () => { @@ -24,7 +29,8 @@ const usePageLoader = () => { /** * Hide the page loader. * - * @method hideLoader + * @function + * @name hideLoader * @returns {void} */ const hideLoader = () => { diff --git a/_dev/js/theme/components/useStickyElement.js b/_dev/js/theme/components/useStickyElement.js index b3da4b55..3cc41b4d 100644 --- a/_dev/js/theme/components/useStickyElement.js +++ b/_dev/js/theme/components/useStickyElement.js @@ -1,4 +1,4 @@ -import debounce from '../utils/debounce'; +import debounce from '../../utils/debounce'; /** * Returns sticky element data diff --git a/_dev/js/theme/components/useThemeForm.js b/_dev/js/theme/components/useThemeForm.js index 73fa0146..179327e3 100644 --- a/_dev/js/theme/components/useThemeForm.js +++ b/_dev/js/theme/components/useThemeForm.js @@ -1,4 +1,4 @@ -import { each } from '../utils/DOMHelpers'; +import { each } from '../../utils/DOM/DOMHelpers'; const supportedValidity = () => { const input = document.createElement('input'); diff --git a/_dev/js/theme/core/address/addressController.js b/_dev/js/theme/core/address/addressController.js index bc52a619..4660961b 100644 --- a/_dev/js/theme/core/address/addressController.js +++ b/_dev/js/theme/core/address/addressController.js @@ -1,4 +1,4 @@ -import useEvent from '../../components/event/useEvent'; +import useEvent from '../../../utils/event/useEvent'; import changeAddressCountryHandler from './handler/changeAddressCountryHandler'; /** diff --git a/_dev/js/theme/core/address/handler/changeAddressCountryHandler.js b/_dev/js/theme/core/address/handler/changeAddressCountryHandler.js index 750179b1..e54f9246 100644 --- a/_dev/js/theme/core/address/handler/changeAddressCountryHandler.js +++ b/_dev/js/theme/core/address/handler/changeAddressCountryHandler.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import parseToHtml from '../../../utils/parseToHtml'; +import { parseToHtml } from '../../../../utils/DOM/DOMHelpers'; import updateAddressRequest from '../request/updateAddressRequest'; /** diff --git a/_dev/js/theme/core/address/index.js b/_dev/js/theme/core/address/index.js index 0f8aaa4d..d150e3f4 100644 --- a/_dev/js/theme/core/address/index.js +++ b/_dev/js/theme/core/address/index.js @@ -1,5 +1,5 @@ import addressController from './addressController'; -import DOMReady from '../../utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; const { init } = addressController(); diff --git a/_dev/js/theme/core/address/request/updateAddressRequest.js b/_dev/js/theme/core/address/request/updateAddressRequest.js index 722213fa..221330a8 100644 --- a/_dev/js/theme/core/address/request/updateAddressRequest.js +++ b/_dev/js/theme/core/address/request/updateAddressRequest.js @@ -1,7 +1,7 @@ -import useHttpRequest from '../../../components/http/useHttpRequest'; -import useHttpController from '../../../components/http/useHttpController'; -import useHttpPayloadDefinition from '../../../components/http/useHttpPayloadDefinition'; -import GenericHttpRequestError from '../../../components/http/error/GenericHttpRequestError'; +import useHttpRequest from '../../../../utils/http/useHttpRequest'; +import useHttpController from '../../../../utils/http/useHttpController'; +import useHttpPayloadDefinition from '../../../../utils/http/useHttpPayloadDefinition'; +import GenericHttpRequestError from '../../../../utils/http/error/GenericHttpRequestError'; /** * @typedef {Object} ServerResponse diff --git a/_dev/js/theme/core/cart/cartController.js b/_dev/js/theme/core/cart/cartController.js index b0859b7b..e9240866 100644 --- a/_dev/js/theme/core/cart/cartController.js +++ b/_dev/js/theme/core/cart/cartController.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import useEvent from '../../components/event/useEvent'; +import useEvent from '../../../utils/event/useEvent'; import submitVoucherHandler from './handler/voucher/submitVoucherHandler'; import codeLinkSubmitHandler from './handler/voucher/codeLinkSubmitHandler'; import deleteVoucherHandler from './handler/voucher/deleteVoucherHandler'; diff --git a/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js b/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js index 82ad31a6..0ccfcba6 100644 --- a/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js +++ b/_dev/js/theme/core/cart/handler/cart/addToCartHandler.js @@ -1,7 +1,7 @@ import prestashop from 'prestashop'; import useAlertToast from '../../../../components/useAlertToast'; import addToCartRequest from '../../request/cart/addToCartRequest'; -import sprintf from '../../../../utils/sprintf'; +import sprintf from '../../../../../utils/sprintf'; const { danger } = useAlertToast(); diff --git a/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js b/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js index 443a1418..8ad8aca3 100644 --- a/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js +++ b/_dev/js/theme/core/cart/handler/cart/updateCartHandler.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import parseToHtml from '../../../../utils/parseToHtml'; +import { parseToHtml } from '../../../../../utils/DOM/DOMHelpers'; import updateCartContentRequest from '../../request/cart/updateCartContentRequest'; /** diff --git a/_dev/js/theme/core/cart/handler/voucher/submitVoucherHandler.js b/_dev/js/theme/core/cart/handler/voucher/submitVoucherHandler.js index 9ef4dbcf..7a220ef8 100644 --- a/_dev/js/theme/core/cart/handler/voucher/submitVoucherHandler.js +++ b/_dev/js/theme/core/cart/handler/voucher/submitVoucherHandler.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; import addVoucherToCartRequest from '../../request/voucher/addVoucherToCartRequest'; -import parseToHtml from '../../../../utils/parseToHtml'; +import { parseToHtml } from '../../../../../utils/DOM/DOMHelpers'; /** * Handles the submission of a voucher form and updates the cart accordingly. diff --git a/_dev/js/theme/core/cart/index.js b/_dev/js/theme/core/cart/index.js index 53486760..61a22c04 100644 --- a/_dev/js/theme/core/cart/index.js +++ b/_dev/js/theme/core/cart/index.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import DOMReady from '../../utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; import cartController from './cartController'; prestashop.cart = prestashop.cart || {}; diff --git a/_dev/js/theme/core/cart/request/cart/addToCartRequest.js b/_dev/js/theme/core/cart/request/cart/addToCartRequest.js index 43664b0d..89a7f050 100644 --- a/_dev/js/theme/core/cart/request/cart/addToCartRequest.js +++ b/_dev/js/theme/core/cart/request/cart/addToCartRequest.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../../components/http/useDefaultHttpRequest'; -import useHttpPayloadDefinition from '../../../../components/http/useHttpPayloadDefinition'; +import useDefaultHttpRequest from '../../../../../utils/http/useDefaultHttpRequest'; +import useHttpPayloadDefinition from '../../../../../utils/http/useHttpPayloadDefinition'; /** * @typedef {object} ServerResponse diff --git a/_dev/js/theme/core/cart/request/cart/deleteFromCartRequest.js b/_dev/js/theme/core/cart/request/cart/deleteFromCartRequest.js index 225eb1fe..ce2705ac 100644 --- a/_dev/js/theme/core/cart/request/cart/deleteFromCartRequest.js +++ b/_dev/js/theme/core/cart/request/cart/deleteFromCartRequest.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../../components/http/useDefaultHttpRequest'; -import useHttpPayloadDefinition from '../../../../components/http/useHttpPayloadDefinition'; +import useDefaultHttpRequest from '../../../../../utils/http/useDefaultHttpRequest'; +import useHttpPayloadDefinition from '../../../../../utils/http/useHttpPayloadDefinition'; /** * @typedef {object} ServerResponse diff --git a/_dev/js/theme/core/cart/request/cart/quantityChangeRequest.js b/_dev/js/theme/core/cart/request/cart/quantityChangeRequest.js index 10e5dede..97620664 100644 --- a/_dev/js/theme/core/cart/request/cart/quantityChangeRequest.js +++ b/_dev/js/theme/core/cart/request/cart/quantityChangeRequest.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../../components/http/useDefaultHttpRequest'; -import useHttpPayloadDefinition from '../../../../components/http/useHttpPayloadDefinition'; +import useDefaultHttpRequest from '../../../../../utils/http/useDefaultHttpRequest'; +import useHttpPayloadDefinition from '../../../../../utils/http/useHttpPayloadDefinition'; /** * @typedef {object} ServerResponse diff --git a/_dev/js/theme/core/cart/request/cart/updateCartContentRequest.js b/_dev/js/theme/core/cart/request/cart/updateCartContentRequest.js index abc953d8..706b4381 100644 --- a/_dev/js/theme/core/cart/request/cart/updateCartContentRequest.js +++ b/_dev/js/theme/core/cart/request/cart/updateCartContentRequest.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../../components/http/useDefaultHttpRequest'; +import useDefaultHttpRequest from '../../../../../utils/http/useDefaultHttpRequest'; /** * @typedef {object} ServerResponse diff --git a/_dev/js/theme/core/cart/request/voucher/addVoucherToCartRequest.js b/_dev/js/theme/core/cart/request/voucher/addVoucherToCartRequest.js index 24cd741a..48fafc7b 100644 --- a/_dev/js/theme/core/cart/request/voucher/addVoucherToCartRequest.js +++ b/_dev/js/theme/core/cart/request/voucher/addVoucherToCartRequest.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../../components/http/useDefaultHttpRequest'; -import useHttpPayloadDefinition from '../../../../components/http/useHttpPayloadDefinition'; +import useDefaultHttpRequest from '../../../../../utils/http/useDefaultHttpRequest'; +import useHttpPayloadDefinition from '../../../../../utils/http/useHttpPayloadDefinition'; /** * @typedef {object} ServerResponse diff --git a/_dev/js/theme/core/cart/request/voucher/deleteVoucherFromCartRequest.js b/_dev/js/theme/core/cart/request/voucher/deleteVoucherFromCartRequest.js index 1bf3dfc5..fa122acb 100644 --- a/_dev/js/theme/core/cart/request/voucher/deleteVoucherFromCartRequest.js +++ b/_dev/js/theme/core/cart/request/voucher/deleteVoucherFromCartRequest.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../../components/http/useDefaultHttpRequest'; -import useHttpPayloadDefinition from '../../../../components/http/useHttpPayloadDefinition'; +import useDefaultHttpRequest from '../../../../../utils/http/useDefaultHttpRequest'; +import useHttpPayloadDefinition from '../../../../../utils/http/useHttpPayloadDefinition'; /** * @typedef {object} ServerResponse diff --git a/_dev/js/theme/core/index.js b/_dev/js/theme/core/index.js index 3efad871..4cfad6e8 100644 --- a/_dev/js/theme/core/index.js +++ b/_dev/js/theme/core/index.js @@ -4,11 +4,10 @@ import './cart/index'; import './product/index'; import './listing/index'; import './address/index'; -import './checkout/index'; import psShowHide from './display/psShowHide'; import emailIdn from './email/emailIdn'; -import DOMReady from '../utils/DOMReady'; +import { DOMReady } from '../../utils/DOM/DOMHelpers'; DOMReady(() => { psShowHide(); diff --git a/_dev/js/theme/core/listing/index.js b/_dev/js/theme/core/listing/index.js index e2d9ce65..8c399fa4 100644 --- a/_dev/js/theme/core/listing/index.js +++ b/_dev/js/theme/core/listing/index.js @@ -1,4 +1,4 @@ -import DOMReady from '@js/theme/utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; import listingController from './listingController'; const { init } = listingController(); diff --git a/_dev/js/theme/core/listing/request/updateListingFacetsRequest.js b/_dev/js/theme/core/listing/request/updateListingFacetsRequest.js index 7968df47..17c05c84 100644 --- a/_dev/js/theme/core/listing/request/updateListingFacetsRequest.js +++ b/_dev/js/theme/core/listing/request/updateListingFacetsRequest.js @@ -1,6 +1,6 @@ -import useHttpRequest from '../../../components/http/useHttpRequest'; -import useHttpController from '../../../components/http/useHttpController'; -import GenericHttpRequestError from '../../../components/http/error/GenericHttpRequestError'; +import useHttpRequest from '../../../../utils/http/useHttpRequest'; +import useHttpController from '../../../../utils/http/useHttpController'; +import GenericHttpRequestError from '../../../../utils/http/error/GenericHttpRequestError'; const { dispatch, abortAll } = useHttpController(); diff --git a/_dev/js/theme/core/product/handler/product/updateProductDOMElementsHandler.js b/_dev/js/theme/core/product/handler/product/updateProductDOMElementsHandler.js index 46bd8c80..f9ed9010 100644 --- a/_dev/js/theme/core/product/handler/product/updateProductDOMElementsHandler.js +++ b/_dev/js/theme/core/product/handler/product/updateProductDOMElementsHandler.js @@ -1,6 +1,5 @@ import prestashop from 'prestashop'; -import parseToHtml from '../../../../utils/parseToHtml'; -import { each } from '../../../../utils/DOMHelpers'; +import { each, parseToHtml } from '../../../../../utils/DOM/DOMHelpers'; import productEventContextSelector from '../../utils/productEventContextSelector'; /** diff --git a/_dev/js/theme/core/product/handler/product/updateProductHandler.js b/_dev/js/theme/core/product/handler/product/updateProductHandler.js index 7bb63903..6c743c71 100644 --- a/_dev/js/theme/core/product/handler/product/updateProductHandler.js +++ b/_dev/js/theme/core/product/handler/product/updateProductHandler.js @@ -7,7 +7,7 @@ import productStateStore from '../../store/productStateStore'; import updateQuantityInputHandler from './updateQuantityInputHandler'; import updateProductCustomizationHandler from './updateProductCustomizationHandler'; import updateProductDOMElementsHandler from './updateProductDOMElementsHandler'; -import { fromSerializeObject } from '../../../../utils/formSerialize'; +import { fromSerializeObject } from '../../../../../utils/formSerialize'; import productEventContextSelector from '../../utils/productEventContextSelector'; const { getCurrentRequestDelayedId, setCurrentRequestDelayedId } = productStateStore(); diff --git a/_dev/js/theme/core/product/index.js b/_dev/js/theme/core/product/index.js index 1a8dfa23..5a4a76a5 100644 --- a/_dev/js/theme/core/product/index.js +++ b/_dev/js/theme/core/product/index.js @@ -1,5 +1,5 @@ import productController from './productController'; -import DOMReady from '../../utils/DOMReady'; +import { DOMReady } from '../../../utils/DOM/DOMHelpers'; const { init } = productController(); diff --git a/_dev/js/theme/core/product/persister/productFormDataPersister.js b/_dev/js/theme/core/product/persister/productFormDataPersister.js index 95253cc0..33bcde83 100644 --- a/_dev/js/theme/core/product/persister/productFormDataPersister.js +++ b/_dev/js/theme/core/product/persister/productFormDataPersister.js @@ -1,4 +1,4 @@ -import { formSerializeArray } from '../../../utils/formSerialize'; +import { formSerializeArray } from '../../../../utils/formSerialize'; let formData = []; diff --git a/_dev/js/theme/core/product/productController.js b/_dev/js/theme/core/product/productController.js index f1587509..e287708d 100644 --- a/_dev/js/theme/core/product/productController.js +++ b/_dev/js/theme/core/product/productController.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import useEvent from '../../components/event/useEvent'; +import useEvent from '../../../utils/event/useEvent'; import quickViewClickHandler from './handler/quickView/quickViewClickHandler'; import quickViewHandler from './handler/quickView/quickViewHandler'; import productUpdateErrorHandler from './handler/product/productUpdateErrorHandler'; diff --git a/_dev/js/theme/core/product/request/product/updateProductRequest.js b/_dev/js/theme/core/product/request/product/updateProductRequest.js index 1686d355..2dcf140e 100644 --- a/_dev/js/theme/core/product/request/product/updateProductRequest.js +++ b/_dev/js/theme/core/product/request/product/updateProductRequest.js @@ -1,8 +1,8 @@ import prestashop from 'prestashop'; -import useHttpRequest from '../../../../components/http/useHttpRequest'; -import useHttpController from '../../../../components/http/useHttpController'; -import useHttpPayloadDefinition from '../../../../components/http/useHttpPayloadDefinition'; -import GenericHttpRequestError from '../../../../components/http/error/GenericHttpRequestError'; +import useHttpRequest from '../../../../../utils/http/useHttpRequest'; +import useHttpController from '../../../../../utils/http/useHttpController'; +import useHttpPayloadDefinition from '../../../../../utils/http/useHttpPayloadDefinition'; +import GenericHttpRequestError from '../../../../../utils/http/error/GenericHttpRequestError'; const { dispatch, abortAll } = useHttpController(); diff --git a/_dev/js/theme/core/product/request/quickView/quickViewRequest.js b/_dev/js/theme/core/product/request/quickView/quickViewRequest.js index cba05f36..63ab14d0 100644 --- a/_dev/js/theme/core/product/request/quickView/quickViewRequest.js +++ b/_dev/js/theme/core/product/request/quickView/quickViewRequest.js @@ -1,6 +1,6 @@ import prestashop from 'prestashop'; -import useDefaultHttpRequest from '../../../../components/http/useDefaultHttpRequest'; -import useHttpPayloadDefinition from '../../../../components/http/useHttpPayloadDefinition'; +import useDefaultHttpRequest from '../../../../../utils/http/useDefaultHttpRequest'; +import useHttpPayloadDefinition from '../../../../../utils/http/useHttpPayloadDefinition'; /** * Server response object for the quick view request. * diff --git a/_dev/js/theme/core/selectors.js b/_dev/js/theme/core/selectors.js index ee546be5..7be3e0ef 100644 --- a/_dev/js/theme/core/selectors.js +++ b/_dev/js/theme/core/selectors.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import DOMReady from '../utils/DOMReady'; +import DOMReady from '../../utils/DOM/DOMHelpers'; prestashop.selectors = { quantityWanted: '#quantity_wanted', diff --git a/_dev/js/theme/handler/error/httpRequestErrorHandler.js b/_dev/js/theme/handler/error/httpRequestErrorHandler.js index dacb73f8..c66cebe9 100644 --- a/_dev/js/theme/handler/error/httpRequestErrorHandler.js +++ b/_dev/js/theme/handler/error/httpRequestErrorHandler.js @@ -1,5 +1,5 @@ import prestashop from 'prestashop'; -import GenericHttpRequestError from '../../components/http/error/GenericHttpRequestError'; +import GenericHttpRequestError from '../../../utils/http/error/GenericHttpRequestError'; import useAlertToast from '../../components/useAlertToast'; const { danger } = useAlertToast(); diff --git a/_dev/js/theme/index.js b/_dev/js/theme/index.js index d15bbba5..7fd4cece 100644 --- a/_dev/js/theme/index.js +++ b/_dev/js/theme/index.js @@ -1,7 +1,5 @@ import EventEmitter from 'events'; -import './core/index'; - import './vendors/bootstrap/bootstrap-imports'; import './components/dynamic-bootstrap-components'; import bsCustomFileInput from 'bs-custom-file-input'; @@ -24,7 +22,7 @@ import useThemeForm from './components/useThemeForm'; import PageLazyLoad from './components/Lazyload'; import httpRequestErrorHandler from './handler/error/httpRequestErrorHandler'; import usePageLoader from "./components/usePageLoader"; -import DOMReady from "./utils/DOMReady"; +import { DOMReady } from "../utils/DOM/DOMHelpers"; prestashop.pageLazyLoad = new PageLazyLoad({ selector: '.lazyload', diff --git a/_dev/js/theme/utils/DOMReady.js b/_dev/js/theme/utils/DOMReady.js deleted file mode 100644 index cd463d5a..00000000 --- a/_dev/js/theme/utils/DOMReady.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * DOMReady function runs a callback function when the DOM is ready (DOMContentLoaded) - * @param callback {function} - callback function - */ -const DOMReady = (callback) => { - if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', callback); - } else { - callback(); - } -}; - -export default DOMReady; diff --git a/_dev/js/theme/utils/parseToHtml.js b/_dev/js/theme/utils/parseToHtml.js deleted file mode 100644 index 6476931c..00000000 --- a/_dev/js/theme/utils/parseToHtml.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Convert a template string into HTML DOM nodes - * @param str {string} - string representation of the HTML - * @return {HTMLElement} - HTML element from the string - */ -const parseToHtml = (str) => { - const parser = new DOMParser(); - const doc = parser.parseFromString(str, 'text/html'); - - return doc.body.children[0]; -}; - -export default parseToHtml; diff --git a/_dev/js/theme/utils/DOMHelpers.js b/_dev/js/utils/DOM/DOMHelpers.js similarity index 52% rename from _dev/js/theme/utils/DOMHelpers.js rename to _dev/js/utils/DOM/DOMHelpers.js index aa31e456..23089065 100644 --- a/_dev/js/theme/utils/DOMHelpers.js +++ b/_dev/js/utils/DOM/DOMHelpers.js @@ -24,3 +24,27 @@ export const each = (elementsOrSelector, fnc) => { fnc(element); }); }; + +/** + * DOMReady function runs a callback function when the DOM is ready (DOMContentLoaded) + * @param callback {function} - callback function + */ +export const DOMReady = (callback) => { + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', callback); + } else { + callback(); + } +}; + +/** + * Convert a template string into HTML DOM nodes + * @param str {string} - string representation of the HTML + * @return {HTMLElement} - HTML element from the string + */ +export const parseToHtml = (str) => { + const parser = new DOMParser(); + const doc = parser.parseFromString(str, 'text/html'); + + return doc.body.children[0]; +}; diff --git a/_dev/js/theme/utils/DOMSelectorsHelper.js b/_dev/js/utils/DOM/DOMSelectorsHelper.js similarity index 100% rename from _dev/js/theme/utils/DOMSelectorsHelper.js rename to _dev/js/utils/DOM/DOMSelectorsHelper.js diff --git a/_dev/js/theme/utils/debounce.js b/_dev/js/utils/debounce.js similarity index 100% rename from _dev/js/theme/utils/debounce.js rename to _dev/js/utils/debounce.js diff --git a/_dev/js/theme/components/display/useToggleDisplay.js b/_dev/js/utils/display/useToggleDisplay.js similarity index 100% rename from _dev/js/theme/components/display/useToggleDisplay.js rename to _dev/js/utils/display/useToggleDisplay.js diff --git a/_dev/js/theme/utils/dynamicImports/componentProxyFactory.js b/_dev/js/utils/dynamicImports/componentProxyFactory.js similarity index 100% rename from _dev/js/theme/utils/dynamicImports/componentProxyFactory.js rename to _dev/js/utils/dynamicImports/componentProxyFactory.js diff --git a/_dev/js/theme/utils/dynamicImports/useBootstrapComponentDynamicImport.js b/_dev/js/utils/dynamicImports/useBootstrapComponentDynamicImport.js similarity index 100% rename from _dev/js/theme/utils/dynamicImports/useBootstrapComponentDynamicImport.js rename to _dev/js/utils/dynamicImports/useBootstrapComponentDynamicImport.js diff --git a/_dev/js/theme/utils/dynamicImports/useDynamicImportEventsHandler.js b/_dev/js/utils/dynamicImports/useDynamicImportEventsHandler.js similarity index 95% rename from _dev/js/theme/utils/dynamicImports/useDynamicImportEventsHandler.js rename to _dev/js/utils/dynamicImports/useDynamicImportEventsHandler.js index 161b070b..b9a5c705 100644 --- a/_dev/js/theme/utils/dynamicImports/useDynamicImportEventsHandler.js +++ b/_dev/js/utils/dynamicImports/useDynamicImportEventsHandler.js @@ -1,4 +1,4 @@ -import useEvent from '../../components/event/useEvent'; +import useEvent from '../event/useEvent'; const { on, off } = useEvent(); diff --git a/_dev/js/theme/utils/dynamicImports/useFunctionCallstackMap.js b/_dev/js/utils/dynamicImports/useFunctionCallstackMap.js similarity index 100% rename from _dev/js/theme/utils/dynamicImports/useFunctionCallstackMap.js rename to _dev/js/utils/dynamicImports/useFunctionCallstackMap.js diff --git a/_dev/js/theme/utils/dynamicImports/useInstanceMap.js b/_dev/js/utils/dynamicImports/useInstanceMap.js similarity index 100% rename from _dev/js/theme/utils/dynamicImports/useInstanceMap.js rename to _dev/js/utils/dynamicImports/useInstanceMap.js diff --git a/_dev/js/theme/components/event/useEvent.js b/_dev/js/utils/event/useEvent.js similarity index 100% rename from _dev/js/theme/components/event/useEvent.js rename to _dev/js/utils/event/useEvent.js diff --git a/_dev/js/theme/utils/formSerialize.js b/_dev/js/utils/formSerialize.js similarity index 100% rename from _dev/js/theme/utils/formSerialize.js rename to _dev/js/utils/formSerialize.js diff --git a/_dev/js/theme/utils/getUniqueId.js b/_dev/js/utils/getUniqueId.js similarity index 100% rename from _dev/js/theme/utils/getUniqueId.js rename to _dev/js/utils/getUniqueId.js diff --git a/_dev/js/theme/components/http/error/GenericHttpRequestError.js b/_dev/js/utils/http/error/GenericHttpRequestError.js similarity index 100% rename from _dev/js/theme/components/http/error/GenericHttpRequestError.js rename to _dev/js/utils/http/error/GenericHttpRequestError.js diff --git a/_dev/js/theme/components/http/useDefaultHttpRequest.js b/_dev/js/utils/http/useDefaultHttpRequest.js similarity index 100% rename from _dev/js/theme/components/http/useDefaultHttpRequest.js rename to _dev/js/utils/http/useDefaultHttpRequest.js diff --git a/_dev/js/theme/components/http/useHttpController.js b/_dev/js/utils/http/useHttpController.js similarity index 97% rename from _dev/js/theme/components/http/useHttpController.js rename to _dev/js/utils/http/useHttpController.js index 192556bd..222663f0 100644 --- a/_dev/js/theme/components/http/useHttpController.js +++ b/_dev/js/utils/http/useHttpController.js @@ -1,4 +1,4 @@ -import getUniqueId from '../../utils/getUniqueId'; +import getUniqueId from '../getUniqueId'; /** * @module useHttpController diff --git a/_dev/js/theme/components/http/useHttpPayloadDefinition.js b/_dev/js/utils/http/useHttpPayloadDefinition.js similarity index 100% rename from _dev/js/theme/components/http/useHttpPayloadDefinition.js rename to _dev/js/utils/http/useHttpPayloadDefinition.js diff --git a/_dev/js/theme/components/http/useHttpRequest.js b/_dev/js/utils/http/useHttpRequest.js similarity index 100% rename from _dev/js/theme/components/http/useHttpRequest.js rename to _dev/js/utils/http/useHttpRequest.js diff --git a/_dev/js/theme/utils/sprintf.js b/_dev/js/utils/sprintf.js similarity index 100% rename from _dev/js/theme/utils/sprintf.js rename to _dev/js/utils/sprintf.js diff --git a/_dev/webpack/webpack.parts.js b/_dev/webpack/webpack.parts.js index 588b9e61..39401bdc 100644 --- a/_dev/webpack/webpack.parts.js +++ b/_dev/webpack/webpack.parts.js @@ -169,6 +169,11 @@ exports.extractVendorsChunks = () => ({ filename: 'js/jquery.js', chunks: 'initial', }, + shared: { + name: 'shared', + chunks: 'initial', + minChunks: 2, + }, }, }, }, diff --git a/config/assets.yml b/config/assets.yml index fc1fb4bf..aaccccff 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -30,12 +30,15 @@ js: runtime: # This file is only used to handle HMR for multiple entry points fileName: runtime.js priority: 1 - swipervendor: - fileName: swipervendor.js - priority: 1 jquery: fileName: jquery.js priority: 1 + shared: # Shared code between all pages autogenerated by Webpack + fileName: shared.js + priority: 1 + swipervendor: + fileName: swipervendor.js + priority: 1 product: fileName: product.js priority: 200 From f74d2d79119c8dad6d5a8ca85be48cb6f7e3d681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Ste=CC=A8pien=CC=81?= Date: Tue, 24 Oct 2023 00:10:40 +0200 Subject: [PATCH 2/9] Lazyload removed lib removed --- _dev/css/theme/components/_index.scss | 1 - .../css/theme/components/lazyload/_index.scss | 1 - .../theme/components/lazyload/_lazyload.scss | 5 ----- _dev/js/theme/components/Lazyload.js | 21 ------------------- _dev/js/theme/index.js | 5 ----- .../miniatures/_partials/product-thumb.tpl | 5 +++-- .../catalog/_partials/miniatures/brand.tpl | 6 +++--- .../_partials/miniatures/pack-product.tpl | 5 +++-- .../_partials/product-cover-thumbnails.tpl | 21 +++++++++++-------- .../_partials/product-images-modal.tpl | 12 ++++++----- .../_partials/cart-detailed-product-line.tpl | 2 +- .../_partials/cart-summary-product-line.tpl | 2 +- .../_partials/order-details-return-table.tpl | 2 +- .../customer/_partials/product-table-line.tpl | 2 +- 14 files changed, 32 insertions(+), 58 deletions(-) delete mode 100644 _dev/css/theme/components/lazyload/_index.scss delete mode 100644 _dev/css/theme/components/lazyload/_lazyload.scss delete mode 100644 _dev/js/theme/components/Lazyload.js diff --git a/_dev/css/theme/components/_index.scss b/_dev/css/theme/components/_index.scss index 22c276d3..34450a05 100644 --- a/_dev/css/theme/components/_index.scss +++ b/_dev/css/theme/components/_index.scss @@ -9,5 +9,4 @@ @import "search/index"; @import "page-loader/index"; @import "links-list/index"; -@import "lazyload/index"; @import "alert-toast/index"; diff --git a/_dev/css/theme/components/lazyload/_index.scss b/_dev/css/theme/components/lazyload/_index.scss deleted file mode 100644 index 1ce293c7..00000000 --- a/_dev/css/theme/components/lazyload/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import "lazyload"; diff --git a/_dev/css/theme/components/lazyload/_lazyload.scss b/_dev/css/theme/components/lazyload/_lazyload.scss deleted file mode 100644 index 78dc3128..00000000 --- a/_dev/css/theme/components/lazyload/_lazyload.scss +++ /dev/null @@ -1,5 +0,0 @@ -img.lazyload { - &:not(.loaded) { - background: $gray-200; - } -} diff --git a/_dev/js/theme/components/Lazyload.js b/_dev/js/theme/components/Lazyload.js deleted file mode 100644 index 1a0eb120..00000000 --- a/_dev/js/theme/components/Lazyload.js +++ /dev/null @@ -1,21 +0,0 @@ -import LazyLoad from 'vanilla-lazyload'; - -class PageLazyLoad { - constructor({ selector = '.lazyload' } = {}) { - this.selector = selector; - this.lazyLoadInstance = null; - this.init(); - } - - init() { - this.lazyLoadInstance = new LazyLoad({ - elements_selector: this.selector, - }); - } - - update() { - this.lazyLoadInstance.update(); - } -} - -export default PageLazyLoad; diff --git a/_dev/js/theme/index.js b/_dev/js/theme/index.js index 7fd4cece..db020550 100644 --- a/_dev/js/theme/index.js +++ b/_dev/js/theme/index.js @@ -19,15 +19,10 @@ for (const i in EventEmitter.prototype) { } import usePasswordPolicy from './components/password/usePasswordPolicy'; import useThemeForm from './components/useThemeForm'; -import PageLazyLoad from './components/Lazyload'; import httpRequestErrorHandler from './handler/error/httpRequestErrorHandler'; import usePageLoader from "./components/usePageLoader"; import { DOMReady } from "../utils/DOM/DOMHelpers"; -prestashop.pageLazyLoad = new PageLazyLoad({ - selector: '.lazyload', -}); - prestashop.pageLoader = usePageLoader(); prestashop.on('handleError', httpRequestErrorHandler); diff --git a/templates/catalog/_partials/miniatures/_partials/product-thumb.tpl b/templates/catalog/_partials/miniatures/_partials/product-thumb.tpl index a02cea53..03c60784 100644 --- a/templates/catalog/_partials/miniatures/_partials/product-thumb.tpl +++ b/templates/catalog/_partials/miniatures/_partials/product-thumb.tpl @@ -5,7 +5,7 @@ {if !empty($product.default_image.legend)}{$product.default_image.legend}{else}{$product.name|truncate:30:'...'}{/if} {/images_block} diff --git a/templates/catalog/_partials/miniatures/brand.tpl b/templates/catalog/_partials/miniatures/brand.tpl index 1038a4a2..17b9d9f2 100644 --- a/templates/catalog/_partials/miniatures/brand.tpl +++ b/templates/catalog/_partials/miniatures/brand.tpl @@ -27,12 +27,12 @@
{$sizes = Image::getSize('home_default')} {$brand.name}

diff --git a/templates/catalog/_partials/miniatures/pack-product.tpl b/templates/catalog/_partials/miniatures/pack-product.tpl index 8c2e7b7a..fa17b280 100644 --- a/templates/catalog/_partials/miniatures/pack-product.tpl +++ b/templates/catalog/_partials/miniatures/pack-product.tpl @@ -29,8 +29,9 @@ {images_block webpEnabled=$webpEnabled}