PageSourceSearch

https://www.gobike.org/wp-content/cache/wpfc-minified/llggwtom/7tjxe.js

js gobike.org collected 2026-10-08 09:17:05 UTC 11,798 bytes, 363 lines download raw bytes

1// source --> https://www.gobike.org/wp-content/themes/twentyseventeen/assets/js/global.js?ver=20211130 
2/* global twentyseventeenScreenReaderText */
3(function( $ ) {
4
5	// Variables and DOM Caching.
6	var $body = $( 'body' ),
7		$customHeader = $body.find( '.custom-header' ),
8		$branding = $customHeader.find( '.site-branding' ),
9		$navigation = $body.find( '.navigation-top' ),
10		$navWrap = $navigation.find( '.wrap' ),
11		$navMenuItem = $navigation.find( '.menu-item' ),
12		$menuToggle = $navigation.find( '.menu-toggle' ),
13		$menuScrollDown = $body.find( '.menu-scroll-down' ),
14		$sidebar = $body.find( '#secondary' ),
15		$entryContent = $body.find( '.entry-content' ),
16		$formatQuote = $body.find( '.format-quote blockquote' ),
17		isFrontPage = $body.hasClass( 'twentyseventeen-front-page' ) || $body.hasClass( 'home blog' ),
18		navigationFixedClass = 'site-navigation-fixed',
19		navigationHeight,
20		navigationOuterHeight,
21		navPadding,
22		navMenuItemHeight,
23		idealNavHeight,
24		navIsNotTooTall,
25		headerOffset,
26		menuTop = 0,
27		resizeTimer;
28
29	// Ensure the sticky navigation doesn't cover current focused links.
30	$( 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], [contenteditable]', '.site-content-contain' ).filter( ':visible' ).on( 'focus', function() {
31		if ( $navigation.hasClass( 'site-navigation-fixed' ) ) {
32			var windowScrollTop = $( window ).scrollTop(),
33				fixedNavHeight = $navigation.height(),
34				itemScrollTop = $( this ).offset().top,
35				offsetDiff = itemScrollTop - windowScrollTop;
36
37			// Account for Admin bar.
38			if ( $( '#wpadminbar' ).length ) {
39				offsetDiff -= $( '#wpadminbar' ).height();
40			}
41
42			if ( offsetDiff < fixedNavHeight ) {
43				$( window ).scrollTo( itemScrollTop - ( fixedNavHeight + 50 ), 0 );
44			}
45		}
46	});
47
48	// Set properties of navigation.
49	function setNavProps() {
50		navigationHeight      = $navigation.height();
51		navigationOuterHeight = $navigation.outerHeight();
52		navPadding            = parseFloat( $navWrap.css( 'padding-top' ) ) * 2;
53		navMenuItemHeight     = $navMenuItem.outerHeight() * 2;
54		idealNavHeight        = navPadding + navMenuItemHeight;
55		navIsNotTooTall       = navigationHeight <= idealNavHeight;
56	}
57
58	// Make navigation 'stick'.
59	function adjustScrollClass() {
60
61		// Make sure we're not on a mobile screen.
62		if ( 'none' === $menuToggle.css( 'display' ) ) {
63
64			// Make sure the nav isn't taller than two rows.
65			if ( navIsNotTooTall ) {
66
67				// When there's a custom header image or video, the header offset includes the height of the navigation.
68				if ( isFrontPage && ( $body.hasClass( 'has-header-image' ) || $body.hasClass( 'has-header-video' ) ) ) {
69					headerOffset = $customHeader.innerHeight() - navigationOuterHeight;
70				} else {
71					headerOffset = $customHeader.innerHeight();
72				}
73
74				// If the scroll is more than the custom header, set the fixed class.
75				if ( $( window ).scrollTop() >= headerOffset ) {
76					$navigation.addClass( navigationFixedClass );
77				} else {
78					$navigation.removeClass( navigationFixedClass );
79				}
80
81			} else {
82
83				// Remove 'fixed' class if nav is taller than two rows.
84				$navigation.removeClass( navigationFixedClass );
85			}
86		}
87	}
88
89	// Set margins of branding in header.
90	function adjustHeaderHeight() {
91		if ( 'none' === $menuToggle.css( 'display' ) ) {
92
93			// The margin should be applied to different elements on front-page or home vs interior pages.
94			if ( isFrontPage ) {
95				$branding.css( 'margin-bottom', navigationOuterHeight );
96			} else {
97				$customHeader.css( 'margin-bottom', navigationOuterHeight );
98			}
99
100		} else {
101			$customHeader.css( 'margin-bottom', '0' );
102			$branding.css( 'margin-bottom', '0' );
103		}
104	}
105
106	// Set icon for quotes.
107	function setQuotesIcon() {
108		$( twentyseventeenScreenReaderText.quote ).prependTo( $formatQuote );
109	}
110
111	// Add 'below-entry-meta' class to elements.
112	function belowEntryMetaClass( param ) {
113		var sidebarPos, sidebarPosBottom;
114
115		if ( ! $body.hasClass( 'has-sidebar' ) ||
116			typeof $sidebar === 'undefined' ||
117			$sidebar.length < 1 || (
118			$body.hasClass( 'search' ) ||
119			$body.hasClass( 'single-attachment' ) ||
120			$body.hasClass( 'error404' ) ||
121			$body.hasClass( 'twentyseventeen-front-page' )
122		) ) {
123			return;
124		}
125
126		sidebarPos       = $sidebar.offset();
127		sidebarPosBottom = sidebarPos.top + ( $sidebar.height() + 28 );
128
129		$entryContent.find( param ).each( function() {
130			var $element = $( this ),
131				elementPos = $element.offset(),
132				elementPosTop = elementPos.top;
133
134			// Add 'below-entry-meta' to elements below the entry meta.
135			if ( elementPosTop > sidebarPosBottom ) {
136				$element.addClass( 'below-entry-meta' );
137			} else {
138				$element.removeClass( 'below-entry-meta' );
139			}
140		});
141	}
142
143	/*
144	 * Test if inline SVGs are supported.
145	 * @link https://github.com/Modernizr/Modernizr/
146	 */
147	function supportsInlineSVG() {
148		var div = document.createElement( 'div' );
149		div.innerHTML = '<svg/>';
150		return 'http://www.w3.org/2000/svg' === ( 'undefined' !== typeof SVGRect && div.firstChild && div.firstChild.namespaceURI );
151	}
152
153	/**
154	 * Test if an iOS device.
155	*/
156	function checkiOS() {
157		return /iPad|iPhone|iPod/.test(navigator.userAgent) && ! window.MSStream;
158	}
159
160	/*
161	 * Test if background-attachment: fixed is supported.
162	 * @link http://stackoverflow.com/questions/14115080/detect-support-for-background-attachment-fixed
163	 */
164	function supportsFixedBackground() {
165		var el = document.createElement('div'),
166			isSupported;
167
168		try {
169			if ( ! ( 'backgroundAttachment' in el.style ) || checkiOS() ) {
170				return false;
171			}
172			el.style.backgroundAttachment = 'fixed';
173			isSupported = ( 'fixed' === el.style.backgroundAttachment );
174			return isSupported;
175		}
176		catch (e) {
177			return false;
178		}
179	}
180
181	// Fire on document ready.
182	$( function() {
183
184		// If navigation menu is present on page, setNavProps and adjustScrollClass.
185		if ( $navigation.length ) {
186			setNavProps();
187			adjustScrollClass();
188		}
189
190		// If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event.
191		if ( $menuScrollDown.length ) {
192
193			if ( $( 'body' ).hasClass( 'admin-bar' ) ) {
194				menuTop -= 32;
195			}
196			if ( $( 'body' ).hasClass( 'blog' ) ) {
197				menuTop -= 30; // The div for latest posts has no space above content, add some to account for this.
198			}
199			if ( ! $navigation.length ) {
200				navigationOuterHeight = 0;
201			}
202
203			$menuScrollDown.on( 'click', function( e ) {
204				e.preventDefault();
205				$( window ).scrollTo( '#primary', {
206					duration: 600,
207					offset: { top: menuTop - navigationOuterHeight }
208				});
209			});
210		}
211
212		adjustHeaderHeight();
213		setQuotesIcon();
214		belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
215		if ( true === supportsInlineSVG() ) {
216			document.documentElement.className = document.documentElement.className.replace( /(\s*)no-svg(\s*)/, '$1svg$2' );
217		}
218
219		if ( true === supportsFixedBackground() ) {
220			document.documentElement.className += ' background-fixed';
221		}
222	} );
223
224	// If navigation menu is present on page, adjust it on scroll and screen resize.
225	if ( $navigation.length ) {
226
227		// On scroll, we want to stick/unstick the navigation.
228		$( window ).on( 'scroll', function() {
229			adjustScrollClass();
230			adjustHeaderHeight();
231		});
232
233		// Also want to make sure the navigation is where it should be on resize.
234		$( window ).on( 'resize', function() {
235			setNavProps();
236			setTimeout( adjustScrollClass, 500 );
237		});
238	}
239
240	$( window ).on( 'resize', function() {
241		clearTimeout( resizeTimer );
242		resizeTimer = setTimeout( function() {
243			belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
244		}, 300 );
245		setTimeout( adjustHeaderHeight, 1000 );
246	});
247
248	// Add header video class after the video is loaded.
249	$( document ).on( 'wp-custom-header-video-loaded', function() {
250		$body.addClass( 'has-header-video' );
251	});
252
253})( jQuery );
254// source --> https://www.gobike.org/wp-content/themes/twentyseventeen/assets/js/navigation.js?ver=2
2540210122 
255/* global twentyseventeenScreenReaderText */
256/**
257 * Theme functions file.
258 *
259 * Contains handlers for navigation and widget area.
260 */
261
262(function( $ ) {
263	var masthead, menuToggle, siteNavContain, siteNavigation;
264
265	function initMainNavigation( container ) {
266
267		// Add dropdown toggle that displays child menu items.
268		var dropdownToggle = $( '<button />', { 'class': 'dropdown-toggle', 'aria-expanded': false })
269			.append( twentyseventeenScreenReaderText.icon )
270			.append( $( '<span />', { 'class': 'screen-reader-text', text: twentyseventeenScreenReaderText.expand }) );
271
272		container.find( '.menu-item-has-children > a, .page_item_has_children > a' ).after( dropdownToggle );
273
274		// Set the active submenu dropdown toggle button initial state.
275		container.find( '.current-menu-ancestor > button' )
276			.addClass( 'toggled-on' )
277			.attr( 'aria-expanded', 'true' )
278			.find( '.screen-reader-text' )
279			.text( twentyseventeenScreenReaderText.collapse );
280		// Set the active submenu initial state.
281		container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );
282
283		container.find( '.dropdown-toggle' ).on( 'click', function( e ) {
284			var _this = $( this ),
285				screenReaderSpan = _this.find( '.screen-reader-text' );
286
287			e.preventDefault();
288			_this.toggleClass( 'toggled-on' );
289			_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
290
291			_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
292
293			screenReaderSpan.text( screenReaderSpan.text() === twentyseventeenScreenReaderText.expand ? twentyseventeenScreenReaderText.collapse : twentyseventeenScreenReaderText.expand );
294		});
295	}
296
297	initMainNavigation( $( '.main-navigation' ) );
298
299	masthead       = $( '#masthead' );
300	menuToggle     = masthead.find( '.menu-toggle' );
301	siteNavContain = masthead.find( '.main-navigation' );
302	siteNavigation = masthead.find( '.main-navigation > div > ul' );
303
304	// Enable menuToggle.
305	(function() {
306
307		// Return early if menuToggle is missing.
308		if ( ! menuToggle.length ) {
309			return;
310		}
311
312		// Add an initial value for the attribute.
313		menuToggle.attr( 'aria-expanded', 'false' );
314
315		menuToggle.on( 'click.twentyseventeen', function() {
316			siteNavContain.toggleClass( 'toggled-on' );
317
318			$( this ).attr( 'aria-expanded', siteNavContain.hasClass( 'toggled-on' ) );
319		});
320	})();
321
322	// Fix sub-menus for touch devices and better focus for hidden submenu items for accessibility.
323	(function() {
324		if ( ! siteNavigation.length || ! siteNavigation.children().length ) {
325			return;
326		}
327
328		// Toggle `focus` class to allow submenu access on tablets.
329		function toggleFocusClassTouchScreen() {
330			if ( 'none' === $( '.menu-toggle' ).css( 'display' ) ) {
331
332				$( document.body ).on( 'touchstart.twentyseventeen', function( e ) {
333					if ( ! $( e.target ).closest( '.main-navigation li' ).length ) {
334						$( '.main-navigation li' ).removeClass( 'focus' );
335					}
336				});
337
338				siteNavigation.find( '.menu-item-has-children > a, .page_item_has_children > a' )
339					.on( 'touchstart.twentyseventeen', function( e ) {
340						var el = $( this ).parent( 'li' );
341
342						if ( ! el.hasClass( 'focus' ) ) {
343							e.preventDefault();
344							el.toggleClass( 'focus' );
345							el.siblings( '.focus' ).removeClass( 'focus' );
346						}
347					});
348
349			} else {
350				siteNavigation.find( '.menu-item-has-children > a, .page_item_has_children > a' ).unbind( 'touchstart.twentyseventeen' );
351			}
352		}
353
354		if ( 'ontouchstart' in window ) {
355			$( window ).on( 'resize.twentyseventeen', toggleFocusClassTouchScreen );
356			toggleFocusClassTouchScreen();
357		}
358
359		siteNavigation.find( 'a' ).on( 'focus.twentyseventeen blur.twentyseventeen', function() {
360			$( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' );
361		});
362	})();
363})( 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.