1( function () { 2 function isPlaceholderLink( link ) { 3 if ( ! link || 'A' !== link.tagName ) { 4 return false; 5 } 6 7 const href = ( link.getAttribute( 'href' ) || '' ).trim().toLowerCase(); 8 9 return '' === href || '#' === href || '#0' === href || 'javascript:void(0)' === href || 'javascript:void(0);' === href; 10 } 11 12 function updateToggleState( toggle, shouldOpen ) { 13 const submenu = toggle.nextElementSibling; 14 const screenReaderText = toggle.querySelector( '.screen-reader-text' ); 15 const link = toggle.previousElementSibling; 16 17 if ( ! submenu || ! submenu.classList.contains( 'sub-menu' ) ) { 18 return; 19 } 20 21 if ( screenReaderText ) { 22 if ( ! toggle.dataset.openLabel ) { 23 toggle.dataset.openLabel = screenReaderText.textContent.trim(); 24 } 25 if ( ! toggle.dataset.closeLabel ) { 26 toggle.dataset.closeLabel = 'Close dropdown menu'; 27 } 28 29 screenReaderText.textContent = shouldOpen ? toggle.dataset.closeLabel : toggle.dataset.openLabel; 30 } 31 32 toggle.classList.toggle( 'open-dropdown', shouldOpen ); 33 toggle.setAttribute( 'aria-expanded', shouldOpen ? 'true' : 'false' ); 34 35 if ( isPlaceholderLink( link ) ) { 36 link.classList.toggle( 'open-dropdown', shouldOpen ); 37 link.setAttribute( 'aria-expanded', shouldOpen ? 'true' : 'false' ); 38 } 39 } 40 41 function closeSiblingToggles( toggle ) { 42 const parentItem = toggle.closest( 'li' ); 43 const parentList = parentItem ? parentItem.parentElement : null; 44 45 if ( ! parentItem || ! parentList ) { 46 return; 47 } 48 49 Array.from( parentList.children ).forEach( function ( sibling ) { 50 if ( sibling === parentItem ) { 51 return; 52 } 53 54 Array.from( sibling.children ).forEach( function ( child ) { 55 if ( child.classList && child.classList.contains( 'submenu-expand' ) ) { 56 updateToggleState( child, false ); 57 } 58 } ); 59 } ); 60 } 61 62 function handleToggleActivation( toggle ) { 63 const isOpen = toggle.classList.contains( 'open-dropdown' ); 64 65 if ( ! isOpen ) { 66 closeSiblingToggles( toggle ); 67 } 68 69 updateToggleState( toggle, ! isOpen ); 70 } 71 72 function initializeSidebarAccordions() { 73 const sidebar = document.getElementById( 'mobile-sidebar-fallback' ); 74 if ( ! sidebar ) { 75 return; 76 } 77 78 const toggles = sidebar.querySelectorAll( '.assembly-mobile-sidebar__menu .submenu-expand' ); 79 if ( ! toggles.length ) { 80 return; 81 } 82 83 toggles.forEach( function ( toggle, index ) { 84 const submenu = toggle.nextElementSibling; 85 const link = toggle.previousElementSibling; 86 if ( ! submenu || ! submenu.classList.contains( 'sub-menu' ) ) { 87 return; 88 } 89 90 if ( ! submenu.id ) { 91 submenu.id = 'assembly-mobile-submenu-' + ( index + 1 ); 92 } 93 94 toggle.setAttribute( 'aria-controls', submenu.id ); 95 toggle.setAttribute( 'aria-haspopup', 'true' ); 96 updateToggleState( toggle, false ); 97 98 if ( isPlaceholderLink( link ) ) { 99 link.setAttribute( 'role', 'button' ); 100 link.setAttribute( 'aria-controls', submenu.id ); 101 link.setAttribute( 'aria-haspopup', 'true' ); 102 link.setAttribute( 'aria-expanded', 'false' ); 103 104 link.addEventListener( 'click', function ( event ) { 105 event.preventDefault(); 106 handleToggleActivation( toggle ); 107 } ); 108 109 link.addEventListener( 'keydown', function ( event ) { 110 if ( ' ' !== event.key && 'Spacebar' !== event.key ) { 111 return; 112 } 113 114 event.preventDefault(); 115 handleToggleActivation( toggle ); 116 } ); 117 } 118 119 toggle.addEventListener( 'click', function ( event ) { 120 event.preventDefault(); 121 handleToggleActivation( toggle ); 122 } ); 123 } ); 124 } 125 126 if ( document.readyState === 'loading' ) { 127 document.addEventListener( 'DOMContentLoaded', initializeSidebarAccordions ); 128 } else { 129 initializeSidebarAccordions(); 130 } 131} )(); 132
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.