PageSourceSearch

https://bathnovelaward.co.uk/wp-content/themes/museum/js/navigation.js?ver=20120206

js bathnovelaward.co.uk collected 2026-10-02 10:27:51 UTC 2,138 bytes, 82 lines download raw bytes

1/**
2 * navigation.js
3 *
4 * Handles toggling the navigation menu for small screens.
5 */
6( function() {
7
8	var navigationWrapper;
9
10	navigationWrapper = document.getElementById( 'site-navigation-wrapper' );
11
12	// Fix child menus for touch devices.
13	function fixMenuTouchTaps( navigationWrapper ) {
14		var touchStartFn,
15		    parentLink = navigationWrapper.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
16
17		if ( 'ontouchstart' in window ) {
18			touchStartFn = function( e ) {
19				var menuItem = this.parentNode;
20
21				if ( ! menuItem.classList.contains( 'focus' ) ) {
22					e.preventDefault();
23					for( var i = 0; i < menuItem.parentNode.children.length; ++i ) {
24						if ( menuItem === menuItem.parentNode.children[i] ) {
25							continue;
26						}
27						menuItem.parentNode.children[i].classList.remove( 'focus' );
28					}
29					menuItem.classList.add( 'focus' );
30				} else {
31					menuItem.classList.remove( 'focus' );
32				}
33			};
34
35			for ( var i = 0; i < parentLink.length; ++i ) {
36				parentLink[i].addEventListener( 'touchstart', touchStartFn, false )
37			}
38		}
39	}
40
41	fixMenuTouchTaps( navigationWrapper );
42
43
44	var container, button, menu;
45
46	container = document.getElementById( 'site-navigation' );
47	if ( ! container ) {
48		return;
49	}
50
51	button = container.getElementsByTagName( 'button' )[0];
52	if ( 'undefined' === typeof button ) {
53		return;
54	}
55
56	menu = container.getElementsByTagName( 'ul' )[0];
57
58	// Hide menu toggle button if menu is empty and return early.
59	if ( 'undefined' === typeof menu ) {
60		button.style.display = 'none';
61		return;
62	}
63
64	menu.setAttribute( 'aria-expanded', 'false' );
65
66	if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
67		menu.className += ' nav-menu';
68	}
69
70	button.onclick = function() {
71		if ( -1 !== container.className.indexOf( 'toggled' ) ) {
72			container.className = container.className.replace( ' toggled', '' );
73			button.setAttribute( 'aria-expanded', 'false' );
74			menu.setAttribute( 'aria-expanded', 'false' );
75		} else {
76			container.className += ' toggled';
77			button.setAttribute( 'aria-expanded', 'true' );
78			menu.setAttribute( 'aria-expanded', 'true' );
79		}
80	};
81
82} )();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.