PageSourceSearch

https://www.drevenkynaborku.cz/wp-content/themes/drevozelezo-theme/src/js/main.js?ver=1.04

js drevenkynaborku.cz collected 2026-10-01 23:56:42 UTC 14,959 bytes, 499 lines download raw bytes

1let _passiveSupported_ = false;
2try 
3{
4    let options = 
5    {
6        get passive() 
7        {
8            _passiveSupported_ = true;
9        }
10    };
11    window.addEventListener("test", options, options);
12    window.removeEventListener("test", options, options);
13} 
14catch(err) 
15{
16    _passiveSupported_ = false;
17}
18function triggerEvent(el, type)
19{
20    if ('createEvent' in document) 
21    {
22        let e = document.createEvent('HTMLEvents');
23        e.initEvent(type, false, true);
24        el.dispatchEvent(e);
25    } 
26    else 
27    {
28        let e = document.createEventObject();
29        e.eventType = type;
30        el.fireEvent('on'+e.eventType, e);
31    }
32}
33function _redirect_(_location_)
34{
35    window.location = _location_;
36}
37let i = 0,
38j = 0,
39_loading_ = false,
40_replaceContent_ = false,
41_galerie_ = [],
42_gifImagesPreload_ = [];
43const _header_ = document.getElementById('main-header'),
44_nav_ = document.getElementById('main-menu-1'),
45_animateElements_ = document.getElementsByClassName('animate'),
46_hamburger_ = document.getElementsByClassName('hamburger-button')[0],
47_headerOffsetTop_ = _header_.offsetTop,
48_svgMapContainer_ = document.getElementById('svg-mapa-container'),
49_loader_ = document.getElementById('loader');
50/*_linkChildren_ = document.querySelectorAll('.menu-item-has-children > a'),
51_linksWithChildren_ = document.querySelectorAll('#main-header .menu-item-has-children > a');*/
52
53window.addEventListener('resize',handleWindowResize,_passiveSupported_ ? { passive: true } : false);
54window.addEventListener('scroll',handleWindowScroll,_passiveSupported_ ? { passive: true } : false);
55window.addEventListener('scroll',handleAnimateScroll,_passiveSupported_ ? { passive: true } : false);
56//window.addEventListener('load',handleWindowLoad,_passiveSupported_ ? { passive: true } : false);
57_hamburger_.addEventListener('click',handleHamburgerClick,_passiveSupported_ ? { passive: true } : false);
58
59const _hashLinks_ = document.querySelectorAll('a[href^="#"]:not(.no-scroll):not(.cmplz-link)');
60for(i = 0 ; i < _hashLinks_.length; i++)
61{
62    _hashLinks_[i].addEventListener('click',smoothScroll,false);
63}
64/*for(i = 0 ; i < _linkChildren_.length; i++)
65{
66    _linkChildren_[i].addEventListener('click',disableAll,false);
67}
68for(i = 0; i< _linksWithChildren_.length;i++)
69{
70    _linksWithChildren_[i].addEventListener('click',handleChildrenLinkClick,false);
71}*/
72if(_svgMapContainer_)
73{
74    let _gifs_ = _svgMapContainer_.querySelectorAll('a.map-gif img');
75    for(i = 0 ; i < _gifs_.length; i++)
76    {
77        let _gifId_ = _gifs_[i].dataset.id,
78        _image_ = new Image();
79        _image_.src = _gifs_[i].src;
80        _gifImagesPreload_[_gifId_] = _image_;
81        _gifs_[i].addEventListener('mouseenter',handleGifMouseEnter,_passiveSupported_ ? { passive: true } : false);
82    }
83    //console.log(_gifImagesPreload_);
84    //console.log(_gifImagesPreload_[299].src);
85}
86
87/*
88==========================================================================================================
89*/
90
91function handleGifMouseEnter()
92{
93    let _gifId_ = this.dataset.id;
94    this.src = _gifImagesPreload_[_gifId_].src;
95}
96
97/*
98==========================================================================================================
99*/
100
101function handleHamburgerClick()
102{
103    if(this.classList.contains('hamburger-active'))
104    {
105        this.classList.remove('hamburger-active');
106        _nav_.classList.remove('show');
107        _nav_.style.maxHeight = 0;
108        return;
109    }
110    _nav_.classList.add('show');
111    _nav_.style.maxHeight = `${_nav_.scrollHeight}px`;
112    this.classList.add('hamburger-active');
113    return;
114}
115
116/*
117==========================================================================================================
118*/
119
120/*function handleChildrenLinkClick(e)
121{
122    disableAll(e)
123    if(window.innerWidth >= 768) return;
124    const _submenu_ = this.nextElementSibling;
125    if(this.parentElement.classList.contains('show-submenu'))
126    {
127        this.parentElement.classList.remove('show-submenu');
128        _submenu_.style.maxHeight = 0;
129        _nav_.style.maxHeight = `${_nav_.scrollHeight-_submenu_.scrollHeight}px`;
130        return;
131    }
132    this.parentElement.classList.add('show-submenu');
133    _submenu_.style.maxHeight = `${_submenu_.scrollHeight}px`;
134    _nav_.style.maxHeight = `${_nav_.scrollHeight+_submenu_.scrollHeight}px`;
135    return;
136}*/
137
138/*
139==========================================================================================================
140*/
141
142function handleWindowResize()
143{
144    if(window.innerWidth < 768) 
145    {
146        if(_header_.classList.contains('is-scrolled'))
147        {
148            _header_.classList.remove('is-scrolled');
149        }
150        return;
151    }
152    else
153    {
154        if(_hamburger_.classList.contains('hamburger-active'))
155        {
156            _hamburger_.classList.remove('hamburger-active');
157            _nav_.classList.remove('show');
158        }
159        if(_nav_.hasAttribute('style'))
160        {
161            _nav_.removeAttribute('style');
162        }
163    }
164    handleWindowScroll();
165}
166
167/*
168==========================================================================================================
169*/
170
171function handleWindowScroll()
172{
173    if(window.innerWidth < 768) return;
174    if(window.pageYOffset > _headerOffsetTop_)
175    {
176        if(!_header_.classList.contains('is-scrolled'))
177        {
178            _header_.classList.add('is-scrolled');
179        }
180    }
181    else
182    {
183        if(_header_.classList.contains('is-scrolled'))
184        {
185            _header_.classList.remove('is-scrolled');
186        }
187    }
188}
189
190/*
191==========================================================================================================
192*/
193
194function handleAnimateScroll()
195{
196    let _scale_ = 0;
197    if(window.innerHeight > document.body.scrollHeight)
198    {
199        for(i = 0; i < _animateElements_.length; i++)
200        {
201            if(!_animateElements_[i].classList.contains('inView'))
202            {
203                _animateElements_[i].classList.add('inView');
204            }
205        }
206        window.removeEventListener('scroll', handleAnimateScroll);
207        return;
208    }
209    if(!_animateElements_)
210    {
211        window.removeEventListener('scroll', handleAnimateScroll);
212        return;
213    }
214    let _inView_ = document.querySelectorAll('.inView');
215    if(_animateElements_.length == _inView_.length)
216    {
217        console.log('removed');
218        window.removeEventListener('scroll', handleAnimateScroll);
219        return;
220    }
221    for(i = 0; i < _animateElements_.length; i++)
222    {
223        if(isScrolledIntoView(_animateElements_[i],80))
224        {
225            if(!_animateElements_[i].classList.contains('inView'))
226            {
227                _animateElements_[i].classList.add('inView');
228            }
229        }
230    }
231}
232
233/*
234==========================================================================================================
235*/
236
237function isScrolledIntoView(el,treshold) 
238{
239    let _rect_ = el.getBoundingClientRect();
240    return _rect_.bottom > 0 &&
241        _rect_.right > 0 &&
242        _rect_.left < (window.innerWidth-treshold || document.documentElement.clientWidth-treshold) /* or $(window).width() */ &&
243        _rect_.top < (window.innerHeight-treshold || document.documentElement.clientHeight-treshold) /* or $(window).height() */;
244}
245
246/*
247==========================================================================================================
248*/
249
250function smoothScroll(e,_hashParam_)
251{
252    let _hash_ = '';
253    if(e !== null)
254    {
255        _hash_ = this.hash;
256        e.preventDefault();
257    }
258    if(_hashParam_ !== undefined)
259    {
260        _hash_ = _hashParam_;
261    }
262    if(_hash_ == '')
263    {
264        return;
265    }
266    const _scrollTo_ = document.querySelector(_hash_), 
267    _excludeLinks_ = ['cmplz-link'];
268    for(i = 0 ; i < _excludeLinks_.length; i++)
269    {
270        if(_scrollTo_.classList.contains(_excludeLinks_[i]))
271        {
272            return;
273        }
274    }
275    if(_scrollTo_ === null)
276    {
277        return;
278    }
279    const _offsetTop_ = _scrollTo_.getBoundingClientRect().top,
280    _scrollTop_ = window.scrollY || window.pageYOffset;
281    let _totalOffset_ = 0;
282    if(window.innerWidth >= 768)
283    {
284        _totalOffset_ = _offsetTop_+_scrollTop_-100;
285    }
286    else
287    {
288        _totalOffset_ = _offsetTop_+_scrollTop_;
289    }
290    jQuery('html, body').animate({scrollTop: _totalOffset_}, 500, function(){
291        return;
292    });
293}
294
295/*
296==========================================================================================================
297*/
298
299function historyExists()
300{
301    if(history.pushState) 
302    {
303        return true;
304    }
305    return false;
306}
307
308/*
309==========================================================================================================
310*/
311
312function scrollTo(_node_,_scrollPast_,_offset_)
313{
314    const _offsetTop_ = _node_.getBoundingClientRect().top,
315    _scrollTop_ = window.scrollY || window.pageYOffset;
316    let _totalOffset_ = 0;
317    if(_offset_)
318    {
319        _totalOffset_ = _offsetTop_+_scrollTop_-_offset_;
320    }
321    else
322    {
323        _totalOffset_ = _offsetTop_+_scrollTop_;
324    }
325    if(_scrollPast_)
326    {
327        _totalOffset_ += _node_.scrollHeight;
328    }
329    jQuery('html, body').animate({scrollTop: _totalOffset_}, 500, function(){
330        return;
331    });
332}
333
334/*
335==========================================================================================================
336*/
337
338/*function _calculateScrollbarWidth() 
339{
340    document.documentElement.style.setProperty('--scrollbar-width', (window.innerWidth - document.documentElement.clientWidth) + "px");
341}
342// recalculate on resize
343window.addEventListener('resize', _calculateScrollbarWidth, false);
344// recalculate on dom load
345document.addEventListener('DOMContentLoaded', _calculateScrollbarWidth, false); 
346// recalculate on load (assets loaded as well)
347window.addEventListener('load', _calculateScrollbarWidth);*/
348
349/*
350==========================================================================================================
351*/
352
353function disableAll(e)
354{
355    e.stopPropagation();
356    e.preventDefault();
357}
358
359/*
360==========================================================================================================
361*/
362
363function handleWindowLoad()
364{
365    /*if(document.querySelector('.atraktivityblock-swiper'))
366    {
367        let _akce_ = new Swiper ('.swiper-container.atraktivityblock-swiper', {
368            direction: 'horizontal',
369            loop: true,
370            slidesPerView: 1,
371            spaceBetween: 0,
372            navigation: {
373                nextEl: '.atraktivityblock-swiper-next',
374                prevEl: '.atraktivityblock-swiper-prev'
375            },
376            pagination: {
377                el: '.atraktivityblock-swiper-pagination',
378                clickable: true
379            },
380        });
381    } */
382    if(document.querySelector('.mainslider'))
383    {
384        let _akce_ = new Swiper ('.swiper-container.mainslider', {
385            direction: 'horizontal',
386            loop: true,
387            slidesPerView: 1,
388            spaceBetween: 0,
389            navigation: {
390                nextEl: '.mainslider-swiper-next',
391                prevEl: '.mainslider-swiper-prev'
392            },
393            pagination: {
394                el: '.mainslider-swiper-pagination',
395                clickable: true
396            },
397        });
398    }
399    if(document.querySelector('.atraktivity-swiper'))
400    {
401        let _akce_ = new Swiper ('.swiper-container.atraktivity-swiper', {
402            direction: 'horizontal',
403            loop: true,        
404            autoHeight: true,
405            slidesPerView: 1,
406            spaceBetween: 0,
407            navigation: {
408                nextEl: '.atraktivity-swiper-next',
409                prevEl: '.atraktivity-swiper-prev'
410            },
411        });
412    }
413    if(document.querySelector('.atraktivita-swiper'))
414    {
415        let _atraktivity_ = new Swiper ('.swiper-container.atraktivita-swiper', {
416            direction: 'horizontal',
417            loop: true,
418            autoHeight: true,
419            slidesPerView: 1,
420            spaceBetween: 0,
421            navigation: {
422                nextEl: '.atraktivita-swiper-next',
423                prevEl: '.atraktivita-swiper-prev'
424            }
425        });
426    }
427    /*if(document.querySelector('.galerie-swiper'))
428    {
429        let _galleries_ = document.querySelectorAll('.swiper-container.galerie-swiper');
430        for(i = 0 ; i < _galleries_.length; i++)
431        {
432            let _id_ = _galleries_[i].dataset.gallery;
433            _galerie_[_id_] = new Swiper (_galleries_[i], {
434                direction: 'horizontal',
435                loop: true,
436                slidesPerView: 1,
437                spaceBetween: 4,
438                navigation: {
439                    nextEl: '.galerie-swiper-next',
440                    prevEl: '.galerie-swiper-prev',
441                },
442                breakpoints: {
443                    992: {
444                        slidesPerView: 4
445                    },
446                    768: {
447                        slidesPerView: 3
448                    },
449                    576: {
450                        slidesPerView: 2
451                    }
452                }
453            });
454        }
455    }*/
456    /*if(document.querySelector('.akce-swiper'))
457    {
458        let _akce_ = new Swiper ('.swiper-container.akce-swiper', {
459            direction: 'horizontal',
460            loop: true,
461            slidesPerView: 1,
462            spaceBetween: 0,
463            navigation: {
464                nextEl: '.akce-swiper-next',
465                prevEl: '.akce-swiper-prev'
466            },
467            pagination: {
468                el: '.akce-swiper-pagination',
469                clickable: true
470            },
471        });
472    }
473    if(document.querySelector('.obchody-swiper'))
474    {
475        let _obchody_ = new Swiper ('.swiper-container.obchody-swiper', {
476            direction: 'horizontal',
477            loop: true,
478            slidesPerView: 1,
479            spaceBetween: 0,
480            navigation: {
481                nextEl: '.obchody-swiper-next',
482                prevEl: '.obchody-swiper-prev'
483            },
484            pagination: {
485                el: '.obchody-swiper-pagination',
486                clickable: true
487            },
488        });
489    }*/
490    //_loader_.classList.add('d-none');
491    handleAnimateScroll();
492    handleWindowScroll();
493}
494
495handleWindowLoad();
496
497/*
498==========================================================================================================
499*/

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.