PageSourceSearch

https://ilfbpartners.com/wp-content/themes/ag-site-theme/js/navigation.js?ver=1.1

js ilfbpartners.com collected 2026-10-02 05:26:18 UTC 3,092 bytes, 99 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
8( function($) {
9	const siteNavigation = document.getElementById( 'site-navigation' );
10	const siteContainer = document.querySelector( '.nav-container' );
11	const button = document.querySelector( ".hamburger" );
12	const menu = siteNavigation.getElementsByTagName( 'ul' )[ 0 ];
13
14	// Hide menu toggle button if menu is empty and return early.
15	// if ( 'undefined' === typeof menu ) {
16	// 	button.style.display = 'none';
17	// 	return;
18	// }
19
20	// Toggle the .toggled class and the aria-expanded value each time the button is clicked.
21	button.addEventListener( 'click', function() {
22		siteContainer.classList.toggle( 'toggled' );
23
24		if ( button.getAttribute( 'aria-expanded' ) === 'true' ) {
25			button.setAttribute( 'aria-expanded', 'false' );
26		} else {
27			button.setAttribute( 'aria-expanded', 'true' );
28		}
29	} );
30
31	// Remove the .toggled class and set aria-expanded to false when the user clicks outside the navigation.
32	// document.addEventListener( 'click', function( event ) {
33	// 	const isClickInside = siteNavigation.contains( event.target );
34
35	// 	if ( ! isClickInside ) {
36	// 		siteNavigation.classList.remove( 'toggled' );
37	// 		button.setAttribute( 'aria-expanded', 'false' );
38	// 	}
39	// } );
40
41	// Open subnav menus
42	// siteContainer.addEventListener('click', function( event ){
43	// 	event.preventDefault();
44	// 	console.log(this);
45		
46	// });
47
48	$('.menu-item-has-children').on('click', function(e){
49		$(this).toggleClass('open-subnav');
50	});
51
52	// Get all the link elements within the menu.
53	const links = menu.getElementsByTagName( 'a' );
54
55	// Get all the link elements with children within the menu.
56	const linksWithChildren = menu.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
57
58	// Toggle focus each time a menu link is focused or blurred.
59	for ( const link of links ) {
60		link.addEventListener( 'focus', toggleFocus, true );
61		link.addEventListener( 'blur', toggleFocus, true );
62	}
63
64	// Toggle focus each time a menu link with children receive a touch event.
65	for ( const link of linksWithChildren ) {
66		link.addEventListener( 'touchstart', toggleFocus, false );
67	}
68
69	/**
70	 * Sets or removes .focus class on an element.
71	 */
72	function toggleFocus() {
73		if ( event.type === 'focus' || event.type === 'blur' ) {
74			let self = this;
75			// Move up through the ancestors of the current link until we hit .nav-menu.
76			while ( ! self.classList.contains( 'nav-menu' ) ) {
77				// debugger;
78				// On li elements toggle the class .focus.
79				if ( 'li' === self.tagName.toLowerCase() ) {
80					self.classList.toggle( 'focus' );
81				}
82				self = self.parentNode;
83				// debugger;
84			}
85			// debugger;
86		}
87
88		if ( event.type === 'touchstart' ) {
89			const menuItem = this.parentNode;
90			// event.preventDefault();
91			for ( const link of menuItem.parentNode.children ) {
92				if ( menuItem !== link ) {
93					link.classList.remove( 'focus' );
94				}
95			}
96			menuItem.classList.toggle( 'focus' );
97		}
98	}
99}(jQuery) );

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.