1document.addEventListener('DOMContentLoaded', () => { 2 const allLinks = document.querySelectorAll('#fresponsive a'); // Wszystkie linki w menu 3 const mainMenuLinks = Array.from(document.querySelectorAll('#fresponsive > li > a')); // Tylko gÅówne linki 4 5 // Set tabindex dla wszystkich linków 6 allLinks.forEach(link => link.setAttribute('tabindex', '0')); 7 8 // Ustaw aria-expanded na true dla wszystkich linków, które majÄ podmenu 9 document.querySelectorAll('.menu-item-has-children > a').forEach(link => { 10 link.setAttribute('aria-expanded', 'true'); // Menu jest zawsze rozwiniÄte 11 link.removeAttribute('aria-haspopup'); // UsuÅ atrybut aria-haspopup, żeby nie sugerowaÄ, że jest rozwijany 12 }); 13 14 // ObsÅuga nawigacji za pomocÄ klawiatury 15 document.addEventListener('keydown', (e) => { 16 const focusedElement = document.activeElement; 17 if (!focusedElement || !focusedElement.closest('#fresponsive')) return; // WyjÅcie, jeÅli nie ma skupionego elementu w menu 18 19 const currentItem = focusedElement.closest('li'); 20 const parentMenu = currentItem.closest('ul'); 21 const allItems = Array.from(parentMenu.querySelectorAll('a')); 22 const currentIndex = allItems.indexOf(focusedElement); 23 24 // ObsÅuguje nawigacjÄ za pomocÄ strzaÅek w górÄ i w dóŠw obrÄbie podmenu 25 const handleArrowNavigation = (direction) => { 26 if (direction === 'down') { 27 if (currentItem.classList.contains('menu-item-has-children')) { 28 const firstDropdownLink = currentItem.querySelector('.dropdown-menu a'); 29 if (firstDropdownLink) firstDropdownLink.focus(); 30 } else { 31 if (allItems[currentIndex + 1]) allItems[currentIndex + 1].focus(); 32 } 33 } else if (direction === 'up') { 34 if (allItems[currentIndex - 1]) { 35 allItems[currentIndex - 1].focus(); 36 } else { 37 const parentItem = currentItem.closest('.dropdown-menu') && currentItem.closest('.dropdown-menu').closest('li.menu-item-has-children'); 38 if (parentItem) parentItem.querySelector('a').focus(); 39 } 40 } 41 }; 42 43 // ObsÅuguje nawigacjÄ strzaÅkami w lewo i w prawo po gÅównych elementach menu 44 const handleArrowMainNavigation = (direction) => { 45 const currentMainIndex = mainMenuLinks.indexOf(focusedElement); 46 const nextMainItem = direction === 'right' 47 ? mainMenuLinks[(currentMainIndex + 1) % mainMenuLinks.length] 48 : mainMenuLinks[(currentMainIndex - 1 + mainMenuLinks.length) % mainMenuLinks.length]; 49 if (nextMainItem) nextMainItem.focus(); 50 }; 51 52 switch (e.key) { 53 case 'ArrowRight': 54 handleArrowMainNavigation('right'); 55 break; 56 57 case 'ArrowLeft': 58 handleArrowMainNavigation('left'); 59 break; 60 61 case 'ArrowDown': 62 handleArrowNavigation('down'); 63 break; 64 65 case 'ArrowUp': 66 handleArrowNavigation('up'); 67 break; 68 69 case 'Escape': 70 const parentItem = currentItem.closest('.dropdown-menu') && currentItem.closest('.dropdown-menu').closest('li.menu-item-has-children'); 71 if (parentItem) parentItem.querySelector('a').focus(); // Escape do linku rodzica 72 break; 73 } 74 }); 75});
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.