PageSourceSearch

https://www.mrsupply.com/skin1/mrsupply/js/themejs/so_megamenu.js

js mrsupply.com collected 2026-10-04 05:01:58 UTC 10,072 bytes, 269 lines download raw bytes

1var active = false;
2var hover = false;
3var mr_itemver =  11 ;
4var show_mr_itemver = mr_itemver-1 ;
5$(document).ready(function() {
6	$(".vertical .megamenu .loadmore").click(function(){
7		if($(this).hasClass('open')){
8			$('ul.megamenu li.mr_item-vertical').each(function(i){
9					if(i>show_mr_itemver){
10							$(this).slideUp(200);
11							$(this).css('display', 'none');
12					}
13			});
14			$(this).removeClass('open');
15			$('.vertical .megamenu .loadmore').html('<i class="fa fa-plus-square"></i><span class="more-view">Open Categories</span>');
16		}else{
17			$('.vertical ul.megamenu li.mr_item-vertical').each(function(i){
18				if(i>show_mr_itemver){
19						$(this).slideDown(200);
20				}
21			});
22			$(this).addClass('open');
23			$('.vertical .megamenu .loadmore').html('<i class="fa fa-minus-square"></i><span class="more-view">Close Categories</span>');
24		}
25	});
26
27	$("ul.megamenu li .sub-menu .mr_content .hover-menu ul li").hover(function () {
28		$(this).children("ul").show();
29
30	},function () {
31		$(this).children("ul").hide();
32	});
33	
34	
35	var wd_width = $(window).width();
36	if(wd_width <= 991) {
37		$("ul.megamenu > li.hover").unbind('mouseenter mouseleave');
38		removeWidthSubmenu();	
39		clickMegaMenu();
40	} else {
41		$( "ul.megamenu > li.hover").unbind( "click" );
42		hoverMegaMenu();
43		renderWidthSubmenu();
44	}
45	
46	$(window).resize(function() {
47		var sp_width = $(window).width();
48		if(sp_width <= 991){
49			$("ul.megamenu > li.hover").unbind('mouseenter mouseleave');
50			removeWidthSubmenu();
51			clickMegaMenu();
52		}	
53		else{
54			$( "ul.megamenu > li.hover").unbind( "click" );
55			hoverMegaMenu();
56			renderWidthSubmenu();
57		}	
58	});
59	
60	
61	$("ul.megamenu > li.click").click(function () {
62		if($(this).find(".mr_content").is(':visible')) { return false; }
63		active = $(this);
64		hover = true;
65		var transition = $(this).closest(".megamenu").data("transition");
66		var animation_time = $(this).closest(".megamenu").data("animationtime");		
67		$("ul.megamenu > li").removeClass("active");
68		$(this).addClass("active");
69		$("ul.megamenu > li").children(".sub-menu").hide();
70		$("ul.megamenu > li").find(".mr_content").hide();
71		$(this).children(".sub-menu").show();
72		if(transition == 'slide') {
73			$(this).find(".mr_content").show();
74			
75		} else if(transition == 'fade') {
76			$(this).find(".mr_content").fadeIn(animation_time);
77		} else {
78			$(this).find(".mr_content").show();
79		}		
80		$(this).children(".sub-menu").css("right", "auto");
81			if ($("html").css("direction").toLowerCase() == "rtl"){
82				var $whatever        = $(this).children(".sub-menu");
83				var $whatever2       =  $($whatever).closest('ul.megamenu');
84				if($whatever.offset().left < $whatever2.offset().left) {
85					$(this).children(".sub-menu").css("right", "0");
86				}				
87			}else{
88				var $whatever        = $(this).children(".sub-menu");
89				var ending_right     = ($(window).width() - ($whatever.offset().left + $whatever.outerWidth()));
90				var $whatever2       =  $($whatever).closest('ul.megamenu');
91				var ending_right2    = ($(window).width() - ($whatever2.offset().left + $whatever2.outerWidth()));
92				if(ending_right2 > ending_right) {
93					$(this).children(".sub-menu").css("right", "0");
94				}				
95			}
96
97		return false;
98	});
99	
100	$("#mr_show-megamenu").click(function () {
101		if($('.megamr_menu-mr_wrapper').hasClass('so-megamr_menu-active'))
102			$('.megamr_menu-mr_wrapper').removeClass('so-megamr_menu-active');
103		else
104			$('.megamr_menu-mr_wrapper').addClass('so-megamr_menu-active');
105	}); 
106	$('#remove-megamenu').click(function() {
107        $('.megamr_menu-mr_wrapper').removeClass('so-megamr_menu-active');
108        return false;
109    });		
110	
111	$("#mr_show-verticalmenu").click(function () {
112		if($('.vertical-mr_wrapper').hasClass('so-vertical-active'))
113			$('.vertical-mr_wrapper').removeClass('so-vertical-active');
114		else
115			$('.vertical-mr_wrapper').addClass('so-vertical-active');
116	}); 
117	$('#remove-verticalmenu').click(function() {
118        $('.vertical-mr_wrapper').removeClass('so-vertical-active');
119        return false;
120    });	
121	
122	$('html').on('click', function () {
123		$("ul.megamenu > li.click").removeClass("active");
124		$("ul.megamenu > li.click").children(".sub-menu").hide();
125		$("ul.megamenu > li.click").find(".mr_content").hide();
126	});
127	$('.close-menu').on('click', function () {
128		$(this).parent().removeClass("active");
129		$(this).parent().children(".sub-menu").hide();
130		$(this).parent().find(".mr_content").hide();
131		return false;
132	});
133});
134
135function renderWidthSubmenu()
136{
137	$('.vertical .sub-menu').each(function(){
138		value = $(this).data("subwidth");
139		if(value){
140			var mr_container_width = $('.mr_container').width();
141			var vertical_width = $('.vertical').width();
142			var full_width = mr_container_width - vertical_width;
143			var width_submenu = (full_width*value)/100;
144			$(this).css('width',width_submenu+'px');
145		}	
146	});
147}	
148function removeWidthSubmenu()
149{
150	$('.vertical .sub-menu').each(function(){
151		$(this).css('width','100%');
152	});
153}
154function clickMegaMenu(){
155	$("ul.megamenu > li.hover").click(function () {
156		if($(this).find(".mr_content").is(':visible')) { return true; }
157		active = $(this);
158		hover = true;
159		var transition = $(this).closest(".megamenu").data("transition");
160		var animation_time = $(this).closest(".megamenu").data("animationtime");
161		$("ul.megamenu > li").removeClass("active");
162		$(this).addClass("active");
163		$("ul.megamenu > li").children(".sub-menu").hide();
164		$("ul.megamenu > li").find(".mr_content").hide();
165		$(this).children(".sub-menu").show();
166		if(transition == 'slide') {
167			$(this).find(".mr_content").show();
168			$(this).find(".mr_content").css("height", "auto");
169			var originalHeight = $(this).find(".mr_content").height();
170		} else if(transition == 'fade') {
171			$(this).find(".mr_content").fadeIn(animation_time);
172		} else {
173			$(this).find(".mr_content").show();
174		}		
175		$(this).children(".sub-menu").css("right", "auto");
176			if ($("html").css("direction").toLowerCase() == "rtl"){
177				var $whatever        = $(this).children(".sub-menu");
178				var $whatever2       =  $($whatever).closest('ul.megamenu');
179				if($whatever.offset().left < $whatever2.offset().left) {
180					$(this).children(".sub-menu").css("right", "0");
181				}				
182			}else{
183				var $whatever        = $(this).children(".sub-menu");
184				var ending_right     = ($(window).width() - ($whatever.offset().left + $whatever.outerWidth()));
185				var $whatever2       =  $($whatever).closest('ul.megamenu');
186				var ending_right2    = ($(window).width() - ($whatever2.offset().left + $whatever2.outerWidth()));
187				if(ending_right2 > ending_right) {
188					$(this).children(".sub-menu").css("right", "0");
189				}				
190			}
191
192	});	
193}
194
195function hoverMegaMenu(){
196		$("ul.megamenu > li.hover").hover(function () {
197			active = $(this);
198			hover = true;
199			var transition = $(this).closest(".megamenu").data("transition");
200			var animation_time = $(this).closest(".megamenu").data("animationtime");
201			$("ul.megamenu > li").removeClass("active");
202			$(this).addClass("active");
203			$("ul.megamenu > li").children(".sub-menu").hide();
204			$("ul.megamenu > li").find(".mr_content").hide();
205			$(this).children(".sub-menu").show();
206			if(transition == 'slide') {
207				$(this).find(".mr_content").show();
208				
209			} else if(transition == 'fade') {
210				$(this).find(".mr_content").fadeIn(animation_time);
211			} else {
212				$(this).find(".mr_content").show();
213			}	
214			$(this).children(".sub-menu").css("right", "auto");	
215			if ($("html").css("direction").toLowerCase() == "rtl"){
216				var $whatever        = $(this).children(".sub-menu");
217				var $whatever2       =  $($whatever).closest('ul.megamenu');
218				if($whatever.offset().left < $whatever2.offset().left) {
219					$(this).children(".sub-menu").css("right", "0");
220				}				
221			}else{
222				var $whatever        = $(this).children(".sub-menu");
223				var ending_right     = ($(window).width() - ($whatever.offset().left + $whatever.outerWidth()));
224				var $whatever2       =  $($whatever).closest('ul.megamenu');
225				var ending_right2    = ($(window).width() - ($whatever2.offset().left + $whatever2.outerWidth()));
226				if(ending_right2 > ending_right) {
227					$(this).children(".sub-menu").css("right", "0");
228				}				
229			}
230
231		},function () {
232			var rel = $(this).attr("title");
233			hover = false;
234			var transition = $(this).closest(".megamenu").data("transition");
235			var animation_time = $(this).closest(".megamenu").data("animationtime");
236			if(rel == 'hover-intent') {
237				var hoverintent = $(this);
238				setTimeout(function (){
239					if(hover == false) {
240						if(transition == 'slide') {
241							$(hoverintent).find(".mr_content").stop(true, true).animate({ height:"hide" },animation_time, function() { if(hover == false) { $(hoverintent).removeClass("active"); $(hoverintent).children(".sub-menu").hide(); } });
242						} else if(transition == 'fade') {
243							$(hoverintent).removeClass("active");
244							$(hoverintent).find(".mr_content").fadeOut(animation_time, function() {
245								if(hover == false) { $(hoverintent).children(".sub-menu").hide(); }
246							});
247						} else {
248							$(hoverintent).removeClass("active");
249							$(hoverintent).children(".sub-menu").hide();
250							$(hoverintent).find(".mr_content").hide();
251						}
252					}
253				}, 500);
254			} else {
255				if(transition == 'slide') {
256					$(this).find(".mr_content").stop(true, true).animate({ height:"hide" },animation_time, function() { if(hover == false) { $(active).removeClass("active"); $(active).children(".sub-menu").hide(); } });
257				} else if(transition == 'fade') {
258					$(active).removeClass("active");
259					$(this).find(".mr_content").fadeOut(animation_time, function() {
260						if(hover == false) { $(active).children(".sub-menu").hide(); }
261					});
262				} else {
263					$(this).removeClass("active");
264					$(this).children(".sub-menu").hide();
265					$(this).find(".mr_content").hide();
266				}
267			}
268		});	
269}

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.