MCPcopy Index your code
hub / github.com/jackvale/rectg / initSidebar

Function initSidebar

web/src/scripts/main.js:454–484  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

452}
453
454function initSidebar() {
455 function openSidebar() {
456 sidebar?.classList.add('open');
457 sidebarOverlay?.classList.add('open');
458 document.body.style.overflow = 'hidden';
459 }
460
461 function closeSidebar() {
462 sidebar?.classList.remove('open');
463 sidebarOverlay?.classList.remove('open');
464 document.body.style.overflow = '';
465 }
466
467 menuBtn?.addEventListener('click', openSidebar);
468 closeSidebarBtn?.addEventListener('click', closeSidebar);
469 sidebarOverlay?.addEventListener('click', closeSidebar);
470
471 document.querySelectorAll('.nav-item, .mobile-category-item').forEach((item) => {
472 item.addEventListener('click', (event) => {
473 const id = item.dataset.id || 'featured';
474 const href = item.getAttribute('href');
475 if (href && id !== 'featured') {
476 if (window.innerWidth <= 768) closeSidebar();
477 return;
478 }
479 event.preventDefault();
480 renderSection(id, { updateUrl: true, clearSearch: true, scroll: true });
481 if (window.innerWidth <= 768) closeSidebar();
482 });
483 });
484}
485
486function initSearch() {
487 function clearSearch({ focus = true } = {}) {

Callers

nothing calls this directly

Calls 2

closeSidebarFunction · 0.85
renderSectionFunction · 0.85

Tested by

no test coverage detected