PageSourceSearch

https://interiorhouse.us/wp-content/themes/color-magazine/assets/js/navigation.js?ver=1.1.2

js interiorhouse.us collected 2026-10-08 23:53:33 UTC 2,365 bytes, 82 lines download raw bytes

1/**
2 * File navigation.js.
3 *
4 * Handles toggling the navigation menu for small screens and enables TAB key
5 * navigation support for dropdown menus.
6 */
7( function() {
8	var container, button, menu, links, i, len;
9
10	container = document.getElementById( 'site-navigation' );
11	if ( ! container ) {
12		return;
13	}
14
15	menu = container.getElementsByTagName( 'ul' )[0];
16	menu.setAttribute( 'aria-expanded', 'false' );
17	if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
18		menu.className += ' nav-menu';
19	}
20
21	// Get all the link elements within the menu.
22	links    = menu.getElementsByTagName( 'a' );
23
24	// Each time a menu link is focused or blurred, toggle focus.
25	for ( i = 0, len = links.length; i < len; i++ ) {
26		links[i].addEventListener( 'focus', toggleFocus, true );
27		links[i].addEventListener( 'blur', toggleFocus, true );
28	}
29
30	/**
31	 * Sets or removes .focus class on an element.
32	 */
33	function toggleFocus() {
34		var self = this;
35
36		// Move up through the ancestors of the current link until we hit .nav-menu.
37		while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
38
39			// On li elements toggle the class .focus.
40			if ( 'li' === self.tagName.toLowerCase() ) {
41				if ( -1 !== self.className.indexOf( 'focus' ) ) {
42					self.className = self.className.replace( ' focus', '' );
43				} else {
44					self.className += ' focus';
45				}
46			}
47
48			self = self.parentElement;
49		}
50	}
51
52	/**
53	 * Toggles `focus` class to allow submenu access on tablets.
54	 */
55	( function( container ) {
56		var touchStartFn, i,
57			parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
58
59		if ( 'ontouchstart' in window ) {
60			touchStartFn = function( e ) {
61				var menuItem = this.parentNode, i;
62
63				if ( ! menuItem.classList.contains( 'focus' ) ) {
64					e.preventDefault();
65					for ( i = 0; i < menuItem.parentNode.children.length; ++i ) {
66						if ( menuItem === menuItem.parentNode.children[i] ) {
67							continue;
68						}
69						menuItem.parentNode.children[i].classList.remove( 'focus' );
70					}
71					menuItem.classList.add( 'focus' );
72				} else {
73					menuItem.classList.remove( 'focus' );
74				}
75			};
76
77			for ( i = 0; i < parentLink.length; ++i ) {
78				parentLink[i].addEventListener( 'touchstart', touchStartFn, false );
79			}
80		}
81	}( container ) );
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.