PageSourceSearch

https://sterck.es/wp-content/themes/emenia21/js/navigation.js?ver=1.0.19

js sterck.es collected 2026-10-05 20:08:38 UTC 3,459 bytes, 135 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	button = document.getElementById('nav-icon');
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	menu.setAttribute('aria-expanded', 'false');
29	if (-1 === menu.className.indexOf('nav-menu')) {
30		menu.className += ' nav-menu';
31	}
32
33	button.onclick = function () {
34
35		if (-1 !== container.className.indexOf('toggled')) {
36			container.className = container.className.replace(' toggled', '');
37			button.setAttribute('aria-expanded', 'false');
38			button.className = button.className.replace(' open', '');
39			menu.setAttribute('aria-expanded', 'false');
40		} else {
41			container.className += ' toggled';
42			button.className += ' open';
43			button.setAttribute('aria-expanded', 'true');
44			menu.setAttribute('aria-expanded', 'true');
45		}
46	};
47
48	// Get all the link elements within the menu.
49	links = menu.getElementsByTagName('a');
50
51	// Each time a menu link is focused or blurred, toggle focus.
52	for (i = 0, len = links.length; i < len; i++) {
53		links[i].addEventListener('focus', toggleFocus, true);
54		links[i].addEventListener('blur', toggleFocus, true);
55	}
56
57	/**
58	 * Sets or removes .focus class on an element.
59	 */
60	function toggleFocus() {
61		var self = this;
62
63		// Move up through the ancestors of the current link until we hit .nav-menu.
64		while (-1 === self.className.indexOf('nav-menu')) {
65
66			// On li elements toggle the class .focus.
67			if ('li' === self.tagName.toLowerCase()) {
68				if (-1 !== self.className.indexOf('focus')) {
69					self.className = self.className.replace(' focus', '');
70				} else {
71					self.className += ' focus';
72				}
73			}
74
75			self = self.parentElement;
76		}
77	}
78
79	/**
80	 * Toggles `focus` class to allow submenu access on tablets.
81	 */
82	(function (container) {
83		var touchStartFn, i,
84			parentLink = container.querySelectorAll('.menu-item-has-children > a, .page_item_has_children > a');
85
86		if ('ontouchstart' in window) {
87			touchStartFn = function (e) {
88				var menuItem = this.parentNode, i;
89
90				if (!menuItem.classList.contains('focus')) {
91					e.preventDefault();
92					for (i = 0; i < menuItem.parentNode.children.length; ++i) {
93						if (menuItem === menuItem.parentNode.children[i]) {
94							continue;
95						}
96						menuItem.parentNode.children[i].classList.remove('focus');
97					}
98					menuItem.classList.add('focus');
99				} else {
100					menuItem.classList.remove('focus');
101				}
102			};
103
104			for (i = 0; i < parentLink.length; ++i) {
105				parentLink[i].addEventListener('touchstart', touchStartFn, false);
106			}
107		}
108	}(container));
109})();
110
111(function ($) {
112
113	/**
114	 * Menú toggle en móvil
115	 */
116
117	$('.menu-close').on('click', function () {
118
119		$('.main-navigation').removeClass('toggled');
120		$('.menu-toggle').removeClass('open');
121
122		return false;
123	});
124
125	/**
126	 * Modal home
127	 */
128
129	$('.boton-informacion-producto').on('click', function() {
130		$("#formModal").removeClass('fade').addClass('show');
131	});
132	$('.close-informacion-producto').on('click', function() {
133		$("#formModal").removeClass('show').addClass('fade');
134	});
135})(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.