2024-10-18 18:44:03 +02:00
|
|
|
import { useLayoutStore } from '../stores/layout';
|
|
|
|
|
|
|
|
export function handleReactiveness() {
|
|
|
|
const layoutStore = useLayoutStore();
|
|
|
|
layoutStore.setupResizeListenner();
|
|
|
|
|
|
|
|
(function setupEtapeListeCollapse() {
|
|
|
|
const listeToggleButton = document.querySelector('#retractable-message');
|
|
|
|
|
|
|
|
const listeEtape = document.querySelector('#etapes-liste');
|
|
|
|
|
2024-10-19 03:49:16 +02:00
|
|
|
if (!layoutStore.isDesktop) layoutStore.collapseEtapeListe(listeEtape, layoutStore);
|
2024-10-18 18:44:03 +02:00
|
|
|
|
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
if (layoutStore.isDesktop && layoutStore.isEtapeListRetracted) {
|
2024-10-19 03:49:16 +02:00
|
|
|
layoutStore.expandEtapeListe(listeEtape, layoutStore);
|
2024-10-18 18:44:03 +02:00
|
|
|
} else if (!layoutStore.isDesktop && !layoutStore.isEtapeListRetracted) {
|
2024-10-19 03:49:16 +02:00
|
|
|
layoutStore.collapseEtapeListe(listeEtape, layoutStore);
|
2024-10-18 18:44:03 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
listeToggleButton.addEventListener('click', () => {
|
|
|
|
if (!layoutStore.isDesktop) {
|
|
|
|
if (!layoutStore.isEtapeListRetracted) {
|
2024-10-19 03:49:16 +02:00
|
|
|
layoutStore.collapseEtapeListe(listeEtape, layoutStore);
|
2024-10-18 18:44:03 +02:00
|
|
|
} else {
|
2024-10-19 03:49:16 +02:00
|
|
|
layoutStore.expandEtapeListe(listeEtape, layoutStore);
|
2024-10-18 18:44:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
2024-10-19 03:49:16 +02:00
|
|
|
|
2024-10-18 18:44:03 +02:00
|
|
|
}
|
|
|
|
|
2024-10-17 02:50:39 +02:00
|
|
|
export function setMenuToggle() {
|
2024-10-22 11:50:33 +02:00
|
|
|
const layoutStore = useLayoutStore();
|
2024-10-17 02:50:39 +02:00
|
|
|
const menuBurger = document.querySelector('#hamburger');
|
2024-10-22 11:50:33 +02:00
|
|
|
const menuContainer = document.querySelector('#block-caravane-mainnavigation > #menu > ul');
|
|
|
|
|
|
|
|
layoutStore.setUpHamburgerToggle(menuBurger, menuContainer);
|
2024-10-17 02:50:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setHamburgerWhenLogged(drupalSettings) {
|
|
|
|
if (drupalSettings.user.uid != 0) {
|
|
|
|
const menuBurger = document.querySelector('#hamburger');
|
|
|
|
const menuTitle = document.querySelector('#menu-title');
|
|
|
|
const menuContainer = document.querySelector('#block-caravane-mainnavigation > #menu > ul');
|
|
|
|
const header = document.querySelector('.dialog-off-canvas-main-canvas');
|
|
|
|
const headerTop = header.getBoundingClientRect().top;
|
|
|
|
|
|
|
|
menuTitle.style.top = `${headerTop}px`;
|
|
|
|
menuBurger.style.top = `${headerTop}px`;
|
|
|
|
menuContainer.style.paddingTop = `${headerTop}px`;
|
|
|
|
}
|
|
|
|
}
|