PageSourceSearch

https://awb-landkreis-karlsruhe.de/site/awb-landkreis-karlsruhe/resourceCached/24b/js/functions.js

js awb-landkreis-karlsruhe.de collected 2026-10-06 06:04:48 UTC 16,688 bytes, 442 lines download raw bytes

1// functions.js
2// version  1.0   23.05.2020
3
4
5// megamenu (megmen) Prototyp
6jQuery(document).ready(function($) {
7  jQuery(".l-navigation > ul > li").each(function(index) {
8    var clickItem = jQuery("> a", this);
9    //console.log(index + ": " + clickItem).text(); // Kontrollpunkt
10    clickItem.css('cursor', 'pointer'); // hover -> maushand
11    jQuery(clickItem).removeAttr("href").attr("href", "#"); // href raus, '#' dafür rein
12
13    // klick -> toggle Klasse 'megmen-open' auf parent
14    jQuery(clickItem).click(function() {
15      if (jQuery(this).parent().hasClass("megmen-open")) {
16        jQuery(this).parent().removeClass("megmen-open");
17      } else {
18        jQuery(".l-navigation > ul > li").removeClass("megmen-open");
19        jQuery(this).parent().addClass("megmen-open");
20      }
21    });
22  });
23  // Level 2 nicht klickbar
24  jQuery(".l-navigation > ul > li > ul > li > a").removeAttr("href").attr("href", "#");
25});
26
27
28// megamenu close-button
29jQuery(document).ready(function($) {
30    // insert
31    jQuery('.l-navigation > ul > li > ul').append('<button type="button" class="megmen-close" data-handler="hide" data-event="click">schlie&szlig;en <span class="cross"></span></button>');
32    // function
33    jQuery(function() {
34        jQuery('.megmen-close').click(function() {
35            jQuery('.l-navigation > ul > li').removeClass('megmen-open');
36        });
37    });
38});
39
40/*
41// MMenu (Main)
42document.addEventListener("DOMContentLoaded", () => {
43  var logoBrand = document.querySelector(".brand img");
44  var logoBrandClone = logoBrand.cloneNode(true);
45
46  const menu = new Mmenu("#mobile-menu", {
47    "navbars": [{
48      "position": "top",
49      "content": [logoBrandClone]
50    }, {
51        "position": "bottom",
52        "content": [
53            "<a href='/2437403'>Impressum</a>",
54            "<a href='/2437414'>Datenschutz</a>"
55            //"<a class='fa fa-envelope' href='#/'></a>"
56        ]
57    }],
58    "extensions": [
59        "border-full",
60        "pagedim-black",
61        "position-back",
62        "position-right",
63        "theme-white",
64        "shadow-page"
65    ],
66    "setSelected": {
67        "hover": true,
68        "parent": true
69    },
70    "dividers": {
71        "add": true,
72        "addTo": "#mm-3 .mm-listview",
73    },
74    backButton: {
75        // back button options
76    }
77  }, {
78      backButton: {
79          // back button configuration
80      },
81
82  });
83  const api = menu.API;
84
85  // MMenu (Hamburger Clickfunktion)
86  document.querySelector("#mobile-nav-button").addEventListener(
87      "click", (evnt) => {
88          evnt.preventDefault();
89          api.open();
90      }
91  );
92
93});
94*/
95
96// MMenu (Neue Menüpunkte hinzufügen - manuell)
97// https://mmenujs.com/tutorials/dynamic-content.html
98document.addEventListener("DOMContentLoaded", () => {
99
100    // Find the panel and listview.
101    var panel = document.querySelector(".mb-menu");
102    var listview = document.querySelector(".mm-listview");
103    //console.log(listview);
104
105    // Create the new listitem.
106    var listitem = document.createElement("li");
107    //console.log(listitem);
108    //listitem.className = "mm-listitem secondlist";
109    //listitem.innerHTML = '<a class="mm-listitem__text" href="/2437403">Impressum</a>';
110
111    // Create the new listitem.
112    var listitemDatenschutz = document.createElement("li");
113    //console.log(listitemDatenschutz);
114    //listitemDatenschutz.className = "mm-listitem secondlist";
115    //listitemDatenschutz.innerHTML = '<a class="mm-listitem__text" href="/2437414">Datenschutz</a>';
116
117
118    // Add the listitem to the listview.
119    //listview.append(listitem);
120    //listview.append(listitemDatenschutz);
121
122    // Update the listview.
123    //api.initListview(listview);
124
125})
126
127
128// Pressemeldungen klickbar
129jQuery(document).ready(function() {
130    var clickBox = jQuery('.pm-meldung');
131    clickBox.css('cursor', 'pointer'); // Maushand Hover
132    clickBox.click(function() { // Link innerhalb suchen und auf .pm-meldung anwenden
133      location.href = jQuery(this).find("a[href]").attr("href");
134    });
135    clickBox.mouseover(function() {
136      /*
137      jQuery('.pm-meldung:hover').css('background', '#ddd'); // Hinterleger bei Hover
138      */
139      jQuery(this).attr('title', jQuery(this).find("a[href]").attr("title")); // Titel des Links nutzen
140    });
141    /*
142    clickBox.mouseleave(function() {
143      jQuery('.pm-meldung').css('background', '#ececec'); // Hinterleger entfernen bei Mouseout
144    });
145    */
146});
147
148// Dynamic-Content: items komplett klickbar
149jQuery(document).ready(function() {
150    jQuery('.basecontent-dynamic-content > article').css('cursor', 'pointer');
151    // Link innerhalb suchen und auf '.klickbar' anwenden 
152    jQuery(".basecontent-dynamic-content > article").click(function() {
153        window.location = jQuery(this).find("a[href]").attr("href");
154        return false;
155    });
156    // Titel des Links für die neue Verlinkung nutzen
157    jQuery('.basecontent-dynamic-content > article').mouseover(function() {
158        jQuery(this).attr('title', jQuery(this).find("a[href]").attr("title"));
159    });
160});
161
162// Suchergebnisse: komplett klickbar
163jQuery(document).ready(function() {
164    jQuery('.ergebnisseRumpf li').css('cursor', 'pointer');
165    // Link innerhalb suchen und auf '.klickbar' anwenden 
166    jQuery(".ergebnisseRumpf li").click(function() {
167        window.location = jQuery(this).find("a[href]").attr("href");
168        return false;
169    });
170    // Titel des Links für die neue Verlinkung nutzen
171    jQuery('.ergebnisseRumpf li').mouseover(function() {
172        jQuery(this).attr('title', jQuery(this).find("a[href]").attr("title"));
173    });
174});
175
176
177// TOC & Scrollspy
178jQuery(function($) {
179
180    // CMS Pirobase Redaktion
181    jQuery(".l-content .composedcontent-standardseite-awbka > a[id^='anker']").each(function() {
182      //console.log(this.id);
183      jQuery(this).next().attr('id', 'toc' + this.id);
184    });
185
186    // Pressemodul Übersicht
187    jQuery(".l-content .presse-uebersich h3").each(function() {
188        var iddesankers = jQuery(this).prev().attr("id");
189        jQuery(this).uniqueId();
190    });
191
192    jQuery(document).ready(function($) {
193        jQuery(function() {
194            jQuery('.c-toc__bars').click(function() {
195                jQuery('.l-toc').toggleClass('opened');
196                // Ändere auf aria-expanded="true"
197                // to-do
198
199                var menuItem = jQuery('.l-toc');
200
201                if (menuItem.attr('aria-expanded') === 'true') {
202                    jQuery('.l-toc').attr('aria-expanded', 'false');
203                } else {
204                    jQuery('.l-toc').attr('aria-expanded', 'true');
205                }
206
207
208            });
209        });
210    });
211
212
213    // var content = document.querySelector('.js-toc-content')
214    // var headings = content.querySelectorAll('h1, h2, h3, h4, h5, h6, h7')
215    // var headingMap = {}
216
217    // Array.prototype.forEach.call(headings, function (heading) {
218    //   var id = heading.id ? heading.id : heading.textContent.trim().toLowerCase()
219    //     .split(' ').join('-').replace(/[!@#$%^&*():]/ig, '')
220    //   headingMap[id] = !isNaN(headingMap[id]) ? ++headingMap[id] : 0
221    //   if (headingMap[id]) {
222    //     heading.id = id + '-' + headingMap[id]
223    //   } else {
224    //     heading.id = id
225    //   }
226    // })
227
228    tocbot.init({
229        // Where to render the table of contents.
230        tocSelector: '.c-toc__body',
231        // Where to grab the headings to build the table of contents.
232        contentSelector: '.l-content',
233        // Which headings to grab inside of the contentSelector element.
234        headingSelector: 'h2',
235        // For headings inside relative or absolute positioned containers within content.
236        hasInnerContainers: true,
237
238        // Headings that match the ignoreSelector will be skipped.
239        ignoreSelector: '.js-toc-ignore',
240        // Main class to add to links.
241        linkClass: 'toc-link',
242        // Extra classes to add to links.
243        extraLinkClasses: '',
244        // Class to add to active links,
245        // the link corresponding to the top most heading on the page.
246        activeLinkClass: 'is-active-link',
247        // Main class to add to lists.
248        listClass: 'toc-list',
249        // Extra classes to add to lists.
250        extraListClasses: '',
251        // Class that gets added when a list should be collapsed.
252        isCollapsedClass: 'is-collapsed',
253        // Class that gets added when a list should be able
254        // to be collapsed but isn't necessarily collapsed.
255        collapsibleClass: 'is-collapsible',
256        // Class to add to list items.
257        listItemClass: 'toc-list-item',
258        // How many heading levels should not be collapsed.
259        // For example, number 6 will show everything since
260        // there are only 6 heading levels and number 0 will collapse them all.
261        // The sections that are hidden will open
262        // and close as you scroll to headings within them.
263        collapseDepth: 6,
264        // Smooth scrolling enabled.
265        scrollSmooth: true,
266        // Smooth scroll duration.
267        scrollSmoothDuration: 420,
268        // Callback for scroll end.
269        scrollEndCallback: function(e) {},
270        // Headings offset between the headings and the top of the document (this is meant for minor adjustments).
271        headingsOffset: 1,
272        // Timeout between events firing to make sure it's
273        // not too rapid (for performance reasons).
274        throttleTimeout: 50,
275        // Element to add the positionFixedClass to.
276        positionFixedSelector: null,
277        // Fixed position class to add to make sidebar fixed after scrolling
278        // down past the fixedSidebarOffset.
279        positionFixedClass: 'is-position-fixed',
280        // fixedSidebarOffset can be any number but by default is set
281        // to auto which sets the fixedSidebarOffset to the sidebar
282        // element's offsetTop from the top of the document on init.
283        fixedSidebarOffset: 'auto',
284        // includeHtml can be set to true to include the HTML markup from the
285        // heading node instead of just including the textContent.
286        includeHtml: false,
287        // onclick function to apply to all links in toc. will be called with
288        // the event as the first parameter, and this can be used to stop,
289        // propagation, prevent default or perform action
290        onClick: false,
291        // orderedList can be set to false to generate unordered lists (ul)
292        // instead of ordered lists (ol)
293        orderedList: false,
294        // If there is a fixed article scroll container, set to calculate titles' offset
295        scrollContainer: null,
296        // prevent ToC DOM rendering if it's already rendered by an external system
297        skipRendering: false,
298        // ignore headings that are hidden in DOM
299        ignoreHiddenElements: false,
300        // Optional callback to modify properties of parsed headings.
301        // The heading element is passed in node parameter and information parsed by default parser is provided in obj parameter.
302        // Function has to return the same or modified obj.
303        // The heading will be excluded from TOC if nothing is returned.
304        // function (object, HTMLElement) => object | void
305        headingObjectCallback: null,
306        // Set the base path, useful if you use a `base` tag in `head`.
307        basePath: '',
308
309    });
310
311    // komplettes toc ausblenden bei weniger als zwei items
312    jQuery(document).ready(function($) {
313        if ($(".toc-list-item").length < 2) {
314            jQuery('.l-toc').addClass('d-none');
315        };
316    });
317});
318
319
320
321// Swiper
322jQuery(document).ready(function () {
323
324	
325    // Slider in Top-Slot Stage
326    jQuery('.l-header__stage .kopfbild-slider').children().wrapAll("<div class='swiper-wrapper'></div>");
327    jQuery('.l-header__stage .kopfbild-slider .swiper-wrapper').children().addClass("swiper-slide");
328    jQuery(".l-header__stage .kopfbild-slider").append("<div class='swiper-pagination'></div>");
329    jQuery(".l-header__stage .kopfbild-slider").prepend("<div class='swiper-button-next'></div><div class='swiper-button-prev'></div>");
330    jQuery(".l-header__stage .kopfbild-slider").prepend("<div class='swiper-controls-wrapper'></div>");
331    jQuery(".l-header__stage .kopfbild-slider .swiper-controls-wrapper").append("<div class='swiper-buttons-autoplay'><button class='swiper-button-play disabled' aria-label='Slider starten' tabindex='0'><i class='fas fa-play'></i></button><button class='swiper-button-pause' aria-label='Slider anhalten' tabindex='0'><i class='fa-light fa-pause'></i></button></div>" );
332  
333    // Autoplay Buttons
334  
335    jQuery(".swiper-button-pause").click(function(){
336      swiperStage.autoplay.stop();
337      console.log('Swiper Autoplay Stop')
338      jQuery('.swiper-button-pause').addClass('disabled');
339      jQuery('.swiper-button-play').addClass('active');
340      jQuery('.swiper-button-play').removeClass('disabled');
341      
342    //  jQuery('.l-header__stage .swiper-horizontal .swiper-slide .image-inner img').addClass('not-animation not-animation-onplay');
343     // jQuery('.l-header__stage .swiper-horizontal .swiper-slide .image-inner img').removeClass('animation');
344  
345    });
346  
347    jQuery(".swiper-button-play").click(function(){
348      swiperStage.autoplay.start();
349      console.log('Swiper Autoplay Start')
350      jQuery('.swiper-button-play').addClass('disabled');
351      jQuery('.swiper-button-pause').addClass('active');
352      jQuery('.swiper-button-pause').removeClass('disabled');
353    });
354  
355    
356    const swiperStage = new Swiper('.l-header__stage .kopfbild-slider', {
357      // Optional parameters
358      direction: 'horizontal',
359      loop: true,
360      centeredSlides: true,
361      spaceBetween: 20,
362      slidesPerView: 1,
363      autoplay: {
364        delay: 8000,
365        pauseOnMouseEnter: false,
366        stopOnLastSlide: true,
367        waitForTransition: false,
368      },
369      // If we need pagination
370      pagination: {
371        el: '.swiper-pagination',
372        clickable: true,
373      },
374      // Keyboard Control
375      keyboard: {
376        enabled: true,
377        onlyInViewport: false,
378        },
379      // Navigation arrows
380      navigation: {
381        nextEl: '.swiper-button-next',
382        prevEl: '.swiper-button-prev',
383      },
384  
385      // And if we need scrollbar
386      scrollbar: {
387        el: '.swiper-scrollbar',
388      },
389      a11y: {
390        prevSlideMessage: 'Previous slide',
391        nextSlideMessage: 'Next slide',
392        },
393      breakpoints: {
394        // when window width is >= 499px
395        0: {
396          slidesPerView: 1,
397          spaceBetweenSlides: 20
398        },
399        // when window width is >= 600px
400        600: {
401          slidesPerView: 1,
402          spaceBetweenSlides: 20
403        },
404        // when window width is >= 830px
405        830: {
406          slidesPerView: 1,
407          spaceBetweenSlides: 20
408        }
409      },
410    });
411  
412    function reset_animation() {
413     jQuery('.l-header__stage .swiper-horizontal .swiper-slide .image-inner img').addClass('not-animation');
414     jQuery('.l-header__stage .swiper-horizontal .swiper-slide .image-inner img').removeClass('animation');
415  
416     jQuery('.l-header__stage .swiper-horizontal .swiper-slide-active .image-inner img').removeClass('not-animation');
417     jQuery('.l-header__stage .swiper-horizontal .swiper-slide-active .image-inner img').addClass('animation');
418    }
419  
420    swiperStage.on('slideChange', function (e) {
421     //console.log('*** mySwiper.activeIndex', swiperStage.activeIndex);
422      reset_animation();
423    });
424  
425    swiperStage.on('autoplayStop', function (e) {
426      //console.log('*** mySwiper.activeIndex', swiperStage.activeIndex);
427      //console.log('test test test');
428      jQuery('.l-header__stage .swiper-horizontal .swiper-slide-active .image-inner img').removeClass('animation');
429      jQuery('.l-header__stage .swiper-horizontal .swiper-slide-active .image-inner img').addClass('not-animation');
430      jQuery('.l-header__stage .swiper-horizontal .swiper-slide-active .image-inner img').addClass('not-animation-autoplaystop');
431    });
432    
433    swiperStage.on('autoplayStart', function (e) {
434      //console.log('*** mySwiper.activeIndex', swiperStage.activeIndex);
435      //console.log('test1 test1 test1');
436      reset_animation();
437    });
438     
439  
440  
441  
442  });

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.