Skip to content

Commit

Permalink
Merge pull request #231 from Oksydan/core-js-changes
Browse files Browse the repository at this point in the history
[WIP] clearing usage of jQuery, removing core-js
  • Loading branch information
Oksydan authored Sep 11, 2023
2 parents e2ce7e9 + e5847f0 commit 7260884
Show file tree
Hide file tree
Showing 82 changed files with 2,829 additions and 12,439 deletions.
9 changes: 9 additions & 0 deletions _dev/css/checkout/components/checkout/_checkout-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
cursor: not-allowed;
opacity: 0.5;
}
.step-edit {
display: none;
}
}

&.-current {
Expand All @@ -41,6 +44,9 @@
.content {
display: block;
}
.step-edit {
display: none;
}
}

&.-reachable.-complete {
Expand All @@ -51,6 +57,9 @@
.content {
display: none;
}
.step-edit {
display: block;
}
}

&.-current.-reachable.-complete {
Expand Down
21 changes: 12 additions & 9 deletions _dev/js/checkout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,29 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
import $ from 'jquery';
import prestashop from 'prestashop';

function setUpCheckout() {
$(prestashop.themeSelectors.checkout.termsLink).on('click', (event) => {
$(prestashop.selectors.checkout.termsLink).on('click', (event) => {
event.preventDefault();
let url = $(event.target).attr('href');

if (url) {
// TODO: Handle request if no pretty URL
url += '?content_only=1';
$.get(url, (content) => {
$(prestashop.themeSelectors.modal)
.find(prestashop.themeSelectors.modalContent)
$(prestashop.selectors.modal)
.find(prestashop.selectors.modalContent)
.html($(content).find('.page-cms').contents());
}).fail((resp) => {
prestashop.emit('handleError', { eventType: 'clickTerms', resp });
});
}

$(prestashop.themeSelectors.modal).modal('show');
$(prestashop.selectors.modal).modal('show');
});

$(prestashop.themeSelectors.checkout.giftCheckbox).on('click', () => {
$(prestashop.selectors.checkout.giftCheckbox).on('click', () => {
$('#gift').slideToggle();
});
}
Expand All @@ -56,13 +55,17 @@ $(document).ready(() => {
}

prestashop.on('updatedDeliveryForm', (params) => {
if (typeof params.deliveryOption === 'undefined' || params.deliveryOption.length === 0) {
if (typeof params.deliveryOption === 'undefined' || params.deliveryOption === null) {
return;
}

// Hide all carrier extra content ...
$(prestashop.themeSelectors.checkout.carrierExtraContent).hide();
document.querySelectorAll(prestashop.selectors.checkout.carrierExtraContent).forEach((element) => {
element.classList.add('d-none');
});

// and show the one related to the selected carrier
params.deliveryOption.next(prestashop.themeSelectors.checkout.carrierExtraContent).show();
params.deliveryOption.nextElementSibling.classList.remove('d-none');
});
prestashop.on('changedCheckoutStep', (params) => {
if (typeof params.event.currentTarget !== 'undefined') {
Expand Down
14 changes: 7 additions & 7 deletions _dev/js/listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ import prestashop from 'prestashop';
import Filters from '@js/listing/components/filters/Filters';

function updateProductListDOM(data) {
$(prestashop.themeSelectors.listing.searchFilters).replaceWith(
$(prestashop.selectors.listing.searchFilters).replaceWith(
data.rendered_facets,
);
$(prestashop.themeSelectors.listing.activeSearchFilters).replaceWith(
$(prestashop.selectors.listing.activeSearchFilters).replaceWith(
data.rendered_active_filters,
);
$(prestashop.themeSelectors.listing.listTop).replaceWith(
$(prestashop.selectors.listing.listTop).replaceWith(
data.rendered_products_top,
);

const renderedProducts = $(data.rendered_products);
const productSelectors = $(prestashop.themeSelectors.listing.product);
const productSelectors = $(prestashop.selectors.listing.product);

if (productSelectors.length > 0) {
productSelectors.removeClass().addClass(productSelectors.first().attr('class'));
} else {
productSelectors.removeClass().addClass(renderedProducts.first().attr('class'));
}

$(prestashop.themeSelectors.listing.list).replaceWith(renderedProducts);
$(prestashop.themeSelectors.listing.listBottom).replaceWith(data.rendered_products_bottom);
$(prestashop.selectors.listing.list).replaceWith(renderedProducts);
$(prestashop.selectors.listing.listBottom).replaceWith(data.rendered_products_bottom);

if (data.rendered_products_header) {
$(prestashop.themeSelectors.listing.listHeader).replaceWith(data.rendered_products_header);
$(prestashop.selectors.listing.listHeader).replaceWith(data.rendered_products_header);
}

prestashop.emit('updatedProductList', data);
Expand Down
1 change: 0 additions & 1 deletion _dev/js/product/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import $ from 'jquery';
import ProductGallery from '@js/product/components/ProductGallery';

function activateFirstProductTab() {
Expand Down
Loading

0 comments on commit 7260884

Please sign in to comment.