PageSourceSearch

https://northeastgrainshed.com/_static/--wp-content/themes/olsen/a…/js/skip-link-focus-fix_m-1491858590.js

js northeastgrainshed.com collected 2026-10-09 17:20:56 UTC 5,756 bytes, 193 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10/**
11 * File navigation.js.
12 *
13 * Handles toggling the navigation menu for small screens and enables TAB key
14 * navigation support for dropdown menus.
15 */
16( function() {
17	var container, button, menu, links, i, len;
18
19	container = document.getElementById( 'site-navigation' );
20	if ( ! container ) {
21		return;
22	}
23
24	button = container.getElementsByTagName( 'button' )[0];
25	if ( 'undefined' === typeof button ) {
26		return;
27	}
28
29	menu = container.getElementsByTagName( 'ul' )[0];
30
31	// Hide menu toggle button if menu is empty and return early.
32	if ( 'undefined' === typeof menu ) {
33		button.style.display = 'none';
34		return;
35	}
36
37	menu.setAttribute( 'aria-expanded', 'false' );
38	if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
39		menu.className += ' nav-menu';
40	}
41
42	button.onclick = function() {
43		if ( -1 !== container.className.indexOf( 'toggled' ) ) {
44			container.className = container.className.replace( ' toggled', '' );
45			button.setAttribute( 'aria-expanded', 'false' );
46			menu.setAttribute( 'aria-expanded', 'false' );
47		} else {
48			container.className += ' toggled';
49			button.setAttribute( 'aria-expanded', 'true' );
50			menu.setAttribute( 'aria-expanded', 'true' );
51		}
52	};
53
54	// Get all the link elements within the menu.
55	links = menu.getElementsByTagName( 'a' );
56
57	// Each time a menu link is focused or blurred, toggle focus.
58	for ( i = 0, len = links.length; i < len; i++ ) {
59		links[i].addEventListener( 'focus', toggleFocus, true );
60		links[i].addEventListener( 'blur', toggleFocus, true );
61	}
62
63	/**
64	 * Sets or removes .focus class on an element.
65	 */
66	function toggleFocus() {
67		var self = this;
68
69		// Move up through the ancestors of the current link until we hit .nav-menu.
70		while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
71
72			// On li elements toggle the class .focus.
73			if ( 'li' === self.tagName.toLowerCase() ) {
74				if ( -1 !== self.className.indexOf( 'focus' ) ) {
75					self.className = self.className.replace( ' focus', '' );
76				} else {
77					self.className += ' focus';
78				}
79			}
80
81			self = self.parentElement;
82		}
83	}
84
85	/**
86	 * Toggles `focus` class to allow submenu access on tablets.
87	 */
88	( function( container ) {
89		var touchStartFn, i,
90			parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
91
92		if ( 'ontouchstart' in window ) {
93			touchStartFn = function( e ) {
94				var menuItem = this.parentNode, i;
95
96				if ( ! menuItem.classList.contains( 'focus' ) ) {
97					e.preventDefault();
98					for ( i = 0; i < menuItem.parentNode.children.length; ++i ) {
99						if ( menuItem === menuItem.parentNode.children[i] ) {
100							continue;
101						}
102						menuItem.parentNode.children[i].classList.remove( 'focus' );
103					}
104					menuItem.classList.add( 'focus' );
105				} else {
106					menuItem.classList.remove( 'focus' );
107				}
108			};
109
110			for ( i = 0; i < parentLink.length; ++i ) {
111				parentLink[i].addEventListener( 'touchstart', touchStartFn, false );
112			}
113		}
114	}( container ) );
115
116	/**
117	 * Add mobile submenu toggles
118	 */
119	( function ( container ) {
120		var toggleButton, toggleButtons, dropdownLinks, ancestors;
121
122		// Add dropdown toggle that displays child menu items.
123		dropdownLinks = container.querySelectorAll( '.menu-item-has-children, .page_item_has_children' );
124
125		if ( 'undefined' === typeof dropdownLinks || 0 === dropdownLinks ) {
126			return;
127		}
128
129		for ( i = 0, len = dropdownLinks.length; i < len; i++ ) {
130			toggleButton = document.createElement( 'button' );
131			toggleButton.classList.add( 'dropdown-toggle' );
132			toggleButton.setAttribute( 'aria-expanded', 'false' );
133			dropdownLinks[i].appendChild( toggleButton );
134		}
135
136		toggleButtons = container.getElementsByClassName( 'dropdown-toggle' );
137		ancestors     = container.querySelectorAll( '.current-menu-ancestor, .current_page_ancestor' );
138
139		// Toggle submenu items with active children menu items.
140		for ( i = 0, len = ancestors.length; i < len; i++ ) {
141			ancestors[i].classList.add( 'toggled-on' );
142		}
143
144		for ( i = 0, len = toggleButtons.length; i < len; i++ ) {
145			toggleButtons[i].addEventListener( 'click', function ( e ) {
146				var parent;
147				e.preventDefault();
148				parent = this.parentNode;
149
150				if ( parent.classList.contains( 'toggled-on' ) ) {
151					parent.classList.remove( 'toggled-on' );
152				} else {
153					parent.classList.add( 'toggled-on' );
154				}
155			} );
156		}
157	} )( container );
158} )();
159;
160/**
161 * File skip-link-focus-fix.js.
162 *
163 * Helps with accessibility for keyboard only users.
164 *
165 * Learn more: https://git.io/vWdr2
166 */
167(function() {
168	var isIe = /(trident|msie)/i.test( navigator.userAgent );
169
170	if ( isIe && document.getElementById && window.addEventListener ) {
171		window.addEventListener( 'hashchange', function() {
172			var id = location.hash.substring( 1 ),
173				element;
174
175			if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
176				return;
177			}
178
179			element = document.getElementById( id );
180
181			if ( element ) {
182				if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
183					element.tabIndex = -1;
184				}
185
186				element.focus();
187			}
188		}, false );
189	}
190})();
191;
192
193}

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.