PageSourceSearch

https://fastlifegarage.com/wp-content/themes/ovation/assets/js/header.js?ver=20161216

js fastlifegarage.com collected 2026-10-02 15:38:45 UTC 2,992 bytes, 109 lines download raw bytes

1window.ovation = window.ovation || {};
2
3(function( window, document, undefined ) {
4	'use strict';
5
6	function addEventListeners( el, events, fn ) {
7		events.split( ' ' ).forEach(function( e ) {
8			el.addEventListener( e, fn, false );
9		});
10	}
11
12	function offset( el ) {
13		var rect = el.getBoundingClientRect();
14
15		return {
16			top: rect.top + window.pageYOffset,
17			left: rect.left + document.body.scrollLeft
18		};
19	}
20
21	function throttle( fn, wait ) {
22		var doCallback = true;
23
24		return function() {
25			if ( doCallback ) {
26				fn.call();
27				doCallback = false;
28				setTimeout(function() {
29					doCallback = true;
30				}, wait );
31			}
32		};
33	}
34
35	function Header() {
36		this.initialized = false;
37	}
38
39	Header.prototype.initialize = function() {
40		if ( this.initialized ) {
41			return;
42		}
43
44		this.initialized = true;
45
46		this.body = document.body;
47		this.demobar = document.getElementById( 'audiotheme-bar' );
48		this.navigation = document.getElementById( 'site-navigation' );
49		this.toolbar = document.getElementById( 'wpadminbar' );
50
51		this.navigationTop = offset( this.navigation ).top - this.toolbarHeight() - this.demobarHeight();
52
53		var onResize = throttle( this.onResize.bind( this ), 150 );
54		addEventListeners( window, 'load orientationchange resize', onResize );
55		addEventListeners( document, 'wp-custom-header-video-loaded', onResize );
56		addEventListeners( window, 'load orientationchange scroll', this.onScroll.bind( this ) );
57	};
58
59	Header.prototype.onResize = function() {
60		var isFixed = this.body.classList.contains( 'site-navigation-is-fixed' );
61
62		this.body.classList.remove( 'site-navigation-is-fixed' );
63		this.navigationTop = offset( this.navigation ).top - this.toolbarHeight() - this.demobarHeight();
64
65		if ( isFixed ) {
66			this.body.classList.add( 'site-navigation-is-fixed' );
67		}
68	};
69
70	Header.prototype.onScroll = function() {
71		if ( 1 > this.navigationTop - window.pageYOffset ) {
72			this.body.classList.add( 'site-navigation-is-fixed' );
73		} else {
74			this.body.classList.remove( 'site-navigation-is-fixed' );
75		}
76	};
77
78	Header.prototype.demobarHeight = function() {
79		if ( this.demobar && 'fixed' === window.getComputedStyle( this.demobar ).position ) {
80			return parseInt( this.demobar.clientHeight, 10 );
81		}
82
83		return 0;
84	};
85
86	Header.prototype.toolbarHeight = function() {
87		if ( this.toolbar && 'fixed' === getComputedStyle( this.toolbar ).position ) {
88			return parseInt( this.toolbar.clientHeight, 10 );
89		}
90
91		return 0;
92	};
93
94	/**
95	 * Retrieve the viewport width.
96	 *
97	 * @link https://stackoverflow.com/a/8876069
98	 *
99	 * @return {Number}
100	 */
101	Header.prototype.viewportWidth = function() {
102		return Math.max( document.documentElement.clientWidth, window.innerWidth || 0 );
103	};
104
105	window.ovation.header = new Header();
106	document.addEventListener( 'DOMContentLoaded', window.ovation.header.initialize.bind( window.ovation.header ), false );
107	window.addEventListener( 'load', window.ovation.header.initialize.bind( window.ovation.header ), false );
108
109})( this, document );

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.