starting to refactor js menu

This commit is contained in:
Antoine M 2023-12-13 17:37:10 +01:00
parent 044f741cc6
commit 7d3e168465

View File

@ -161,22 +161,25 @@ export default function menuInit() {
// searchModule.removeAttribute('mobile-opened', '');
// }, 50);
}
function handleSearchOpening() {
// SEARCH TOGGLE open/close
searchModuleToggle.addEventListener('click', function (e) {
closeSubmenus();
// SEARCH TOGGLE open/close
searchModuleToggle.addEventListener('click', function (e) {
closeSubmenus();
// SEARCH IS CLOSED --> OPEN IT
if (isSearchOpen() === false) {
openSearch();
return;
}
// SEARCH IS CLOSED --> OPEN IT
if (isSearchOpen() === false) {
openSearch();
return;
}
// SEARCH IS OPEN --> CLOSE IT
if (isSearchOpen() === true) {
closeSearch();
}
});
}
// SEARCH IS OPEN --> CLOSE IT
if (isSearchOpen() === true) {
closeSearch();
}
});
handleSearchOpening();
/* -----------------------------------------------------------
HANDLE MOBILE
@ -184,11 +187,6 @@ export default function menuInit() {
const renovateurNavListContainer = header.querySelector('.menu-renovateur__navlist-container');
const HomegradeNavListContainer = header.querySelector('.menu-homegrade');
function isMobileNavOpened() {
console.log('is mobile nav opened');
console.log(
renovateurNavListContainer.hasAttribute('opened') &&
mobileMenuToggle.getAttribute('aria-expanded') === 'true'
);
return (
renovateurNavListContainer.hasAttribute('opened') &&
mobileMenuToggle.getAttribute('aria-expanded') === 'true'