PageSourceSearch

https://www.greenfields-restaurant.de/js/custom.260316155457.js

js greenfields-restaurant.de collected 2026-10-04 05:11:24 UTC 15,446 bytes, 482 lines download raw bytes

1/* JS for preset "Back to top button V3" */
2(function() {
3    var initBackToTop = function() {
4        var $button = $('.back-to-top-button-icon');
5        
6    	clickToTop($button);
7    	
8    	// Show back to top only below the fold
9    	viewport.observe('scroll', function() {
10    		if (viewport.getScrollTop() > (viewport.getHeight() / 3)) {
11    			$button.addClass('show');
12    		} else {
13    			$button.removeClass('show');
14    		}
15    	});
16    };
17    
18    var clickToTop = function($trigger) {
19    	$trigger.removeClass('show');
20    
21    	$trigger.click(function(e) {
22    		e.preventDefault();
23    		viewport.scrollTo(0, 'top', 500, 0);
24    	});
25    };
26    
27    $(initBackToTop);
28})();
29/* End JS for preset "Back to top button V3" */
30
31/* JS for preset "Menu V2" */
32(function() {
33	$(function() {
34		$('.menu-wrapper').each(function() {
35			initMenu($(this))
36		});
37	});
38
39	// Make :active pseudo classes work on iOS
40	document.addEventListener("touchstart", function() {}, false);
41
42	var initMenu = function($menuWrapper) {
43		var $body = $('body');
44		var $menu = $('.ed-menu', $menuWrapper);
45		var $menuLinks = $('a', $menu);
46		var $menuTrigger = $('.menu-trigger', $menuWrapper);
47		var $banner = $('.banner').first();
48
49		var menuWrapperHeight = $menuWrapper.outerHeight();
50		var bannerHeight = $banner.length ? $banner.outerHeight() : 0;
51		var smoothScrollOffset = 20;
52		
53		toggleClassOnClick($body.add($menu), $menuTrigger, null, 'open open-menu'); // Keep open on $menu for backward compatibility
54		activateSmoothScroll($menuLinks.add($('.scroll a')), smoothScrollOffset);
55		addClassOnVisibleLinkTargets($menuLinks, 'active', 2 / 3);
56		handleSticky($menuWrapper, 'sticky', $banner);
57	};
58
59	/**
60	 * Observe element's height changes and reload the initMenu() function
61	 *
62	 * @param {HTMLElement} elm Element to observe
63	 * @param {function} callback to call when elmement's height changed
64	 */
65	var observeHeightChange = function(elm, callback) {
66		if (!('ResizeObserver' in window) || elm == null) return;
67
68		var ro = new ResizeObserver(callback);
69		ro.observe(elm);
70	}
71
72	/**
73	 * Toggles class on a target when a trigger is clicked
74	 * 
75	 * @param {jQuery} $target The target to apply the CSS class to
76	 * @param {jQuery} $trigger The Trigger
77	 * @param {jQuery} $closeTrigger Optional close trigger
78	 * @param {string} cssClass CSS Class to toggle on the target
79	 */
80	var toggleClassOnClick = function($target, $trigger, $closeTrigger, cssClass) {
81
82		// Reset in case class "open" was saved accidentally
83		$target.removeClass(cssClass);
84		$trigger.removeClass(cssClass);
85
86		// Click on trigger toggles class "open"
87		$trigger.off('.toggle').on('click.toggle', function() {
88			$(this).toggleClass(cssClass);
89			$target.toggleClass(cssClass);
90		});
91
92		// Close target when link inside is clicked
93		$target.find('a').click(function() {
94			$target.removeClass(cssClass);
95			$trigger.removeClass(cssClass);
96		});
97
98		if (!$closeTrigger || !$closeTrigger.length) {
99			return;
100		}
101
102		$closeTrigger.click(function() {
103			$target.removeClass(cssClass);
104			$trigger.removeClass(cssClass);
105		});
106	};
107
108	/**
109	 * Smooth scroll to link targets
110	 * 
111	 * @param {jQuery} $scrollLinks The links
112	 * @param {jQuery} scrollOffset Offset to subtract from the scroll target position (e.g. for fixed positioned elements like a menu)
113	 */
114	var activateSmoothScroll = function($scrollLinks, scrollOffset) {
115		if (typeof scrollOffset === 'undefined') {
116			scrollOffset = 0;
117		}
118
119		var determineTarget = function($trigger, hash) {
120			if (hash == '#!next') {
121				return $trigger.closest('.ed-element').next();
122			}
123
124			return $(hash);
125		}
126
127		$scrollLinks.click(function(e) {
128			var $target = determineTarget($(this), this.hash);
129			if (!$target.length) return;
130			e.preventDefault();
131
132			viewport.scrollTo($target, 'top', 500, 0);
133
134		});
135	};
136
137	/**
138	 * We are using the fill property on an element to pass user's choices from CSS to JavaScript
139	 * 
140	 * @param {jQuery} $element
141	 */
142	var getStickyMode = function($element) {
143		var fillValue = getComputedStyle($element[0]).fill;
144
145		return fillValue === 'rgb(255, 0, 0)' ?
146			'sticky_banner' :
147			fillValue === 'rgb(0, 255, 0)' ?
148			'sticky_menu' :
149			fillValue === 'rgb(0, 0, 255)' ?
150			'sticky_instant' :
151			fillValue === 'rgb(255, 255, 255)' ?
152			'sticky_reverse' :
153			'sticky_none';
154	};
155
156	/**
157	 * Adds a class to an element when not currently visible
158	 * 
159	 * @param {jQuery} $element The element to handle stickyness for
160	 * @param {string} cssClass The actual CSS class to be applied to the element when it's above a certain scroll position
161	 * @param {jQuery} $banner A banner to reference the scroll position to
162	 */
163	var handleSticky = function($element, cssClass, $banner) {
164		var triggerPos = 0,
165			offset = 0;
166		var menuWrapperHeight = $element.outerHeight();
167		var mode;
168		var prevScroll = 0;
169		$element.removeClass(cssClass);
170		
171		var toggleSpacer = function(toggle) {
172			document.body.style.setProperty('--spacer-height', toggle ? menuWrapperHeight + 'px' : '');
173		};
174
175		var handleScroll = function() {
176			if (!$element.length || mode === 'sticky_none') return;
177
178			var isReverse = mode === 'sticky_reverse',
179				curScroll = viewport.getScrollTop();
180
181			if (triggerPos <= curScroll && (!isReverse || prevScroll > curScroll)) {
182				$element.addClass(cssClass);
183				toggleSpacer(true);
184			} else {
185				$element.removeClass(cssClass);
186				toggleSpacer(false);
187			}
188
189			prevScroll = curScroll;
190		};
191		
192		var updateOffset = function() {
193			mode = getStickyMode($element);
194			menuWrapperHeight = $element.outerHeight();
195			if (!$element.hasClass(cssClass)) {
196				offset = $element.offset().top;
197			}
198			if (mode === 'sticky_banner' && !$banner.length) {
199				mode = 'sticky_menu';
200			}
201			if (mode === 'sticky_banner') {
202				triggerPos = $banner.offset().top + ($banner.length ? $banner.outerHeight() : $element.outerHeight());
203			}
204			if (mode === 'sticky_menu' || mode === 'sticky_reverse') {
205				triggerPos = offset + $element.outerHeight();
206			}
207			if (mode === 'sticky_instant') {
208				triggerPos = offset;
209			}
210			
211			handleScroll();
212		}
213		
214		viewport.observe('resize', updateOffset);
215		viewport.observe('animation.end', updateOffset);
216		observeHeightChange($element[0], updateOffset);
217		updateOffset();
218		
219		viewport.observe('scroll', handleScroll);
220		handleScroll();
221	};
222
223	/**
224	 * Adds a class to links whose target is currently inside the viewport
225	 * 
226	 * @param {jQuery} $links Link(s) to be observed
227	 * @param {string} cssClass CSS Class to be applied
228	 * @param {float} sectionViewportRatio Ratio by which the target should be within the viewport
229	 */
230	var addClassOnVisibleLinkTargets = function($links, cssClass, sectionViewportRatio) {
231		if (typeof sectionViewportRatio === 'undefined') {
232			sectionViewportRatio = 1 / 2;
233		}
234
235		var menuTargets = [];
236		var activeLink = $links.filter('.active:not(.wv-link-elm)').eq(0);
237
238		var links = $links.filter(function() {
239			var $target = $(this.hash);
240			if (!$target.length) {
241				return false;
242			}
243
244			// Cache offset position to improve performance (update on resize)		
245			var updateOffset = function() {
246				$target.data('offset', $target.offset().top);
247			};
248
249			viewport.observe('resize', updateOffset);
250			viewport.observe('animation.end', updateOffset);
251			updateOffset();
252
253			menuTargets.push($target);
254			return true;
255		});
256
257		// No hash links found, so don't handle it at all
258		if (!links.length) {
259			return;
260		}
261
262		var checkVisibility = function() {
263			$links.removeClass('active');
264
265			// Check section position reversely
266			for (var i = menuTargets.length - 1; i >= 0; i--) {
267				var desiredScrollPosition = menuTargets[i].data('offset') - viewport.getHeight() * (1 - sectionViewportRatio);
268				if (viewport.getScrollTop() >= desiredScrollPosition && menuTargets[i][0].offsetParent !== null) {
269					links.eq(i).addClass(cssClass);
270					return;
271				}
272			}
273
274			// Fallback to originally active item
275			activeLink.addClass(cssClass);
276		};
277
278		viewport.observe('scroll', checkVisibility);
279		checkVisibility();
280	};
281})();
282/* End JS for preset "Menu V2" */
283
284/* JS for preset "Cookie Consent Bar V3" */
285$(function() {
286	$('#cookieClose').click(function(e) {
287		e.preventDefault();
288		createCookie('cookieConsentBar', "rejected", 0.5);
289		$('.cookie-consent-bar').hide();
290		
291		// If inside of an overlay, close it too
292		if ($('.cookie-consent-bar').closest('.mfp-content').length) {
293			$.magnificPopup.close();
294			return;
295		}
296	});
297
298	$('#acceptCookie').click(function(e) {
299		e.preventDefault();
300		createCookie('cookieConsentBar', "accepted", 0.5);
301		$('.cookie-consent-bar').hide();
302
303		if (typeof ThirdPartyScripts !== "undefined") {
304			ThirdPartyScripts.unblock();
305		}
306
307		// If inside of an overlay, close it too
308		if ($('.cookie-consent-bar').closest('.mfp-content').length) {
309			$.magnificPopup.close();
310			return;
311		}
312	});
313
314	var preview = false;
315	
316	var listener = function() {
317		if (!preview && document.body.classList.contains('preview')) {
318			console.log("entering preview");
319			preview = true;
320		} else if (preview && !document.body.classList.contains('preview')) {
321			console.log("leaving preview");
322			$('.cookie-consent-bar').show();
323			preview = false;
324		}
325		requestAnimationFrame(listener);
326	};
327	
328	requestAnimationFrame(listener);
329
330	if (document.body.classList.contains('edit') || document.body.classList.contains('preview')) {
331		return;
332	}
333
334	
335	// Cookie bar
336	if (readCookie('cookieConsentBar') == "accepted") {
337		$('.cookie-consent-bar').hide();
338		window.setTimeout(function() {
339			if (typeof ThirdPartyScripts !== "undefined") {
340				ThirdPartyScripts.unblock();
341			}
342		}, 100);
343	} else if (readCookie('cookieConsentBar') == "rejected") {
344		$('.cookie-consent-bar').hide();
345	} else {
346		$('.cookie-consent-bar').show();
347	}
348	
349	function readCookie(name) {
350		var nameEQ = name + "=";
351		var ca = document.cookie.split(';');
352		for (var i = 0; i < ca.length; i++) {
353			var c = ca[i];
354			while (c.charAt(0) == ' ') c = c.substring(1, c.length);
355			if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
356		}
357		return null;
358	}   
359    
360	function createCookie(name, value, days) {
361		if (days) {
362			var date = new Date();
363			date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
364			var expires = "; expires=" + date.toGMTString();
365		} else expires = "";
366		document.cookie = name + "=" + value + expires + "; path=/";
367	}
368	
369    // Fix for hiding Content till page is loaded
370	$(document).ready(function() {
371		$('.hide-cookie-content').removeClass("hide-cookie-content");
372	});
373});   
374/* End JS for preset "Cookie Consent Bar V3" */
375
376/* JS for preset "Language V2" */
377$(function() {
378	//Adds Flag data attr
379	setTimeout(function() {
380		$(".language-item").children('a').each(function() {
381			//Check for potentially unfitting language codes as they might differentiate from flag codes
382			function correctLangCode(source) {
383				return source === "en" ? 'gb' : // English -> United Kingdom
384					source === "km" ? "kh" : // Khmer -> Cambodia
385					source === "ko" ? "kr" : // Korean -> South Korea
386					source === "he" ? "il" : // Hebrew -> Israel
387					source === "ar" ? "ae" : // Arabic -> United Arab Emirates
388					source === "da" ? "dk" : // Danish -> Denmark
389					source === "uk" ? "ua" : // Ukrainian -> Ukraine
390					source === "el" ? "gr" : // Greek -> Greece
391					source === "lb" ? "lu" : // Luxembourgish -> Luxembourg
392					source === "sl" ? "si" : // Slovenian -> Slovenia
393					source === "sq" ? "al" : // Albanian -> Albania
394					source === "sv" ? "se" : // Swedish -> Sweden
395					source === "ca" ? "es-ca" : // Catalan -> Spain/Catalonia
396					source === "ja" ? "jp" : // Japanese -> Japan
397					source === "hi" ? "in" : // Hindi -> India
398					source === "be" ? "by" : // Belarusian -> Belarus
399					source === "bn" ? "bd" : // Bengali -> Bangladesh
400					source === "pa" ? "in" : // Punjabi -> India
401					source === "ur" ? "pk" : // Urdu -> Pakistan
402					source === "vi" ? "vn" : // Vietnamese -> Vietnam
403					source === "zh" ? "cn" : // Chinese -> China
404					source === "sr" ? "rs" : // Serbian -> Serbia
405					source === "bs" ? "ba" : // Bosnian -> Bosnia and Herzegovina
406					source === "cs" ? "cz" : // Czech -> Czech Republic
407					source === "fa" ? "ir" : // Persian -> Iran
408					source === "ka" ? "ge" : // Georgian -> Georgia
409					source === "hy" ? "am" : // Armenian -> Armenia
410					source === "kk" ? "kz" : // Kazakh -> Kazakhstan
411					source === "ky" ? "kg" : // Kyrgyz -> Kyrgyzstan
412					source === "tg" ? "tj" : // Tajik -> Tajikistan
413					source === "tk" ? "tm" : // Turkmen -> Turkmenistan
414					source === "my" ? "mm" : // Burmese -> Myanmar
415					source === "lo" ? "la" : // Lao -> Laos
416					source === "si" ? "lk" : // Sinhala -> Sri Lanka
417					source === "ta" ? "lk" : // Tamil -> Sri Lanka
418					source === "ne" ? "np" : // Nepali -> Nepal
419					source === "dz" ? "bt" : // Dzongkha -> Bhutan
420					source === "bo" ? "cn" : // Tibetan -> China
421					source === "eu" ? "es" : // Basque -> Spain
422					source === "gl" ? "es" : // Galician -> Spain
423					source === "cy" ? "gb" : // Welsh -> United Kingdom
424					source === "ga" ? "ie" : // Irish -> Ireland
425					source === "gd" ? "gb" : // Scottish Gaelic -> United Kingdom
426					source === "kl" ? "gl" : // Greenlandic -> Greenland
427					source === "mi" ? "nz" : // Maori -> New Zealand
428					source === "sm" ? "ws" : // Samoan -> Samoa
429					source === "ny" ? "mw" : // Chichewa -> Malawi
430					source === "sn" ? "zw" : // Shona -> Zimbabwe
431					source === "sw" ? "tz" : // Swahili -> Tanzania
432					source === "am" ? "et" : // Amharic -> Ethiopia
433					source === "ti" ? "er" : // Tigrinya -> Eritrea
434					source === "om" ? "et" : // Oromo -> Ethiopia
435					source === "rn" ? "bi" : // Kirundi -> Burundi
436					source === "lg" ? "ug" : // Luganda -> Uganda
437					source === "wo" ? "sn" : // Wolof -> Senegal
438					source === "ff" ? "sn" : // Fulah -> Senegal
439					source === "ha" ? "ng" : // Hausa -> Nigeria
440					source === "ig" ? "ng" : // Igbo -> Nigeria
441					source === "yo" ? "ng" : // Yoruba -> Nigeria
442					source === "zu" ? "za" : // Zulu -> South Africa
443					source === "xh" ? "za" : // Xhosa -> South Africa
444					source === "af" ? "za" : // Afrikaans -> South Africa
445					source === "st" ? "ls" : // Sesotho -> Lesotho
446					source === "tn" ? "bw" : // Tswana -> Botswana
447					source === "ss" ? "sz" : // Swati -> Eswatini
448					source === "ve" ? "za" : // Venda -> South Africa
449					source === "ts" ? "za" : // Tsonga -> South Africa
450					source === "nr" ? "za" : // Ndebele -> South Africa
451					source === "et" ? "ee" : // Ethiopia -> Estonia
452					source;
453			}
454			$(this).css("backgroundImage", "url(/bundles/flag-icon-css/flags/4x3/" + correctLangCode($(this).attr("data-lang")) + ".svg)");
455		});
456	}, 1000);
457
458	//Prevents select trigger from working within the CMS
459	if (document.body.classList.contains('edit') || document.body.classList.contains('preview')) {
460		return;
461	}
462
463	// Click event to open cusom select box  - quotes is being used as an identifier
464	if ($(".language-icon").css('quotes') == '"“" "”"') {
465		$(".language-icon").on("click", function() {
466			if (!$(".language-icon").hasClass("active")) {
467				$(".language-item").slideDown({
468					start: function() {
469						$(this).css({
470							display: "flex"
471						});
472					}
473				});
474				$(".language-icon").addClass("active");
475			} else if ($(".language-icon").hasClass("active")) {
476				$(".language-icon").removeClass("active");
477				$(".language-item").slideUp();
478			}
479		});
480	}
481});
482/* End JS for preset "Language V2" */

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.