PageSourceSearch

https://upolitics.com/wp-content/themes/upolitics/js/megamenu.js

js upolitics.com collected 2026-09-26 00:08:11 UTC 3,702 bytes, 138 lines download raw bytes

1var ww = document.body.clientWidth;
2
3jQuery(document).ready(function($) {  
4 
5 "use strict";  
6
7  $(window).scroll(function() { 
8		if (ww >= 800) {		
9			 var additionHeight = 1;
10			 var addClass = "fixed animated fadeInDown";
11			 var classAddTo = "section#header";
12			 
13			 
14			 var scroll = $(window).scrollTop();
15			 var actionHeight = additionHeight;
16			 
17				if (scroll >= actionHeight) {
18				   $(classAddTo).addClass(addClass);
19				   $('.bredcrumbs-container').css({'padding-top' : $(classAddTo).outerHeight()});
20				} else {
21					$(classAddTo).removeClass(addClass);
22					 $('.bredcrumbs-container').css({'padding-top' : 0});
23				}
24				adjustMegamenu();
25			}
26			
27	});  
28 
29  jQuery(".nav li a").each(function() {
30    if (jQuery(this).next().length > 0) {
31    	jQuery(this).addClass("parent");
32		};
33	})
34	
35	$(".toggleMenu").click(function(e) {
36		e.preventDefault();
37		jQuery(this).toggleClass("active");
38		jQuery(".nav").toggle();
39	});
40	adjustMenu();	
41	adjustMegamenu();
42	$(window).trigger('resize');
43});
44
45
46
47jQuery(window).load(function() {
48	adjustMenu();
49	adjustMegamenu();
50});
51
52jQuery(window).resize(function() {
53	adjustMenu();
54	adjustMegamenu();
55});
56
57jQuery(window).bind('resize orientationchange', function() {
58	ww = document.body.clientWidth;
59	adjustMenu();
60	adjustMegamenu();
61});
62
63var adjustMenu = function() {
64	if (ww < 800) {
65
66	jQuery('.nav.crm-menu').css( 'width' , jQuery('.nav.crm-menu').closest('.row').innerWidth()-30);
67    // if "more" link not in DOM, add it
68    jQuery('.more').remove(); 
69    jQuery('.nav > li > .parent').each(function(){
70    	jQuery('<div class="more"><i class="fa fa-angle-down"></i></div>').insertBefore(jQuery(this)); 
71    })
72    
73		jQuery(".toggleMenu").css("display", "inline-block");
74		if (!jQuery(".toggleMenu").hasClass("active")) {
75			jQuery(".nav").hide();
76		} else {
77			jQuery(".nav").show();
78		}
79		jQuery(".nav li").unbind('mouseenter mouseleave');
80		jQuery(".nav li a.parent").unbind('click');
81    	jQuery(".nav li .more").unbind('click').bind('click', function() {
82			
83			jQuery(this).parent("li").toggleClass("hover");
84		});
85	} 
86	else if (ww > 800) {    	
87
88    	// remove .more link in desktop view
89    	jQuery('.more').remove(); 
90		jQuery(".toggleMenu").css("display", "none");
91		jQuery(".nav").show();
92		jQuery(".nav li").removeClass("hover");
93		jQuery(".nav li a").unbind('click');
94		jQuery(".nav li").unbind('mouseenter mouseleave').bind('mouseenter', function() {
95		 	// must be attached to li so that mouseleave is not triggered when hover over submenu
96		 	jQuery(this).addClass('hover');
97		}).bind(' mouseleave', function(){
98			jQuery(this).removeClass('hover');
99		});
100	}
101}
102
103function adjustMegamenu(){
104	if (ww >= 800) {
105	  jQuery('.megamenu').each(function(){
106			var p = jQuery(this).position();
107
108			var menuWidth = jQuery(this).closest('ul').parent().outerWidth();
109			var extwidth = jQuery('.search-col').outerWidth();
110			
111			if(jQuery('body').hasClass('rtl')){
112				var leftOffset = p.left-14+extwidth;
113			}else{
114				var leftOffset = p.left-14;
115			}
116			
117			jQuery(this).children('ul').css({'left': -leftOffset, 'width': (menuWidth + extwidth-30 )});
118		});
119
120	  	// get the height of the tallest LI within each UL group
121	    var max = Math.max.apply(Math, jQuery(".nav > li").map(
122	        function(){
123	          return jQuery(this).height();
124	        }
125	      ));
126
127		// now render the height in each parent UL
128		jQuery('.search > i, .form-search .search-query').height(max);
129	    jQuery(".nav > li").each(function() {
130	      jQuery(this).height(max);
131	    });
132
133  }else{
134	  jQuery(this).children('ul').attr('style', '');
135	  jQuery(".nav > li").attr('style', '');
136	  jQuery('.search > i, .form-search .search-query').attr('style', '');
137  }
138}

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.