PageSourceSearch

https://www.bedstationhostel.com/wp-content/plugins/diviflash/public/js/df-menu-ext-script.js?ver=1.4.13

js bedstationhostel.com collected 2026-09-26 11:00:42 UTC 14,158 bytes, 284 lines download raw bytes

1(function($){
2    const dfMenuEx = {
3        navItem: $('.df-menu-nav li'),
4        mMenuButton: $('.df-mobile-menu-button'),
5        subMenu: $('.df-normal-menu-wrap .df-custom-submenu'),
6        ofcButton: $('.df-offcanvas-menu-button'),
7        ofcSubMenu: $('.df-offcanvas-menu .sub-menu'),
8        ofcbMenuItem: $('.df-offcanvas-menu .menu-item a'),
9        mSubMenu: $('.df-mobile-menu .sub-menu'),
10        fullWidthType: $('.df-normal-menu-wrap [data-menu-width-type="full_width"]'),
11        positionBottomCenter: $('.df-normal-menu-wrap [data-submenu-position="bottom_center"]'),
12        searchModalTriggerButton: $('.df-am-search-button'),
13        leftWidth: 460,
14        leftStatus: false,
15        init: function() {
16            this.subMenuReveal();
17            this.mobileMenuSlide();
18            this.revealOfc();
19            this.searchBoxModal();
20            this.megaMenuColumn();
21            this.hideOnSticky();
22            //this.button_show_on_hover_class_add();
23        },
24        hideOnSticky: function() {
25            $(window).on('scroll', function(ev){
26                if($('.et_pb_sticky_module').hasClass('et_pb_sticky')) {
27                    $('.hide_on_sticky').slideUp();
28                } else {
29                    $('.hide_on_sticky').slideDown();
30                }
31            })
32        },
33        megaMenuColumn: function() {
34            $('.df-normal-menu-wrap .df-mega-menu').each(function(i, ele) {
35                const _col_number = Number(ele.dataset.column);
36                let _c = 1;
37                $(this).find(".df-mega-menu-item>li").each(function(index, element){
38                    if(!$(this).attr("data-column")) {
39                        $(this).attr("data-column", _c);
40                        if(_c === _col_number) {
41                            _c = 1;
42                        } else {
43                            _c++;
44                        }
45                    }
46                });
47                if(!$(this).find('>ul:not(.df-vertical-menu-nav)').hasClass('col-added')) {
48                    $(this).find('li:not(.df-vertical-menu-item)[data-column="1"]').wrapAll('<div class="col col-1"></div>');
49                    $(this).find('li:not(.df-vertical-menu-item)[data-column="2"]').wrapAll('<div class="col col-2"></div>');
50                    $(this).find('li:not(.df-vertical-menu-item)[data-column="3"]').wrapAll('<div class="col col-3"></div>');
51                    $(this).find('li:not(.df-vertical-menu-item)[data-column="4"]').wrapAll('<div class="col col-4"></div>');
52                    $(this).find('li:not(.df-vertical-menu-item)[data-column="5"]').wrapAll('<div class="col col-5"></div>');
53                    $(this).find('li:not(.df-vertical-menu-item)[data-column="6"]').wrapAll('<div class="col col-6"></div>');
54                    $(this).find('li:not(.df-vertical-menu-item)[data-column="7"]').wrapAll('<div class="col col-7"></div>');
55                    $(this).find('>ul:not(.df-vertical-menu-nav)').addClass('col-added');
56                }
57            })
58        },
59        megaMenu: function($obj) {
60            if($obj.hasClass('df-mega-menu')) {
61                var _dataSet = $obj[0].dataset;
62                var offsetLeft = $obj.offset().left;
63                var containerOffsetLeft = $obj.closest('.row-inner').offset().left;
64
65                if( _dataSet.width === 'full_width' ) {
66                    $obj.find(">.sub-menu")
67                    .css('width', $(window).width())
68                    .css('left', `-${$obj.offset().left}px`);
69                } else if ( _dataSet.width === 'custom_width' ) {
70                    var _width = _dataSet.widthValue ? parseInt(_dataSet.widthValue) : '270';
71                    var _left = '0';
72                    if( _dataSet.alignment === 'bottom_center' ) {
73                        _left = `-${Number(_width)/2 - ($obj.width() /2)}`;
74                    } else if ( _dataSet.alignment === 'bottom_right' ) {
75                        _left = `-${Number(_width) - $obj.width()}`;
76                    }
77                    $obj.find(">.sub-menu")
78                    .css('width', _width)
79                    .css('left', `${_left}px`);
80                } else {
81                    $obj.find(">.sub-menu")
82                    .css('width', $obj.closest('.row-inner').width())
83                    .css('left', -`${offsetLeft - containerOffsetLeft}`);
84                }
85                $obj.find(">.sub-menu").css('display', '')
86            }
87        },
88        megaMenuHide: function($obj) {
89            if($obj.hasClass('df-mega-menu')) {
90                $obj.find(">.sub-menu")
91                    .css('width', '')
92                    .css('left', '')
93                    .css('display', 'none');
94            }
95        },
96        subMenuReveal: function() {
97            $('.df-mega-menu > .sub-menu').addClass('df-mega-menu-item');
98            $('.df-mega-menu > .sub-menu .sub-menu').addClass('df-inside-mega-menu');
99            $('.df-normal-menu-wrap .df-menu-nav li').each(function(index, ele){
100                var $this = $(this);
101                const isInsideMegaMenu = $this.parent().hasClass('df-mega-menu-item') || $this.parent().hasClass('df-inside-mega-menu') || $this.parent().hasClass('col') ? true : false;
102                // reverse direction class for submenu
103                if(!isInsideMegaMenu) {
104                    if(($(window).width() - ele.getBoundingClientRect().left) < dfMenuEx.leftWidth) {
105                        dfMenuEx.leftStatus = true;
106                        $this.closest('.df-menu-wrap').addClass('df-submenu-reverse');
107                    }
108                    if(dfMenuEx.leftStatus){
109                        dfMenuEx.leftWidth += 420;
110                    }
111                }
112            });
113
114            $('.df-normal-menu-wrap .df-menu-nav').on({
115                mouseenter: function() {
116                    var _this = $(this);
117                    const isInsideMegaMenu = _this.parent().hasClass('df-mega-menu-item') || _this.parent().hasClass('df-inside-mega-menu') || _this.parent().hasClass('col') ? true : false;
118                    dfMenuEx.megaMenu(_this);
119                    _this.css('overflow', 'visible');
120                    if(!isInsideMegaMenu) {
121                        _this.addClass('df-hover')
122                        .addClass('df-show-dropdown');
123                    }
124                    if(_this.hasClass('menu-item-level-0')) {
125                        const _zIndex = _this.closest('.et_pb_section').css('z-index');
126                        if(_zIndex === 'auto') {
127                            _this.closest('.et_pb_section').css('z-index', '999');
128                        } else {
129                            _this.closest('.et_pb_section').css('z-index', _zIndex);
130                        }
131					} else {
132                        if(!isInsideMegaMenu) {
133                            if(_this.closest('.df-menu-wrap').hasClass('df-submenu-reverse')){
134                                _this.find('>.sub-menu').css('right', _this.outerWidth());
135                                _this.find('>.sub-menu').css('left', 'auto');
136                            }else{
137                                _this.find('>.sub-menu').css('left', _this.outerWidth());
138                            }
139                        }
140                    }
141                    _this.find(">.sub-menu").addClass('df-hover');
142                },
143                mouseleave: function () {
144                    var _this = $(this);
145                    dfMenuEx.megaMenuHide(_this);
146                    const isInsideMegaMenu = _this.parent().hasClass('df-mega-menu-item') || _this.parent().hasClass('df-inside-mega-menu') || _this.parent().hasClass('col') ? true : false;
147                    if(!isInsideMegaMenu) {
148                        _this.removeClass('df-hover')
149                        .removeClass('df-show-dropdown');
150                    }
151                    setTimeout(function(){
152                        if(!_this.hasClass('df-show-dropdown')) {
153                            _this.find(">.sub-menu").removeClass('df-hover');
154                        }
155                    }, 200);
156                }
157            }, 'li');
158
159            $('.sub-menu').on({
160                mouseenter: function() {
161                    $(this).css('z-index', '99');
162                },
163                mouseleave: function () {
164                    $(this).css('z-index', '');
165                }
166            }, '.col');
167        },
168        revealOfc: function() {
169            dfMenuEx.ofcButton.on('click', function(ev) {
170                ev.preventDefault();
171                var ofcClass = $(`.df-offcanvas-wrap[data-menu="${ev.target.dataset.menu}"]`);
172                ofcClass.toggleClass('df-menu-show');
173                ofcClass.css('z-index', '999999');
174                ofcClass.find('.df-ofc-close').on('click', function() {
175                    ofcClass.removeClass('df-menu-show');
176                })
177            })
178            dfMenuEx.ofcSubMenuReveal();
179        },
180        ofcSubMenuReveal: function() {
181            dfMenuEx.ofcbMenuItem.on('click', function(ev) {
182                if(ev.originalEvent.detail === 2 ) return;
183                var _this = $(this);
184                var item = _this.siblings('.sub-menu');
185                if(item.length > 0) {
186                    ev.preventDefault();
187                    _this.siblings('.sub-menu').toggleClass('open');
188                    _this.siblings('.sub-menu').slideToggle("slow")
189                }
190            })
191        },
192        mSubmenuReveal: function() {
193            dfMenuEx.mSubMenu.each(function(){
194                var $this = $(this);
195                $this.siblings("a").on('click', function(ev){
196                    if(ev.originalEvent.detail === 2 ) return;
197                    ev.preventDefault();
198                    $this.slideToggle("slow");
199                    $(this).parent().toggleClass('df-show-dropdown');
200                })
201            })
202        },
203        mobileMenuSlide: function() {
204            dfMenuEx.mMenuButton.on('click', function(ev){
205                ev.preventDefault();
206                var mobileMenuClass = ev.target.dataset.menu;
207                $(`.${mobileMenuClass}`).slideToggle('slow')
208                .closest('.et_pb_section:not(.et_pb_sticky_module)').css('z-index', '99');
209
210                const open_status = ev.target.dataset.open;
211                const inner_content = 'off' === open_status ? $(ev.target).html() : ev.target.dataset.content;
212
213                $(this).html('off' === open_status ? 'M' : inner_content)
214                    .attr("style", 'off' === open_status ? "font-family:ETmodules !important;" : "")
215                    .attr('data-content', 'off' === open_status ? inner_content : '')
216                    .removeAttr('on' === open_status ? "data-content" : "")
217                    .removeAttr('on' === open_status ? "style" : "");
218
219                $(this).attr('data-open', ('on' === open_status) ? 'off' : 'on');
220            })
221            dfMenuEx.mSubmenuReveal();
222            dfMenuEx.mMenuScrollableItemClickControll();
223        },
224        searchBoxModal: function() {
225            $('.df-searchbox-style-5.df-am-search').css('opacity', 1);
226            $(document).click(function(event) {
227                const target = event.target;
228                const $popup = $('.df-searchbox-style-5.df-am-search.show');
229                if(!target.classList.value.includes('df-am-search-button')) {
230                    if (!$popup.is(target) && !$popup.has(target).length) {
231                        $popup.removeClass('show');
232                    }
233                }
234            })
235            dfMenuEx.searchModalTriggerButton.on('click', function(ev){
236                var searchModal = ev.target.dataset.search;
237                $(`.${searchModal}_modal`).toggleClass('show');
238            })
239            $('.serach-box-close').on('click', function(){
240                $(this).parent().removeClass('show');
241            })
242        },
243        button_show_on_hover_class_add: function(){
244            var selectors = document.querySelectorAll('.difl_advancedmenu');
245                [].forEach.call(selectors, function (selector, index) {
246               var elements = selector.querySelectorAll('.df-am-col.right .df-menu-button.show_icon_on_hover');
247                //console.log(elements.length);
248                // Check if any elements were found
249                if (elements.length > 0) {
250                    selector.querySelector('.df-am-col.right').classList.add('show_icon_on_hover');
251                }
252
253
254            });
255        },
256        mMenuScrollableItemClickControll: function (){
257            $(".df-mobile-menu li:not(:has(.sub-menu)) a").on('click', function(ev){
258                const select_parent = parent_selector($(this));
259                $(select_parent[0]).slideToggle('slow');
260				let menuClass = select_parent[0].classList.value.split(" ").filter(function (class_name) {
261					return class_name.indexOf('difl_advancedmenu_') !== -1;
262				});
263				if(menuClass.length === 0) {
264					menuClass = select_parent[0].classList.value.split(" ").filter(function (class_name) {
265						return class_name.indexOf('difl_advancedmenuitem_') !== -1;
266					});
267				}
268
269                const menu_button = $(`button.df-mobile-menu-button[data-menu="${menuClass[0]}"][data-open="on"]`);
270                $(menu_button[0]).html('a');
271                $(menu_button[0]).attr('data-open', 'off');
272                function parent_selector(data) {
273                    if($(data).parent().hasClass("df-mobile-menu")){
274                        return $(data).parent();
275                    }
276                    return parent_selector($(data).parent());
277                }
278            });
279        }
280    }
281    document.addEventListener( 'DOMContentLoaded', () => {
282        dfMenuEx.init();
283    } );
284})(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.