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