PageSourceSearch

https://www.buron-familienspass.de/templates/main/js/scripts.js?30

js buron-familienspass.de collected 2026-10-09 17:06:48 UTC 6,659 bytes, 202 lines download raw bytes

1/**
2 * @link   http://zwetschke.de
3 * @author Zwetschke Team <[email protected]>
4 *
5 * Copyright (c) 2025 zwetschke GmbH & Co. KG
6 */
7
8;((window, document) => {
9'use strict';
10
11const App = {};
12
13App.setupSliders = function(){};
14
15App.setupMainmenu = function(){
16    const $mResp= document.querySelector('#mainmenu');
17    const toggleMenu = (force) => {
18        $mResp.classList.toggle('open', force);
19        document.body.classList.toggle('mobile-menu-opened', force);
20        document.querySelectorAll('button[data-mainmenu-toggler]').forEach((btn) => {
21            btn.classList.toggle('open', force);
22        });
23        if ($mResp.classList.contains('open')){
24            //$mResp.focus();
25            // Animation delay
26            setTimeout(() => {
27                $mResp.classList.add('opened');
28            }, 10);
29            // location.hash = 'menu';
30        } else {
31            $mResp.classList.remove('opened');
32            // location.hash = '!';
33        }
34    };
35    if (!$mResp) return;
36
37    document.addEventListener('click', (event) => {
38        if (!event.target.closest('[data-mainmenu-toggler]')) return;
39        event.preventDefault();
40        toggleMenu();
41    });
42    document.addEventListener('keydown', (event) => {
43        if (event.code === 'Escape' && $mResp.classList.contains('open')) {
44            toggleMenu(false);
45        }
46    });
47    // window.addEventListener('hashchange', function (event) {
48    //     // Detect back button
49    //     if ((!location.hash || location.hash === '#!') && event.oldURL.indexOf('#menu') && $mResp.classList.contains('open')) {
50    //         toggleMenu(false);
51    //     }
52    // });
53};
54
55App.initGalleries = function () {
56    if (!window.GLightbox) return;
57
58    // Init the simple galleries
59    const p1 = GLightbox({
60        selector: '.lightbox--gallery-image',
61        closeEffect: 'fade',
62    });
63
64    // Init popup link
65    const p2 = GLightbox({
66        selector: '.lightbox--popup-link',
67        closeEffect: 'fade',
68        closeButton: false,
69        draggable: false,
70    });
71
72    document.addEventListener('click', function (event){
73        if (!event.target.closest('.ginner-container .gclose')) return;
74        p1.close();p2.close();
75    });
76};
77
78App.setUpAccordion = function () {
79    var delegateSelector = '.accordion-title';
80    document.addEventListener('click', function (event){
81        var $title = event.target.closest(delegateSelector);
82        if (!$title) return;
83        event.preventDefault();
84        var $item = $title.closest('.accordion-item'),
85            $list = [].slice.call($item.parentElement.children).filter(function($el){ return $el.classList.contains('accordion-item');});
86
87        $item.classList.toggle('active');
88        $list.forEach(function ($el){
89            if ($el === $item) return;
90            $el.classList.remove('active');
91        });
92    });
93};
94
95App.setUpTabs = function () {
96    function switchTab(hash, $btn){
97        var $tab = $btn.parentElement, $content = document.querySelector(hash);
98        if (!$content) return;
99
100        [].slice.call($tab.parentNode.querySelectorAll('.active')).forEach(function($el){
101            $el.classList.remove('active');
102        });
103
104        if ($tab.parentNode !== $content.parentNode) {
105            [].slice.call($content.parentNode.querySelectorAll('.active')).forEach(function($el){
106                $el.classList.remove('active');
107            });
108        }
109
110        $tab.classList.add('active');
111        $content.classList.add('active');
112    }
113    document.addEventListener('click', function (event){
114        if (!event.target.matches('.tab-title>a')) return;
115        event.preventDefault();
116        switchTab(event.target.getAttribute('href').replace('#tab-', '#'), event.target)
117    });
118    // Check for the tabid in url
119    // if (location.hash.indexOf('#tab-') !== -1) {
120    //     switchTab(location.hash.replace('#tab-', '#'));
121    // }
122};
123
124App.interactiveButtons = function() {
125    // Toggle active class data-toggler-active=".blabla-target"
126    [].slice.call(document.querySelectorAll('[data-toggler-active]')).forEach(function ($btn){
127        $btn.addEventListener('click', function (){
128            var $target = $btn.dataset.togglerActive ? document.querySelector($btn.dataset.togglerActive) : null;
129            $btn.classList.toggle('active');
130            $target && $target.classList.toggle('active');
131        });
132    });
133
134    // <button type="button" data-action-scroll-to=".section-class">scroll to</button>
135    [].slice.call(document.querySelectorAll('[data-action-scroll-to]')).forEac
135h(function ($btn){
136        $btn.addEventListener('click', function(e){
137            var target = $btn.getAttribute('data-action-scroll-to'),
138                $target = target ? document.querySelector(target) : null;
139            if (!$target) return;
140            e.preventDefault();
141            var y = $target.getBoundingClientRect().top + window.scrollY - 120;
142            window.scrollTo({top: y, behavior: 'smooth'});
143            //$target.scrollIntoView({behavior: 'smooth'});
144        });
145    });
146};
147
148App.magickOnScroll = function () {
149    var $items = [].slice.call(document.querySelectorAll('.animate-scroll'));
150    if (!$items.length) return;
151
152    $items.forEach(function ($item) {
153        var threshold = $item.dataset.threshold ? parseFloat($item.dataset.threshold) : false;
154        var observer = new IntersectionObserver(function(entries, observer){
155            if (entries[0].isIntersecting){
156                $item.classList.add('in-view');
157                observer.unobserve($item);
158                observer.disconnect();
159            }
160        }, {threshold: threshold || 0});
161        observer.observe($item);
162    });
163};
164
165/**
166 * Function for applying a debounce effect to a function call.
167 * @function
168 * @param {Function} func - Function to be called at end of timeout.
169 * @param {Number} delay - Time in ms to delay the call of `func`.
170 * @returns function
171 */
172App.throttle = function (func, delay) {
173    var timer = null;
174
175    return function () {
176        var context = this, args = arguments;
177
178        if (timer === null) {
179            timer = setTimeout(function () {
180                func.apply(context, args);
181                timer = null;
182            }, delay);
183        }
184    };
185};
186
187App.run = function() {
188    document.addEventListener('DOMContentLoaded', () =>{
189        this.setupSliders();
190        this.setupMainmenu();
191        this.initGalleries();
192        this.interactiveButtons();
193        //this.setUpAccordion();
194        //this.setUpTabs();
195        //this.setUpParallax();
196    });
197
198    // window.addEventListener('load', () => {});
199};
200
201App.run();
202})(window, 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.