MCPcopy Create free account
hub / github.com/Alfredredbird/CyberKelp / initMobileMenu

Function initMobileMenu

script.js:394–425  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

392// --- Mobile sidebar toggle ------------------------------------
393
394function initMobileMenu() {
395 const menuBtn = document.getElementById("menu-toggle");
396 const sidebar = document.getElementById("sidebar");
397 const overlay = document.getElementById("sidebar-overlay");
398 if (!menuBtn || !sidebar || !overlay) return;
399
400 function openSidebar() {
401 sidebar.classList.add("open");
402 overlay.classList.add("visible");
403 menuBtn.classList.add("open");
404 document.body.style.overflow = "hidden";
405 }
406
407 function closeSidebar() {
408 sidebar.classList.remove("open");
409 overlay.classList.remove("visible");
410 menuBtn.classList.remove("open");
411 document.body.style.overflow = "";
412 }
413
414 menuBtn.addEventListener("click", () => {
415 sidebar.classList.contains("open") ? closeSidebar() : openSidebar();
416 });
417
418 overlay.addEventListener("click", closeSidebar);
419
420 treeEl.addEventListener("click", (e) => {
421 if (e.target.classList.contains("note-link") && window.innerWidth <= 768) {
422 closeSidebar();
423 }
424 });
425}
426
427// --- Hash routing ---------------------------------------------
428

Callers 1

initFunction · 0.85

Calls 2

closeSidebarFunction · 0.85
openSidebarFunction · 0.85

Tested by

no test coverage detected