Merge pull request #242 from mfields/navigation-menu

Rework Navigation Menu. Closes #200, #205, #237, #243.
This commit is contained in:
Konstantin Obenland 2013-06-26 09:44:59 -07:00
commit 55596d6c67
2 changed files with 25 additions and 26 deletions

View File

@ -4,29 +4,31 @@
* Handles toggling the navigation menu for small screens. * Handles toggling the navigation menu for small screens.
*/ */
( function() { ( function() {
var container = document.getElementById( 'site-navigation' ), var container, button, menu;
button = container.getElementsByTagName( 'h1' )[0],
menu = container.getElementsByTagName( 'ul' )[0];
if ( undefined == button || undefined == menu ) container = document.getElementById( 'site-navigation' )
return false; 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() { button.onclick = function() {
if ( -1 == menu.className.indexOf( 'nav-menu' ) ) if ( -1 != container.className.indexOf( 'toggled' ) )
menu.className = 'nav-menu'; container.className = container.className.replace( ' toggled', '' );
else
if ( -1 != button.className.indexOf( 'toggled-on' ) ) { container.className += ' toggled';
button.className = button.className.replace( ' toggled-on', '' );
menu.className = menu.className.replace( ' toggled-on', '' );
container.className = container.className.replace( 'main-small-navigation', 'navigation-main' );
} else {
button.className += ' toggled-on';
menu.className += ' toggled-on';
container.className = container.className.replace( 'navigation-main', 'main-small-navigation' );
}
}; };
// Hide menu toggle button if menu is empty.
if ( ! menu.childNodes.length )
button.style.display = 'none';
} )(); } )();

View File

@ -441,13 +441,9 @@ a:active {
cursor: pointer; cursor: pointer;
} }
.main-small-navigation ul {
display: none;
}
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
.menu-toggle, .menu-toggle,
.main-small-navigation ul.nav-menu.toggled-on { .navigation-main.toggled-on .nav-menu {
display: block; display: block;
} }
@ -456,6 +452,7 @@ a:active {
} }
} }
/* =Content /* =Content
----------------------------------------------- */ ----------------------------------------------- */