Skip to content

Commit

Permalink
customer account jquery removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Oksydan committed Oct 9, 2023
1 parent 3edea9a commit e9bdb2d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 50 deletions.
18 changes: 0 additions & 18 deletions _dev/js/theme/components/customer.js

This file was deleted.

34 changes: 34 additions & 0 deletions _dev/js/theme/components/customer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import DOMReady from "../../utils/DOMReady";

Check failure on line 1 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Strings must use singlequote
import $ from "jquery";

Check failure on line 2 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

`jquery` import should occur before import of `../../utils/DOMReady`

Check failure on line 2 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

'$' is defined but never used

Check failure on line 2 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Strings must use singlequote

const initCustomerLinksTriggerActive = () => {
const url = window.location.pathname;
const customerLinks = document.querySelectorAll('.js-customer-links a');

customerLinks.forEach((el) => {
if (el.getAttribute('href').indexOf(url) !== -1) {
el.classList.add('active');
}
});
}

Check failure on line 13 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Missing semicolon

const initRmaForm = () => {
const returnForm = document.querySelector(prestashop.selectors.order.returnForm);

if (!returnForm) {
return;
}

returnForm.querySelector('thead input[type=checkbox]').addEventListener('click', ({ currentTarget }) => {
const checked = currentTarget.checked;

Check failure on line 23 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Use object destructuring
returnForm.querySelectorAll('tbody input[type=checkbox]').forEach((checkbox) => {
checkbox.checked = checked;
});
});
}

Check failure on line 28 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Missing semicolon


Check failure on line 30 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

More than 1 blank line not allowed
DOMReady(() => {
initCustomerLinksTriggerActive();
initRmaForm();
})

Check failure on line 34 in _dev/js/theme/components/customer/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Missing semicolon
21 changes: 21 additions & 0 deletions _dev/js/theme/components/header/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import DOMReady from "../../utils/DOMReady";

Check failure on line 1 in _dev/js/theme/components/header/index.js

View workflow job for this annotation

GitHub Actions / Code quality - ESLint

Strings must use singlequote
import useTopMenu from './useTopMenu';
import useStickyElement from "../useStickyElement";

const initStickyHeader = () => {
const header = document.querySelector('.js-header-top');
const headerWrapper = document.querySelector('.js-header-top-wrapper');

if (header && headerWrapper) {
const { init } = useStickyElement(header, headerWrapper);

init();
}
}

DOMReady(() => {
const { init: initTopMenu } = useTopMenu('.js-main-menu');

initTopMenu();
initStickyHeader();
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import useEvent from './event/useEvent';
import useEvent from '../event/useEvent';

const useTopMenu = (selector) => {
const { on, off } = useEvent();
Expand Down
9 changes: 6 additions & 3 deletions _dev/js/theme/components/useStickyElement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce from '@js/theme/utils/debounce';
import debounce from '../utils/debounce';

/**
* Returns sticky element data
Expand Down Expand Up @@ -65,11 +65,14 @@ export default (element, stickyWrapper, options = {}) => {
}
};

window.addEventListener('scroll', debounce(handleSticky, debounceTime));
handleSticky();
const init = () => {
window.addEventListener('scroll', debounce(handleSticky, debounceTime));
handleSticky();
}

return {
getExtraOffsetTop,
getIsSticky,
init,
};
};
31 changes: 3 additions & 28 deletions _dev/js/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import $ from 'jquery';

import EventEmitter from 'events';

import '@js/theme/core';
import './core/index';

import './vendors/bootstrap/bootstrap-imports';
import './components/dynamic-bootstrap-components';
import bsCustomFileInput from 'bs-custom-file-input';
import './components/header/index';
import './components/customer/index';
import './components/sliders';
import './components/responsive';
import './components/customer';
import './components/quickview';
import './components/product';
import prestashop from 'prestashop';
import useTopMenu from './components/useTopMenu';
/* eslint-enable */

/* eslint-disable */
Expand All @@ -25,7 +25,6 @@ import usePasswordPolicy from './components/password/usePasswordPolicy';
import Form from './components/form';
import PageLazyLoad from './components/Lazyload';
import PageLoader from './components/PageLoader';
import useStickyElement from './components/useStickyElement';
import httpRequestErrorHandler from './handler/error/httpRequestErrorHandler';

prestashop.pageLazyLoad = new PageLazyLoad({
Expand All @@ -36,35 +35,11 @@ prestashop.pageLoader = new PageLoader();

prestashop.on('handleError', httpRequestErrorHandler);

function accLinksTriggerActive() {
const url = window.location.pathname;
$('.js-customer-links a').each((i, el) => {
const $el = $(el);

if ($el.attr('href').indexOf(url) !== -1) {
$el.addClass('active');
}
});
}

function initStickyHeader() {
const header = document.querySelector('.js-header-top');
const headerWrapper = document.querySelector('.js-header-top-wrapper');

if (header && headerWrapper) {
useStickyElement(header, headerWrapper);
}
}

$(() => {
const { init: initTopMenu } = useTopMenu('.js-main-menu');

initStickyHeader();
accLinksTriggerActive();
Form.init();
bsCustomFileInput.init();
usePasswordPolicy('.field-password-policy');
initTopMenu();

$('.js-select-link').on('change', ({ target }) => {
window.location.href = $(target).val();
Expand Down

0 comments on commit e9bdb2d

Please sign in to comment.