PageSourceSearch

https://berghof-freienorla.de/wp-content/themes/radiate/js/navigation.js?ver=20120206

js berghof-freienorla.de collected 2026-09-24 14:58:42 UTC 4,001 bytes, 115 lines download raw bytes

1/**
2 * navigation.js
3 *
4 * Handles toggling the navigation menu for small screens.
5 */
6( function() {
7	var container, button, menu, links, i, len;
8
9	brm = document.getElementsByClassName( 'better-responsive-menu' )[0];
10	container = document.getElementById( 'site-navigation' );
11	if ( ! container || brm ) {
12		return;
13	}
14
15	button = container.getElementsByTagName( 'h4' )[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} )();
70jQuery(document).ready(function() {
71    jQuery('.better-responsive-menu #site-navigation .menu-item-has-children').append('<span class="sub-toggle"> <span class="genericon genericon-expand"></span> </span>');
72    jQuery('.better-responsive-menu #site-navigation .sub-toggle').click(function() {
73        jQuery(this).parent('.menu-item-has-children').children('ul.sub-menu').first().slideToggle('1000');
74        jQuery(this).children('<span class="genericon genericon-rightarrow"></span>').first().toggleClass('<span class="genericon genericon-expand"></span>');
75        jQuery(this).toggleClass('active');
76    });
77});
78
79// Show Submenu on click on touch enabled deviced
80( function () {
81    var container;
82    container = document.getElementById( 'site-navigation' );
83
84    /**
85     * Toggles `focus` class to allow submenu access on tablets.
86     */
87    ( function( container ) {
88        var touchStartFn, i,
89            parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
90
91        if ( 'ontouchstart' in window ) {
92            touchStartFn = function( e ) {
93                var menuItem = this.parentNode, i;
94
95                if ( ! menuItem.classList.contains( 'focus' ) ) {
96                    e.preventDefault();
97                    for ( i = 0; i < menuItem.parentNode.children.length; ++i ) {
98                        if ( menuItem === menuItem.parentNode.children[i] ) {
99                            continue;
100                        }
101                        menuItem.parentNode.children[i].classList.remove( 'focus' );
102                    }
103                    menuItem.classList.add( 'focus' );
104                } else {
105                    menuItem.classList.remove( 'focus' );
106                }
107            };
108
109            for ( i = 0; i < parentLink.length; ++i ) {
110                parentLink[i].addEventListener( 'touchstart', touchStartFn, false );
111            }
112        }
113    }( container ) );
114} ) ();
115

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.