fix: Improved active class added to account
Found a bug where when you click on "details"button in order history, all the customer links become active. This fixes that.
This commit is contained in:
@ -1,28 +1,29 @@
|
|||||||
import $ from 'jquery';
|
import $ from "jquery";
|
||||||
import '@js/theme/vendors/bootstrap/bootstrap-imports';
|
import "@js/theme/vendors/bootstrap/bootstrap-imports";
|
||||||
import 'bootstrap-touchspin';
|
import "bootstrap-touchspin";
|
||||||
import 'jquery-hoverintent';
|
import "jquery-hoverintent";
|
||||||
import '@js/theme/components/dynamic-bootstrap-components';
|
import "@js/theme/components/dynamic-bootstrap-components";
|
||||||
import bsCustomFileInput from 'bs-custom-file-input';
|
import bsCustomFileInput from "bs-custom-file-input";
|
||||||
|
|
||||||
import '@js/theme/components/selectors';
|
import "@js/theme/components/selectors";
|
||||||
import '@js/theme/components/sliders';
|
import "@js/theme/components/sliders";
|
||||||
import '@js/theme/components/responsive';
|
import "@js/theme/components/responsive";
|
||||||
import '@js/theme/components/customer';
|
import "@js/theme/components/customer";
|
||||||
import '@js/theme/components/quickview';
|
import "@js/theme/components/quickview";
|
||||||
import '@js/theme/components/product';
|
import "@js/theme/components/product";
|
||||||
import '@js/theme/components/cart/cart';
|
import "@js/theme/components/cart/cart";
|
||||||
import '@js/theme/components/cart/block-cart';
|
import "@js/theme/components/cart/block-cart";
|
||||||
|
import "@js/theme/components/product_miniature_form";
|
||||||
|
|
||||||
import usePasswordPolicy from '@js/theme/components/usePasswordPolicy';
|
import usePasswordPolicy from "@js/theme/components/usePasswordPolicy";
|
||||||
import prestashop from 'prestashop';
|
import prestashop from "prestashop";
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from "events";
|
||||||
import Form from '@js/theme/components/form';
|
import Form from "@js/theme/components/form";
|
||||||
import TopMenu from '@js/theme/components/TopMenu';
|
import TopMenu from "@js/theme/components/TopMenu";
|
||||||
|
|
||||||
import PageLazyLoad from '@js/theme/components/Lazyload';
|
import PageLazyLoad from "@js/theme/components/Lazyload";
|
||||||
import PageLoader from '@js/theme/components/PageLoader';
|
import PageLoader from "@js/theme/components/PageLoader";
|
||||||
import useStickyElement from '@js/theme/components/useStickyElement';
|
import useStickyElement from "@js/theme/components/useStickyElement";
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
// "inherit" EventEmitter
|
// "inherit" EventEmitter
|
||||||
@ -32,25 +33,34 @@ for (const i in EventEmitter.prototype) {
|
|||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
|
||||||
prestashop.pageLazyLoad = new PageLazyLoad({
|
prestashop.pageLazyLoad = new PageLazyLoad({
|
||||||
selector: '.lazyload',
|
selector: ".lazyload",
|
||||||
});
|
});
|
||||||
|
|
||||||
prestashop.pageLoader = new PageLoader();
|
prestashop.pageLoader = new PageLoader();
|
||||||
|
|
||||||
function accLinksTriggerActive() {
|
function accLinksTriggerActive() {
|
||||||
const url = window.location.pathname;
|
const currentUrl = window.location.pathname + window.location.search;
|
||||||
$('.js-customer-links a').each((i, el) => {
|
|
||||||
const $el = $(el);
|
|
||||||
|
|
||||||
if ($el.attr('href').indexOf(url) !== -1) {
|
$(".js-customer-links a").each((i, el) => {
|
||||||
$el.addClass('active');
|
const $el = $(el);
|
||||||
|
const linkHref = $el.attr("href");
|
||||||
|
let linkPath = linkHref;
|
||||||
|
try {
|
||||||
|
const linkUrl = new URL(linkHref, window.location.origin);
|
||||||
|
linkPath = linkUrl.pathname + linkUrl.search;
|
||||||
|
} catch (e) {}
|
||||||
|
if (
|
||||||
|
currentUrl === linkPath ||
|
||||||
|
(linkPath !== "/" && currentUrl.startsWith(linkPath))
|
||||||
|
) {
|
||||||
|
$el.addClass("active");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initStickyHeader() {
|
function initStickyHeader() {
|
||||||
const header = document.querySelector('.js-header-top');
|
const header = document.querySelector(".js-header-top");
|
||||||
const headerWrapper = document.querySelector('.js-header-top-wrapper');
|
const headerWrapper = document.querySelector(".js-header-top-wrapper");
|
||||||
|
|
||||||
if (header && headerWrapper) {
|
if (header && headerWrapper) {
|
||||||
useStickyElement(header, headerWrapper);
|
useStickyElement(header, headerWrapper);
|
||||||
@ -62,12 +72,12 @@ $(() => {
|
|||||||
accLinksTriggerActive();
|
accLinksTriggerActive();
|
||||||
Form.init();
|
Form.init();
|
||||||
bsCustomFileInput.init();
|
bsCustomFileInput.init();
|
||||||
const topMenu = new TopMenu('#_desktop_top_menu .js-main-menu');
|
const topMenu = new TopMenu("#_desktop_top_menu .js-main-menu");
|
||||||
usePasswordPolicy('.field-password-policy');
|
usePasswordPolicy(".field-password-policy");
|
||||||
|
|
||||||
topMenu.init();
|
topMenu.init();
|
||||||
|
|
||||||
$('.js-select-link').on('change', ({ target }) => {
|
$(".js-select-link").on("change", ({ target }) => {
|
||||||
window.location.href = $(target).val();
|
window.location.href = $(target).val();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user