PageSourceSearch

https://hidden-hotel.com/wp-content/plugins/de-builder-evo-blocks/…/assets/js/room_indexing.js?ver=1.0.0

js hidden-hotel.com collected 2026-09-26 10:06:05 UTC 25,250 bytes, 623 lines download raw bytes

1(function ($) {
2
3    $(document).on('click', 'qw-week-calendar', function (e) {
4        var isArrow = $(e.target).hasClass('qw-week-calendar__icon');
5        if (!isArrow) {
6            var $this = jQuery(this);
7            var top = $this.offset().top;
8            var left = $this.offset().left;
9            var parentWidth = $this.closest('qw-card').innerWidth();
10            var elWidth = window_width >= 1200 ? $this.innerWidth() : parentWidth;
11            var elLeft = window_width >= 1200 ? left + 'px' : 'auto';
12            var topDistance = top - $('.fusion_rooms_section').offset().top;
13            var calendar = $('qw-calendar[qw-calendar-id="rooms_qw_calendar"] .flatpickr-calendar');
14
15            calendar.fadeIn();
16            calendar.css({
17                'top': topDistance + 'px',
18                'left': elLeft,
19                'max-width': elWidth,
20                'margin-left': '0',
21                'margin-right': '0'
22            })
23        }
24    });
25
26
27    $(document).on('click', 'qw-price-calendar', function (e) {
28        var isArrow = $(e.target).hasClass('qw-price-calendar__icon');
29        if (!isArrow) {
30            var $this = jQuery(this);
31            var top = $this.offset().top;
32            var left = $this.offset().left;
33            var parentWidth = $this.closest('qw-card').innerWidth();
34            var elWidth = window_width >= 1200 ? $this.innerWidth() : parentWidth;
35            var elLeft = window_width >= 1200 ? left + 'px' : 'auto';
36            var topDistance = top - $('.fusion_rooms_section').offset().top;
37            var calendar = $('qw-calendar[qw-calendar-id="rooms_qw_calendar"] .flatpickr-calendar');
38
39            calendar.fadeIn();
40            calendar.css({
41                'top': topDistance + 'px',
42                'left': elLeft,
43                'max-width': elWidth,
44                'margin-left': '0',
45                'margin-right': '0'
46            })
47        }
48    });
49
50
51    $(document).on('click', '.controllers qw-calendar-inline', function (e) {
52        var $this = jQuery(this);
53        var top = $this.offset().top;
54        var parent = $this.closest('.controllers');
55        var height = $this.outerHeight();
56        var topDistance = top - $('.fusion_rooms_section').offset().top + 20;
57        var calendar = $('qw-calendar[qw-calendar-id="rooms_qw_calendar"] .flatpickr-calendar');
58        var left = 'auto';
59        var right = 'auto';
60        var margin_left = 'auto';
61        var margin_right = 'auto';
62
63        if (parent.hasClass('left')) {
64            left = window_width >= 1200 ? '0px' : 'auto';
65            margin_left = parent.css('margin-left');
66
67        }
68        if (parent.hasClass('right')) {
69            right = window_width >= 1200 ? '0px' : 'auto';
70            margin_right = parent.css('margin-left');
71        }
72
73        calendar.fadeIn();
74        calendar.css({
75            'top': topDistance + height + 'px',
76            'left': left,
77            'right': right,
78            'margin-left': margin_left,
79            'margin-right': margin_right,
80        })
81    });
82
83    $(document).ready(function () {
84        closeRoomsBF();
85    });
86
87
88    //this event is triggered by the components itself
89    $('qw-room-list').on('qwRoomListOnLoad', function () {
90        initRoomList();
91    });
92
93    // original function found on Hotel Gabriel; needed to associate room cards to corresponding page
94    // https://git.fastbooking.ch/webprogram/hotel-gabriel/-/blob/master/src/js/room-list.js
95    // indexing variable room_id_mapping is created by a php function (see templates/utils.php)
96
97
98    function closeRoomsBF() {
99        jQuery('body').click(function (event) {
100
101            var roomsCalendar = $('qw-calendar[qw-calendar-id="rooms_qw_calendar"] .flatpickr-calendar');
102
103            if (!$(event.target).closest('qw-week-calendar').length
104                && !$(event.target).is('.qw-week-calendar')
105                && !$(event.target).is('qw-calendar[qw-calendar-id="rooms_qw_calendar"]')
106                && !$(event.target).parents('qw-calendar[qw-calendar-id="rooms_qw_calendar"]').length
107            ) {
108                roomsCalendar.fadeOut();
109            }
110
111        });
112    }
113
114    function initRoomList() {
115        document.addEventListener('qwRoomListClickRoom', function (e) {
116             console.log(e);
117            if (e.detail.type === 'changeDate') {
118                Modal.openModal(document.querySelector('#modal-calendar-guest'));
119                return;
120            }
121            var strRoomId = e.detail.room.roomId.toString();
122            if (typeof room_id_mapping[strRoomId] !== 'undefined') {
123                window.location.href = room_id_mapping[strRoomId] + '?type=' + e.detail.type;
124            }
125        });
126    }
127
128
129    //debouncing
130    function debouncing(func, timeout) {
131        var timer;
132        return function () {
133            var args = arguments;
134            clearTimeout(timer);
135            timer = setTimeout(function () {
136                func.apply(this, args);
137            }, timeout);
138        };
139    }
140
141
142    function manageRoomsReprint() {
143        //fires at the session loading
144        $(window).one('qwSessionLoaded', debouncing(function (e) {
145            if ($('.fusion_rooms_section.list_offers ').length > 0) {
146                console.log('session loaded reprint');
147                initOrCollapseRates();
148               // addScrollBarOrNot();
149            }
150        }, 500));
151
152        //fires after adding/removing a room
153        $(window).on('qwBasketChange qwRoomListOnLoad', debouncing(function (e) {
154            console.log('cart change reprint');
155            initOrCollapseRates();
156            //addScrollBarOrNot();
157        }, 500));
158
159    }
160
161
162    manageRoomsReprint();
163
164
165    //first round: use intersection observer in order to wait until the rates are all loaded
166    window.initOrCollapseRates = function () {
167        var rooms = $('.fusion_rooms_section .qw-room-list-card--inline qw-card');
168        console.log('collapseRates', rooms);
169        rooms.each(function () {
170            var room = $(this);
171            if (!room.attr('collapseInitialized')) {
172                var observer = new MutationObserver(debouncing(function (mutList, observer) {
173                    console.log('room initialized');
174                    observer.disconnect();
175                    collapseRates(room);
176                    room.attr('collapseInitialized', true);
177                }, 200));
178               // console.log('lepre', room.find('qw-room-rates .qw-room-rates__wrapper')[0]);
179                observer.observe(room.find('qw-room-rates .qw-room-rates__wrapper')[0], {childList: true});
180            } else {
181                setTimeout(function () {
182                    collapseRates(room)
183                }, 100);
184            }
185        });
186    };
187
188    window.collapseRates = function (room) {
189        console.log(room);
190        var rowRates = room.find('qw-room-rate:visible');
191        var wrapper = room.find('qw-room-rates');
192        var button = room.find('.expand_rooms_rates');
193
194
195        var maxHeight = 'auto';
196
197        var rowHeightExp = (rowRates.eq(0).outerHeight() + rowRates.eq(1).outerHeight());
198        wrapper.css({
199            'overflow': 'hidden',
200            'height': rowHeightExp + 'px'
201        });
202
203        var counter_highlited = 0;
204        rowRates.each(function () {
205            if ($(this).hasClass('qw-room-rate__highlight')) {
206                counter_highlited++;
207            }
208        });
209
210        if (counter_highlited === 0) {
211            room.find('qw-room-rate:first').find('.qw-room-rate__package-trigger').css('display', 'flex');
212            room.find('qw-room-rate:nth-child(2)').find('.qw-room-rate__package-trigger').css('display', 'flex');
213        } else if (counter_highlited === 1) {
214            room.find('qw-room-rate.qw-room-rate__highlight').find('.qw-room-rate__package-trigger').css('display', 'flex');
215            if (room.find('qw-room-rate.qw-room-rate__highlight').index() === 0) {
216
217                room.find('qw-room-rate:nth-child(2)').find('.qw-room-rate__package-trigger').css('display', 'flex');
218            } else {
219                room.find('qw-room-rate:nth-child(1)').find('.qw-room-rate__package-trigger').css('display', 'flex');
220            }
221        } else {
222            var highlited = room.find('qw-room-rate.qw-room-rate__highlight').slice(0, 2);
223            highlited.each(function () {
224                room.find('.qw-room-rate__package-trigger').css('display', 'flex');
225            });
226        }
227
228        wrapper.css({
229            'overflow': 'hidden',
230            'height': rowHeightExp + 'px'
231        });
232
233
234        if (rowRates.length > 2 && button.length === 0) {
235            var buttonHtml = '<a href="javascript:;" class="expand_rooms_rates info collapsed">' + qwRoomsExpandOffersList + '</a>';
236            room.find('.qw-room-list-card__rates').append(buttonHtml)
237        } else if (rowRates.length <= 2) {
238            var exapand = room.find('.qw-room-list-card__rates .expand_rooms_rates');
239            if (exapand.length > 0) {
240                exapand.remove();
241            }
242        }
243
244        // avoid binding to this click twice. (once when the page loads - session, rooms, etc - and every time
245        // the basket changes.
246        if (!room.attr('collapseInitialized')) {
247            room.find('.expand_rooms_rates').on('click', function () {
248                var thisButton = $(this);
249
250
251                if (thisButton.hasClass('collapsed')) {
252                    wrapper.css({
253                        'overflow': 'visible',
254                        'height': maxHeight
255                    });
256                    thisButton.removeClass('collapsed').addClass('rotateArrow');
257                    wrapper.addClass('expanded');
258                } else {
259                    wrapper.css({
260                        'overflow': 'hidden',
261                        'height': rowHeightExp + 'px'
262                    });
263                    thisButton.addClass('collapsed').removeClass('rotateArrow');
264                    wrapper.removeClass('expanded');
265                }
266
267
268            })
269        }
270    };
271
272    $(document).on('click', '.qw-room-rate__conditions-trigger', function () {
273        setTimeout(function () {
274            initOrCollapseRates();
275        }, 200);
276    });
277
278
279    //HOURS SPENT TO MAKE THE OFFER CARDS LIKE A CAROUSEL: 36
280    //Please increase the counter above if you will work on it
281
282    //this event is triggered on every cards component mutation
283    window.deBounce = false;
284
285    function calculateScrollbarRoomsOffers(){
286
287        $('qw-room-list qw-room-rates').parent().each(function () {
288            var me = $(this).find('qw-room-rates');
289            if(!me.hasClass('qw-room-list-card__prices') && me.find('.qw-room-rates__wrapper').children().length > 0 ) {
290                var arrows = me.find('.arrow');
291                if (arrows.length === 0 ) {
292                    me.find('.qw-room-rates__wrapper').removeClass('justify_center');
293                    me.append(' <a href="javascript:;" class="arrow next hidden-sm hidden-xs "></a> <a href="javascript:;" class="arrow prev hidden-sm hidden-xs disabled"></a><div class="progressive_bar"><div class="scrolled"></div></div>');
294                }
295
296                if(me.find('.progressive_bar').is(":hidden")){
297                    me.find('.qw-room-rates__wrapper').addClass('justify_center');
298                }
299
300                var num_cards_room = me.find('qw-room-rate').length; //width + margin\n
301                var card_width_room = me.find('qw-room-rate').outerWidth(true); //width + margin + border
302                // var card_width_room = me.find('qw-room-rate').width() + 25; //width + margin + border
303                var starting_width_room = me.find('.qw-room-rates__wrapper').width();
304
305                var width_container_room = starting_width_room;
306                var start_point_room = (100 * width_container_room) / (card_width_room * num_cards_room);
307                if(starting_width_room >= (card_width_room*num_cards_room)){
308                    start_point_room = 100;
309                    me.find('.progressive_bar').css('display', 'none');
310                    me.find('.arrow.next').css('display','none');
311                    me.find('.arrow.prev').css('display','none');
312                } else {
313                    me.find('.progressive_bar').css('display', 'block');
314                    me.find('.arrow.next').css('display','block');
315                    me.find('.arrow.prev').css('display','block');
316                }
317
318                var init_progress_room = start_point_room;
319
320                me.find('.progressive_bar .scrolled').css('width', init_progress_room+ '%');
321                me.find('.arrow.prev').addClass('disabled_arrow');
322
323
324                me.find('.qw-room-rates__wrapper').on("scroll", function (e) {
325                    var drag_progress_room = 0;
326                    var horizontal_room = e.currentTarget.scrollLeft;
327                    var scrolled_div_room = parseInt(starting_width_room) + parseInt(horizontal_room);
328                    if(scrolled_div_room < num_cards_room*card_width_room){
329                        drag_progress_room = (100 * scrolled_div_room) / (card_width_room * num_cards_room);
330                        me.find('.progressive_bar .scrolled').css('width', drag_progress_room+ '%');
331                    } else {
332                        me.find('.progressive_bar .scrolled').css('width', '100%');
333                    }
334
335                });
336
337                var goto_room, position_cards_room;
338                me.find('.arrow.next').on('click', function (e) {
339                    e.preventDefault();
340                    e.stopPropagation();
341
342                    if( ! $(this).hasClass('disabled_arrow') && ! $(this).hasClass('disable_click')){
343                        me.find('.arrow.prev').removeClass('disabled_arrow');
344
345                        position_cards_room = me.find('qw-room-rate').css('transform');//.split(',')[4];
346                        if(position_cards_room !== 'none'){
347                            position_cards_room = parseInt(position_cards_room.split(',')[4]);
348                            goto_room = position_cards_room - card_width_room;
349                        } else {
350                            goto_room = -card_width_room;
351                        }
352
353                        width_container_room += card_width_room;
354                        if(width_container_room > (card_width_room*num_cards_room)){
355                            init_progress_room = 100;
356                            $(this).addClass('disabled_arrow');
357                        } else {
358                            init_progress_room = (100 * width_container_room) / (card_width_room * num_cards_room);
359                        }
360
361                        me.find('.progressive_bar .scrolled').css('width', init_progress_room+ '%');
362
363                        me.find('qw-room-rate').css('transform', 'translateX('+ goto_room +'px)');//disable arrows while animating
364                        var this_arrow = $(this);
365                        this_arrow.addClass("disable_click");
366                        me.find('.arrow.prev').addClass("disable_click");
367                        setTimeout(function(){
368                            this_arrow.removeClass("disable_click");
369                            me.find('.arrow.prev').removeClass("disable_click");
370                        }, 500);
371                    }
372
373                });
374
375                me.find('.arrow.prev').on('click', function (e) {
376                    e.preventDefault();
377                    e.stopPropagation();
378
379                    if( ! $(this).hasClass('disabled_arrow') && ! $(this).hasClass('disable_click')) {
380                        me.find('.arrow.next').removeClass('disabled_arrow');
381
382                        position_cards_room = me.find('qw-room-rate').css('transform');
383                        if (position_cards_room !== 'none') {
384                            position_cards_room = parseInt(position_cards_room.split(',')[4]);
385                            goto_room = position_cards_room + card_width_room;
386                        } else {
387                            goto_room = card_width_room;
388                        }
389
390                        if(position_cards_room !== 'none' && ((position_cards_room + card_width_room) >= 0 || position_cards_room === 0)) {
391                            goto_room = 0;
392                            $(this).addClass('disabled_arrow');
393                        }
394
395                        width_container_room -= card_width_room;
396                        if((position_cards_room + card_width_room) >= 0 || position_cards_room === 0) {
397                            init_progress_room = start_point_room;
398                        } else {
399                            init_progress_room = (100 * width_container_room) / (card_width_room * num_cards_room);
400                        }
401
402                        me.find('.progressive_bar .scrolled').css('width', init_progress_room + '%');
403                        me.find('qw-room-rate').css('transform', 'translateX(' + goto_room + 'px)');
404
405                        //disable arrows while animating
406                        var this_arrow = $(this);
407                        this_arrow.addClass("disable_click");
408                        me.find('.arrow.next').addClass("disable_click");
409                        setTimeout(function(){
410                            this_arrow.removeClass("disable_click");
411                            me.find('.arrow.next').removeClass("disable_click");
412                        }, 500);
413                    }
414                });
415            }
416
417
418        });
419
420    }
421
422
423    function checkIfHasRoomCode(){
424        $('qw-room-list .qw-room-list__card-wrapper').each(function(){
425            var item_classes = $(this).attr('class').split(/\s+/);
426            if(item_classes.length > 0){
427                var room_code = item_classes[0].replace('qw-room-list__room-id-','');
428                if (typeof room_id_mapping[room_code] !== 'undefined') {
429                    $('.qw-room-list__room-id-'+room_code).find('.qw-room-list-card__cta div:nth-child(1)').css('display','flex');
430                } else {
431                    $('.qw-room-list__room-id-'+room_code).find('.qw-room-list-card__cta div:nth-child(3)').css('display','flex');
432                }
433            }
434        })
435    }
436
437    function addScrollbarPopup(){
438
439        var theme = $('body').attr('id');
440        var scrollTheme = theme === 'dark_theme' || theme === 'darken_theme' ? 'light' : 'dark';
441        if(!is_mobile) {
442
443            $('.qw-room-list-card__details-popup-wrapper .content-info').each(function () {
444                var el = $(this);
445                el.mCustomScrollbar({
446                    axis: "y",
447                    scrollInertia: 500,
448                    theme: scrollTheme,
449                    mouseWheel: {enable: true},
450                    advanced: {
451                        autoExpandVerticalScroll: true,
452                        updateOnContentResize: true
453                    },
454                    scrollButtons: {
455                        enable: true,
456                        scrollType: "stepped"
457                    },
458                    // snapAmount: widthCard
459                });
460            });
461        }
462
463    }
464
465
466    //this event is triggered on every cards component mutation
467    $(document).on("DOMSubtreeModified", '.fusion_rooms_section.card .qw-room-rates__wrapper', function () {
468        if (deBounce) {
469            return;
470        }
471        deBounce = true;
472
473        setTimeout(function () {
474            deBounce = false;
475        }, 1000);
476
477        setTimeout(function () {
478            var cards = $('.qw-room-rate--card:visible');
479            var widthCard = cards.outerWidth(true);
480            var theme = $('body').attr('id');
481            var scrollTheme = theme === 'dark_theme' || theme === 'darken_theme' ? 'light' : 'dark';
482
483            calculateScrollbarRoomsOffers();
484        }, 300)
485    });
486    //this event is triggered on every cards component mutation
487    $(document).on("DOMSubtreeModified", '.fusion_rooms_section .qw-room-list__cards', function () {
488        if (deBounce) {
489            return;
490        }
491        deBounce = true;
492
493        setTimeout(function () {
494            deBounce = false;
495        }, 1000);
496
497        setTimeout(function () {
498            checkIfHasRoomCode();
499        }, 300)
500    });
501
502    //this event is triggered on every cards component mutation
503    $(document).on("DOMSubtreeModified", '.fusion_rooms_section qw-card', function () {
504        if (deBounce) {
505            return;
506        }
507        deBounce = true;
508
509        setTimeout(function () {
510            deBounce = false;
511        }, 1000);
512
513        setTimeout(function () {
514            addScrollbarPopup();
515        }, 1000)
516    });
517
518    $('qw-basket').on('qwBasketIsAccommodationSatisfy', function (e) {
519        $(document).on("DOMSubtreeModified", '.fusion_rooms_section.card .qw-room-rates__wrapper', function () {
520            setTimeout(function () {
521                calculateScrollbarRoomsOffers();
522            }, 500);
523        });
524    });
525
526    //package
527    $(document).on('click', '.qw-room-rate__package-close', function() {
528
529        $('body').removeClass('no_scroll');
530
531    });
532
533    //details popup
534    $(document).on('click', 'qw-button qw-button--to-remove:nth-child(3)', function() {
535        setTimeout(function() {
536            var popup = $('.qw-room-list-card__details-popup-content');
537            popup.appendTo('body');
538            $('body').addClass('no_scroll');
539            checkIfHasRoomCode();
540        }, 10);
541    });
542
543
544    $(document).on('click', '.qw-room-list-card__details-popup-content .close-icon', function(e) {
545        e.preventDefault();
546        e.stopPropagation();
547
548        $('body').removeClass('no_scroll');
549
550        setTimeout(function () {
551            initOrCollapseRates();
552            checkIfHasRoomCode();
553
554        }, 1500);
555
556    });
557
558    //no availability
559    // window.appendCounterNoAvailability = 0;
560    // $(window).on('qwNoAvailability', function (e) {
561    //
562    //     function appendStuff() {
563    //         var message = '<span>The minimum stay for the dates selected is ' + e.detail.minstay + ' nights</span>';
564    //         var arrival = new Date(e.detail.date);
565    //         var departure = new Date();
566    //         departure.setDate(arrival.getDate() + e.detail.minstay);
567    //
568    //         var curr_date = ("0" + departure.getDate()).slice(-2);
569    //         var curr_month = ("0" + (departure.getMonth() + 1)).slice(-2);
570    //         var curr_year = departure.getFullYear();
571    //
572    //         var link = '<br>';
573    //         link += '<div class="btns_wrap">';
574    //         link += '<span class="btnCta btn">';
575    //         link += '<a href="http://test-sequoia-3.showcase.d-edge.ws/rooms/';
576    //         link += '?departureDate=' + curr_year + '-' + curr_month + '-' + curr_date;
577    //         link += '&arrivalDate=' + e.detail.date + '">';
578    //         link += 'Apply ' +  e.detail.minstay +  ' nights';
579    //         link += '</a>';
580    //         link += '</span>';
581    //         link += '</div>';
582    //
583    //         $('#qw-no-availability').append(message);
584    //         $('#qw-no-availability').append(link);
585    //     }
586    //
587    //     if (e.detail !== null) {
588    //         var queryString = window.location.search;
589    //         var urlParams = new URLSearchParams(queryString);
590    //         var arrivalParam = urlParams.get('arrivalDate');
591    //         var departureParam = urlParams.get('departureDate');
592    //
593    //         if (( arrivalParam === null || departureParam === null)) {
594    //             if(appendCounterNoAvailability === 0){
595    //                 appendCounterNoAvailability++;
596    //                 appendStuff();
597    //             }
598    //             $.fancybox.open({
599    //                 src: '#qw-no-availability',
600    //                 type: 'inline',
601    //                 opts: {
602    //                     afterShow: function (instance, current) {
603    //                         console.info('done!');
604    //                     }
605    //                 }
606    //             });
607    //         }
608    //
609    //     }else{
610    //         $.fancybox.open({
611    //             src: '#qw-no-availability',
612    //             type: 'inline',
613    //             opts: {
614    //                 afterShow: function (instance, current) {
615    //                     console.info('done!');
616    //                 }
617    //             }
618    //         });
619    //     }
620    //
621    // })
622
623}(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.