PageSourceSearch

https://hypup.fr/assets/scripts/navbar/navbar-15f0b21100ff4d671d0e3ead7f419073.js

js hypup.fr collected 2026-10-02 01:01:58 UTC 2,874 bytes, 100 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2  const menu = document.querySelector(".navbar .menu-icon-container");
3  const menuLinks = document.querySelector(".navbar .menu-links");
4  const navbar = document.querySelector(".navbar");
5  const logo = document.getElementById("connected");
6  const closeMenuBtn = document.getElementById("close-menu-links");
7
8  // NOUVEAU : Fonction centralisée pour fermer le menu
9  function closeMenu() {
10    menuLinks.classList.remove("active");
11    menu.classList.remove("active");
12  }
13
14  // NOUVEAU : Fonction centralisée pour basculer (ouvrir/fermer)
15  function toggleMenu() {
16    menuLinks.classList.toggle("active");
17    menu.classList.toggle("active");
18  }
19
20  // 1. Ouverture / Fermeture via l'icône menu (mobile)
21  menu.addEventListener("click", toggleMenu);
22
23  // 2. Ouverture / Fermeture via le logo (desktop)
24  if (logo) {
25    logo.addEventListener("click", toggleMenu);
26  }
27
28  // Fermeture au clic sur le bouton croix #close-menu-links
29  if (closeMenuBtn) {
30    closeMenuBtn.addEventListener("click", closeMenu);
31  }
32
33  // --- Fermer au clic à l'extérieur ---
34  document.addEventListener("click", (event) => {
35    const isClickInsideMenu = menuLinks.contains(event.target);
36    const isClickOnIcon = menu.contains(event.target);
37    const isClickOnLogo = logo ? logo.contains(event.target) : false;
38
39    if (!isClickInsideMenu && !isClickOnIcon && !isClickOnLogo) {
40      closeMenu();
41    }
42  });
43
44  // --- Fermer lors d'un redimensionnement ---
45  let currentWidth = window.innerWidth;
46  window.addEventListener("resize", () => {
47    if (window.innerWidth !== currentWidth) {
48      closeMenu();
49      currentWidth = window.innerWidth;
50    }
51  });
52
53  // 3. Gestion de l'apparition / disparition de la navbar au scroll
54  let lastScrollY = window.scrollY;
55  let ticking = false;
56  let isHidden = false;
57
58  window.addEventListener(
59    "scroll",
60    () => {
61      if (ticking) return;
62      if (document.body.dataset.filterLocked === "true") return;
63
64      requestAnimationFrame(() => {
65        const currentY = window.scrollY;
66        const delta = Math.abs(currentY - lastScrollY);
67
68        if (delta < 5) {
69          ticking = false;
70          return;
71        }
72
73        if (currentY > lastScrollY && currentY > 60) {
74          if (!isHidden) {
75            navbar.classList.add("hidden");
76            closeMenu(); // On ferme le menu quand la navbar disparait
77            isHidden = true;
78          }
79        } else {
80          if (isHidden) {
81            navbar.classList.remove("hidden");
82            isHidden = false;
83          }
84        }
85
86        lastScrollY = currentY;
87        ticking = false;
88      });
89
90      ticking = true;
91    },
92    { passive: true },
93  );
94
95  window.showNavbar = function () {
96    navbar.classList.remove("hidden");
97    isHidden = false;
98    lastScrollY = window.scrollY;
99  };
100});

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.