1(function ($) { 2 $.fn.dnngomegamenu = function (m) { 3 m = $.extend({ 4 slide_speed: 200, 5 delay_show: 150, 6 delay_disappear: 500, 7 megamenuwidth: "box", 8 WidthBoxClassName: ".container", 9 popUp: "vertical", 10 direction: "ltr", 11 clickdisplay:false, 12 masklayer:false 13 }, m || {}); 14 var rtl = m.direction == "rtl" ? true : false; 15 return this.each(function (index) { 16 var me = $(this), 17 primary = me.find(".primary_structure > li"); 18 19 if(me.parent().data("clickdisplay")){ 20 m.clickdisplay = true; 21 if(me.parent().data("masklayer")){ 22 m.masklayer = true; 23 } 24 } 25 26 me.find(".primary_structure").attr({ 27 "role": "menubar" 28 }); 29 me.find("li").attr({ 30 "role": "none" 31 }); 32 33 me.find("li > a").attr({ 34 "role": "menuitem", 35 }); 36 me.find(".dir > a").attr({ 37 "aria-haspopup": "true", 38 "aria-expanded": "false" 39 }); 40 41 me.find(".primary_structure ul").attr({ 42 "role": "menu" 43 }); 44 45 if (rtl) { 46 me.addClass("rtl"); 47 } 48 49 if(m.masklayer){ 50 var mask=$('<div class="menu-mask"></div>'); 51 if(me.parent().data("maskbg")){ 52 mask.css("background-color",me.parent().data("maskbg")) 53 } 54 55 me.parents("header").append(mask); 56 } 57 58 if (!!('ontouchstart' in window) || m.clickdisplay) { 59 primary.children("a").on('click', function (event) { 60 if ($(this).siblings("div").eq(0).is(":hidden")) { 61 event.preventDefault(); 62 $(this).data("nolink",true); 63 }else{ 64 $(this).data("nolink",false); 65 } 66 }) 67 } 68 69 function primaryMenuHide(i){ 70 if(i.length){ 71 i.removeClass("menu_hover"); 72 if(i.parent().hasClass(".dir")){ 73 i.children("a").attr("aria-expanded","false"); 74 } 75 i.find(".dnngo_menuslide").stop().fadeOut(m.slide_speed); 76 77 i.hasClass("dir") && m.clickdisplay && m.masklayer && mask.stop().fadeOut(); 78 } 79 } 80 function primaryMenuShow(i){ 81 i.addClass("menu_hover"); 82 if(i.parent().hasClass(".dir")){ 83 i.children("a").attr("aria-expanded","true"); 84 } 85 i.find(".dnngo_menuslide").stop().fadeIn(m.slide_speed); 86 87 i.hasClass("dir") && m.clickdisplay && m.masklayer && mask.stop().fadeIn(); 88 89 } 90 91 if( m.clickdisplay){ 92 primary.on("click",function (event) { 93 if(!$(this).hasClass("menu_hover")){ 94 var Prev = me.find(".primary_structure > li.menu_hover"); 95 primaryMenuHide(Prev); 96 primaryMenuShow($(this)); 97 }else{ 98 event.stopPropagation(); 99 } 100 101 }) 102 103 me.on("blur",function(){ 104 var Prev = me.find(".primary_structure > li.menu_hover"); 105 Prev.length && primaryMenuHide(Prev); 106 }) 107 108 $(document).on("click",function(event){ 109 if(!me.is(event.target)&&me.has(event.target).length===0){ 110 var Prev = me.find(".primary_structure > li.menu_hover"); 111 Prev.length && primaryMenuHide(Prev); 112 } 113 }) 114 115 116 117 118 }else{ 119 primary.on("mouseenter",function () { 120 primaryMenuShow($(this)); 121 }).on("mouseleave",function () { 122 primaryMenuHide($(this)); 123 }) 124 } 125 126 127 primary.find(".dnngo_menu_list,.dnngo_boxslide").each(function(){ 128 var itembox = $(this), 129 parent = itembox.parent(".dnngo_menuslide"), 130 parentVis = parent.parent("li"), 131 width = parent.data("width") ? parent.data("width") : false, 132 position = parent.data("position") ? parent.data("position") : 0, 133 contWindth = 0, 134 dir="left"; 135 function itemPosition(){ 136 contWindth = m.megamenuwidth == 'box' ? $(m.WidthBoxClassName+":visible").last().width():$(window).width(); 137 if(width){ 138 var iWidth = Math.min(width, $(window).width()); 139 if(iWidth > contWindth){ 140 contWindth = $(window).width(); 141 } 142 }else{ 143 var iWidth = contWindth; 144 } 145 if (position == 0 || position == 1) { 146 var cur = Math.min((($(window).width() - contWindth)/2 + contWindth) - (parentVis.offset().left+iWidth),position==0?0:parentVis.width()/2 - iWidth/2); 147 } else if (position == 2) { 148 dir="right"; 149 parent.css("left","auto"); 150 var cur = Math.min((parentVis.offset().left + parentVis.width() - iWidth) - (($(window).width() - contWindth)/2),0); 151 } 152 parent.css({"width":iWidth}).css(dir,cur); 153 } 154 itemPosition(); 155 $(window).resize(function(){ 156 itemPosition(); 157 }) 158 }) 159 160 primary.find(".dnngo_slide_menu > li.dir,.dnngo_submenu > ul > li.dir").on("mouseenter",function () { 161 var e = $(this),sub=e.children(".dnngo_submenu"); 162 if(!sub.length) return; 163 sub.stop().fadeIn(m.slide_speed); 164 e.addClass("menu_hover"); 165 $(this).children("a").attr("aria-expanded","true"); 166 if(sub.offset().left + sub.width() > $(window).width()){ 167 e.addClass("reverse"); 168 } 169 }).on("mouseleave",function () { 170 var e = $(this),sub=e.children(".dnngo_submenu"); 171 if(!sub.length) return; 172 e.removeClass("menu_hover");
173 $(this).children("a").attr("aria-expanded","false"); 174 sub.stop().fadeOut(m.slide_speed,function(){e.removeClass("reverse")}); 175 }) 176 177 primary.find(".dnngo_menuslide,.dnngo_submenu").each(function(){ 178 var e = $(this), 179 ih = e.height(), 180 wh = $(window).height(), 181 ioft = e.offset().top; 182 var clearTop = 0; 183 $(window).resize(function(){ 184 wh = $(window).height(); 185 ih = e.height(); 186 ioft = e.parent().offset() ? e.parent().offset().top:ioft; 187 }) 188 189 e.on("mouseenter",function () { 190 // e.css("top",""); 191 ih = e.height(); 192 ioft = e.offset().top - $(window).scrollTop(), 193 ioft2 = e.offset().top - $(window).scrollTop(); 194 clearInterval(clearTop); 195 }).on("mouseleave",function () { 196 clearTop = setTimeout(function(){ 197 if(e.is(":hidden")) e.css("top",""); 198 },500) 199 }) 200 201 e.on("mousewheel DOMMouseScroll", function (event) { 202 event.preventDefault(); 203 event.stopPropagation(); 204 ioft2 = e.offset().top - $(window).scrollTop(); 205 step = 100; 206 207 if(e.css("opacity")!=1){return ;} 208 209 if(ioft + ih > wh){ 210 var delta = (event.originalEvent.wheelDelta && (event.originalEvent.wheelDelta > 0 ? 1 : -1)) || (event.originalEvent.detail && (event.originalEvent.detail > 0 ? -1 : 1)); 211 if(delta== -1){ 212 if(ih + ioft2 > wh){ 213 if( ioft2 - step < wh - ih){ step = Math.abs(wh - ih - ioft2) } 214 e.stop().animate({"top": e.position().top - step },240) 215 } 216 } 217 if(delta== 1){ 218 if(ioft2 < 0 ){ 219 if( ioft2 > -step){ step = Math.abs(ioft2) } 220 e.stop().animate({"top":e.position().top + step},240) 221 } 222 } 223 } 224 }) 225 }) 226 227 228 primary.find(".dnngo_menu_list").each(function () { 229 var line = $("<div class=\"line\"></div>"); 230 var n = $(this).parent("div").attr("class").split("numbercolumns-")[1].split(" ")[0]; 231 for (var i = 0; i < n; i++) { 232 line.append("<span></span>") 233 } 234 $(this).find(".dnngo_submenu").each(function () { 235 $(this).children("ul").unwrap(); 236 }) 237 238 $(this).after(line); 239 }) 240 241 me.data("clickdisplay",m.clickdisplay).menusKeyboard(); 242 243 }); 244 }; 245})(jQuery); 246 247(function ($) { 248 $.fn.menusKeyboard = function () { 249 250 var menus = $(this); 251 var curr = menus.find(":focus"); 252 var keyCode; 253 var shiftKey; 254 var role ; 255 var clickdisplay = menus.data("clickdisplay"); 256 var keydown = false; 257 258 function menusondownkey(e, key) { 259 switch (key) { 260 case 9: 261 menusonfocus("tab"); 262 break; 263 case 13: 264 case 32: 265 if (curr.parent("li").hasClass("dir") && curr.siblings("div").is(":hidden")) { 266 e.preventDefault(); 267 menusonfocus("enter"); 268 } 269 break; 270 case 37: 271 e.preventDefault(); 272 menusonfocus("left"); 273 break; 274 case 38: 275 e.preventDefault(); 276 menusonfocus("up"); 277 break; 278 case 39: 279 e.preventDefault(); 280 menusonfocus("right"); 281 break; 282 case 40: 283 e.preventDefault(); 284 menusonfocus("down"); 285 break; 286 case 27: 287 e.preventDefault(); 288 menusonfocus("end"); 289 break; 290 } 291 292 } 293 294 function menusonup() { 295 if(role=="menubar" && curr.siblings("div").length){ 296 297 clickdisplay ? curr.parent().click():curr.parent().mouseenter(); 298 299 curr.siblings("div").find("a").last().focus(); 300 301 }else if(role=="menu"){ 302 if (curr.parent("li").prev().length) { 303 curr.parent("li").prev().children("a").focus(); 304 } else { 305 curr.parent("li").siblings().last().children("a").focus(); 306 } 307 } 308 309 } 310 311 function menusondown() { 312 if(role=="menubar" && curr.siblings("div").length){ 313 clickdisplay ? curr.parent().click():curr.parent().mouseenter(); 314 curr.siblings("div").find("a").eq(0).focus(); 315 }else if(role=="menu"){ 316 if (curr.parent("li").next().length) { 317 curr.parent("li").next().children("a").focus(); 318 } else { 319 curr.parent("li").siblings().first().children("a").focus(); 320 } 321 } 322 323 } 324 325 function menusonright() { 326 if(role=="menubar"){ 327 if (curr.parent("li").next().length) { 328 curr.parent("li").next().children("a").focus(); 329 } else { 330 curr.parent("li").siblings().first().children("a").focus(); 331 } 332 clickdisplay && menus.trigger("blur"); 333 }else if(role=="menu" && curr.siblings("div").length){ 334 curr.parent().mouseenter(); 335 curr.siblings("div").find("a").eq(0).focus(); 336 } 337 } 338 339 function menusonleft() { 340 if(role=="menubar"){ 341 if (curr.parent("li").prev().length) { 342 curr.parent("li").prev().children("a").focus(); 343 } else {
344 curr.parent("li").siblings().last().children("a").focus(); 345 } 346 clickdisplay && menus.trigger("blur"); 347 }else if(role=="menu"){ 348 var p = curr.parent().parents("li.dir").first(); 349 p.mouseleave().children("a").focus(); 350 p.parents("li.dir").first().mouseenter(); 351 } 352 } 353 354 function menusonfocus(action) { 355 356 switch (action) { 357 case "first": 358 menus.find("a").eq(0).focus(); 359 break; 360 case "down": 361 menusondown(); 362 break; 363 case "up": 364 menusonup(); 365 break; 366 case "right": 367 menusonright(); 368 break; 369 case "left": 370 menusonleft(); 371 break; 372 case "enter": 373 clickdisplay ? curr.parent().click():curr.parent().mouseenter(); 374 break; 375 case "end": 376 curr.parents("li.dir").last().mouseenter().children("a").focus(); 377 clickdisplay ? menus.trigger("blur"):curr.mouseleave(); 378 drop = false; 379 break; 380 381 curr = menus.find(":focus"); 382 role = curr.parents("ul").first().attr("role"); 383 if (curr.parents("ul").eq(0).hasClass("primary_structure")) { 384 curr.parent().mouseleave(); 385 } 386 387 388 } 389 } 390 menus.on("keydown", function (e) { 391 keyCode = e.keyCode || e.which || e.charCode; 392 shiftKey = e.shiftKey; 393 if (menus.find("a").is(":focus") || keyCode == 123) { 394 //curr.mouseout(); 395 curr = menus.find(":focus"); 396 role = curr.parents("ul").first().attr("role"); 397 if (shiftKey && keyCode == 123) { 398 e.preventDefault(); 399 menusonfocus("first"); 400 } else if (shiftKey && keyCode == 9) { 401 menusonfocus("backtab"); 402 } else { 403 menusondownkey(e, e.keyCode); 404 } 405 } 406 keydown = true; 407 }).on("keyup", function (e) { 408 menus.find(":focus").parent().siblings("li.dir").children("div:visible").each(function(){ 409 $(this).parent("li.dir").mouseleave(); 410 $(this).parent("li.dir").parents("li.dir").first().mouseenter(); 411 clickdisplay && menus.trigger("blur"); 412 }) 413 keydown = false; 414 }).find("a").on("blur",function(){ 415 if(!menus.is(":focus-within") && keydown){ 416 clickdisplay ? menus.trigger("blur") : menus.find(".dnngo_menuslide:visible").find("li").eq(0).mouseleave(); 417 } 418 keydown = false; 419 }); 420 421 }; 422})(jQuery); 423 424
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.