PageSourceSearch

https://onlineborenkopen.nl/wp-content/themes/Impreza/common/js/base/header.no-cache.js?ver=8.39.2

js onlineborenkopen.nl collected 2026-10-08 07:27:21 UTC 5,315 bytes, 206 lines download raw bytes

1/**
2 * Script that needed to be exluded for JS delay execution
3 */
4! ( function( $, _undefined ) {
5	"use strict";
6
7	const _window = window;
8	const _document = document;
9
10	_window.$us = _window.$us || {};
11
12	function isNode( node ) {
13		return ( node && node.nodeType );
14	}
15
16	function hasClass( node, className ) {
17		if ( isNode( node ) ) {
18			return node.classList.contains( className );
19		}
20		return false;
21	}
22
23	function getAt( node ) {
24		if ( isNode( node ) ) {
25			return ( node.className.match( 'at_([\dA-z_-]+)' ) || [] )[1];
26		}
27		return;
28	}
29
30	// Retrieve/set/erase dom modificator class <mod>_<value>
31	function usMod( node, mod, value ) {
32		if ( ! isNode( node ) || ! mod ) {
33			return;
34		}
35		if ( value ) {
36			value = `${mod}_${value}`;
37		}
38		var className = String( node.className );
39		className = className.replace( new RegExp( `${mod}_([a-z]+)` ), value );
40		if ( value && ! className.includes( value )  ) {
41			className += ` ${value}`;
42		}
43		if ( node.className !== className ) {
44			node.className = className;
45		}
46	}
47
48	function USHeader_NoCache() {
49		const self = this;
50
51		// Elements
52		const lHeader = _document.querySelector( '.l-header' );
53		if ( ! isNode( lHeader ) ) {
54			return;
55		}
56
57		self.places = {
58			hidden: lHeader.querySelector( '.l-subheader.for_hidden' )
59		};
60		self.elms = {};
61		self.state = 'default';
62
63		// Private "Variables"
64		self.settings = $us.headerSettings || {};
65
66		// Screen breakpoints
67		self.breakpoints = {
68			laptops: 1280,
69			tablets: 1024,
70			mobiles: 600
71		};
72		for ( const k in self.breakpoints ) {
73			self.breakpoints[ k ] = parseInt( ( ( self.settings[ k ] || {} ).options || {} ).breakpoint ) || self.breakpoints[ k ];
74		}
75
76		// Bondable events
77		self._events = {
78			resize: self.resize.bind( self ),
79		};
80
81		// Get all places in the header
82		lHeader.querySelectorAll( '.l-subheader-cell' ).forEach( ( node ) => {
83			self.places[ getAt( node.parentNode.parentNode ) + '_' + getAt( node ) ] = node;
84		} );
85
86		// Get all header elements and save them into the this.$elms list
87		lHeader.querySelectorAll( '[class*=ush_]' ).forEach( ( node ) => {
88			// Regular expression to find elements in the header via class 
88names
89			const matches = /(^| )ush_([a-z_]+)_([\d]+)(\s|$)/.exec( node.className );
90			if ( ! matches ) {
91				return;
92			}
93			const id = matches[2] + ':' + matches[3];
94			// If the element is a wrapper, store it into the this.$places list.
95			if ( hasClass( node, 'w-vwrapper' ) || hasClass( node, 'w-hwrapper' ) ) {
96				self.places[ id ] = node;
97			}
98			self.elms[ id ] = node;
99		} );
100
101		// Events
102		_window.addEventListener( 'resize', self._events.resize );
103
104		self.setView( 'default' );
105		self.resize();
106	}
107
108	/**
109	 * Set view for current screen.
110	 *
111	 * @param {String} newState
112	 */
113	USHeader_NoCache.prototype.setView = function( newState ) {
114		const self = this;
115
116		if ( newState !== self.state ) {
117			usMod( _document.body, 'state', self.state = newState );
118		}
119
120		const orientation = ( ( self.settings[ newState ] || {} ).options || {} ).orientation || 'hor';
121		if ( orientation !== self.orientation ) {
122			usMod( _document.body, 'header', self.orientation = orientation );
123		}
124
125		if ( [ 'default', 'laptops' ].includes( newState ) ) {
126			_document.body.classList.remove( 'header-show' );
127		}
128	};
129
130	/**
131	 * Set the layout.
132	 *
133	 * @param {String} value New layout.
134	 */
135	USHeader_NoCache.prototype.setLayout = function( newState ) {
136		const self = this;
137		const layout = ( self.settings[ newState ] || {} ).layout || {};
138		for ( const place in layout ) {
139			if ( ! layout[ place ] || ! self.places[ place ] ) {
140				// The case when the wrapper is hidden on all states,
141				// but has elements that can be visible on a certain state
142				if ( place.indexOf( 'wrapper' ) > -1 ) {
143					self.places[ place ] = self.places['hidden'];
144				} else {
145					continue;
146				}
147			}
148			self._placeElements( layout[ place ], self.places[ place ] );
149		}
150	};
151
152	/**
153	 * Recursive function to place elements based on their ids.
154	 *
155	 * @param {[]} elms This is a list of all the elements in the header.
156	 * @param {Node} place
157	 */
158	USHeader_NoCache.prototype._placeElements = function( elms, place ) {
159		const self = this;
160		for ( var i = 0; i < elms.length; i ++ ) {
161			var elmId;
162			if ( typeof elms[ i ] == 'object' ) {
163				// Wrapper
164				elmId = elms[ i ][0];
165				if ( ! self.places[ elmId ] || ! self.elms[ elmId ] ) {
166					continue;
167				}
168				place.append( self.elms[ elmId ] );
169				self._placeElements( elms[ i ].shift(), self.places[ elmId ] );
170			} else {
171				elmId = elms[ i ];
172				if ( ! self.elms[ elmId ] ) {
173					continue;
174				}
175				place.append( self.elms[ elmId ] );
176			}
177		}
178	};
179
180	/**
181	 * This method is called every time the browser window is resized.
182	 */
183	USHeader_NoCache.prototype.resize = function() {
184		const self = this;
185		// Determine the state based on the current size of the browser window.
186		var newState = 'default';
187		for ( const state in self.breakpoints ) {
188			if ( _window.innerWidth <= self.breakpoints[ state ] ) {
189				newState = state;
190			} else {
191				break;
192			}
193		}
194		if ( self.state !== newState ) {
195			self.setLayout( newState );
196			self.setView( newState );
197			if ( $us.header && typeof $us.header.setView == 'function' ) {
198				$us.header.setView( newState );
199			}
200		}
201	};
202
203
204	$us.headerNoCache = new USHeader_NoCache;
205
206} ) ();

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.