PageSourceSearch

https://pecsisor.hu/wp-content/themes/pecsishop/js/app.js?v=16

js pecsisor.hu collected 2026-10-02 06:54:39 UTC 9,665 bytes, 290 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2 // Mobil menu
3
4const btn = document.getElementById("menu-btn");
5const nav = document.getElementById("menu");
6
7function navToggle() {
8  btn.classList.toggle("open");
9  nav.classList.toggle("hidden");
10  document.body.classList.toggle("no-scroll");
11}
12
13btn.addEventListener("click", navToggle);
14
15let links = document.querySelectorAll("#menu a");
16
17if (links) {
18  links.forEach((item) => item.addEventListener("click", hidePanel));
19  function hidePanel() {
20    nav.classList.toggle("hidden");
21    document.body.classList.remove("no-scroll");
22    btn.classList.remove("open");
23  }
24}
25
26
27    function hidePanel() {
28        if (nav) {
29            nav.classList.add('hidden');
30            document.body.classList.remove('no-scroll');
31        }
32        if (btn) {
33            btn.classList.remove('open');
34        }
35    }
36
37    // Swiper inicializálás
38    function initializeSwiper(selector, options) {
39        if (document.querySelector(selector)) {
40            try {
41                new Swiper(selector, options);
42        
43            } catch (error) {
44                console.error(`Error initializing ${selector}:`, error);
45            }
46        }
47    }
48
49    initializeSwiper('.swiperMain', {
50        loop: true,
51        slidesPerView: 1,
52        autoplay: { delay: 5000, disableOnInteraction: false }
53    });
54
55    initializeSwiper('.swiperProduct', {
56        loop: true,
57        slidesPerView: 1,
58        autoplay: { delay: 13000, disableOnInteraction: false },
59        navigation: {
60            nextEl: '.swiper-button-prev',
61            prevEl: '.swiper-button-next'
62        }
63    });
64
65    initializeSwiper('.swiperTL', {
66        slidesPerView: 4,
67        spaceBetween: 10,
68        navigation: {
69            nextEl: '.next-tl',
70            prevEl: '.prev-tl'
71        },
72        breakpoints: {
73            320: { slidesPerView: 1, spaceBetween: 10 },
74            480: { slidesPerView: 1, spaceBetween: 30 },
75            940: { slidesPerView: 2, spaceBetween: 40 },
76            1140: { slidesPerView: 4, spaceBetween: 20 }
77        }
78    });
79    initializeSwiper('.swiperPR', {
80        effect: 'fade', // Fade hatás
81        fadeEffect: { crossFade: true }, // Lágy áttűnés
82        loop: true,
83        
84        slidesPerView: 1,
85        autoplay: { delay: 5000, disableOnInteraction: false },
86    
87        navigation: {
88            nextEl: '.next-pr',
89            prevEl: '.prev-pr'
90        },
91    
92        pagination: {
93            el: ".swiperPR .swiper-custom-pagination",
94            clickable: true,
95            renderBullet: function (index, className) {
96                return `<div class="${className}">
97                    <span class="number">${index + 1}</span>
98                    <span class="line"></span>
99                </div>`;
100            }
101        },
102    
103        centeredSlides: true, // A csúszka középre kerül
104        loop: true, // Folyamatos görgetés
105    
106        on: {
107            slideChange: function () {
108                const bullets = document.querySelectorAll('.swiper-pagination-bullet');
109                bullets.forEach((bullet, index) => {
110                    if (index === this.activeIndex) {
111                        bullet.style.opacity = 1;  // Az aktív bullet teljesen látható
112                    } else {
113                        bullet.style.opacity = 0.9; // Az inaktív bulletek áttetszőek
114                    }
115                });
116            }
117        }
118    });
119// Kártyás Swiper Slider
120document.querySelectorAll('.swiperCard').forEach((swiperContainer, index) => {
121    let slides = swiperContainer.querySelectorAll(".swiper-slide");
122    if (slides.length > 1) {
123        initializeSwiper('.swiper-' + index, {
124            slidesPerView: 1,
125            spaceBetween: 10,
126            autoplay: { delay: 150000, disableOnInteraction: false },
127            loop: false,
128            grabCursor: true,
129            navigation: {
130                nextEl: `.swiper-button-nextd-${index}`,
131                prevEl: `.swiper-button-prevd-${index}`
132            },
133            breakpoints: {
134                320: { 
135                    slidesPerView: 1,  // Mobilnézet: egy slide látszódik
136                    spaceBetween: 10 
137                },
138                480: { 
139                    slidesPerView: 1,  // 480px és kisebb képernyőkön is egy slide
140                    spaceBetween: 10
141                },
142                780: { 
143                    slidesPerView: 2,  // 780px-nél már 2 slide látszódik
144                    spaceBetween: 10 
145                },
146                1024: { 
147                    slidesPerView: 2,  // 1024px-nél 2 slide
148                    spaceBetween: 30 
149                },
150                1280: { 
151                    slidesPerView: 3,  // 1180px-nél már 3 slide látszódik
152                    spaceBetween: 20 
153                }
154            }
155        });
156    }
157});
158      // Related products swiper
159      if (document.querySelector('.related-products-slider')) {
160        setTimeout(() => {
161            const swiper = new Swiper('.related-products-slider', {
162                slidesPerView: 4,
163                spaceBetween: 20,
164                navigation: {
165                    nextEl: '.swiper-button-nextr',
166                    prevEl: '.swiper-button-prevr',
167                },
168                breakpoints: {
169                    968: { slidesPerView: 4 },
170                    768: { slidesPerView: 2 },
171                    480: { slidesPerView: 1 },
172                },
173                loop: true,
174            });
175            swiper.update();
176        }, 300);
177    }
178});
179    // Magnific Popup - Képgaléria
180    if (typeof jQuery !== "undefined") {
181        jQuery(function () {
182            jQuery('.gallery').each(function () {
183                jQuery(this).magnificPopup({
184                    delegate: 'a',
185                    type: 'image',
186                    gallery: {
187                        enabled: true,
188                        tCounter: '%curr% / %total%'
189                    }
190                });
191            });
192        });
193    }
194
195   
196
197    // Accordion
198    let acc = document.getElementsByClassName("accordion");
199    Array.from(acc).forEach(item => {
200        item.addEventListener("click", function () {
201            this.classList.toggle("active");
202            let panel = this.nextElementSibling;
203            if (panel) {
204                panel.style.maxHeight = panel.style.maxHeight ? null : panel.scrollHeight + "px";
205            }
206        });
207    });
208
209    // WooCommerce mennyiség gombok
210    document.querySelectorAll(".custom-qty-wrapper").forEach(wrapper => {
211        const minusBtn = wrapper.querySelector(".qty-minus");
212        const plusBtn = wrapper.querySelector(".qty-plus");
213        const input = wrapper.querySelector(".qty");
214    
215        const min = parseInt(input.getAttribute("min")) || 1;
216        const max = parseInt(input.getAttribute("max")) || 999; // Alapértelmezett max, ha nincs beállítva
217        const step = parseInt(input.getAttribute("step")) || 1; // Alapértelmezett step, ha nincs beállítva
218    
219        // Mennyiség csökkentése
220        minusBtn.addEventListener("click", function() {
221            let value = parseInt(input.value);
222            if (value > min) {
223                input.value = Math.max(value - step, min); // A mínusz gomb megakadályozza a túl alacsony értéket
224            }
225            input.dispatchEvent(new Event('change'));
226        });
227    
228        // Mennyiség növelése
229        plusBtn.addEventListener("click", function() {
230            let value = parseInt(input.value);
231            if (value < max) {
232                input.value = Math.min(value + step, max); // A plusz gomb megakadályozza a túl magas értéket
233            }
234            input.dispatchEvent(new Event('change'));
235        });
236    });
237    
238    // Kosár oldalon is alkalmazzuk a qty mezőket
239    document.querySelectorAll(".quantity .qty").forEach(input => {
240        const minusBtn = input.closest(".quantity").querySelector(".qty-minus");
241        const plusBtn = input.closest(".quantity").querySelector(".qty-plus");
242    
243        if (!minusBtn || !plusBtn) return;
244    
245        const min = parseInt(input.getAttribute("min")) || 1;
246        const max = parseInt(input.getAttribute("max")) || 999;
247        const step = parseInt(input.getAttribute("step")) || 1;
248    
249        // Mennyiség csökkentése
250        minusBtn.addEventListener("click", function() {
251            let value = parseInt(input.value);
252            if (value > min) {
253                input.value = Math.max(value - step, min);
254            }
255            input.dispatchEvent(new Event('change'));
256        });
257    
258        // Mennyiség növelése
259        plusBtn.addEventListener("click", function() {
260            let value = parseInt(input.value);
261            if (value < max) {
262                input.value = Math.min(value + step, max);
263            }
264            input.dispatchEvent(new Event('change'));
265        });
266    });
267    
268 
269  
270
271
272    let originalTitle = document.title; // Eredeti cím mentése
273let interval;
274
275document.addEventListener("visibilitychange", function () {
276    if (document.hidden) {
277        let messages = ["Gyere vissza! 🍺", "Webshopunk vár! 🛒"]; // Az üzenetek itt
278        let i = 0;
279
280        interval = setInterval(() => {
281            document.title = messages[i % messages.length]; // Cím ciklikus változtatása
282            i++;
283        }, 1000); // 1 másodpercenként váltakozik
284    } else {
285        clearInterval(interval); // Ha visszatér, leállítja a változást
286        document.title = originalTitle; // Visszaállítja az eredeti címet
287    }
288});
289
290

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.