PageSourceSearch

https://wineeconomist.com/_static/??wp-content/plugins/coblocks/di…/elemin/js/navigation.js?m=1719276502

js wineeconomist.com collected 2026-10-02 07:37:08 UTC 3,608 bytes, 114 lines download raw bytes

1(()=>{const e=document.querySelectorAll(".coblocks-animate");if("IntersectionObserver"in window){const t=new IntersectionObserver((e=>{e.forEach((e=>{e.isIntersecting&&(e.target.classList.add(e.target.dataset.coblocksAnimation),t.unobserve(e.target))}))}),{threshold:[.15]});e.forEach((e=>{t.observe(e)}))}else e.forEach((e=>{e.classList.remove("coblocks-animate"),delete e.dataset.coblocksAnimation}))})();;
2/**
3 * File navigation.js.
4 *
5 * Handles toggling the navigation menu for small screens and enables TAB key
6 * navigation support for dropdown menus.
7 */
8( function() {
9	var container, button, menu, links, subMenus, i, len;
10
11	container = document.getElementById( 'access' );
12	if ( ! container ) {
13		return;
14	}
15
16	button = container.getElementsByTagName( 'button' )[0];
17	if ( 'undefined' === typeof button ) {
18		return;
19	}
20
21	menu = container.getElementsByTagName( 'ul' )[0];
22
23	// Hide menu toggle button if menu is empty and return early.
24	if ( 'undefined' === typeof menu ) {
25		button.style.display = 'none';
26		return;
27	}
28
29	menu.setAttribute( 'aria-expanded', 'false' );
30	if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
31		menu.className += ' nav-menu';
32	}
33
34	button.onclick = function() {
35		if ( -1 !== container.className.indexOf( 'toggled' ) ) {
36			container.className = container.className.replace( ' toggled', '' );
37			button.setAttribute( 'aria-expanded', 'false' );
38			menu.setAttribute( 'aria-expanded', 'false' );
39		} else {
40			container.className += ' toggled';
41			button.setAttribute( 'aria-expanded', 'true' );
42			menu.setAttribute( 'aria-expanded', 'true' );
43		}
44	};
45
46	// Get all the link elements within the menu.
47	links    = menu.getElementsByTagName( 'a' );
48	subMenus = menu.getElementsByTagName( 'ul' );
49
50	// Set menu items with submenus to aria-haspopup="true".
51	for ( i = 0, len = subMenus.length; i < len; i++ ) {
52		subMenus[i].parentNode.setAttribute( 'aria-haspopup', 'true' );
53	}
54
55	// Each time a menu link is focused or blurred, toggle focus.
56	for ( i = 0, len = links.length; i < len; i++ ) {
57		links[i].addEventListener( 'focus', toggleFocus, true );
58		links[i].addEventListener( 'blur', toggleFocus, true );
59	}
60
61	/**
62	 * Sets or removes .focus class on an element.
63	 */
64	function toggleFocus() {
65		var self = this;
66
67		// Move up through the ancestors of the current link until we hit .nav-menu.
68		while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
69
70			// On li elements toggle the class .focus.
71			if ( 'li' === self.tagName.toLowerCase() ) {
72				if ( -1 !== self.className.indexOf( 'focus' ) ) {
73					self.className = self.className.replace( ' focus', '' );
74				} else {
75					self.className += ' focus';
76				}
77			}
78
79			self = self.parentElement;
80		}
81	}
82
83	/**
84	 * Toggles `focus` class to allow submenu access on tablets.
85	 */
86	( function( container ) {
87		var touchStartFn, i,
88			parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
89
90		if ( 'ontouchstart' in window ) {
91			touchStartFn = function( e ) {
92				var menuItem = this.parentNode, i;
93
94				if ( ! menuItem.classList.contains( 'focus' ) ) {
95					e.preventDefault();
96					for ( i = 0; i < menuItem.parentNode.children.length; ++i ) {
97						if ( menuItem === menuItem.parentNode.children[i] ) {
98							continue;
99						}
100						menuItem.parentNode.children[i].classList.remove( 'focus' );
101					}
102					menuItem.classList.add( 'focus' );
103				} else {
104					menuItem.classList.remove( 'focus' );
105				}
106			};
107
108			for ( i = 0; i < parentLink.length; ++i ) {
109				parentLink[i].addEventListener( 'touchstart', touchStartFn, false );
110			}
111		}
112	}( container ) );
113} )();
114;

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.