achille-press/js/navigation.js
Michael Fields ac3cda4543 Rework Navigation Menu Part 2
* Separate scoping and assignment so that a decision does not need to be made as to whether we should intermix spaces and tabs on the left
 * Restore the previously removed nav-menu class addition to the first unordered list in `#site-navigation`.
 * Restore the `.navigation-main.toggled-on .nav-menu` selector.
 * Remove rules for the `.main-small-navigation ul` selector.
2013-06-25 01:45:52 -07:00

34 lines
No EOL
821 B
JavaScript

/**
* navigation.js
*
* Handles toggling the navigation menu for small screens.
*/
( function() {
var container, button, menu;
container = document.getElementById( 'site-navigation' )
if ( ! container )
return;
button = container.getElementsByTagName( 'h1' )[0];
if ( 'undefined' == typeof button )
return;
menu = container.getElementsByTagName( 'ul' )[0];
// Hide menu toggle button if menu is empty and return early.
if ( 'undefined' == typeof menu ) {
button.style.display = 'none';
return;
}
if ( -1 == menu.className.indexOf( 'nav-menu' ) )
menu.className += ' nav-menu';
button.onclick = function() {
if ( -1 != container.className.indexOf( 'toggled' ) )
container.className = container.className.replace( ' toggled', '' );
else
container.className += ' toggled';
};
} )();