PageSourceSearch

https://www.polska.travel/wp-content/themes/polskatravel/src/js/custom.js?ver=1790081999

js polska.travel collected 2026-09-24 15:26:11 UTC 13,895 bytes, 456 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2  const isPolskaTravel = window.location.hostname.includes('polska.travel');
3
4  let swiperThumb;
5  if (document.querySelector(".mySwiper")) {
6    swiperThumb = new Swiper(".mySwiper", {
7      loop: false,
8      spaceBetween: 10,
9      slidesPerView: 4,
10      freeMode: true,
11      watchSlidesProgress: true,
12      keyboard: {
13        enabled: true,
14        onlyInViewport: true
15      }
16    });
17  }
18
19  let swiperMain;
20  if (document.querySelector(".mySwiper2")) {
21    const multipleSlides = document.querySelectorAll(".mySwiper2 .swiper-slide").length > 1;
22
23    swiperMain = new Swiper(".mySwiper2", {
24      loop: multipleSlides,
25      spaceBetween: 0,
26      slidesPerView: 1,
27      speed: 800,
28      on: {
29        setTransition(swiper, duration) {
30          swiper.wrapperEl.style.transitionTimingFunction = 'cubic-bezier(0.7, 0, 0.3, 1)';
31        },
32      },
33      autoplay: (!multipleSlides || isPolskaTravel) ? false : {
34        delay: 6000,
35        disableOnInteraction: false,
36      },
37      navigation: multipleSlides ? {
38        nextEl: ".swiper-button-next",
39        prevEl: ".swiper-button-prev",
40      } : false,
41      pagination: {
42        el: ".swiper-pagination",
43        clickable: true,
44      },
45      thumbs: {
46        swiper: swiperThumb,
47      },
48      keyboard: {
49        enabled: true,
50        onlyInViewport: true
51      }
52    });
53  }
54
55  const playBtn = document.querySelector('.intro-slider__toggle--play');
56  const pauseBtn = document.querySelector('.intro-slider__toggle--pause');
57
58  if (swiperMain && playBtn && pauseBtn) {
59    pauseBtn.addEventListener('click', () => {
60      swiperMain.autoplay.stop();
61      pauseBtn.classList.remove('is-active');
62      playBtn.classList.add('is-active');
63
64      pauseBtn.setAttribute('aria-pressed', 'false');
65      playBtn.setAttribute('aria-pressed', 'true');
66    });
67
68    playBtn.addEventListener('click', () => {
69      swiperMain.autoplay.start();
70      playBtn.classList.remove('is-active');
71      pauseBtn.classList.add('is-active');
72
73      playBtn.setAttribute('aria-pressed', 'false');
74      pauseBtn.setAttribute('aria-pressed', 'true');
75    });
76  }
77
78  if (playBtn && window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
79    playBtn.setAttribute('aria-pressed', 'false');
80  }
81
82  if (isPolskaTravel && playBtn && pauseBtn) {
83    pauseBtn.setAttribute('aria-pressed', 'false');
84    playBtn.setAttribute('aria-pressed', 'true');
85    pauseBtn.classList.remove('is-active');
86    playBtn.classList.add('is-active');
87  }
88
89  const tabsGroups = document.querySelectorAll('.tabs-wrapper');
90
91  tabsGroups.forEach((group) => {
92    const tabList = group.querySelector('[role="tablist"]');
93    const tabs = group.querySelectorAll('[role="tab"]');
94    const panels = group.querySelectorAll('[role="tabpanel"]');
95
96    if (!tabList || !tabs.length || !panels.length) {
97      return;
98    }
99
100    tabList.addEventListener('click', (e) => {
101      const clickedTab = e.target.closest('[role="tab"]');
102      if (!clickedTab) return;
103
104      switchTab(clickedTab, tabs, panels);
105    });
106
107    tabList.addEventListener('keydown', (e) => {
108      const currentTab = document.activeElement.closest('[role="tab"]');
109      if (!currentTab || !Array.from(tabs).includes(currentTab)) return;
110
111      let newTab;
112      const currentIndex = Array.from(tabs).indexOf(currentTab);
113
114      switch (e.key) {
115        case 'ArrowRight':
116        case 'ArrowDown':
117          e.preventDefault();
118          const nextIndex = (currentIndex + 1) % tabs.length;
119          newTab = tabs[nextIndex];
120          break;
121        case 'ArrowLeft':
122        case 'ArrowUp':
123          e.preventDefault();
124          const prevIndex = (currentIndex - 1 + tabs.length) % tabs.length;
125          newTab = tabs[prevIndex];
126          break;
127        default:
128          return;
129      }
130
131      if (newTab) {
132        newTab.focus();
133        switchTab(newTab, tabs, panels);
134      }
135    });
136  });
137
138  function switchTab(newTab, allTabs, allPanels) {
139    const activePanelId = newTab.getAttribute('aria-controls');
140
141    allTabs.forEach((tab) => {
142      tab.setAttribute('aria-selected', 'false');
143      tab.setAttribute('tabindex', '-1');
144      tab.classList.remove('current');
145    });
146    allPanels.forEach((panel) => {
147      panel.hidden = true;
148      panel.classList.remove('current');
149    });
150
151    newTab.setAttribute('aria-selected', 'true');
152    newTab.setAttribute('tabindex', '0');
153    newTab.classList.add('current');
154
155    const activePanel = document.getElementById(activePanelId);
156    if (activePanel) {
157      activePanel.hidden = false;
158      activePanel.classList.add('current');
159    }
160  }
161
162  const mapWithSvg = document.querySelectorAll('.map-points');
163
164  if (mapWithSvg.length) {
165    mapWithSvg.forEach((mapWrapper) => {
166      const points = mapWrapper.querySelectorAll('.map-point');
167      const textPoints = mapWrapper.querySelectorAll('.map-text-point');
168      const mpis = mapWrapper.querySelectorAll('.mpi');
169
170      function setActivePoint(dataId) {
171        points.forEach((point) => {
172          point.classList.remove('active');
173          point.removeAttribute('aria-current');
174        });
175
176        textPoints.forEach((textPoint) => {
177          textPoint.classList.remove('active');
178          textPoint.removeAttribute('aria-current');
179        });
180
181        const activeVisualPoint = mapWrapper.querySelector(
182          `.map-point[data-id="${dataId}"]`
183        );
184        const activeTextPoint = mapWrapper.querySelector(
185          `.map-text-point[data-id="${dataId}"]`
186        );
187
188        if (activeVisualPoint) {
189          activeVisualPoint.classList.add('active');
190          activeVisualPoint.setAttribute('aria-current', 'true');
191        }
192
193        if (activeTextPoint) {
194          activeTextPoint.classList.add('active');
195          activeTextPoint.setAttribute('aria-current', 'true');
196        }
197
198        mpis.forEach((mpi) => {
199          mpi.classList.remove('active');
200          if (mpi.dataset.id === dataId) {
201            mpi.classList.add('active');
202
203            if (window.innerWidth < 768) {
204              mpi.scrollIntoView({ behavior: 'smooth' });
205            }
206          }
207        });
208      }
209
210      points.forEach((point) => {
211        point.addEventListener('click', (e) => {
212          e.preventDefault();
213          setActivePoint(point.dataset.id);
214        });
215
216        point.addEventListener('keydown', (e) => {
217          if (e.key === 'Enter' || e.key === ' ') {
218            e.preventDefault();
219            setActivePoint(point.dataset.id);
220          }
221        });
222      });
223
224      textPoints.forEach((textPoint) => {
225        textPoint.addEventListener('click', (e) => {
226          e.preventDefault();
227          setActivePoint(textPoint.dataset.id);
228        });
229
230        textPoint.addEventListener('keydown', (e) => {
231          if (e.key === 'Enter' || e.key === ' ') {
232            e.preventDefault();
233            setActivePoint(textPoint.dataset.id);
234          }
235        });
236      });
237
238      if (mapWrapper.classList.contains('random')) {
239        if (points.length > 0) {
240          const randomPoint = points[Math.floor(Math.random() * points.length)];
241          setActivePoint(randomPoint.dataset.id);
242        }
243      }
244    });
245  }
246
247  document.addEventListener('DOMContentLoaded', function () {
248    const gallerySwiper = new Swiper('.new-rit__gallery-swiper', {
249      slidesPerView: 1,
250      spaceBetween: 20,
251      loop: true,
252      pagination: {
253        el: '.new-rit__swiper-pagination',
254        clickable: true,
255      },
256      breakpoints: {
257        640: {
258          slidesPerView: 1,
259        },
260        768: {
261          slidesPerView: 1,
262        },
263        1024: {
264          slidesPerView: 1,
265        },
266      },
267    });
268
269    if (typeof lightGallery !== 'undefined') {
270      lightGallery(document.querySelector('.gallery-swiper'), {
271        selector: '.gallery-slider__item',
272        download: false,
273      });
274    }
275  });
276});
277
278function isMobileDevice() {
279  return /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
280}
281
282let originalStyles = new Map();
283let sliderOriginalStyles = new Map();
284let swiperOriginalStyles = new Map();
285let buttonOriginalStyles = new Map();
286
287function adjustElements() {
288  if (isMobileDevice()) return;
289
290  const zoomLevel = Math.round((window.outerWidth / window.innerWidth) * 100) / 100;
291
292  const thumbSlider = document.getElementById('thumbSlider');
293
294  if (thumbSlider && !sliderOriginalStyles.has(thumbSlider)) {
295    sliderOriginalStyles.set(thumbSlider, {
296      position: thumbSlider.style.position || '',
297      marginTop: thumbSlider.style.marginTop || '',
298      display: thumbSlider.style.display || '',
299      left: thumbSlider.style.left || '',
300      transform: thumbSlider.style.transform || '',
301      width: thumbSlider.style.width || ''
302    });
303  }
304
305  if (thumbSlider) {
306    if (zoomLevel >= 1.75) {
307      thumbSlider.style.position = 'relative'; // żeby był pod sliderem
308      thumbSlider.style.display = 'flex'; // zamiast none
309      thumbSlider.style.justifyContent = 'center'; // wyśrodkowanie
310      thumbSlider.style.marginTop = '10px';
311      thumbSlider.style.left = 'unset';
312      thumbSlider.style.transform = 'unset';
313      thumbSlider.style.width = '100%';
314    } else {
315      const original = sliderOriginalStyles.get(thumbSlider);
316      thumbSlider.style.position = original.position;
317      thumbSlider.style.marginTop = original.marginTop;
318      thumbSlider.style.display = original.display;
319      thumbSlider.style.left = original.left;
320      thumbSlider.style.transform = original.transform;
321      thumbSlider.style.width = original.width;
322    }
323  }
324
325  const elems = document.querySelectorAll('.elem1');
326
327  elems.forEach(elem => {
328    if (!elem) return;
329
330    if (!originalStyles.has(elem)) {
331      originalStyles.set(elem, {
332        position: elem.style.position || '',
333        top: elem.style.top || '',
334        bottom: elem.style.bottom || '',
335        left: elem.style.left || '',
336        right: elem.style.right || '',
337        transform: elem.style.transform || ''
338      });
339    }
340
341    if (zoomLevel >= 1.75) {
342      elem.style.position = 'absolute';
343      elem.style.top = '25%';
344      elem.style.left = '50%';
345      elem.style.bottom = 'unset';
346      elem.style.right = 'unset';
347      elem.style.transform = 'translate(-50%, -25%)';
348    } else if (zoomLevel >= 1.7) {
349
350      elem.style.position = 'absolute';
351      elem.style.top = '50%';
352      elem.style.left = '50%';
353      elem.style.bottom = 'unset';
354      elem.style.right = 'unset';
355      elem.style.transform = 'translate(-50%, -50%)';
356
357    } else {
358      const original = originalStyles.get(elem);
359      elem.style.position = original.position;
360      elem.style.top = original.top;
361      elem.style.bottom = original.bottom;
362      elem.style.left = original.left;
363      elem.style.right = original.right;
364      elem.style.transform = original.transform;
365    }
366  });
367
368  const swiper = document.querySelector('.swiper-container');
369  const header = document.querySelector('.header');
370  const headerHeight = header ? header.offsetHeight : 0;
371
372  if (swiper) {
373    if (!swiperOriginalStyles.has(swiper)) {
374      swiperOriginalStyles.set(swiper, {
375        marginTop: swiper.style.marginTop || ''
376      });
377    }
378
379    if (zoomLevel >= 1.75) {
380      swiper.style.marginTop = headerHeight + 'px';
381    } else {
382      const original = swiperOriginalStyles.get(swiper);
383      swiper.style.marginTop = original.marginTop;
384    }
385  }
386
387  const buttons = document.querySelectorAll('.swiper-button-prev, .swiper-button-next');
388
389  buttons.forEach(button => {
390    if (!button) return;
391
392    if (!buttonOriginalStyles.has(button)) {
393      buttonOriginalStyles.set(button, {
394        position: button.style.position || '',
395        top: button.style.top || '',
396        transform: button.style.transform || ''
397      });
398    }
399
400    if (zoomLevel >= 1.75 && swiper) {
401      button.style.position = 'absolute';
402      button.style.top = '50%';
403      button.style.transform = 'translateY(-50%)';
404    } else {
405      const original = buttonOriginalStyles.get(button);
406      button.style.position = original.position;
407      button.style.top = original.top;
408      button.style.transform = original.transform;
409    }
410  });
411
412  const body = document.body;
413  const toggles = document.querySelectorAll(
414    '.intro-slider__toggle--play, .intro-slider__toggle--pause'
415  );
416
417  toggles.forEach(toggle => {
418    if (!toggle) return;
419
420    if (zoomLevel >= 1.75 && !body.classList.contains('contrast')) {
421      toggle.classList.add('intro-slider__toggle--dark');
422    } else {
423      toggle.classList.remove('intro-slider__toggle--dark');
424    }
425  });
426
427  const bullets = document.querySelectorAll('.swiper-pagination-bullet');
428
429  bullets.forEach(bullet => {
430    if (!bullet) return;
431
432    if (zoomLevel >= 1.75 && !body.classList.contains('contrast')) {
433      bullet.classList.add('swiper-pagination-bullet--dark');
434    } else {
435      bullet.classList.remove('swiper-pagination-bullet--dark');
436    }
437  });
438
439  const activeThumbs = document.querySelectorAll(
440    '.swiper-thumb-img'
441  );
442
443  activeThumbs.forEach(thumb => {
444    if (!thumb) return;
445
446    if (zoomLevel >= 1.75 && !body.classList.contains('contrast')) {    
447      thumb.classList.add('swiper-thumb-img--dark');
448    } else {
449      thumb.classList.remove('swiper-thumb-img--dark');
450    }
451  });
452}
453
454
455window.addEventListener('load', adjustElements);
456window.addEventListener('resize', adjustElements);

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.