PageSourceSearch

https://arbejdermuseet.dk/wp-content/themes/s/js/script.js?ver=1755162842

js arbejdermuseet.dk collected 2026-10-02 04:03:00 UTC 7,264 bytes, 252 lines download raw bytes

1/**
2 * S main script.
3 *
4 * @since S 1.0.0
5 */
6
7
8
9(function($) {
10
11	/* ===== Document ready ===== */
12	
13	/**
14	 * Update header height CSS variable
15	 * 
16	 * @since S 1.0.0
17	 */
18	if (!function_exists('headerHeightCSSVariable')) {
19		var headerHeightResizeTimer = false;
20		var headerHeightCSSVariableTimer = null;
21		
22		STANDOUT.headerHeightCSSVariable = function(waitForTransition, overrideSize, setActualHeight) {
23			if (typeof overrideSize !== 'undefined' && overrideSize !== -1) {
24				document.body.style.setProperty('--header-visible-height', overrideSize);
25
26				if (null !== headerHeightCSSVariableTimer) {
27					window.clearTimeout(headerHeightCSSVariableTimer);
28					headerHeightCSSVariableTimer = null;
29				}
30
31				return true;
32			}
33
34
35			if (typeof setActualHeight !== 'undefined' && setActualHeight) {
36				document.body.style.setProperty('--header-actual-height', $('#masthead').outerHeight() + 'px');
37
38				return true;
39			}
40
41
42			if (false === headerHeightResizeTimer) {
43				$(window).on('resize orientationchange', function() {
44					if (headerHeightResizeTimer) {
45						window.clearTimeout(headerHeightResizeTimer);
46						headerHeightResizeTimer = null;
47					}
48
49					headerHeightResizeTimer = window.setTimeout(function() {
50						document.body.style.setProperty('--header-visible-height', $('#masthead').outerHeight() + 'px');
51						// document.body.style.setProperty('--header-actual-height', $('#masthead').outerHeight() + 'px');
52					}, 50);
53				});
54			}
55
56			if (typeof waitForTransition !== 'undefined' && waitForTransition) {
57				var logoTransition = $('#masthead').length ? $('#masthead').css('transition-duration') : '0';
58				logoTransition = logoTransition ? logoTransition : '0';
59				var multiply = logoTransition.indexOf('ms') !== -1 ? 1 : 1000;
60				var converted = parseInt(parseFloat(logoTransition) * multiply, 10);
61				var buffer = 25;
62
63				headerHeightCSSVariableTimer = window.setTimeout(function() {
64					document.body.style.setProperty('--header-visible-height', $('#masthead').outerHeight() + 'px');
65					// document.body.style.setProperty('--header-actual-height', $('#masthead').outerHeight() + 'px');
66					headerHeightCSSVariableTimer = null;
67				}, buffer + converted);
68			} else {
69				document.body.style.setProperty('--header-visible-height', $('#masthead').outerHeight() + 'px');
70				// document.body.style.setProperty('--header-actual-height', $('#masthead').outerHeight() + 'px');
71
72				// window.setTimeout(function() {
73				// 	document.body.style.setProperty('--header-visible-height', $('#masthead').outerHeight() + 'px');
74				// }, 10);
75
76				// window.setTimeout(function() {
77				// 	document.body.style.setProperty('--header-visible-height', $('#masthead').outerHeight() + 'px');
78				// }, 25);
79			}
80		}
81		STANDOUT.headerHeightCSSVariable(false, -1, true);
82
83		$(window).on('load', function() {
84			STANDOUT.headerHeightCSSVariable(false, -1, true);
85		});
86	}
87	
88	/* ===== END Document ready ===== */
89
90
91
92	/* ===== Window load ===== */
93
94	$(window).on('load', function() {
95	
96		/**
97		 * Block scroll of body and add padding right
98		 * 
99		 * @since S 1.0.0
100		 */
101		if (!function_exists('blockScrollUi')) {
102			STANDOUT.blockScrollUi = function(delay) {
103				function getScrollbarWidth() {
104					var outer = document.createElement("div");
105					outer.style.visibility = "hidden";
106					outer.style.width = "100px";
107					outer.style.msOverflowStyle = "scrollbar";
108	
109					document.body.appendChild(outer);
110	
111					var widthNoScroll = outer.offsetWidth;
112					// force scrollbars
113					outer.style.overflow = "scroll";
114	
115					// add innerdiv
116					var inner = document.createElement("div");
117					inner.style.width = "100%";
118					outer.appendChild(inner);        
119	
120					var widthWithScroll = inner.offsetWidth;
121	
122					// remove divs
123					outer.parentNode.removeChild(outer);
124	
125					return widthNoScroll - widthWithScroll;
126				}
127
128
129				delay = typeof delay == 'undefined' ? 0 : delay;
130
131				window.setTimeout(function() {
132					document.documentElement.style.overflow = 'hidden';
133					// document.body.style.overflow = 'hidden';
134	
135					$('body').addClass('scroll-block-ui');
136					$('#page > *').css('padding-right', getScrollbarWidth());
137				}, delay);
138			}
139		}
140		/**
141		 * END Block scroll of body and add padding right
142		 */
143
144
145
146		/**
147		 * Unblock scroll of body and remove padding right
148		 * 
149		 * @since S 1.0.0
150		 */
151		if (!function_exists('unblockScrollUi')) {
152			STANDOUT.unblockScrollUi = function(delay) {
153				delay = typeof delay == 'undefined' ? 0 : delay;
154
155				window.setTimeout(function() {
156					document.documentElement.style.overflow = '';
157					// document.body.style.overflow = '';
158
159					$('body').removeClass('scroll-block-ui');
160					$('#page > *').css('padding-right', '');
161				}, delay);
162			}
163		}
164		/**
165		 * END Unblock scroll of body and remove padding right
166		 */
167
168
169
170		/**
171		 * Get element CSS transition-duration value
172		 * 
173		 * @since S 1.0.0
174		 */
175		if (!function_exists('getElementTransition')) {
176			STANDOUT.getElementTransition = function(element) {
177				return ((parseFloat(window.getComputedStyle(element).transitionDuration)) * 1000);
178			}
179		}
180		/**
181		 * END Get element CSS transition-duration value
182		 */
183
184
185
186		/**
187		 * Mobile menu handler.
188		 * 
189		 * @since S 1.0.0
190		 */
191		if (!function_exists('mobileMenuClickHandler')) {
192			STANDOUT.mobileMenuClickHandler = function() {
193				$(document).on('click', '.standout-mobile-menu-container a', function(e) {
194					var $liParent = $(this).closest('li');
195
196					if ($liParent.hasClass('menu-item-has-children')) {
197						e.preventDefault();
198
199						$liParent.addClass('sub-menu-active');
200					}
201				});
202
203
204				$(document).on('click', '.standout-mobile-menu-container .menu-item-type-up-one-level > a', function(e) {
205					e.preventDefault();
206
207					$(this).closest('li.sub-menu-active').removeClass('sub-menu-active');
208				});
209
210
211				$(document).on('click', '.standout-mobile-menu-toggle', function(e) {
212					e.preventDefault();
213
214					$('header .standout-mobile-menu-content').addClass('active');
215					
216					STANDOUT.blockScrollUi();
217				});
218
219
220				$(document).on('click', '.standout-mobile-menu-content .mobile-menu-close', function(e) {
221					e.preventDefault();
222
223					$('header .standout-mobile-menu-content').removeClass('active');
224
225					STANDOUT.unblockScrollUi(STANDOUT.getElementTransition($('.mobile-menu-content-inner').get(0)));
226				});
227
228				$(document).on('click', '.standout-mobile-menu-content.active', function(e) {
229					if (e.target === this) {
230						$(this).removeClass('active');
231
232						STANDOUT.unblockScrollUi(STANDOUT.getElementTransition($('.mobile-menu-content-inner').get(0)));
233					}
234				});
235
236
237				$(window).on('resize', function() {
238					if ($('.standout-mobile-menu-content').length && !$('.standout-mobile-menu-content').is(':visible')) {
239						if ($('header .standout-mobile-menu-content.active').length) {
240							$('.standout-mobile-menu-content .mobile-menu-close').trigger('click');
241						}
242					}
243				});
244			}
245			STANDOUT.mobileMenuClickHandler();
246		}
247
248	});
249	
250	/* ===== END Window load ===== */
251
252})(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.