Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removeing jquery form theme code #301

Merged
merged 43 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e8799a4
top menu removed jquery
Oksydan Oct 9, 2023
bc6dd1c
Lint fix
Oksydan Oct 9, 2023
3edea9a
relative import path
Oksydan Oct 9, 2023
e9bdb2d
customer account jquery removed
Oksydan Oct 9, 2023
63680e2
vanilla.js pageloader
Oksydan Oct 9, 2023
315b096
Vanilla.js form
Oksydan Oct 9, 2023
d062416
form select link
Oksydan Oct 9, 2023
ad9fd99
Removing jquery, slider componnet
Oksydan Oct 9, 2023
98ba80a
Slider minor changes to folder structure
Oksydan Oct 9, 2023
1612b7f
responsive component vanilla.js
Oksydan Oct 9, 2023
b5a66ff
Vanilla.js
Oksydan Oct 9, 2023
d7260df
Quickview vanilla.js
Oksydan Oct 9, 2023
e0cd01c
eslint fix
Oksydan Oct 9, 2023
21ff91f
eslint fix
Oksydan Oct 9, 2023
f1885f0
Removed not used js code
Oksydan Oct 10, 2023
db815db
Removed jquery form product entry
Oksydan Oct 12, 2023
42496cf
Removed not useful code
Oksydan Oct 12, 2023
d327c81
jquery removed from listing entry
Oksydan Oct 12, 2023
d4ed5e0
Bootstrap dynamic imports POC
Oksydan Oct 16, 2023
fbf2ca8
Checkout events - removed jquery
Oksydan Oct 16, 2023
6a2f048
Not used cache key removed
Oksydan Oct 16, 2023
41edf41
Bootstrap dynamic imports changes
Oksydan Oct 16, 2023
3564065
Linting fix
Oksydan Oct 16, 2023
fe6b1d5
Dynamic import for bootstrap components
Oksydan Oct 21, 2023
068c386
listing jquery removed
Oksydan Oct 21, 2023
c393e78
use password jquery removed
Oksydan Oct 21, 2023
118d4cd
componentProxyFactory - missing jsdocs added
Oksydan Oct 21, 2023
703a065
Moving jquery event handlers to bootstrap
Oksydan Oct 22, 2023
648afcc
quickview fix
Oksydan Oct 22, 2023
c2f999b
product page jquery removed, minor refacto
Oksydan Oct 22, 2023
fa00ae0
product details tabs backward compatibility
Oksydan Oct 22, 2023
6985b08
removed not used jquery dependencies
Oksydan Oct 22, 2023
b5bc16e
jquery removed from checkout entry
Oksydan Oct 22, 2023
8c5d2a3
eslint fix
Oksydan Oct 22, 2023
09fddf0
jsdoc to useAlertToast
Oksydan Oct 22, 2023
2fd8850
js docs improvements
Oksydan Oct 22, 2023
8fed5f9
minor jsdocs changes
Oksydan Oct 22, 2023
fd708da
jsdocs part 2
Oksydan Oct 22, 2023
82fb242
improved js docs for cart
Oksydan Oct 22, 2023
403e5dd
address core js docs changes
Oksydan Oct 22, 2023
8119091
http methods jsdocs changes
Oksydan Oct 22, 2023
25b67db
minor jsdocs changes to checkout
Oksydan Oct 22, 2023
f86dca8
eslint fix
Oksydan Oct 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion _dev/css/theme/utility/_dynamic-import-fix.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
}

