1(function($) { 2 $(function() { 3 4 function isMobile() { 5 if ($(window).width() <= 767) { 6 return true; 7 } else { 8 return false; 9 } 10 } 11 12 function toggleMenu(){ 13 $mainNavs = $('a[data-main-nav-class="main-nav-class"]'); 14 if (isMobile()) { 15 $mainNavs.each(function() { 16 $(this).attr('data-toggle', 'dropdown'); 17 $(this).attr('aria-haspopup', 'dropdown-toggle'); 18 $(this).addClass('dropdown-toggle'); 19 }); 20 } else { 21 $mainNavs.each(function() { 22 $(this).removeAttr('data-toggle'); 23 $(this).removeAttr('aria-haspopup'); 24 $(this).removeClass('dropdown-toggle'); 25 }); 26 } 27 } 28 29 toggleMenu(); 30 31 $('#menu-hlavni-menu ul li.active').parent().parent().addClass('active'); 32 $('#menu-hlavni-menu').addClass('main-menu'); 33 $(window).resize(function () { 34 toggleMenu(); 35 }); 36 $('a[data-main-nav-class="main-nav-class"]').click(function(e) { 37 if(isMobile()) { 38 e.preventDefault(); 39 } 40 }); 41 }); 42})(jQuery); 43 44 45document.addEventListener('DOMContentLoaded', function() { 46 // Select all mega menu buttons 47 const menuButtons = document.querySelectorAll('.gov-navigation--has-megamenu button[aria-controls]'); 48 49 // Select all menu items within mega menus 50 const menuItems = document.querySelectorAll('.gov-mega-menu__heading ul li a'); 51 52 // Add click handlers for menu buttons 53 menuButtons.forEach(button => { 54 button.addEventListener('click', function(event) { 55 // Get the menu ID and menu element 56 const menuId = this.getAttribute('aria-controls'); 57 const megaMenu = document.getElementById(menuId); 58 59 // Check if this menu is already open 60 const isExpanded = this.getAttribute('aria-expanded') === 'true'; 61 62 // If not expanded, close other open menus first 63 if (!isExpanded) { 64 // Close any other open menus 65 menuButtons.forEach(otherButton => { 66 if (otherButton !== this && otherButton.getAttribute('aria-expanded') === 'true') { 67 const otherMenuId = otherButton.getAttribute('aria-controls'); 68 const otherMenu = document.getElementById(otherMenuId); 69 70 otherButton.setAttribute('aria-expanded', 'false'); 71 72 if (otherMenu) { 73 otherMenu.hidden = true; 74 otherMenu.setAttribute('aria-hidden', 'true'); 75 } 76 } 77 }); 78 } 79 80 // Toggle this menu 81 this.setAttribute('aria-expanded', !isExpanded); 82 83 if (megaMenu) { 84 megaMenu.hidden = isExpanded; 85 megaMenu.setAttribute('aria-hidden', isExpanded); 86 } 87 88 // Prevent default action to avoid navigation 89 event.preventDefault(); 90 // Stop propagation to prevent immediate closing by document click handler 91 event.stopPropagation(); 92 }); 93 }); 94 95 // Handle menu item interactions 96 menuItems.forEach(menuItem => { 97 menuItem.addEventListener('click', function(event) { 98 // Highlight the clicked item 99 menuItems.forEach(item => item.classList.remove('active')); 100 this.classList.add('active'); 101 102 // Log when a menu item is clicked 103 console.log('Menu item clicked:', this.textContent); 104 105 // Don't stop propagation here - let the link work as expected 106 }); 107 }); 108 109 // Close menus when clicking elsewhere on the page 110 document.addEventListener('click', function(event) { 111 // Only close if click is outside navigation and mega menu 112 if (!event.target.closest('.gov-navigation--has-megamenu') && 113 !event.target.closest('.gov-mega-menu')) { 114 menuButtons.forEach(button => { 115 if (button.getAttribute('aria-expanded') === 'true') { 116 const menuId = button.getAttribute('aria-controls'); 117 const megaMenu = document.getElementById(menuId); 118 119 button.setAttribute('aria-expanded', 'false'); 120 121 if (megaMenu) { 122 megaMenu.hidden = true; 123 megaMenu.setAttribute('aria-hidden', 'true'); 124 } 125 } 126 }); 127 } 128 }); 129}); 130 131 132document.addEventListener('DOMContentLoaded', function() { 133 // Get the navigation container and the trigger button 134 const navContainer = document.querySelector('.js-gov-header__navigation'); 135 const navTrigger = document.querySelector('.js-gov-header__navigation-trigger'); 136 137 // By default, hide the navigation on mobile 138 if (window.innerWidth <= 768) { 139 navContainer.style.display = 'none'; 140 } 141 142 // Add click event listener to the trigger button 143 navTrigger.addEventListener('click', function() { 144 // Toggle the navigation visibility 145 if (navContainer.style.display === 'none' || navContainer.style.display === '') { 146 navContainer.style.display = 'block'; 147 148 // Update the aria-expanded attribute for accessibility 149 const button = navTrigger.querySelector('button'); 150 if (button) { 151 button.setAttribute('aria-expanded', 'true'); 152 } 153 } else { 154 navContainer.style.display = 'none'; 155 156 // Update the aria-expanded attribute for accessibility 157 const button = navTrigger.querySelector('button'); 158 if (button) { 159 button.setAttribute('aria-expanded', 'false'); 160 } 161 } 162 }); 163 164 // Handle window resize to adjust the display state based on screen width 165 window.addEventListener('resize', function() { 166 if (window.innerWidth > 768) { 167 // Show navigation on larger screens 168 navContainer.style.display = 'block'; 169 } else { 170 // Hide navigation on mobile screens 171 navContainer.style.display = 'none'; 172 173 // Reset aria-expanded attribute 174 const button = navTrigger.querySelector('button'); 175 if (button) { 176 button.setAttribute('aria-expanded', 'false'); 177 } 178 } 179 }); 180});
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.