PageSourceSearch

https://uhv.news/wp-content/themes/newscrunch/assets/js/menu/menu.js?ver=7.1.2

js uhv.news collected 2026-10-04 07:26:03 UTC 13,077 bytes, 279 lines download raw bytes

1/* ---------------------------------------------- /*
2 * Preloader
3 /* ---------------------------------------------- */
4(function(){
5
6    jQuery(document).ready(function() {
7
8        /* ---------------------------------------------- /*
9         * Initialization General Scripts for all pages
10         /* ---------------------------------------------- */
11
12        var homeSection = jQuery('.home-section'),
13            spnc      = jQuery('.spnc-custom'),
14            navHeight   = spnc.height(),
15           // worksgrid   = jQuery('#works-grid'),
16            width       = Math.max(jQuery(window).width(), window.innerWidth),
17            mobileTest  = false;
18
19        if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
20            mobileTest = true;
21        }
22
23        buildHomeSection(homeSection);
24        spncAnimation(spnc, homeSection, navHeight);
25        spncSubmenu(width);
26        spncSubmenuTouch(width)
27        hoverDropdown(width, mobileTest);
28
29        jQuery(window).resize(function() {
30            var width = Math.max(jQuery(window).width(), window.innerWidth);
31            buildHomeSection(homeSection);
32            hoverDropdown(width, mobileTest);
33        });
34
35       /* ---------------------------------------------- /*
36         * Home section height
37         /* ---------------------------------------------- */
38
39        function buildHomeSection(homeSection) {
40            if (homeSection.length > 0) {
41                if (homeSection.hasClass('home-full-height')) {
42                    homeSection.height(jQuery(window).height());
43                } else {
44                    homeSection.height(jQuery(window).height() * 0.85);
45                }
46            }
47        }
48
49
50        /* ---------------------------------------------- /*
51         * Transparent spnc animation
52         /* ---------------------------------------------- */
53
54        function spncAnimation(spnc, homeSection, navHeight) {
55            var topScroll = jQuery(window).scrollTop();
56            if (spnc.length > 0 && homeSection.length > 0) {
57                if(topScroll >= navHeight) {
58                    spnc.removeClass('spnc-transparent');
59                } else {
60                    spnc.addClass('spnc-transparent');
61                }
62            }
63        }
64
65        /* ---------------------------------------------- /*
66         * spnc submenu
67         /* ---------------------------------------------- */
68
69        function spncSubmenu(width) {
70            if (width > 1100) {
71                 jQuery('.spnc-custom .spnc-nav > li.dropdown a').hover(function() {
72                    var MenuLeftOffset  = jQuery(this).parent().offset().left+100;
73                    var Menu1LevelWidth = jQuery('.dropdown-menu', jQuery(this).parent()).width();
74                    if (width - MenuLeftOffset < Menu1LevelWidth * 2) {
75                        jQuery(this).parent().children('.dropdown-menu').addClass('leftauto');
76                    } else {
77                        jQuery(this).parent().children('.dropdown-menu').removeClass('leftauto');
78                    }
79                    if (jQuery('.dropdown', jQuery(this).parent()).length > 0) {
80                        var Menu2LevelWidth = jQuery('.dropdown-menu', jQuery(this).parent()).width();
81                        if (width - MenuLeftOffset - Menu1LevelWidth < Menu2LevelWidth) {
82                            jQuery(this).parent().children('.dropdown-menu').addClass('left-side');
83                        } else {
84                            jQuery(this).parent().children('.dropdown-menu').removeClass('left-side');
85                        }
86                    }
87                });
88                 jQuery('.spnc-custom .spnc-nav > li.dropdown a').focus(function() {
89                    var MenuLeftOffsets  = jQuery(this).parent().offset().left+100;
90                    var Menu1LevelWidth = jQuery('.dropdown-menu', jQuery(this).parent()).width();
91                    if (width - MenuLeftOffsets < Menu1LevelWidth * 2) {
92                        jQuery(this).parent().children('.dropdown-menu').addClass('leftauto');
93                    } else {
94                        jQuery(this).parent().children('.dropdown-menu').removeClass('leftauto');
95                    }
96                    if (jQuery('.dropdown', jQuery(this).parent()).length > 0) {
97                        var Menu2LevelWidth = jQuery('.dropdown-menu', jQuery(this).parent()).width();
98                        if (width - MenuLeftOffsets - Menu1LevelWidth < Menu2LevelWidth) {
99                            jQuery(this).parent().children('.dropdown-menu').addClass('left-side');
100                        } else {
101                            jQuery(this).parent().children('.dropdown-menu').removeClass('left-side');
102                        }
103                    }
104                });
105            }
106        }
107
108          /* ---------------------------------------------- /*
109         * spnc submenu click on firebox 
110         /* ---------------------------------------------- */
111         
112        function spncSubmenuTouch(width) {
113            if (width > 1100 && navigator.userAgent.toLowerCase().indexOf("firefox") > -1) {
114               jQuery('li.dropdown').find('.fa-angle-down').each(function(){
115                   jQuery(this).on('click', function(){
116                    var thisVal=jQuery(this).parent().parent();
117                   var MenuLeftOffsetss  =thisVal.offset().left; 
118                    var Menu1LevelWidth = jQuery('.dropdown-menu', thisVal).width();
119                    if (width - MenuLeftOffsetss < Menu1LevelWidth * 2) {
120                       thisVal.children('.dropdown-menu').addClass('leftauto');
121                    } else {
122                        thisVal.children('.dropdown-menu').removeClass('leftauto');
123                    }
124                    if (jQuery('.dropdown', thisVal).length > 0) {
125                        var Menu2LevelWidth = jQuery('.dropdown-menu', thisVal).width();
126                        if (width - MenuLeftOffsetss - Menu1LevelWidth < Menu2LevelWidth) {
127                            thisVal.children('.dropdown-menu').addClass('left-side');
128                        } else {
129                            thisVal.children('.dropdown-menu').removeClass('left-side');
130                        }
131                    }
132                });
133            });
134        }}
135
136        /* ---------------------------------------------- /*
137         * spnc hover dropdown on desktop
138         /* ---------------------------------------------- */
139
140        function hoverDropdown(width, mobileTest) {
141            if ((width > 1100) && (mobileTest !== true)) {
142                jQuery('.spnc-custom').removeClass('open');
143                var delay = 0;
144                var setTimeoutConst;
145                jQuery('.spnc-custom .spnc-nav > li.dropdown, .spnc-custom li.dropdown > ul > li.dropdown').hover(function() {
146                        var jQuerythis = jQuery(this);
147                        setTimeoutConst = setTimeout(function() {
148                            jQuerythis.addClass('open');
149                            jQuerythis.find('.dropdown-toggle').addClass('disabled');
150                        }, delay);
151                    },
152                    function() {
153                        clearTimeout(setTimeoutConst);
154                        jQuery(this).removeClass('open');
155                        jQuery(this).find('.dropdown-toggle').removeClass('disabled');
156                    });
157            } else {
158                jQuery('.spnc-custom .spnc-nav > li.dropdown, .spnc-custom li.dropdown > ul > li.dropdown').unbind('mouseenter mouseleave');
159                jQuery('.spnc-custom [data-toggle=dropdown]').not('.binded').addClass('binded').on('click', function(event) {
160                    event.preventDefault();
161                    event.stopPropagation();
162                    jQuery(this).parent().siblings().removeClass('open');
163                    jQuery(this).parent().siblings().find('[data-toggle=dropdown]').parent().removeClass('open');
164                    jQuery(this).parent().toggleClass('open');
165                });
166            }
167        }
168
169        /* ---------------------------------------------- /*
170         * spnc collapse on click
171         /* ---------------------------------------------- */
172       
173        /*jQuery('.spnc-toggle').on('click', function(){
174              jQuery('.collapse.spnc-collapse').toggleClass('in');
175        });
176        jQuery('.spnc-toggle').on('click','.spnc-collapse.in',function(e) {
177            if( jQuery(e.target).is('a') && jQuery(e.target).attr('class') != 'dropdown-toggle' ) {
178                jQuery(this).collapse('hide');
179            }
180        });*/
181
182        if( jQuery(window).width() > 1100) {
183           jQuery('.nav li.dropdown').hover(function() {
184             if( jQuery(window).width() > 1100 ) {
185                jQuery('.dropdown-menu').removeAttr("style");
186              }
187               jQuery(this).addClass('open');
188
189           }, function() {
190               jQuery(this).removeClass('open');
191           }); 
192           jQuery('.nav li.dropdown-submenu').hover(function() {
193               jQuery(this).addClass('open');
194           }, function() {
195               jQuery(this).removeClass('open');
196           }); 
197        }
198        
199         jQuery('li.dropdown').find('a').each(function (){
200           var link = jQuery(this).attr('href');
201              if (link==='' || link==="#") {
202                jQuery(this).on('click', function(){
203                if( jQuery(window).width() < 1100) {
204                    jQuery('li.dropdown,li.dropdown-submenu').removeClass('open');
205                    jQuery(this).next().slideToggle();
206                }
207                return false;
208                }); 
209              }
210       });
211
212
213        jQuery('li.dropdown').find('.fa-angle-down').each(function(){
214            jQuery(this).on('click', function(){
215              if(jQuery(window).width() > 1100 && window.matchMedia("(pointer: coarse)").matches && navigator.userAgent.toLowerCase().indexOf("firefox") > -1) {
216                 jQuery(this).parent().parent().siblings().removeClass('open');
217                jQuery(this).parent().parent().toggleClass('open');
218              }
219                return false;
220            });
221        
222        });
223
224
225        /* ---------------------------------------------- /*
226         * Focus dropdown on desktop
227        /* ---------------------------------------------- */
228        const topLevelLinks = Array.prototype.slice.call(document.querySelectorAll(".spnc-custom .spnc-nav > li.dropdown a"), 0);
229          topLevelLinks.forEach(function(link){
230             return link.addEventListener('focus', function(e) {
231                this.parentElement.classList.add('open')
232                e.preventDefault();
233               
234                var div_list = e.target.parentElement.querySelectorAll( ".open" );
235                var div_array = Array.prototype.slice.call(div_list);
236                  div_array.forEach(function(e){
237                   return e.classList.remove( "open" ) 
238                });
239              })             
240        });
241
242        jQuery(document).on('focusin', function (e) {
243            // Check if the focused element is .search-icon or inside it
244            const focusedElement = jQuery(e.target);
245            const searchIcon = jQuery('a.search-icon');
246            // If focus is not on the .search-icon or its children
247            if (!searchIcon.is(focusedElement) && searchIcon.closest('li').has(focusedElement).length === 0) {
248                searchIcon.closest('li').removeClass('open');
249            }
250        });
251
252       jQuery('li a').focus(function() { 
253              jQuery(this).parent().siblings().removeClass('open');
254              jQuery(this).parent().siblings().find(".open").removeClass('open');
255        });    
256        jQuery('a,input').bind('focus', function() {
257            if(!jQuery(this).closest(".menu-item").length ) {
258                topLevelLinks.forEach(function(link){
259                    return link.parentElement.classList.remove('open')
260                });
261            }
262        });
263        jQuery('li.dropdown').find('.fa-angle-down').each(function(){
264            jQuery(this).on('click', function(){
265                if( jQuery(window).width() < 1100) {
266                    jQuery('li.dropdown,li.dropdown-submenu').removeClass('open');
267                    jQuery(this).parent().next().slideToggle();
268                }
269                return false;
270            });
271        });
272        jQuery('a,input').bind('focus', function() {
273            if(!jQuery(this).closest(".menu-item").length && ( jQuery(window).width() <= 1100) ) {
274                jQuery('.spnc-collapse').removeClass('in');
275            }
276        });
277    
278    });
279})(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.