1document.addEventListener('DOMContentLoaded', initNavigation); 2 3function initNavigation() { 4 const body = document.body; 5 const nav = document.getElementById('mainNavigation'); 6 const container = document.querySelector( 7 '.wp-block-navigation__responsive-container' 8 ); 9 10 if (!nav || !container) return; 11 12 const isSinglePost = body.classList.contains('single-post'); 13 const mobileQuery = window.matchMedia('(max-width: 1250px)'); 14 15 document.addEventListener('click', function (e) { 16 17 /* --------------------------- 18 Responsive Menu (Single Post Fix) 19 ---------------------------- */ 20 if (isSinglePost) { 21 if (e.target.closest('.wp-block-navigation__responsive-container-open')) { 22 container.classList.add('is-menu-open'); 23 return; 24 } 25 26 if (e.target.closest('.wp-block-navigation__responsive-container-close')) { 27 container.classList.remove('is-menu-open'); 28 return; 29 } 30 } 31 32 /* --------------------------- 33 Mobile Submenu Behavior 34 ---------------------------- */ 35 if (!mobileQuery.matches) return; 36 37 // If clicking actual submenu arrow, let WP handle it 38 if (e.target.closest('.wp-block-navigation__submenu-icon')) return; 39 40 const item = e.target.closest( 41 '#mainNavigation .wp-block-navigation-item.has-child' 42 ); 43 if (!item) return; 44 45 // Ignore clicks inside submenu content 46 if (e.target.closest('.wp-block-navigation__submenu-container')) return; 47 48 const toggle = item.querySelector( 49 '.wp-block-navigation__submenu-icon' 50 ); 51 if (!toggle) return; 52 53 e.preventDefault(); 54 toggle.click(); 55 }); 56 57 /* --------------------------- 58 Custom Submenu Toggle (if needed) 59 Replaces setupSubmenuToggle() 60 ---------------------------- */ 61 nav.addEventListener('click', function (e) { 62 63 if (!mobileQuery.matches) return; 64 65 const toggle = e.target.closest('.wp-block-navigation-submenu__toggle'); 66 if (!toggle) return; 67 68 const submenu = toggle.nextElementSibling; 69 70 if (submenu && submenu.classList.contains('wp-block-navigation-submenu')) { 71 submenu.classList.toggle('active'); 72 } 73 }); 74}
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.