PageSourceSearch

https://hoerstel-aktuell.de/wp-content/themes/newscrunch/assets/js/custom.js?ver=7.1.3

js hoerstel-aktuell.de collected 2026-10-06 20:43:09 UTC 20,353 bytes, 572 lines download raw bytes

1(function($){
2    
3    $(document).ready(function() {
4
5        
6       /* ---------------------------------------------- /*
7         * Home section height
8         /* ---------------------------------------------- */
9
10        function buildHomeSection(homeSection) {
11            if (homeSection.length > 0) {
12                if (homeSection.hasClass('home-full-height')) {
13                    homeSection.height($(window).height());
14                } else {
15                    homeSection.height($(window).height() * 0.85);
16                }
17            }
18        }
19        
20
21        /* ---------------------------------------------- /*
22         * News highlight section 
23        /* ---------------------------------------------- */ 
24          $('#spnc-marquee-right').on('click', function() {
25                 $('.spnc_highlights').addClass('right');
26             })
27             $('#spnc-marquee-left').on('click', function() {
28                 $('.spnc_highlights').removeClass('right');
29             })
30                    
31        /* ---------------------------------------------- /*
32         * Scroll top
33         /* ---------------------------------------------- */
34
35        $(window).scroll(function() {
36            if ($(this).scrollTop() > 100) {
37                $('.scroll-up').fadeIn();
38            } else {
39                $('.scroll-up').fadeOut();
40            }
41        });
42
43        $('a[href="#totop"]').click(function() {
44            $('html, body').animate({ scrollTop: 0 }, 'slow');
45            return false;
46        });
47    
48        // Accodian Js
49        function toggleIcon(e) {
50            $(e.target)
51            .prev('.panel-heading')
52            .find(".more-less")
53            .toggleClass('fa-plus-square-o fa-minus-square-o');
54        }
55        $('.panel-group').on('hidden.bs.collapse', toggleIcon);
56        $('.panel-group').on('shown.bs.collapse', toggleIcon);
57
58        // top date time
59        var timeElement = $( ".newscrunch-topbar-time" )
60        if( timeElement.length > 0 ) {
61            setInterval(function() {
62                timeElement.html(new Date().toLocaleTimeString())
63            },1000);
64        }
65
66        /* ---------------------------------------------- /*
67         * Sticky Header
68         /* ---------------------------------------------- */
69        jQuery(window).bind('scroll', function () {
70            if ( jQuery(window).scrollTop() > 100) {
71                jQuery('.header-sticky').addClass('stickymenu');
72                jQuery('.wow-callback').addClass('wow-sticky');
73                jQuery('body').addClass('spnc-ad-sticky');
74            } else {
75                jQuery('.header-sticky').removeClass('stickymenu');
76                jQuery('.wow-callback').removeClass('wow-sticky');
77                jQuery('body').removeClass('spnc-ad-sticky');
78            }
79        });
80
81        /* ---------------------------------------------- /*
82         * Banner carousel 
83        /* ---------------------------------------------- */  
84        $("#spnc-banner-carousel-1").owlCarousel({
85            navigation : true, // Show next and prev buttons        
86            autoplay: true,
87            autoplayTimeout: 3000,
88            autoplayHoverPause: true,
89            smartSpeed: 2300,
90            loop:true, // loop is true up to 1199px screen.
91            nav:true, // is true across all sizes
92            margin:10, // margin 10px till 960 breakpoint
93            autoHeight: true,
94            responsiveClass:true, // Optional helper class. Add 'owl-reponsive-' + 'breakpoint' class to main element.
95            //items: 3,
96            dots: false,
97            navText: ["<i class='fa fa-arrow-left'></i>","<i class='fa fa-arrow-right'></i>"],
98            responsive:{    
99                200:{ items:1 },
100                480:{ items:1 },
101                768:{ items:1 },
102                1000:{ items:1 }            
103            }
104        });
105
106        // Video section popup
107        $('.spnc-popup-youtube').magnificPopup({
108            disableOn: 700,
109            type: 'iframe',
110            mainClass: 'mfp-fade',
111            removalDelay: 160,
112            preloader: false,
113            fixedContentPos: false
114        });
115
116
117
118      // Custom MP4 Video Popup (inline)
119    $('.spnc-popup-custom-video').magnificPopup({
120      type: 'inline',
121      midClick: true,
122      mainClass: 'mfp-fade',
123      removalDelay: 160,
124      fixedContentPos: false,
125      closeBtnInside: true,
126      callbacks: {
127        open: function () {
128          const video = document.getElementById('spncCustomVideo');
129          video.pause(); // Ensure paused when opened
130        },
131        close: function () {
132          const video = document.getElementById('spncCustomVideo');
133          video.pause();
134          video.currentTime = 0;
135        }
136      }
137    });
138
139
140
141        /* ---------------------------------------------- /*
142         * Sticky sidebar
143        /* ---------------------------------------------- */    
144        var topLimit = ($('#spnc-sidebar-fixed').offset() || { "top": NaN }).top;
145        //var bottomLimit=$(".spnc-blog-section").height();
146        $(window).scroll(function() {
147            if (topLimit <= $(window).scrollTop()){
148                $('#spnc-sidebar-fixed').addClass('spnc_sticky')
149            } else {
150                $('#spnc-sidebar-fixed').removeClass('spnc_sticky')
151            }
152        });
153        $(document).ready(function() {
154            $('.spnc-sticky-sidebar, .spnc-sticky-content')
155                .theiaStickySidebar({
156                    additionalMarginTop: 30
157            });
158        });
159
160        /* ---------------------------------------------- /*
161         *Add animation class in widget
162        /* ---------------------------------------------- */ 
163        //add css for post title hover effect
164        var className = $('#wrapper #page').attr('class');
165        if (typeof className !== 'undefined') {
166        // Access properties or methods of someVariable here
167
168        className= className.split(' ');
169        $(".wp-block-latest-posts__post-title").addClass(className[1]);
170
171        //add css for img hover effect
172        const footerClass = className[2].split('-');
173        $(".wp-block-latest-posts__featured-image").addClass(footerClass[1]);
174        }
175
176    }); 
177
178    /* Preloader */
179    jQuery(window).on('load', function() {
180        var preloaderFadeOutTime = 500;
181        function newscrunch_hidePreloader() {
182            var preloader = jQuery('.newscrunch-loader');
183            setTimeout(function() {
184                preloader.fadeOut(preloaderFadeOutTime);
185            }, 500);
186        }
187        newscrunch_hidePreloader();
188    });
189
190})(jQuery); 
191
192/* ---------------------------------------------- /*
193         * Sidebar Panel
194/* ---------------------------------------------- */
195function spncOpenPanel() {
196    document.getElementById("spnc_panelSidebar").style.transform = "translate3d(0,0,0)";
197    document.getElementById("spnc_panelSidebar").style.visibility = "visible";
198    document.getElementById("wrapper").style.marginLeft = "0px";
199    document.body.classList.add("spnc_body_sidepanel");
200    const panel_elm = document.getElementById('spnc_panelSidebar');
201    panel_elm.addEventListener('focusout', (event1) => {
202        if(panel_elm.contains(event1.relatedTarget)==false){
203            document.getElementById("spnc_panelSidebar").style.transform = "";
204            document.getElementById("spnc_panelSidebar").style.visibility = "hidden";
205            document.getElementById("wrapper").style.marginLeft = "0px";
206            document.body.classList.remove("spnc_body_sidepanel");
207        }
208    })
209}
210function spncClosePanel() {
211    document.getElementById("spnc_panelSidebar").style.transform = "";
212    document.getElementById("spnc_panelSidebar").style.visibility = "hidden";
213    document.getElementById("wrapper").style.marginLeft = "0px";
214    document.body.classList.remove("spnc_body_sidepanel");
215}
216
217
218jQuery(document).ready(function($) {
219     // When the window resizes
220    $(window).on('resize', function () {
221         // Get the height + padding + border of `#masthead`
222         var headerHeight = $('header').outerHeight();
223         var incrseHeight=  headerHeight-185;
224       //  Add the height to `.page-title-section`
225        $('.page-title-section').css('padding-top', incrseHeight+230);
226        $('.newscrunch-plus:not(.newsblogger) .page-title-section.breadcrumb-2').css('padding-top', incrseHeight+210);
227        $('.newsblogger .page-title-section').css('padding-top', 'unset');
228        $('.newscrunch-plus.newsblogger .page-title-section').css('padding-top', incrseHeight+230);
229        $('.newscrunch-plus.newsblogger .page-title-section.breadcrumb-2').css('padding-top', incrseHeight+210);
230        $('.newscrunch-plus section.bread-nt-2.disable').css('padding-top', incrseHeight+210);
231    });
232     // Trigger the function on document load.
233    $(window).trigger('resize');
234});
235
236
237/* ---------------------------------------------- /*
238         * open and close sidemenu in responsive
239/* ---------------------------------------------- */
240let MenucodeVisible = false;
241function openNav() {
242    MenucodeVisible= true;
243    updateMenuFocusVisibility();
244    var element = document.getElementById("spnc-menu-open");
245    element.classList.add("open");
246    jQuery('body').addClass('off-canvas');
247     const panel_elm1 = document.getElementById('spnc-menu-open');
248    panel_elm1.addEventListener('focusout', (event) => {
249        if(panel_elm1.contains(event.relatedTarget)==false){
250            panel_elm1.classList.remove("open");
251             jQuery('body').removeClass('off-canvas');
252            document.getElementsByClassName("spnc-menu-open")[0].focus();
253            MenucodeVisible= false;
254            updateMenuFocusVisibility();
255        }
256    })
257}
258function closeNav() {
259     MenucodeVisible=false;
260    updateMenuFocusVisibility();
261    var element = document.getElementById("spnc-menu-open");
262    element.classList.remove("open");
263    jQuery('body').removeClass('off-canvas');
264    document.getElementsByClassName("spnc-menu-open")[0].focus();
265}
266jQuery(".spnc-nav-menu-overlay").on('click', function () {
267    var element124 = document.getElementById("spnc-menu-open");
268    element124.classList.remove("open");
269    jQuery('body').removeClass('off-canvas');
270})
271function updateMenuFocusVisibility() {
272    if (MenucodeVisible) {
273        // Show focus
274       document.getElementById("spnc-menu-open").style.display = 'block';
275    } else {
276        // Hide focus
277        document.getElementById("spnc-menu-open").style.display = 'none';
278    }
279}
280updateMenuFocusVisibility();
281// open and close sidemenu
282
283// js for category panel open and close start---------------------------------------------------
284document.addEventListener("DOMContentLoaded", function () {
285  const dropdownWrapper = document.getElementById("shop-product-cat-search");
286   if (!dropdownWrapper) {
287    // Element not found, stop script
288    return;
289  }
290  const trigger = dropdownWrapper.querySelector(".shop-product-cat-selected"); 
291  const dropdown = dropdownWrapper.querySelector(".shop-category-list");
292  const items = dropdown.querySelectorAll("li[role='menuitem']");
293  const shopCloseBtn = dropdownWrapper.querySelector(".shop-cat-close"); 
294  const hiddenInput = document.getElementById("selected-product-cat"); 
295  const categoryLinks = dropdownWrapper.querySelectorAll(".shop-category-list ul li a");
296  const catIcon = dropdownWrapper.querySelector("i.fa-chevron-down");
297
298  let currentIndex = -1;
299
300  // --- Utility functions ---
301  function openDropdown() {
302    dropdownWrapper.classList.add("open");
303    dropdown.setAttribute("aria-hidden", "false");
304    currentIndex = 0;
305
306    if (items.length > 0) {
307      items[currentIndex].querySelector("a").focus();
308    }
309  }
310
311  function closeDropdown() {
312    dropdownWrapper.classList.remove("open");
313    dropdown.setAttribute("aria-hidden", "true");
314    currentIndex = -1;
315    trigger.focus();
316  }
317
318  function selectItem(item) {
319    const link = item.querySelector("a");
320    const value = link.getAttribute("cat-value");
321    const text = link.textContent.trim();
322
323    trigger.textContent = text;
324    hiddenInput.value = value;
325    closeDropdown();
326  }
327
328  // --- Event listeners ---
329
330  // Mouse click on category link
331  categoryLinks.forEach(function (link) {
332    link.addEventListener("click", function (e) {
333      e.preventDefault();
334      const catName = this.textContent;
335      const catSlug = this.getAttribute("cat-value");
336
337      trigger.textContent = catName;
338      hiddenInput.value = catSlug;
339      dropdownWrapper.classList.remove("open");
340    });
341  });
342   if (catIcon) {
343            [trigger, catIcon].forEach(function (element) {
344                element.addEventListener("click", function (e) {
345                    e.stopPropagation();
346                    dropdownWrapper.classList.toggle("open");
347                });
348            });
349        }
350
351  // Trigger button click
352  trigger.addEventListener("click", (e) => {
353    e.stopPropagation();
354    dropdownWrapper.classList.contains("open") ? closeDropdown() : openDropdown();
355  });
356
357  // Close button mouse click
358  shopCloseBtn.addEventListener("click", (e) => {
359    e.stopPropagation();
360    closeDropdown();
361  });
362
363  // Close button keyboard (Enter / Space)
364  shopCloseBtn.addEventListener("keydown", (e) => {
365    if (e.key === "Enter" || e.key === " ") {
366      e.preventDefault();
367      e.stopPropagation();
368      closeDropdown();
369    }
370  });
371
372  // Mouse click on item
373  items.forEach((item) => {
374    item.addEventListener("click", (e) => {
375      e.preventDefault();
376      selectItem(item);
377    });
378  });
379
380  // Sync currentIndex when links are focused (Tab navigation or mouse focus)
381  items.forEach((item, index) => {
382    const link = item.querySelector("a");
383    link.addEventListener("focus", () => {
384      currentIndex = index;
385    });
386  });
387  // close full dropdown when focus leaves panel
388      if (dropdownWrapper) {
389        dropdownWrapper.addEventListener('focusout', () => {
390          setTimeout(() => {
391            if (!dropdownWrapper.contains(document.activeElement)) {
392              closeDropdown();
393            }
394          }, 0);
395        });
396      }
397  // Keyboard navigation inside dropdown
398  dropdownWrapper.addEventListener("keydown", (e) => {
399    if (!dropdownWrapper.classList.contains("open") &&
400        (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {
401      e.preventDefault();
402      openDropdown();
403      return;
404    }
405
406    if (dropdownWrapper.classList.contains("open")) {
407      if (e.key === "ArrowDown") {
408        e.preventDefault();
409        currentIndex = (currentIndex + 1) % items.length;
410        items[currentIndex].querySelector("a").focus();
411      } else if (e.key === "ArrowUp") {
412        e.preventDefault();
413        currentIndex = (currentIndex - 1 + items.length) % items.length;
414        items[currentIndex].querySelector("a").focus();
415      } else if (e.key === "Enter" || e.key === " ") {
416        e.preventDefault();
417        const currentLink = items[currentIndex].querySelector("a");
418        currentLink.click(); // triggers selection
419      } else if (e.key === "Escape") {
420        e.preventDefault();
421        closeDropdown();
422      }
423    }
424  });
425
426  // Close dropdown on outside click
427  document.addEventListener("click", (e) => {
428    if (dropdownWrapper.classList.contains("open") && !dropdownWrapper.contains(e.target)) {
429      closeDropdown();
430    }
431  });
432});
433
434// js for category panel open and close Ends---------------------------------------------------
435
436// header category select open js Start-------------------------------------------------------------
437// Run after DOM is ready (add inside your existing DOMContentLoaded / IIFE)
438(function () {
439  document.addEventListener("DOMContentLoaded", function () {
440    const menus = document.querySelectorAll(".shop-cat-menu");
441    if (!menus.length) return;
442
443    menus.forEach((menuWrapper, idx) => {
444      const toggleBtn = menuWrapper.querySelector(".shop-cat-menu-head");
445      const panel = menuWrapper.querySelector(".shop-cat-card");
446      const items = panel ? panel.querySelectorAll("a") : [];
447      let currentIndex = -1;
448
449      // accessibility setup
450      if (toggleBtn && !toggleBtn.hasAttribute("tabindex")) toggleBtn.setAttribute("tabindex", "0");
451      toggleBtn && toggleBtn.setAttribute("role", "button");
452      toggleBtn && toggleBtn.setAttribute("aria-expanded", "false");
453
454      const panelId = panel.id || `shop-cat-card-${idx}`;
455      panel && panel.setAttribute("id", panelId);
456      toggleBtn && toggleBtn.setAttribute("aria-controls", panelId);
457      panel && panel.setAttribute("aria-hidden", "true");
458
459      function openMenu() {
460        menuWrapper.classList.add("open");
461        panel && panel.setAttribute("aria-hidden", "false");
462        toggleBtn && toggleBtn.setAttribute("aria-expanded", "true");
463        currentIndex = (items.length > 0) ? 0 : -1;
464        if (items.length > 0 && items[0].focus) items[0].focus();
465      }
466
467      function closeMenu() {
468        menuWrapper.classList.remove("open");
469        panel && panel.setAttribute("aria-hidden", "true");
470        toggleBtn && toggleBtn.setAttribute("aria-expanded", "false");
471        currentIndex = -1;
472      }
473
474      function toggleMenu() {
475        menuWrapper.classList.contains("open") ? closeMenu() : openMenu();
476      }
477
478      // click toggle
479      toggleBtn && toggleBtn.addEventListener("click", (ev) => {
480        ev.stopPropagation();
481        toggleMenu();
482      });
483
484      // keyboard toggle
485      toggleBtn && toggleBtn.addEventListener("keydown", (ev) => {
486        const key = ev.key;
487        if (key === "Enter" || key === " ") {
488          ev.preventDefault();
489          toggleMenu();
490        } else if (key === "ArrowDown") {
491          ev.preventDefault();
492          if (!menuWrapper.classList.contains("open")) {
493            openMenu();
494          } else if (items.length) {
495            currentIndex = 0;
496            items[currentIndex].focus();
497          }
498        }
499      });
500
501      // keyboard navigation inside
502      menuWrapper.addEventListener("keydown", (ev) => {
503        const key = ev.key;
504        if (!menuWrapper.classList.contains("open") && (key === "Enter" || key === " " || key === "ArrowDown")) {
505          ev.preventDefault();
506          openMenu();
507          return;
508        }
509        if (!menuWrapper.classList.contains("open")) return;
510
511        if (key === "ArrowDown") {
512          ev.preventDefault();
513          if (!items.length) return;
514          currentIndex = (currentIndex + 1) % items.length;
515          items[currentIndex].focus();
516        } else if (key === "ArrowUp") {
517          ev.preventDefault();
518          if (!items.length) return;
519          currentIndex = (currentIndex - 1 + items.length) % items.length;
520          items[currentIndex].focus();
521        } else if (key === "Escape") {
522          ev.preventDefault();
523          closeMenu();
524          if (toggleBtn && toggleBtn.focus) toggleBtn.focus();
525        }
526      });
527
528      // submenu open/close on focus
529      const parentItems = panel.querySelectorAll('.cat-item');
530      parentItems.forEach((li) => {
531        const submenu = li.querySelector('.children, .sub-menu');
532        if (!submenu) return;
533
534        li.addEventListener('focusin', () => {
535          li.classList.add('keyboard-open');
536          const a = li.querySelector('a');
537          if (a) a.setAttribute('aria-expanded', 'true');
538        });
539
540        li.addEventListener('focusout', () => {
541          setTimeout(() => {
542            if (!li.contains(document.activeElement)) {
543              li.classList.remove('keyboard-open');
544              const a = li.querySelector('a');
545              if (a) a.setAttribute('aria-expanded', 'false');
546            }
547          }, 0);
548        });
549      });
550
551      //  close full dropdown when focus leaves panel
552      if (panel) {
553        panel.addEventListener('focusout', () => {
554          setTimeout(() => {
555            if (!panel.contains(document.activeElement)) {
556              closeMenu();
557            }
558          }, 0);
559        });
560      }
561
562      // close on outside click
563      document.addEventListener("click", (ev) => {
564        if (menuWrapper.classList.contains("open") && !menuWrapper.contains(ev.target)) {
565          closeMenu();
566        }
567      });
568    });
569  });
570})();
571
572// header category select open js Ends-------------------------------------------------------------

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.