PageSourceSearch

https://www.emperorhotel.com.hk/wp-content/plugins/de-builder-evo-…/assets/js/main_content.js?ver=1.0.0

js emperorhotel.com.hk collected 2026-09-30 21:02:36 UTC 13,352 bytes, 318 lines download raw bytes

1( function ($) {
2    $(document).ready(function () {
3        asideScroll();
4        collapsibleContent();
5        doGallery();
6        triggerqwEvent();
7        scrollToRates();
8
9    });
10
11    $(window).scroll(function () {
12        asideScroll();
13    });
14
15
16    function asideScroll() {
17        var aside = $('.aside_wrapper.fixed_on_scroll');
18        if (aside.length > 0) {
19            var bottomController = $('footer');
20            var main = $('main');
21            var afterContent = main.next('div');
22            if (afterContent.length > 0 && !afterContent.is(bottomController)) {
23                bottomController = afterContent;
24            }
25            var windowHeight = $(window).height();
26            var bottomControllerVisiblePart = $(window).scrollTop() - Math.floor(bottomController.offset().top - windowHeight);
27            var bottom = 0;
28            if (bottomControllerVisiblePart >= 0) {
29                bottom = bottomControllerVisiblePart;
30            }
31
32            if ($(window).scrollTop() > (main.offset().top - $('header').height()) && !is_mobile) {
33                aside.css({
34                    'bottom': bottom
35                });
36                aside.addClass('fixed');
37            } else {
38                aside.css({
39                    'bottom': '0'
40                });
41                aside.removeClass('fixed');
42            }
43
44        }
45    }
46
47    function collapsibleContent() {
48        var button = $('.main .collapsibleContent_btn'),
49            mClass = 'open',
50            mClass2 = 'content_is_visible';
51        button.click(function () {
52            setTimeout(function () {
53                asideScroll();
54            }, 200);
55            var btn = $(this);
56            var parent = $('.main .content_wrap');
57            var wrap = parent.find('.collapsibleContent');
58            if (!btn.hasClass(mClass)) {
59                var height = wrap.find('.the_content').outerHeight(true);
60                wrap.css({
61                    'height': height
62                });
63                btn.addClass(mClass);
64                btn.html(read_less);
65                $(parent).addClass(mClass2);
66            } else {
67                wrap.css({
68                    'height': 0
69                });
70                btn.html(read_more);
71                btn.removeClass(mClass);
72                $(parent).removeClass(mClass2);
73            }
74        });
75    }
76
77    function scrollToRates() {
78        var item = $('.main qw-price');
79        var header = $('header');
80        item.click(function () {
81            var goTo = '.fusion_rates_container',
82                top_part = header.outerHeight(),
83                top = $(goTo).offset().top - top_part;
84
85            $('html,body').stop().animate({scrollTop: top}, 500);
86        });
87    }
88
89
90    function doGallery() {
91        var wrap = $('.deb_gallery .gallery_container');
92        if (wrap.length > 0) {
93
94            //LAZY LOADING (before carousel is loaded)
95            wrap.on("init", function () {
96                lazyLoadInstance.update();
97            });
98            var arrow_class = wrap.attr('data-arrows');
99            wrap.parent().append('<a class="arrow hidden-xs hidden-sm prev ' + arrow_class + '" href="javascript:;">' +
100                '<span></span></a><a class="arrow hidden-xs hidden-sm next ' + arrow_class + '" href="javascript:;"><span></span></a>' +
101                '<div class="pager hidden-md hidden-lg"></div>');
102
103            //slideshow setup
104            wrap.slick({
105                rtl : rtl,
106                rows: 0,
107                fade: true,
108                pauseOnHover: false,
109                pauseOnFocus: false,
110                autoplay: true,
111                autoplaySpeed: 5000,
112                speed: 1000,
113                arrows: true,
114                dots: false,
115                nextArrow: wrap.parent().find('.next'),
116                prevArrow: wrap.parent().find('.prev'),
117                responsive: [{
118                    breakpoint: 700,
119                    settings: {
120                        slidesToShow: 1,
121                        slidesToScroll: 1,
122                        variableWidth: false,
123                        arrows: false,
124                        dots: true,
125                        appendDots: wrap.parent().find('.pager')
126                    }
127                }]
128            });
129        }
130    }
131
132
133    $(window).on('qw-room-rich-info--loaded', function () {
134        fusionAmeniteiesTab = $('.qw-room-rich-info__amenities-trigger');
135        fusionAmeniteiesTab.on('click', function () {
136            $(this).toggleClass('active')
137        });
138        if ($('qw-room-rich-info').hasClass('autoexpand')) {
139            fusionAmeniteiesTab.trigger('click');
140        }
141    });
142
143    //this event is trigged on cards component loaded
144    function triggerqwEvent() {
145        var component = $('qw-room-rich-info');
146        counter = 0;
147        if (component.length > 0) {
148            setInterval(function () {
149                if ((component).hasClass('qw-room-rich-info--loaded') && counter === 0) {
150                    $(window).trigger('qw-room-rich-info--loaded');
151
152                    counter++;
153                }
154            }, 500);
155        }
156    }
157
158    //HOURS SPENT TO MAKE THE OFFER CARDS LIKE A CAROUSEL: 36
159    //Please increase the counter above if you will work on it
160
161    window.deBounce = false;
162    //this event is triggered on every cards component mutation
163
164
165    $(document).on("DOMSubtreeModified", '.fusion_rates_container qw-room-rates', function () {
166        if (deBounce) {
167            return;
168        }
169        deBounce = true;
170
171        setTimeout(function () {
172            deBounce = false;
173        }, 1000);
174
175        setTimeout(function () {
176            calculateScrollbarSingleRoomOffers();
177        }, 1200)
178    });
179
180     window.calculateScrollbarSingleRoomOffers = function(){
181
182        $('.fusion_rates_container').each(function () {
183            var me = $(this).find('qw-room-rates');
184            if(!me.hasClass('qw-room-list-card__prices') && me.find('.qw-room-rates__wrapper').children().length > 0 ) {
185                var arrows = me.find('.arrow');
186                if (arrows.length === 0 ) {
187                    me.find('.qw-room-rates__wrapper').removeClass('justify_center');
188                    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>');
189                }
190
191                if(me.find('.progressive_bar').is(":hidden")){
192                    me.find('.qw-room-rates__wrapper').addClass('justify_center');
193                }
194
195                var num_cards_room = me.find('qw-room-rate').length; //width + margin\n
196                var card_width_room = me.find('qw-room-rate').outerWidth(true); //width + margin + border
197                var starting_width_room = me.find('.qw-room-rates__wrapper').width();
198
199                var width_container_room = starting_width_room;
200                var start_point_room = (100 * width_container_room) / (card_width_room * num_cards_room);
201                if(starting_width_room >= (card_width_room*num_cards_room)){
202                    start_point_room = 100;
203                    me.find('.progressive_bar').css('display', 'none');
204                    me.find('.arrow.next').css('display','none');
205                    me.find('.arrow.prev').css('display','none');
206                    me.find('.qw-room-rates__wrapper').addClass('justify_center');
207                } else {
208                    me.find('.progressive_bar').css('display', 'block');
209                    me.find('.arrow.next').css('display','block');
210                    me.find('.arrow.prev').css('display','block');
211                    me.find('.qw-room-rates__wrapper').removeClass('justify_center');
212                }
213
214                var init_progress_room = start_point_room;
215
216                me.find('.progressive_bar .scrolled').css('width', init_progress_room+ '%');
217                me.find('.arrow.prev').addClass('disabled_arrow');
218
219
220                me.find('.qw-room-rates__wrapper').on("scroll", function (e) {
221                    var drag_progress_room = 0;
222                    var horizontal_room = e.currentTarget.scrollLeft;
223                    var scrolled_div_room = parseInt(starting_width_room) + parseInt(horizontal_room);
224                    if(scrolled_div_room < num_cards_room*card_width_room){
225                        drag_progress_room = (100 * scrolled_div_room) / (card_width_room * num_cards_room);
226                        me.find('.progressive_bar .scrolled').css('width', drag_progress_room+ '%');
227                    } else {
228                        me.find('.progressive_bar .scrolled').css('width', '100%');
229                    }
230
231                });
232
233                var goto_room, position_cards_room;
234                me.find('.arrow.next').on('click', function (e) {
235                    e.preventDefault();
236                    e.stopPropagation();
237
238                    if( ! $(this).hasClass('disabled_arrow') && ! $(this).hasClass('disable_click')){
239                        me.find('.arrow.prev').removeClass('disabled_arrow');
240
241                        position_cards_room = me.find('qw-room-rate').css('transform');//.split(',')[4];
242                        if(position_cards_room !== 'none'){
243                            position_cards_room = parseInt(position_cards_room.split(',')[4]);
244                            goto_room = position_cards_room - card_
244width_room;
245                        } else {
246                            goto_room = -card_width_room;
247                        }
248
249                        width_container_room += card_width_room;
250                        if(width_container_room > (card_width_room*num_cards_room)){
251                            init_progress_room = 100;
252                            $(this).addClass('disabled_arrow');
253                        } else {
254                            init_progress_room = (100 * width_container_room) / (card_width_room * num_cards_room);
255                        }
256
257                        me.find('.progressive_bar .scrolled').css('width', init_progress_room+ '%');
258
259                        me.find('qw-room-rate').css('transform', 'translateX('+ goto_room +'px)');//disable arrows while animating
260                        var this_arrow = $(this);
261                        this_arrow.addClass("disable_click");
262                        me.find('.arrow.prev').addClass("disable_click");
263                        setTimeout(function(){
264                            this_arrow.removeClass("disable_click");
265                            me.find('.arrow.prev').removeClass("disable_click");
266                        }, 500);
267                    }
268
269                });
270
271                me.find('.arrow.prev').on('click', function (e) {
272                    e.preventDefault();
273                    e.stopPropagation();
274
275                    if( ! $(this).hasClass('disabled_arrow') && ! $(this).hasClass('disable_click')) {
276                        me.find('.arrow.next').removeClass('disabled_arrow');
277
278                        position_cards_room = me.find('qw-room-rate').css('transform');
279                        if (position_cards_room !== 'none') {
280                            position_cards_room = parseInt(position_cards_room.split(',')[4]);
281                            goto_room = position_cards_room + card_width_room;
282                        } else {
283                            goto_room = card_width_room;
284                        }
285
286                        if(position_cards_room !== 'none' && ((position_cards_room + card_width_room) >= 0 || position_cards_room === 0)) {
287                            goto_room = 0;
288                            $(this).addClass('disabled_arrow');
289                        }
290
291                        width_container_room -= card_width_room;
292                        if((position_cards_room + card_width_room) >= 0 || position_cards_room === 0) {
293                            init_progress_room = start_point_room;
294                        } else {
295                            init_progress_room = (100 * width_container_room) / (card_width_room * num_cards_room);
296                        }
297
298                        me.find('.progressive_bar .scrolled').css('width', init_progress_room + '%');
299                        me.find('qw-room-rate').css('transform', 'translateX(' + goto_room + 'px)');
300
301                        //disable arrows while animating
302                        var this_arrow = $(this);
303                        this_arrow.addClass("disable_click");
304                        me.find('.arrow.next').addClass("disable_click");
305                        setTimeout(function(){
306                            this_arrow.removeClass("disable_click");
307                            me.find('.arrow.next').removeClass("disable_click");
308                        }, 500);
309                    }
310                });
311            }
312
313
314        });
315
316    }
317
318}(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.