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,73 +1,83 @@
|
||||
import $ from 'jquery';
|
||||
import '@js/theme/vendors/bootstrap/bootstrap-imports';
|
||||
import 'bootstrap-touchspin';
|
||||
import 'jquery-hoverintent';
|
||||
import '@js/theme/components/dynamic-bootstrap-components';
|
||||
import bsCustomFileInput from 'bs-custom-file-input';
|
||||
import $ from "jquery";
|
||||
import "@js/theme/vendors/bootstrap/bootstrap-imports";
|
||||
import "bootstrap-touchspin";
|
||||
import "jquery-hoverintent";
|
||||
import "@js/theme/components/dynamic-bootstrap-components";
|
||||
import bsCustomFileInput from "bs-custom-file-input";
|
||||
|
||||
import '@js/theme/components/selectors';
|
||||
import '@js/theme/components/sliders';
|
||||
import '@js/theme/components/responsive';
|
||||
import '@js/theme/components/customer';
|
||||
import '@js/theme/components/quickview';
|
||||
import '@js/theme/components/product';
|
||||
import '@js/theme/components/cart/cart';
|
||||
import '@js/theme/components/cart/block-cart';
|
||||
import "@js/theme/components/selectors";
|
||||
import "@js/theme/components/sliders";
|
||||
import "@js/theme/components/responsive";
|
||||
import "@js/theme/components/customer";
|
||||
import "@js/theme/components/quickview";
|
||||
import "@js/theme/components/product";
|
||||
import "@js/theme/components/cart/cart";
|
||||
import "@js/theme/components/cart/block-cart";
|
||||
import "@js/theme/components/product_miniature_form";
|
||||
|
||||
import usePasswordPolicy from '@js/theme/components/usePasswordPolicy';
|
||||
import prestashop from 'prestashop';
|
||||
import EventEmitter from 'events';
|
||||
import Form from '@js/theme/components/form';
|
||||
import TopMenu from '@js/theme/components/TopMenu';
|
||||
import usePasswordPolicy from "@js/theme/components/usePasswordPolicy";
|
||||
import prestashop from "prestashop";
|
||||
import EventEmitter from "events";
|
||||
import Form from "@js/theme/components/form";
|
||||
import TopMenu from "@js/theme/components/TopMenu";
|
||||
|
||||
import PageLazyLoad from '@js/theme/components/Lazyload';
|
||||
import PageLoader from '@js/theme/components/PageLoader';
|
||||
import useStickyElement from '@js/theme/components/useStickyElement';
|
||||
import PageLazyLoad from "@js/theme/components/Lazyload";
|
||||
import PageLoader from "@js/theme/components/PageLoader";
|
||||
import useStickyElement from "@js/theme/components/useStickyElement";
|
||||
|
||||
/* eslint-disable */
|
||||
// "inherit" EventEmitter
|
||||
for (const i in EventEmitter.prototype) {
|
||||
prestashop[i] = EventEmitter.prototype[i];
|
||||
prestashop[i] = EventEmitter.prototype[i];
|
||||
}
|
||||
/* eslint-enable */
|
||||
|
||||
prestashop.pageLazyLoad = new PageLazyLoad({
|
||||
selector: '.lazyload',
|
||||
selector: ".lazyload",
|
||||
});
|
||||
|
||||
prestashop.pageLoader = new PageLoader();
|
||||
|
||||
function accLinksTriggerActive() {
|
||||
const url = window.location.pathname;
|
||||
$('.js-customer-links a').each((i, el) => {
|
||||
const $el = $(el);
|
||||
const currentUrl = window.location.pathname + window.location.search;
|
||||
|
||||
if ($el.attr('href').indexOf(url) !== -1) {
|
||||
$el.addClass('active');
|
||||
}
|
||||
});
|
||||
$(".js-customer-links a").each((i, el) => {
|
||||
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() {
|
||||
const header = document.querySelector('.js-header-top');
|
||||
const headerWrapper = document.querySelector('.js-header-top-wrapper');
|
||||
const header = document.querySelector(".js-header-top");
|
||||
const headerWrapper = document.querySelector(".js-header-top-wrapper");
|
||||
|
||||
if (header && headerWrapper) {
|
||||
useStickyElement(header, headerWrapper);
|
||||
}
|
||||
if (header && headerWrapper) {
|
||||
useStickyElement(header, headerWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
$(() => {
|
||||
initStickyHeader();
|
||||
accLinksTriggerActive();
|
||||
Form.init();
|
||||
bsCustomFileInput.init();
|
||||
const topMenu = new TopMenu('#_desktop_top_menu .js-main-menu');
|
||||
usePasswordPolicy('.field-password-policy');
|
||||
initStickyHeader();
|
||||
accLinksTriggerActive();
|
||||
Form.init();
|
||||
bsCustomFileInput.init();
|
||||
const topMenu = new TopMenu("#_desktop_top_menu .js-main-menu");
|
||||
usePasswordPolicy(".field-password-policy");
|
||||
|
||||
topMenu.init();
|
||||
topMenu.init();
|
||||
|
||||
$('.js-select-link').on('change', ({ target }) => {
|
||||
window.location.href = $(target).val();
|
||||
});
|
||||
$(".js-select-link").on("change", ({ target }) => {
|
||||
window.location.href = $(target).val();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user