forked from mirror/_s
Merge pull request #242 from mfields/navigation-menu
Rework Navigation Menu. Closes #200, #205, #237, #243.
This commit is contained in:
commit
55596d6c67
|
@ -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],
|
|
||||||
|
container = document.getElementById( 'site-navigation' )
|
||||||
|
if ( ! container )
|
||||||
|
return;
|
||||||
|
|
||||||
|
button = container.getElementsByTagName( 'h1' )[0];
|
||||||
|
if ( 'undefined' == typeof button )
|
||||||
|
return;
|
||||||
|
|
||||||
menu = container.getElementsByTagName( 'ul' )[0];
|
menu = container.getElementsByTagName( 'ul' )[0];
|
||||||
|
|
||||||
if ( undefined == button || undefined == menu )
|
// Hide menu toggle button if menu is empty and return early.
|
||||||
return false;
|
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';
|
|
||||||
} )();
|
} )();
|
|
@ -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
|
||||||
----------------------------------------------- */
|
----------------------------------------------- */
|
||||||
|
|
||||||
|
|
Reference in New Issue