1 2/** 3 * 19. navigation.js 4 * 5 * Handles toggling the navigation menu for small screens. 6 */ 7( function() { 8 var container, button, menu; 9 10 container = document.getElementById( 'site-navigation' ); 11 if ( ! container ) { 12 return; 13 } 14 15 button = container.getElementsByTagName( 'button' )[0]; 16 if ( 'undefined' === typeof button ) { 17 return; 18 } 19 20 menu = container.getElementsByTagName( 'ul' )[0]; 21 22 // Hide menu toggle button if menu is empty and return early. 23 if ( 'undefined' === typeof menu ) { 24 button.style.display = 'none'; 25 return; 26 } 27 28 menu.setAttribute( 'aria-expanded', 'false' ); 29 30 if ( -1 === menu.className.indexOf( 'nav-menu' ) ) { 31 menu.className += ' nav-menu'; 32 } 33 34 button.onclick = function() { 35 if ( -1 !== container.className.indexOf( 'toggled' ) ) { 36 container.className = container.className.replace( ' toggled', '' ); 37 button.setAttribute( 'aria-expanded', 'false' ); 38 menu.setAttribute( 'aria-expanded', 'false' ); 39 } else { 40 container.className += ' toggled'; 41 button.setAttribute( 'aria-expanded', 'true' ); 42 menu.setAttribute( 'aria-expanded', 'true' ); 43 } 44 }; 45} )(); 46
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.