forked from Automattic/_s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavigation.js
34 lines (28 loc) · 821 Bytes
/
navigation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* 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';
};
} )();