//FIX TO TOAST, opacity by default
.toast {
.toast:not(.show),
.fade:not(.show):not(.active) {
opacity: 0;
display: none;
}
125 changes: 59 additions & 66 deletions _dev/js/checkout/index.js
Original file line number Diff line number Diff line change
@@ -1,90 +1,83 @@
/**
* 2007-2017 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2017 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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';

const { on } = useEvent();

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

if (url) {
// TODO: Handle request if no pretty URL
url += '?content_only=1';
$.get(url, (content) => {
$(prestashop.selectors.modal)
.find(prestashop.selectors.modalContent)
.html($(content).find('.page-cms').contents());
}).fail((resp) => {
prestashop.emit('handleError', { eventType: 'clickTerms', resp });
});
const modal = document.querySelector(prestashop.selectors.modal);
const urlObject = new URL(url);
const searchParams = new URLSearchParams(urlObject.searchParams);
searchParams.set('content_only', '1');
urlObject.search = searchParams.toString();

const { request } = useHttpRequest(urlObject.toString());

try {
const res = await request.get().res();
const content = await res.text();

const modalContent = modal.querySelector(prestashop.selectors.modalContent);
const contentElement = parseToHtml(content);
modalContent.innerHTML = contentElement.querySelector('.page-cms')?.innerHTML || '';

const modalInstance = window.bootstrap.Modal.getOrCreateInstance(modal);
modalInstance.show();
} catch (error) {
prestashop.emit('handleError', { eventType: 'changeAddresses', error });
}
}
};

$(prestashop.selectors.modal).modal('show');
});
each(prestashop.selectors.checkout.termsLink, (link) => on(link, 'click', clickTermLinkHandler));

$(prestashop.selectors.checkout.giftCheckbox).on('click', () => {
$('#gift').slideToggle();
});
const giftCheckbox = document.querySelector(prestashop.selectors.checkout.giftCheckbox);

if (giftCheckbox) {
on(giftCheckbox, 'change', ({ target }) => {
const isChecked = target.checked;
const giftBlock = document.querySelector('#gift');
const collapseInstance = window.bootstrap.Collapse.getOrCreateInstance(giftBlock);

collapseInstance.toggle(isChecked);
});
}
}

$(document).ready(() => {
if ($('body#checkout').length === 1) {
DOMReady(() => {
if (prestashop.page.page_name === 'checkout') {
setUpCheckout();
}

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

// Hide all carrier extra content ...
document.querySelectorAll(prestashop.selectors.checkout.carrierExtraContent).forEach((element) => {
element.classList.add('d-none');
each(prestashop.selectors.checkout.deliveryOption, (element) => {
element.classList.remove('selected');
});

// and show the one related to the selected carrier
params.deliveryOption.nextElementSibling.classList.remove('d-none');
});
prestashop.on('changedCheckoutStep', (params) => {
if (typeof params.event.currentTarget !== 'undefined') {
$('.collapse', params.event.currentTarget).not('.show').not('.collapse .collapse').collapse('show');
}
event.deliveryOption.classList.add('selected');
});
});

$(document).on('change', '.checkout-option input[type="radio"]', (event) => {
const $target = $(event.currentTarget);
const $block = $target.closest('.checkout-option');
const $relatedBlocks = $block.parent();
prestashop.on('updatedDeliveryForm', (event) => {
if (typeof event.deliveryOption === 'undefined' || event.deliveryOption === null) {
return;
}

$relatedBlocks.find('.checkout-option').removeClass('selected');
$block.addClass('selected');
});
each(prestashop.selectors.checkout.carrierExtraContent, (element) => {
element.classList.add('d-none');
});

$(document).on('click', '.js-checkout-step-header', (event) => {
const stepIdentifier = $(event.currentTarget).data('identifier');
$(`#${stepIdentifier}`).addClass('-current');
$(`#content-${stepIdentifier}`).collapse('show').scrollTop();
event.deliveryOption.nextElementSibling.classList.remove('d-none');
});
});
32 changes: 18 additions & 14 deletions _dev/js/listing/components/filters/Filters.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import prestashop from 'prestashop';
import $ from 'jquery';
import FiltersRangeSliders from '@js/listing/components/filters/FiltersRangeSliders';
import FiltersRangeSliders from './FiltersRangeSliders';
import useEvent from '../../../theme/components/event/useEvent';

class Filters {
constructor() {
this.$body = $('body');
this.body = document.querySelector('body');
this.setEvents();
this.rangeSliders = FiltersRangeSliders;
this.rangeSliders.init();
}

setEvents() {
const { on } = useEvent();

prestashop.on('updatedProductList', () => {
prestashop.pageLoader.hideLoader();
this.rangeSliders.init();
Expand All @@ -20,34 +22,36 @@ class Filters {
prestashop.pageLoader.showLoader();
});

this.$body.on('click', '.js-search-link', (event) => {
on(this.body, 'click', '.js-search-link', (event) => {
event.preventDefault();
prestashop.emit('updateFacets', $(event.target).closest('a').get(0).href);
prestashop.emit('updateFacets', event.target.closest('a').href);
});

this.$body.on('change', '[data-action="search-select"]', ({ target }) => {
prestashop.emit('updateFacets', $(target).find('option:selected').data('href'));
on(this.body, 'change', '[data-action="search-select"]', ({ target }) => {
const selectedElement = target.options[target.selectedIndex];

prestashop.emit('updateFacets', selectedElement.dataset.href);
});

this.$body.on('click', '.js-search-filters-clear-all', (event) => {
on(this.body, 'click', '.js-search-filters-clear-all', (event) => {
prestashop.emit('updateFacets', this.constructor.parseSearchUrl(event));
});

this.$body.on('change', '#search_filters input[data-search-url]', (event) => {
on(this.body, 'change', '#search_filters input[data-search-url]', (event) => {
prestashop.emit('updateFacets', this.constructor.parseSearchUrl(event));
});
}

static parseSearchUrl(event) {
if (event.target.dataset.searchUrl !== undefined) {
return event.target.dataset.searchUrl;
static parseSearchUrl({ target }) {
if (target.dataset.searchUrl !== undefined) {
return target.dataset.searchUrl;
}

if ($(event.target).parent()[0].dataset.searchUrl === undefined) {
if (target.parent.dataset.searchUrl === undefined) {
throw new Error('Can not parse search URL');
}

return $(event.target).parent()[0].dataset.searchUrl;
return target.parent.dataset.searchUrl;
}
}

Expand Down
11 changes: 5 additions & 6 deletions _dev/js/listing/components/filters/FiltersRangeSliders.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import $ from 'jquery';
import RangeSlider from '@js/listing/components/filters/RangeSlider';
import RangeSlider from './RangeSlider';
import { each } from '../../../theme/utils/DOMHelpers';

class FiltersRangeSliders {
static init() {
const $rangeSliders = $('.js-range-slider');
each('.js-range-slider', (slider) => {
const rangeSlider = new RangeSlider(slider);

$rangeSliders.each((i, el) => {
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "slider" }] */
const slider = new RangeSlider(el);
rangeSlider.init();
});
}
}
Expand Down
Loading