PageSourceSearch

https://www.rinuccini.com/wp-content/themes/enfold/js/avia-snippet-megamenu.js?ver=4.8.4

js rinuccini.com collected 2026-10-04 01:46:38 UTC 5,690 bytes, 228 lines download raw bytes

1//this file is only called if a main menu with submenu items is available
2
3(function($)
4{	
5    "use strict";
6
7    $(document).ready(function()
8    {	
9		//activates the mega menu javascript.
10		if($.fn.aviaMegamenu)
11		$(".main_menu .menu").aviaMegamenu({modify_position:true});
12    });
13
14
15
16// -------------------------------------------------------------------------------------------
17// Avia Menu
18// -------------------------------------------------------------------------------------------
19
20
21	$.fn.aviaMegamenu = function(variables)
22	{
23		var defaults =
24		{
25			modify_position:true,
26			delay:300
27		};
28
29		var options = $.extend(defaults, variables),
30		win			= $(window);
31		
32			
33
34		return this.each(function()
35		{
36			var the_html	= $('html').first(),
37				main		= $('#main .container').first(),
38				left_menu	= the_html.filter('.html_menu_left, .html_logo_center').length,
39				isMobile 	= $.avia_utilities.isMobile,
40				menu = $(this),
41				menuItems = menu.find(">li:not(.ignore_menu)"),
42				megaItems = menuItems.find(">div").parent().css({overflow:'hidden'}),
43				menuActive = menu.find('>.current-menu-item>a, >.current_page_item>a'),
44				dropdownItems = menuItems.find(">ul").parent(),
45				parentContainer = menu.parent(),
46				mainMenuParent = menu.parents('.main_menu').eq(0),
47				parentContainerWidth = parentContainer.width(),
48				delayCheck = {},
49				mega_open = [];
50				
51
52			if(!menuActive.length){ menu.find('.current-menu-ancestor, .current_page_ancestor').eq( 0 ).find( 'a').eq( 0 ).parent().addClass('active-parent-item')}
53			if(!the_html.is('.html_header_top')) { options.modify_position = false; }
54			
55			
56			
57			menuItems.on('click' ,'a', function(e)
58			{
59				if(this.href == window.location.href + "#" || this.href == window.location.href + "/#")
60				e.preventDefault();
61			});
62
63			menuItems.each(function()
64			{
65				var item = $(this),
66					pos = item.position(),
67					megaDiv = item.find("div").first().css({opacity:0, display:"none"}),
68					normalDropdown = "";
69
70				//check if we got a mega menu
71				if(!megaDiv.length)
72				{
73					normalDropdown = item.find(">ul").css({display:"none"});
74				}
75
76				//if we got a mega menu or dropdown menu add the arrow beside the menu item
77				if(megaDiv.length || normalDropdown.length)
78				{
79					var link = item.addClass('dropdown_ul_available').find('>a');
80					link.append('<span class="dropdown_available"></span>');
81
82					//is a mega menu main item doesnt have a link to click use the default cursor
83					if(typeof link.attr('href') != 'string' || link.attr('href') == "#"){ link.css('cursor','default').on('click', function(e){ e.preventDefault(); }); }
84				}
85
86
87				//correct position of mega menus
88				if(options.modify_position && megaDiv.length)
89				{	
90					item.on('mouseenter', function(){ calc_offset(item, pos, megaDiv, parentContainerWidth) });
91				}
92
93
94
95			});
96			
97			
98			function calc_offset(item, pos, megaDiv, parentContainerWidth)
99			{	
100				pos = item.position();
101				
102				if(!left_menu)
103					{
104						if(pos.left + megaDiv.width() < parentContainerWidth)
105						{
106							megaDiv.css({right: -megaDiv.outerWidth() + item.outerWidth()  });
107							//item.css({position:'static'});
108						}
109						else if(pos.left + megaDiv.width() > parentContainerWidth)
110						{
111							megaDiv.css({right: -mainMenuParent.outerWidth() + (pos.left + item.outerWidth() ) });
112						}
113					}
114					else
115					{
116						if(megaDiv.width() > pos.left + item.outerWidth())
117						{
118							megaDiv.css({left: (pos.left* -1)});
119						}
120						else if(pos.left + megaDiv.width() > parentContainerWidth)
121						{
122							megaDiv.css({left: (megaDiv.width() - pos.left) * -1 });
123						}
124					}
125			}
126
127			function megaDivShow(i)
128			{
129				if(delayCheck[i] == true)
130				{
131					var item = megaItems.eq( i ).css({overflow:'visible'}).find("div").first(),
132						link = megaItems.eq( i ).find("a").first();
133						mega_open["check"+i] = true;
134
135						item.stop().css('display','block').animate({opacity:1},300);
136
137						if(item.length)
138						{
139							link.addClass('open-mega-a');
140						}
141				}
142			}
143
144			function megaDivHide (i)
145			{
146				if(delayCheck[i] == false)
147				{
148					megaItems.eq( i ).find(">a").removeClass('open-mega-a');
149
150					var listItem = megaItems.eq( i ),
151						item = listItem.find("div").first();
152
153
154					item.stop().css('display','block').animate({opacity:0}
154,300, function()
155					{
156						$(this).css('display','none');
157						listItem.css({overflow:'hidden'});
158						mega_open["check"+i] = false;
159					});
160				}
161			}
162
163			if(isMobile)
164			{
165				megaItems.each(function(i){
166
167					$(this).on('click', function()
168					{
169						if(mega_open["check"+i] != true) return false;
170					});
171				});
172			}
173
174
175			//bind event for mega menu
176			megaItems.each(function(i){
177
178				$(this).on('mouseenter', 
179					function()
180					{
181						delayCheck[i] = true;
182						setTimeout(function(){megaDivShow(i); },options.delay);
183					}).on('mouseleave',
184					function()
185					{
186						delayCheck[i] = false;
187						setTimeout(function(){megaDivHide(i); },options.delay);
188					}
189				);
190			});
191
192
193			// bind events for dropdown menu
194			dropdownItems.find('li').addBack().each(function()
195			{
196				var currentItem = $(this),
197					sublist = currentItem.find('ul').first(),
198					showList = false;
199
200				if(sublist.length)
201				{
202					sublist.css({display:'block', opacity:0, visibility:'hidden'});
203					var currentLink = currentItem.find('>a');
204
205					currentLink.on('mouseenter', function()
206					{
207						sublist.stop().css({visibility:'visible'}).animate({opacity:1});
208					});
209
210					currentItem.on('mouseleave', function()
211					{
212						sublist.stop().animate({opacity:0}
212, function()
213						{
214							sublist.css({visibility:'hidden'});
215						});
216					});
217
218				}
219
220			});
221
222		});
223	};
224})(jQuery);
225
226
227
228

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.