1(function () { 2 // Warte bis DOM steht, dann querien 3 if (document.readyState === 'loading') { 4 document.addEventListener('DOMContentLoaded', init, { once: true }); 5 } else { 6 init(); 7 } 8 9 function init() { 10 const wc_theme_header = document.getElementById('masthead') || null; 11 const nav = document.getElementById('navigation-area') || null; 12 13 // Nur wenn beide existieren, Sticky/Blurry aktivieren 14 const stickyEnabled = !!(wc_theme_header && nav); 15 16 // Offsets nur berechnen, wenn nav existiert, sonst nie triggern 17 const wc_header_sticky = stickyEnabled ? (nav.offsetTop + 100) : Number.POSITIVE_INFINITY; 18 const wc_header_blurry = stickyEnabled ? (nav.offsetTop + 200) : Number.POSITIVE_INFINITY; 19 20 let wc_last_scroll_position = window.scrollY || 0; 21 22 // Scroll-Handler (passive, überschreibt nichts) 23 window.addEventListener('scroll', onScroll, { passive: true }); 24 25 function onScroll() { 26 const y = window.scrollY || window.pageYOffset || 0; 27 28 if (stickyEnabled) { 29 if (y > wc_header_sticky) { 30 if (y < wc_last_scroll_position) { 31 wc_theme_header.classList.add('sticky'); 32 } else if (y - wc_last_scroll_position >= 150) { 33 wc_theme_header.classList.remove('sticky'); 34 } 35 } else { 36 wc_theme_header.classList.remove('sticky'); 37 } 38 39 if (y > wc_header_blurry) { 40 document.body.classList.add('blurry'); 41 } else { 42 document.body.classList.remove('blurry'); 43 } 44 } 45 46 wc_last_scroll_position = y; 47 } 48 49 // Touch-Flag 50 window.addEventListener('touchstart', () => { 51 document.body.classList.add('is-touch-device'); 52 }, { passive: true }); 53 54 // Body-Loaded-Flag 55 document.body.classList.add('loaded'); 56 57 // Video-Autoplay bei Sichtbarkeit 58 const videos = document.querySelectorAll('.single-slide video'); 59 if (videos.length) { 60 const observer = new IntersectionObserver((entries) => { 61 entries.forEach((entry) => { 62 const v = entry.target; 63 if (!entry.isIntersecting) { 64 if (!v.paused) v.pause(); 65 } else { 66 // play() kann Promise werfen â defensiv behandeln 67 const p = v.play(); 68 if (p && typeof p.catch === 'function') { p.catch(() => {}); } 69 } 70 }); 71 }, {}); 72 videos.forEach(v => observer.observe(v)); 73 } 74 75 // Hero-Video (Desktop/Mobile) sicher starten 76 if (screen.width >= 900) { 77 const heroDesktop = document.getElementById('hero-video-desktop'); 78 if (heroDesktop) { 79 const p = heroDesktop.play(); 80 if (p && typeof p.catch === 'function') { p.catch(() => {}); } 81 } 82 } else { 83 const heroMobile = document.getElementById('hero-video-mobile'); 84 if (heroMobile) { 85 const p = heroMobile.play(); 86 if (p && typeof p.catch === 'function') { p.catch(() => {}); } 87 } 88 } 89 90 // jQuery-abhängige Woo/Wishlist-Trigger nur binden, wenn jQuery da ist 91 if (window.jQuery) { 92 const $ = window.jQuery; 93 // Globales Flag-Objekt einmalig 94 window._wishlistTriggers = window._wishlistTriggers || {}; 95 96 $(document.body).on('wc_fragments_refreshed', function () { 97 if (window._wishlistTriggers.cartUpdated) { 98 $('.header-cart-count').addClass('bounce'); 99 $('.menu-item.class-of-cart').first().trigger('click'); 100 window._wishlistTriggers.cartUpdated = false; 101 } 102 103 if (window._wishlistTriggers.wishlistUpdated) { 104 $('#pling-woocommerce-wishlist_wishlist-count').addClass('bounce'); 105 window._wishlistTriggers.wishlistUpdated = false;
106 } 107 }); 108 109 $(document).on('pling-woocommerce-wishlist_item-added-to-cart', function () { 110 window._wishlistTriggers.cartUpdated = true; 111 }); 112 113 $(document).on('pling-woocommerce-wishlist_wishlist-update', function () { 114 window._wishlistTriggers.wishlistUpdated = true; 115 }); 116 } 117 118 initPaginationJump(); 119 } 120 121 function initPaginationJump() { 122 const form = document.querySelector('.woocommerce-pagination .pagination-jump'); 123 if (!form) { return; } 124 125 const input = form.querySelector('.pagination-jump__input'); 126 const total = parseInt(form.dataset.total, 10) || 1; 127 const current = parseInt(form.dataset.current, 10) || 1; 128 129 let navigating = false; 130 131 function go() { 132 if (navigating) { return; } 133 if (!form.dataset.base) { return; } 134 135 let page = parseInt(input.value, 10); 136 137 if (isNaN(page)) { input.value = current; return; } 138 if (page < 1) { page = 1; } 139 if (page > total) { page = total; } 140 141 input.value = page; 142 143 if (page === current) { return; } 144 145 navigating = true; 146 document.body.classList.add('pling-search-loading'); 147 window.location.href = form.dataset.base.replace('%#%', page); 148 } 149 150 form.addEventListener('submit', function (e) { 151 e.preventDefault(); 152 go(); 153 }); 154 155 input.addEventListener('blur', go); 156 } 157})(); 158jQuery(function () { 159 160 161 jQuery('input.variation_id').change(function () { 162 163 let variation_id = jQuery('input.variation_id').val(); 164 165 if (variation_id === 0 || variation_id === '') { 166 jQuery('body').removeClass('variation-selected'); 167 } else { 168 jQuery('body').addClass('variation-selected'); 169 } 170 171 }); 172 173});
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.