1(function($){ 2 $.fn.megamenu = function(options) { 3 options = jQuery.extend({ 4 wrap:'#meganavigator', 5 easing: "easeInOutCirc", 6 speed: 300, 7 justify: "left", 8 mm_timeout: 250 9 10 }, options); 11 var menuwrap = $(this); 12 //$('li.level1').css({ 'float': options.justify }); 13 buildmenu(menuwrap); 14 // Build menu 15 function buildmenu(mwrap){ 16 mwrap.find('li').each(function(){ 17 var menucontent = $(this).find(".mega-content:first"); 18 var menuitemlink = $(this).find(".item-link:first"); 19 var menucontentinner = $(this).find(".mega-content-inner"); 20 var mshow_timer = 0; 21 var mhide_timer = 0; 22 var li = $(this); 23 var islevel1 = (li.hasClass('level1'))?true:false; 24 var havechild = (li.hasClass('havechild'))?true:false; 25 if(menucontent){ 26 menucontent.hide(); 27 } 28 li.mouseenter(function(el){ 29 el.stopPropagation(); 30 clearTimeout(mhide_timer); 31 clearTimeout(mshow_timer); 32 addHover(li); 33 if(havechild){ 34 positionSubMenu(li, islevel1); 35 mshow_timer = setTimeout(function(){ //Emulate HoverIntent 36 showSubMenu(li, menucontent, menucontentinner); 37 }, options.mm_timeout); 38 } 39 }).mouseleave(function(el){ //return; 40 clearTimeout(mshow_timer); 41 clearTimeout(mhide_timer); 42 if(havechild){ 43 mhide_timer = setTimeout(function(){ //Emulate HoverIntent 44 hideSubMenu(li, menucontent, menucontentinner); 45 }, options.mm_timeout); 46 47 //hideSubMenu(li, menucontent, menucontentinner); 48 } 49 removeHover(li); 50 }); 51 }); 52 } 53 // Show Submenu 54 function showSubMenu(li, mcontent, mcontentinner){ 55 mcontentinner.animate({ 56 opacity: 1 57 }, 100); 58 mcontent.stop(true, true).slideDown({ duration: options.speed, easing: options.easing}); 59 } 60 61 // Hide Submenu 62 function hideSubMenu(li, mcontent, mcontentinner){ 63 mcontentinner.animate({ 64 opacity: 0 65 }, 2*options.mm_timeout); 66 mcontent.slideUp({ duration: options.mm_timeout,easing: options.easing}); 67 } 68 // Add class hover to li 69 function addHover(el){ 70 $(el).addClass('hover'); 71 } 72 // Remove class hover to li 73 function removeHover(el){ 74 $(el).removeClass('hover'); 75 } 76 // Position Submenu 77 function positionSubMenu(el, islevel1){ 78 menucontent = $(el).find(".mega-content:first"); 79 menuitemlink = $(el).find(".item-link:first"); 80 menucontentinner = $(el).find(".mega-content-inner"); 81 wrap_O = menuwrap.offset().left; 82 wrap_W = menuwrap.outerWidth(); 83 menuitemli_O = menuitemlink.parent('li').offset().left; 84 menuitemli_W = menuitemlink.parent('li').outerWidth(); 85 menuitemlink_H = menuitemlink.outerHeight(); 86 menuitemlink_W = menuitemlink.outerWidth(); 87 menuitemlink_O = menuitemlink.offset().left; 88 menucontent_W = menucontent.outerWidth(); 89 90 if (islevel1) { 91 menucontent.css({ 92 'top': menuitemlink_H + "px", 93 'left': menuitemlink_O - menuitemli_O + 'px' 94 }) 95 96 if(options.justify == "left"){ 97 var wrap_RE = wrap_O + wrap_W; 98 // Coordinates of the right end of the megamenu object 99 var menucontent_RE = menuitemlink_O + menucontent_W; 100 // Coordinates of the right end of the megamenu content 101 if( menucontent_RE >= wrap_RE ) { // Menu content exceeding the outer box 102 menucontent.css({ 103 'left':wrap_RE - menucontent_RE + menuitemlink_O - menuitemli_O + 'px' 104 }); // Limit megamenu inside the outer box 105 } 106 } else if( options.justify == "right" ) { 107 var wrap_LE = wrap_O; 108 // Coordinates of the left end of the megamenu object 109 var menucontent_LE = menuitemlink_O - menucontent_W + menuitemlink_W; 110 // Coordinates of the left end of the megamenu content 111 if( menucontent_LE <= wrap_LE ) { // Menu content exceeding the outer box 112 menucontent.css({ 113 'left': wrap_O 114 - (menuitemli_O - menuitemlink_O) 115 - menuitemlink_O + 'px' 116 }); // Limit megamenu inside the outer box 117 } else { 118 menucontent.css({ 119 'left': menuitemlink_W 120 + (menuitemlink_O - menuitemli_O) 121 - menucontent_W + 'px' 122 }); // Limit megamenu inside the outer box 123 } 124 } 125 }else{ 126 _leftsub = 0; 127 menucontent.css({ 128 'top': menuitemlink_H*0 +"px", 129 'left': menuitemlink_W + _leftsub + 'px' 130 }) 131 132 if(options.justify == "left"){ 133 var wrap_RE = wrap_O + wrap_W; 134 // Coordinates of the right end of the megamenu object 135 var menucontent_RE = menuitemli_O + menuitemli_W + _leftsub + menucontent_W; 136 // Coordinates of the right end of the megamenu content 137 138 if( menucontent_RE >= wrap_RE ) { // Menu content exceeding the outer box 139 menucontent.css({ 140 'left': _leftsub - menucontent_W + 'px' 141 }); // Limit megamenu inside the outer box 142 } 143 } else if( options.justify == "right" ) { 144 var wrap_LE = wrap_O; 145 // Coordinates of the left end of the megamenu object 146 var menucontent_LE = menuitemli_O - menucontent_W + _leftsub; 147 // Coordinates of the left end of the megamenu content 148 //console.log(menucontent_LE+' vs '+wrap_LE); 149 if( menucontent_LE <= wrap_LE ) { // Menu content exceeding the outer box 150 menucontent.css({ 151 'left': menuitemli_W - _leftsub + 'px' 152 }); // Limit megamenu inside the outer box 153 } else { 154 menucontent.css({ 155 'left': _leftsub - menucontent_W + 'px' 156 }); // Limit megamenu inside the outer box 157 } 158 } 159 } 160 } 161 }; 162})(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.