PageSourceSearch

https://www.grandiraventure.voyage/wp-content/themes/grandir-avent…/menu-gorette.js?ver=1791181231

js grandiraventure.voyage collected 2026-10-05 06:21:29 UTC 3,923 bytes, 84 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2    const mediaQuery = window.matchMedia("(min-width: 1024px)").matches;
3    const sections = document.querySelectorAll(".menu-gorette");
4    if (!sections) return;
5    if (document.querySelector("body").classList.contains("wp-admin")) return;
6    for (const section of sections) {
7        document.body.style.setProperty("--menu-height", window.getComputedStyle(section, null).getPropertyValue("height"));
8        // set menu height css variable
9        const menuElementsCardsList = section.querySelectorAll(".menu-element.cards,.menu-element.liste");
10        const menuElementsSejours = section.querySelectorAll(".menu-element.sejours");
11        const burgerMenuButton = section.querySelector(".burger");
12        const labels = section.querySelectorAll(".sub-menu-label,.menu-label");
13
14
15
16        // Changement d'event de click en fonction de la taille de l'ecran
17        // car dans le menu, des éléments sur sous-menu deviennent des éléments de menu pricipal en mobile
18        if (mediaQuery) {
19            for (const el of menuElementsCardsList) {
20                el.querySelector(":scope .menu-label").addEventListener("click", (event) => toggleDropdown(event))
21            }
22            for (const el of menuElementsSejours) {
23                el.querySelector(":scope .menu-label").addEventListener("click", (event) => toggleDropdown(event))
24            }
25        } else {
26            for (const el of labels) {
27                el.addEventListener("click", (event) => toggleDropdown(event))
28            }
29
30        }
31        burgerMenuButton.addEventListener("click", handleBurgerButtonClick);
32
33
34
35        function toggleDropdown(event) {
36            const dropdownParent = event.target.parentElement;
37            if (dropdownParent.classList.contains("active")) return closeTheDropdown(dropdownParent);
38            openTheDropdown(dropdownParent)
39        }
40
41        function openTheDropdown(dropdownParent) {
42            const openedDropdowns = section.querySelectorAll(".items-has-children.active");
43            if (openedDropdowns.length !== 0) openedDropdowns.forEach(openedDropdown => closeTheDropdown(openedDropdown));
44            dropdownParent.classList.toggle("active");
45
46            window.addEventListener("click", handleClickWhenOpenned);
47            document.body.style.overflowY = "hidden"
48        }
49
50        function closeTheDropdown(dropdownParent) {
51            if (dropdownParent) {
52                document.removeEventListener("click", handleClickWhenOpenned);
53                if (dropdownParent.classList.contains("active")) {
54                    dropdownParent.classList.remove("active");
55                }
56                document.body.style.overflowY = "auto"
57            }
58        }
59
60        function handleBurgerButtonClick(event) {
61            this.classList.toggle("opened");
62            const isOpen = this.classList.contains("opened");
63            this.setAttribute("aria-expanded", isOpen);
64            section.dataset.menuIsOpen = isOpen;
65
66            if (isOpen) {
67                document.documentElement.style.overflowY = "hidden";
68                document.documentElement.style.position = "fixed";
69                document.body.style.overflowY = "hidden";
70                document.body.style.position = "fixed";
71            } else {
72                document.documentElement.style.removeProperty("overflow-y");
73                document.documentElement.style.removeProperty("position");
74                document.body.style.removeProperty("overflow-y");
75                document.body.style.removeProperty("position");
76            }
77        }
78        const handleClickWhenOpenned = (event) => {
79            const theOpenDropdown = document.querySelector(".items-has-children.active");
80            if (event.composedPath().includes(theOpenDropdown)) return;
81            closeTheDropdown(theOpenDropdown);
82        }
83    }
84});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.