PageSourceSearch

https://www.museoangelmateos.com/wp-content/themes/accelerate/js/navigation.js?ver=1.6.0

js museoangelmateos.com collected 2026-10-08 11:36:47 UTC 3,614 bytes, 129 lines download raw bytes

1/**
2 * navigation.js
3 *
4 * Handles toggling the navigation menu for small screens.
5 */
6( function() {
7
8	var container, button, menu, links, i, len;
9
10	container = document.getElementById( 'site-navigation' );
11	if ( !container ) {
12		return;
13	}
14
15	button = container.getElementsByTagName( 'h3' )[ 0 ];
16	if ( 'undefined' === typeof button ) {
17		return;
18	}
19
20	menu = container.getElementsByTagName( 'ul' )[ 0 ];
21
22	// Hide menu toggle button if menu is empty and return early.
23	if ( 'undefined' === typeof menu ) {
24		button.style.display = 'none';
25		return;
26	}
27
28	if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
29		menu.className += 'nav-menu';
30	}
31
32	button.onclick = function() {
33		if ( -1 !== container.className.indexOf( 'main-small-navigation' ) ) {
34			container.className = container.className.replace( 'main-small-navigation', 'main-navigation' );
35		} else {
36			container.className = container.className.replace( 'main-navigation', 'main-small-navigation' );
37		}
38	};
39
40	// Get all the link elements within the menu.
41	links = menu.getElementsByTagName( 'a' );
42
43	// Each time a menu link is focused or blurred, toggle focus.
44	for ( i = 0, len = links.length; i < len; i++ ) {
45		links[i].addEventListener( 'focus', toggleFocus, true );
46		links[i].addEventListener( 'blur', toggleFocus, true );
47	}
48
49	/**
50	 * Sets or removes .focus class on an element.
51	 */
52	function toggleFocus() {
53		var self = this;
54
55		// Move up through the ancestors of the current link until we hit .nav-menu.
56		while ( - 1 === self.className.indexOf( 'nav-menu' ) ) {
57			// On li elements toggle the class .focus.
58			if ( 'li' === self.tagName.toLowerCase() ) {
59				if ( - 1 !== self.className.indexOf( 'focus' ) ) {
60					self.className = self.className.replace( ' focus', '' );
61				} else {
62					self.className += ' focus';
63				}
64			}
65
66			self = self.parentElement;
67		}
68	}
69
70} )();
71jQuery( document ).ready( function() {
72
73	jQuery( '#site-navigation .menu-item-has-children' ).append( '<span class="sub-toggle"> <i class="fa fa-caret-down"></i> </span>' );
74
75	jQuery( '#site-navigation .sub-toggle' ).click( function() {
76
77		jQuery( this ).parent( '.menu-item-has-children' ).children( 'ul.sub-menu' ).first().slideToggle( '1000' );
78		// The icon is created as fa-caret-down; swap it with fa-caret-up so it turns when opened.
79		jQuery( this ).children( '.fa' ).first().toggleClass( 'fa-caret-down fa-caret-up' );
80		jQuery( this ).toggleClass( 'active' );
81
82	} );
83
84} );
85
86// Show Submenu on click on touch enabled deviced
87( function() {
88
89	var container = document.getElementById( 'site-navigation' );
90
91	// Pages without the primary nav (e.g. Legacy Widget previews in wp-admin) have no container.
92	if ( ! container ) {
93		return;
94	}
95
96	/**
97	 * Toggles `focus` class to allow submenu access on tablets.
98	 */
99	( function( container ) {
100
101		var touchStartFn, i,
102		    parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
103
104		if ( 'ontouchstart' in window ) {
105			touchStartFn = function( e ) {
106				var menuItem = this.parentNode, i;
107
108				if ( !menuItem.classList.contains( 'focus' ) ) {
109					e.preventDefault();
110					for ( i = 0; i < menuItem.parentNode.children.length; ++i ) {
111						if ( menuItem === menuItem.parentNode.children[ i ] ) {
112							continue;
113						}
114						menuItem.parentNode.children[ i ].classList.remove( 'focus' );
115					}
116					menuItem.classList.add( 'focus' );
117				} else {
118					menuItem.classList.remove( 'focus' );
119				}
120			};
121
122			for ( i = 0; i < parentLink.length; ++i ) {
123				parentLink[ i ].addEventListener( 'touchstart', touchStartFn, false );
124			}
125		}
126
127	}( container ) );
128
129} )();

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.