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