()
| 452 | } |
| 453 | |
| 454 | function 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 | |
| 486 | function initSearch() { |
| 487 | function clearSearch({ focus = true } = {}) { |
nothing calls this directly
no test coverage detected