PageSourceSearch

https://www.victoriapalacehotels.com/wp-content/themes/victoriapalace/assets/js/main.js?ver=7.1.3

js victoriapalacehotels.com collected 2026-10-10 02:05:28 UTC 13,586 bytes, 410 lines download raw bytes

1(function($){
2    'user strict';
3    const xs = window.matchMedia( "(max-width: 767px)" );
4    const sm = window.matchMedia( "(min-width: 768px) and (max-width: 991px)");
5    const md = window.matchMedia( "(min-width: 992px) and (max-width: 1198px)" );
6    const lg = window.matchMedia( "(min-width: 1199px)" );
7    const minPageLoad = 2000;
8    const beforeLoad = (new Date()).getTime();
9    const triggerFixed = calcHeaderBarHeight();
10    const triggerAnimation = triggerFixed +200;
11
12    $(window).load(function() {
13        editMasterSlider();
14        checkHalfBlocksBackground();
15        let loadingTime = getPageLoadTime();
16        let delay = 0;
17        if(loadingTime < minPageLoad)
18        {
19            delay += minPageLoad - loadingTime;
20        }
21        if($('body').hasClass('home'))
22        {
23            $('.logo-splash').delay(delay + 250).animate({opacity:0}, 250,'easeOutQuad',function(){
24                $('#splash').delay(250).animate({opacity: 0}, 250,'easeInQuad',function()
25                {
26                    $(this).remove();
27                });
28            });
29        } else {
30            $('#splash').delay(delay).animate({opacity: 0}, 250,'easeInQuad',function()
31            {
32                $(this).remove();
33            });
34        }
35    });
36
37    $(function(){
38
39        retinajs();
40
41        if($('body').hasClass('home'))
42        {
43            $('.logo-splash').delay(500).animate({opacity: 1}, 500,'easeInQuad');
44        } else {
45            let headerBar = $('#header-bar');
46            headerBar.addClass('fixed animate transition-off');
47            $('#fixed-spacing').height(headerBar.outerHeight(true));
48        }
49
50
51        /* WOW JS */
52        let wow = new WOW({'offset':50,'mobile':false});
53        wow.init();
54
55        checkFixed();
56        checkAnimation();
57        checkFixedSpacing();
58        setupBooking();
59
60        /* SLICK GALLERIES INIT */
61        let config = {
62            "slidesToShow": 1,
63            "slidesToScroll": 1,
64            "prevArrow": '<span class="slick-prev slick-arrow"><img src=' + templateUrl + '/assets/images/freccia_sx.png data-rjs="2"></span>',
65            "nextArrow": '<span class="slick-next slick-arrow"><img src=' + templateUrl + '/assets/images/freccia_dx.png data-rjs="2"></span>'
66        };
67
68        let galleryWrapper = $('.gallery-wrapper');
69
70        galleryWrapper.on('init reInit afterChange', function(event, slick, currentSlide, nextSlide)
71        {
72            let current = (currentSlide ? currentSlide : 0) + 1;
73            let currentFormatted = current;
74            if(current < 10){
75                currentFormatted = '0'+currentFormatted;
76            }
77            let max = slick.slideCount;
78            let maxFormatted = max;
79            if(max < 10)
80            {
81                maxFormatted = '0'+maxFormatted;
82            }
83            $(this).next().find('.gallery-pager').text(currentFormatted + '/' + maxFormatted);
84            current = current -1;
85            if(max === 1)
86            {
87                $(this).addClass('only-one');
88            }
89            let slide = $(this).find('.slick-slide[data-slick-index='+current+']');
90            let alt = slide.attr('data-alt');
91            $(this).prev().text(alt);
92        });
93
94        galleryWrapper.each(function(index) {
95            config['appendArrows'] = $(this).next().find('.gallery-controls');
96            $(this).slick(config);
97        });
98
99
100        $('.filter-term').click(function(){
101            if($(this).hasClass('active'))
102            {
103                $(this).removeClass('active');
104            } else {
105                $(this).addClass('active');
106            }
107
108            let currentFilters = [];
109            let block = $(this).parents('.block');
110            let filters = block.find('.filter-term');
111            filters.each(function(index){
112                if($(this).hasClass('active')){
113                    currentFilters.push($(this).data('filter'));
114                }
115            });
116
117            let elements = block.find('.filterable');
118            if(currentFilters.length === 0){
119                elements.each(function(){
120                    $(this).fadeIn(300);
121                });
122            } else {
123                elements.each(function(){
124                    let filterableTerms = $(this).data('terms').split(' ').map(Number);
125                    let intersect = $.grep(currentFilters, function(element) {
126                        return $.inArray(element, filterableTerms ) !== -1;
127                    });
128                    if(intersect.length>0)
129                    {
130                        $(this).fadeIn();
131                    } else {
132                        $(this).fadeOut();
133                    }
134
135                });
136            }
137
138
139        });
140
141
142
143        $('.header-bottombar-toggle').click(function()
144        {
145            $(this).toggleClass('closed open');
146
147            let body = $('body');
148            body.toggleClass('mobile-closed mobile-open');
149            if((md.matches || lg.matches))
150            {
151                if(body.hasClass('mobile-closed')){
152                    body.css('margin-right','0');
153                } else {
154                    body.css('margin-right',getScrollBarWidth());
155                }
156            }
157
158            let headerMobile = $('#header-mobile');
159            let headerMobileSocialLanguages = $('.header-mobile-social-languages');
160            headerMobile.toggleClass('closed open');
161            if((md.matches || lg.matches))
162            {
163                if(headerMobile.hasClass('closed')){
164                    headerMobileSocialLanguages.css('right','20px');
165                } else {
166                    headerMobileSocialLanguages.css('right',20 + getScrollBarWidth());
167                }
168            }
169
170            let headerBar = $('#header-bar');
171            let headerBottombarBooking = $('.header-bottombar-booking');
172            if((md.matches || lg.matches))
173            {
174                if(headerMobile.hasClass('closed')){
175                    headerBottombarBooking.css('margin-right','0');
176                } else {
177                    if(headerBar.hasClass('fixed')){
178                        headerBottombarBooking.css('margin-right', getScrollBarWidth()+1);
179                    } else {
180                        headerBottombarBooking.css('margin-right','0');
181                    }
182                }
183            }
184        });
185
186
187
188        /**
189         *****************************************************************************************************************************************
190         * Scroll events
191         */
192        $(window).scroll(function() {
193            checkFixed();
194            checkAnimation();
195            checkFixedSpacing();
196        });
197
198
199        /**
200         *****************************************************************************************************************************************
201         * Resize events
202         */
203        $(window).resize(function() {
204            checkFixedSpacing();
205            checkHalfBlocksBackground();
206            if($(window).width() < 992)
207            {
208                if($('body').hasClass('home'))
209                {
210                    $('#header-bar').removeClass('fixed');
211                }
212            } else {
213                checkFixed();
214            }
215        });
216
217    });
218
219
220    function checkFixedSpacing()
221    {
222        let body = $('body');
223        let headerBar = $('#header-bar');
224        if((md.matches || lg.matches))
225        {
226            if(body.hasClass('home'))
227            {
228                if(headerBar.hasClass('fixed')){
229                    $('#fixed-spacing').height(190);
230                } else {
231                    $('#fixed-spacing').height(0);
232                }
233            } else {
234                $('#fixed-spacing').height(calcHeaderBarHeight());
235            }
236        } else {
237            $('#fixed-spacing').height(0);
238        }
239    }
240
241    function checkFixed()
242    {
243        if($('body').hasClass('home'))
244        {
245            let headerBar = $('#header-bar');
246            if ((md.matches || lg.matches))
247            {
248                if ($(window).scrollTop() > triggerFixed)
249                {
250                    headerBar.addClass('fixed');
251                    headerBar.slideDown();
252                } else {
253                    headerBar.removeClass('transition');
254                    headerBar.removeClass('fixed');
255                }
256            } else {
257                headerBar.removeClass('transition');
258                headerBar.removeClass('fixed');
259            }
260        }
261    }
262
263    function checkAnimation()
264    {
265        let body = $('body');
266        let headerBar = $('#header-bar');
267        if(body.hasClass('home')) {
268            if ((md.matches || lg.matches))
269            {
270                if ($(window).scrollTop() > triggerAnimation)
271                {
272                    headerBar.addClass('animate');
273                    headerBar.addClass('transition');
274                } else {
275                    headerBar.removeClass('animate');
276                }
277            } else {
278                headerBar.removeClass('animate');
279            }
280        }
281    }
282
283    function getScrollBarWidth()
284    {
285        let $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
286            widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth();
287        $outer.remove();
288        return 100 - widthWithScroll;
289    }
290
291    function checkHalfBlocksBackground()
292    {
293        let halfBlockBackground = $('.black-background.top , .black-background.bottom');
294        $.each(halfBlockBackground, function(index,el) {
295            let blockHeight = $(this).outerHeight();
296            let galleryHeight = $(this).find('.gallery-wrapper').outerHeight()/2;
297            let galleryOffsetParent = $(this).find('.gallery-wrapper').offsetParent();
298            if(galleryOffsetParent.length > 0){
299                let galleryOffset = galleryOffsetParent[0].offsetTop;
300                let height = blockHeight - galleryHeight - (galleryOffset);
301                $(this).find('.background').css('height',height);
302            }
303
304        });
305    }
306
307    function getPageLoadTime()
308    {
309        return (new Date()).getTime() - beforeLoad;
310    }
311
312    function calcHeaderBarHeight()
313    {
314        let body = $('body');
315        let headerBar = $('#header-bar');
316        if(body.hasClass('home'))
317        {
318            if(headerBar.hasClass('fixed')){
319                return 164;
320            } else {
321                return 190;
322            }
323        } else {
324            return 164;
325        }
326    }
327
328    function setupBooking()
329    {
330        let checkin = $('#checkin');
331        let checkout = $('#checkout');
332
333        let checkinInstance = checkin.flatpickr({
334            dateFormat: "m/d/Y",
335            altInput: true,
336            altFormat: "d.m",
337            defaultDate: new Date(),
338            disable: [
339                function (date) {
340                    return (date < new Date());
341                }
342            ],
343            onChange:
344                function (selectedDates, dateStr, instance) {
345                    if (+new Date(dateStr) === +new Date(checkout.val())) {
346                        checkoutInstance.clear();
347                        checkoutInstance.redraw();
348                        checkoutInstance.open();
349                    }
350                }
351        });
352
353        if (!checkin.val()) {
354            let today = new Date();
355            checkinInstance.setDate(today, true);
356        }
357
358        let checkoutInstance = checkout.flatpickr({
359            dateFormat: "m/d/Y",
360            altInput: true,
361            altFormat: "d.m",
362            defaultDate: new Date(checkin.val()).setDate(new Date(checkin.val()).getDate() + 1),
363            disable: [
364                function (date) {
365                    return (+date < +new Date(checkin.val()) + 86400);
366                }
367            ],
368        });
369    }
370
371    function editMasterSlider()
372    {
373        let masterSliderInstances = window.masterslider_instances;
374        if(masterSliderInstances)
375        {
376            let slider = masterSliderInstances[0];
377            let next = $('.ms-nav-next');
378            let prev = $('.ms-nav-prev');
379            next.next().andSelf().wrapAll('<div class="slider-control
379s"/>');
380            next.addClass('slider-next slider-arrow');
381            prev.addClass('slider-prev slider-arrow');
382            $('.slider-controls').wrapAll('<div class="slider-footer"/>');
383
384            //let max = slider.api.count(); non funziona su firefox
385            //console.log(slider.slides.length);
386            let max = slider.slides.length;
387            if(max<10){
388                max = '0'+max;
389            }
390            $('.slider-footer').append('<div class="slider-pager">01/'+max+'</div>');
391            prev.append('<img alt="prev-arrow" src="'+templateUrl+'/assets/images/freccia_sx.png" data-rjs="2"/>');
392            next.append('<img alt="next-arrow" src="'+templateUrl+'/assets/images/freccia_dx.png" data-rjs="2"/>');
393            retinajs( $('.slider-arrow img'));
394
395            slider.api.addEventListener(MSSliderEvent.CHANGE_START , function(){
396                let current = slider.api.index() + 1;
397                if(current < 10)
398                {
399                    current = '0' + current;
400                }
401                let max = slider.slides.length;
402                if(max<10){
403                    max = '0'+max;
404                }
405                $('.slider-pager').text(current+'/'+max);
406            });
407        }
408    }
409
410})(jQuery);

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.