1(function ($, window, document) { 2 "use strict"; 3 var pluginName = "accessibleMegaMenu", 4 defaults = { 5 uuidPrefix: "accessible-megamenu", 6 menuClass: "accessible-megamenu", 7 topNavItemClass: "accessible-megamenu-top-nav-item", 8 panelClass: "accessible-megamenu-panel", 9 panelGroupClass: "accessible-megamenu-panel-group", 10 hoverClass: "hover", 11 focusClass: "focus", 12 openClass: "open", 13 toggleButtonClass: "accessible-megamenu-toggle", 14 openDelay: 0, 15 closeDelay: 250, 16 openOnMouseover: true, 17 }, 18 Keyboard = { 19 BACKSPACE: 8, 20 COMMA: 188, 21 DELETE: 46, 22 DOWN: 40, 23 END: 35, 24 ENTER: 13, 25 ESCAPE: 27, 26 HOME: 36, 27 LEFT: 37, 28 PAGE_DOWN: 34, 29 PAGE_UP: 33, 30 PERIOD: 190, 31 RIGHT: 39, 32 SPACE: 32, 33 TAB: 9, 34 UP: 38, 35 keyMap: { 36 48: "0", 37 49: "1", 38 50: "2", 39 51: "3", 40 52: "4", 41 53: "5", 42 54: "6", 43 55: "7", 44 56: "8", 45 57: "9", 46 59: ";", 47 65: "a", 48 66: "b", 49 67: "c", 50 68: "d", 51 69: "e", 52 70: "f", 53 71: "g", 54 72: "h", 55 73: "i", 56 74: "j", 57 75: "k", 58 76: "l", 59 77: "m", 60 78: "n", 61 79: "o", 62 80: "p", 63 81: "q", 64 82: "r", 65 83: "s", 66 84: "t", 67 85: "u", 68 86: "v", 69 87: "w", 70 88: "x", 71 89: "y", 72 90: "z", 73 96: "0", 74 97: "1", 75 98: "2", 76 99: "3", 77 100: "4", 78 101: "5", 79 102: "6", 80 103: "7", 81 104: "8", 82 105: "9", 83 190: ".", 84 }, 85 }, 86 clearTimeout = window.clearTimeout, 87 setTimeout = window.setTimeout, 88 isOpera = window.opera && window.opera.toString() === "[object Opera]"; 89 function AccessibleMegaMenu(element, options) { 90 this.element = element; 91 this.settings = $.extend({}, defaults, options); 92 this._defaults = defaults; 93 this._name = pluginName; 94 this.mouseTimeoutID = null; 95 this.focusTimeoutID = null; 96 this.mouseFocused = false; 97 this.justFocused = false; 98 this.init(); 99 } 100 AccessibleMegaMenu.prototype = (function () { 101 var uuid = 0, 102 keydownTimeoutDuration = 1000, 103 keydownSearchString = "", 104 isTouch = "ontouchstart" in window || window.navigator.msMaxTouchPoints, 105 _getPlugin, 106 _addUniqueId, 107 _togglePanel, 108 _clickHandler, 109 _touchmoveHandler, 110 _clickOutsideHandler, 111 _DOMAttrModifiedHandler, 112 _focusInHandler, 113 _focusOutHandler, 114 _keyDownHandler, 115 _mouseDownHandler, 116 _mouseOverHandler, 117 _mouseOutHandler, 118 _clickToggleHandler, 119 _toggleExpandedEventHandlers, 120 _addEventHandlers, 121 _removeEventHandlers; 122 _getPlugin = function (element) { 123 return $(element) 124 .closest(":data(plugin_" + pluginName + ")") 125 .data("plugin_" + pluginName); 126 }; 127 _addUniqueId = function (element) { 128 element = $(element); 129 var settings = this.settings; 130 if (!element.attr("id")) { 131 element.attr("id", settings.uuidPrefix + "-" + new Date().getTime() + "-" + ++uuid); 132 } 133 }; 134 _togglePanel = function (event, hide) { 135 var target = $(event.target), 136 that = this, 137 settings = this.settings, 138 menu = this.menu, 139 topli = target.closest("." + settings.topNavItemClass), 140 panel = target.hasClass(settings.panelClass) ? target : target.closest("." + settings.panelClass), 141 newfocus; 142 _toggleExpandedEventHandlers.call(this, true); 143 if (hide) { 144 topli = menu.find("." + settings.topNavItemClass + " ." + settings.openClass + ":first").closest("." + settings.topNavItemClass); 145 if (!(topli.is(event.relatedTarget) || topli.has(event.relatedTarget).length > 0)) { 146 if ((event.type === "mouseout" || event.type === "focusout") && topli.has(document.activeElement).length > 0) { 147 return; 148 } 149 topli.find("[aria-expanded]").attr("aria-expanded", "false").removeClass(settings.openClass); 150 topli 151 .find("." + settings.panelClass) 152 .removeClass(settings.openClass) 153 .attr("aria-hidden", "true"); 154 if ((event.type === "keydown" && event.keyCode === Keyboard.ESCAPE) || event.type === "DOMAttrModified") { 155 newfocus = topli.find(":tabbable:first"); 156 setTimeout(function () { 157 menu.find("[aria-expanded]." + that.settings.panelClass).off("DOMAttrModified.accessible-megamenu"); 158 newfocus.focus(); 159 that.justFocused = false;
160 }, 99); 161 } 162 } else if (topli.length === 0) { 163 menu.find("[aria-expanded=true]") 164 .attr("aria-expanded", "false") 165 .removeClass(settings.openClass) 166 .closest("." + settings.topNavItemClass) 167 .find("." + settings.panelClass) 168 .removeClass(settings.openClass) 169 .attr("aria-hidden", "true"); 170 } 171 } else { 172 clearTimeout(that.focusTimeoutID); 173 var openli = menu.find("[aria-expanded=true]").closest("." + settings.topNavItemClass); 174 if (!openli.is(topli)) { 175 openli.find("[aria-expanded]").attr("aria-expanded", "false").removeClass(settings.openClass); 176 openli 177 .find("." + settings.panelClass) 178 .removeClass(settings.openClass) 179 .attr("aria-hidden", "true"); 180 } 181 topli.find("[aria-expanded]").attr("aria-expanded", "true").addClass(settings.openClass); 182 topli 183 .find("." + settings.panelClass) 184 .addClass(settings.openClass) 185 .attr("aria-hidden", "false"); 186 if (topli.length) { 187 var pageScrollPosition = $("html")[0].scrollTop; 188 var openPanelTopPosition = topli.offset().top; 189 if (pageScrollPosition > openPanelTopPosition) { 190 } 191 } 192 if (event.type === "mouseover" && target.is(":tabbable") && topli.length === 1 && panel.length === 0 && menu.has(document.activeElement).length > 0) { 193 target.focus(); 194 that.justFocused = false; 195 } 196 _toggleExpandedEventHandlers.call(that); 197 } 198 }; 199 _clickHandler = function (event) { 200 var target = $(event.target).closest(":tabbable"), 201 topli = target.closest("." + this.settings.topNavItemClass), 202 panel = target.closest("." + this.settings.panelClass); 203 if (topli.length === 1 && panel.length === 0 && topli.find("." + this.settings.panelClass).length === 1) { 204 if (!target.hasClass(this.settings.openClass)) { 205 _togglePanel.call(this, event); 206 this.justFocused = false; 207 } else { 208 if (this.justFocused) { 209 this.justFocused = false; 210 } else if (isTouch || (!isTouch && !this.settings.openOnMouseover)) { 211 _togglePanel.call(this, event, target.hasClass(this.settings.openClass)); 212 } 213 } 214 } else if (topli.length === 1 && panel.length === 0 && event.type == "keydown" && target.hasAttribute("href")) { 215 window.location.href = target.attr("href"); 216 } 217 }; 218 _touchmoveHandler = function () { 219 this.justMoved = true; 220 }; 221 _clickOutsideHandler = function (event) { 222 if ($(event.target).closest(this.menu).length === 0) { 223 event.preventDefault(); 224 event.stopPropagation(); 225 _togglePanel.call(this, event, true); 226 } 227 }; 228 _DOMAttrModifiedHandler = function (event) { 229 if (event.originalEvent.attrName === "aria-expanded" && event.originalEvent.newValue === "false" && $(event.target).hasClass(this.settings.openClass)) { 230 event.preventDefault(); 231 event.stopPropagation(); 232 _togglePanel.call(this, event, true); 233 } 234 }; 235 _focusInHandler = function (event) { 236 clearTimeout(this.focusTimeoutID); 237 var target = $(event.target), 238 panel = target.closest("." + this.settings.panelClass); 239 target.addClass(this.settings.focusClass); 240 this.justFocused = !this.mouseFocused || (!this.settings.openOnMouseover && this.mouseFocused); 241 this.mouseFocused = false;
242 if (this.justFocused && this.panels.not(panel).filter("." + this.settings.openClass).length) { 243 _togglePanel.call(this, event); 244 } 245 }; 246 _focusOutHandler = function (event) { 247 this.justFocused = false; 248 var that = this, 249 target = $(event.target), 250 topli = target.closest("." + this.settings.topNavItemClass); 251 target.removeClass(this.settings.focusClass); 252 if (typeof window.cvox === "object" && typeof window.cvox.Api !== "object") { 253 that.focusTimeoutID = setTimeout(function () { 254 window.cvox.Api.getCurrentNode(function (node) { 255 if (topli.has(node).length) { 256 clearTimeout(that.focusTimeoutID); 257 } else { 258 that.focusTimeoutID = setTimeout( 259 function (scope, event, hide) { 260 _togglePanel.call(scope, event, hide); 261 }, 262 275, 263 that, 264 event, 265 true 266 ); 267 } 268 }); 269 }, 25); 270 } else { 271 that.focusTimeoutID = setTimeout(function () { 272 if (that.mouseFocused && event.relatedTarget === null) { 273 return; 274 } 275 _togglePanel.call(that, event, true); 276 }, 300); 277 } 278 }; 279 _keyDownHandler = function (event) { 280 var that = this.constructor === AccessibleMegaMenu ? this : _getPlugin(this), 281 settings = that.settings, 282 target = $($(this).is("." + settings.hoverClass + ":tabbable") ? this : event.target), 283 menu = that.menu, 284 topnavitems = that.topnavitems, 285 topli = target.closest("." + settings.topNavItemClass), 286 tabbables = menu.find(":tabbable"), 287 panel = target.hasClass(settings.panelClass) ? target : target.closest("." + settings.panelClass), 288 panelGroups = panel.find("." + settings.panelGroupClass), 289 currentPanelGroup = target.closest("." + settings.panelGroupClass), 290 next, 291 keycode = event.keyCode || event.which, 292 start, 293 i, 294 o, 295 label, 296 found = false, 297 newString = Keyboard.keyMap[event.keyCode] || "", 298 regex, 299 isTopNavItem = topli.length === 1 && panel.length === 0;
300 if (target.is("input:focus, select:focus, textarea:focus, button:focus")) { 301 return; 302 } 303 if (target.is("." + settings.hoverClass + ":tabbable")) { 304 $("html").off("keydown.accessible-megamenu"); 305 } 306 switch (keycode) { 307 case Keyboard.ESCAPE: 308 this.mouseFocused = false; 309 _togglePanel.call(that, event, true); 310 break; 311 case Keyboard.DOWN: 312 event.preventDefault(); 313 this.mouseFocused = false; 314 if (isTopNavItem) { 315 _togglePanel.call(that, event); 316 found = topli.find("." + settings.panelClass + " :tabbable:first").focus().length === 1; 317 } else { 318 found = tabbables.filter(":gt(" + tabbables.index(target) + "):first").focus().length === 1; 319 } 320 if (!found && isOpera && (event.ctrlKey || event.metaKey)) { 321 tabbables = $(":tabbable"); 322 i = tabbables.index(target); 323 found = $(":tabbable:gt(" + $(":tabbable").index(target) + "):first").focus().length === 1; 324 } 325 break; 326 case Keyboard.UP: 327 event.preventDefault(); 328 this.mouseFocused = false; 329 if (isTopNavItem && target.hasClass(settings.openClass)) { 330 _togglePanel.call(that, event, true); 331 next = topnavitems.filter(":lt(" + topnavitems.index(topli) + "):last"); 332 if (next.children("." + settings.panelClass).length) { 333 next.find("[aria-expanded]").attr("aria-expanded", "true").addClass(settings.openClass); 334 found = 335 next 336 .children("." + settings.panelClass) 337 .addClass(settings.openClass) 338 .attr("aria-hidden", "false") 339 .find(":tabbable:last") 340 .focus() === 1; 341 } 342 } else if (!isTopNavItem) { 343 found = tabbables.filter(":lt(" + tabbables.index(target) + "):last").focus().length === 1; 344 } 345 if (!found && isOpera && (event.ctrlKey || event.metaKey)) { 346 tabbables = $(":tabbable"); 347 i = tabbables.index(target); 348 found = $(":tabbable:lt(" + $(":tabbable").index(target) + "):first").focus().length === 1; 349 } 350 break; 351 case Keyboard.RIGHT: 352 event.preventDefault(); 353 this.mouseFocused = false; 354 if (isTopNavItem) { 355 found = 356 topnavitems 357 .filter(":gt(" + topnavitems.index(topli) + "):first") 358 .find(":tabbable:first") 359 .focus().length === 1; 360 } else { 361 if (panelGroups.length && currentPanelGroup.length) { 362 found = 363 panelGroups 364 .filter(":gt(" + panelGroups.index(currentPanelGroup) + "):first") 365 .find(":tabbable:first") 366 .focus().length === 1; 367 } 368 if (!found) { 369 found = topli.find(":tabbable:first").focus().length === 1; 370 } 371 } 372 break; 373 case Keyboard.LEFT: 374 event.preventDefault(); 375 this.mouseFocused = false; 376 if (isTopNavItem) { 377 found = 378 topnavitems 379 .filter(":lt(" + topnavitems.index(topli) + "):last") 380 .find(":tabbable:first") 381 .focus().length === 1; 382 } else { 383 if (panelGroups.length && currentPanelGroup.length) { 384 found = 385 panelGroups 386 .filter(":lt(" + panelGroups.index(currentPanelGroup) + "):last") 387 .find(":tabbable:first") 388 .focus().length === 1; 389 } 390 if (!found) { 391 found = topli.find(":tabbable:first").focus().length === 1; 392 } 393 } 394 break; 395 case Keyboard.TAB: 396 this.mouseFocused = false;
397 i = tabbables.index(target); 398 if (event.shiftKey && isTopNavItem && target.hasClass(settings.openClass)) { 399 _togglePanel.call(that, event, true); 400 next = topnavitems.filter(":lt(" + topnavitems.index(topli) + "):last"); 401 if (next.children("." + settings.panelClass).length) { 402 found = next 403 .children() 404 .attr("aria-expanded", "true") 405 .addClass(settings.openClass) 406 .filter("." + settings.panelClass) 407 .attr("aria-hidden", "false") 408 .find(":tabbable:last") 409 .focus(); 410 } 411 } else if (event.shiftKey && i > 0) { 412 found = tabbables.filter(":lt(" + i + "):last").focus().length === 1; 413 } else if (!event.shiftKey && i < tabbables.length - 1) { 414 found = tabbables.filter(":gt(" + i + "):first").focus().length === 1; 415 } else if (isOpera) { 416 tabbables = $(":tabbable"); 417 i = tabbables.index(target); 418 if (event.shiftKey) { 419 found = $(":tabbable:lt(" + $(":tabbable").index(target) + "):last").focus().length === 1; 420 } else { 421 found = $(":tabbable:gt(" + $(":tabbable").index(target) + "):first").focus().length === 1; 422 } 423 } 424 if (found) { 425 event.preventDefault(); 426 } 427 break; 428 case Keyboard.SPACE: 429 case Keyboard.ENTER: 430 if (isTopNavItem) { 431 if (target.hasClass("open")) { 432 this.mouseFocused = false; 433 _togglePanel.call(that, event, true); 434 } else { 435 _clickHandler.call(that, event); 436 } 437 } else { 438 return true; 439 } 440 break; 441 default: 442 clearTimeout(this.keydownTimeoutID); 443 keydownSearchString += newString !== keydownSearchString ? newString : ""; 444 if (keydownSearchString.length === 0) { 445 return; 446 } 447 this.keydownTimeoutID = setTimeout(function () { 448 keydownSearchString = ""; 449 }, keydownTimeoutDuration); 450 if (isTopNavItem && !target.hasClass(settings.openClass)) { 451 tabbables = tabbables.filter(":not(." + settings.panelClass + " :tabbable)"); 452 } else { 453 tabbables = topli.find(":tabbable"); 454 } 455 if (event.shiftKey) { 456 tabbables = $(tabbables.get().reverse()); 457 } 458 for (i = 0; i < tabbables.length; i++) { 459 o = tabbables.eq(i); 460 if (o.is(target)) { 461 start = keydownSearchString.length === 1 ? i + 1 : i; 462 break; 463 } 464 } 465 regex = new RegExp("^" + keydownSearchString.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"), "i"); 466 for (i = start; i < tabbables.length; i++) { 467 o = tabbables.eq(i); 468 label = $.trim(o.text()); 469 if (regex.test(label)) { 470 found = true; 471 o.focus(); 472 break; 473 } 474 } 475 if (!found) { 476 for (i = 0; i < start; i++) { 477 o = tabbables.eq(i); 478 label = $.trim(o.text()); 479 if (regex.test(label)) { 480 o.focus(); 481 break; 482 } 483 } 484 } 485 break; 486 } 487 that.justFocused = false;
488 }; 489 _mouseDownHandler = function (event) { 490 if ($(event.target).closest(this.settings.panelClass) || $(event.target).closest(":focusable").length) { 491 this.mouseFocused = true; 492 if ($(event.target).closest(this.settings.menuClass)) { 493 $("html").on("keydown.accessible-megamenu", $.proxy(_keyDownHandler, event.target)); 494 } 495 } 496 clearTimeout(this.mouseTimeoutID); 497 this.mouseTimeoutID = setTimeout(function () { 498 clearTimeout(this.focusTimeoutID); 499 }, 1); 500 }; 501 _mouseOverHandler = function (event) { 502 clearTimeout(this.mouseTimeoutID); 503 var that = this; 504 if (!that.settings.openOnMouseover) { 505 return; 506 } 507 this.mouseTimeoutID = setTimeout(function () { 508 $(event.target).addClass(that.settings.hoverClass); 509 _togglePanel.call(that, event); 510 if ($(event.target).closest(that.settings.menuClass)) { 511 $("html").on("keydown.accessible-megamenu", $.proxy(_keyDownHandler, event.target)); 512 } 513 }, this.settings.openDelay); 514 }; 515 _mouseOutHandler = function (event) { 516 clearTimeout(this.mouseTimeoutID); 517 var that = this; 518 if (!that.settings.openOnMouseover) { 519 return; 520 } 521 $(event.target).removeClass(that.settings.hoverClass); 522 that.mouseTimeoutID = setTimeout(function () { 523 _togglePanel.call(that, event, true); 524 }, this.settings.closeDelay); 525 if ($(event.target).is(":tabbable")) { 526 $("html").off("keydown.accessible-megamenu"); 527 } 528 }; 529 _clickToggleHandler = function () { 530 var isExpanded = this.toggleButton.attr("aria-expanded") === "true"; 531 this.toggleButton.attr({ "aria-expanded": !isExpanded }); 532 }; 533 _toggleExpandedEventHandlers = function (hide) { 534 var menu = this.menu; 535 if (hide) { 536 $("html").off("mouseup.outside-accessible-megamenu, touchend.outside-accessible-megamenu, mspointerup.outside-accessible-megamenu, pointerup.outside-accessible-megamenu"); 537 menu.find("[aria-expanded]." + this.settings.panelClass).off("DOMAttrModified.accessible-megamenu"); 538 } else { 539 $("html").on("mouseup.outside-accessible-megamenu, touchend.outside-accessible-megamenu, mspointerup.outside-accessible-megamenu, pointerup.outside-accessible-megamenu", $.proxy(_clickOutsideHandler, this)); 540 menu.find("[aria-expanded=true]." + this.settings.panelClass).on("DOMAttrModified.accessible-megamenu", $.proxy(_DOMAttrModifiedHandler, this)); 541 } 542 }; 543 _addEventHandlers = function () { 544 var menu = this.menu, 545 toggleButton = this.toggleButton; 546 menu.on("focusin.accessible-megamenu", ":focusable, ." + this.settings.panelClass, $.proxy(_focusInHandler, this)) 547 .on("focusout.accessible-megamenu", ":focusable, ." + this.settings.panelClass, $.proxy(_focusOutHandler, this)) 548 .on("keydown.accessible-megamenu", $.proxy(_keyDownHandler, this)) 549 .on("mouseover.accessible-megamenu", $.proxy(_mouseOverHandler, this)) 550 .on("mouseout.accessible-megamenu", $.proxy(_mouseOutHandler, this)) 551 .on("mousedown.accessible-megamenu", $.proxy(_mouseDownHandler, this)) 552 .on("click.accessible-megamenu", $.proxy(_clickHandler, this)); 553 toggleButton.on("click.accessible-megamenu", $.proxy(_clickToggleHandler, this)); 554 if (isTouch) { 555 menu.on("touchmove.accessible-megamenu", $.proxy(_touchmoveHandler, this)); 556 } 557 if ($(document.activeElement).closest(menu).length) { 558 $(document.activeElement).trigger("focusin.accessible-megamenu"); 559 } 560 }; 561 _removeEventHandlers = function () { 562 var menu = this.menu, 563 toggleButton = this.toggleButton; 564 menu.off(".accessible-megamenu"); 565 if (menu.find("[aria-expanded=true]." + this.settings.panelClass).length) { 566 _toggleExpandedEventHandlers.call(this, true); 567 } 568 toggleButton.off(".accessible-megamenu"); 569 }; 570 return { 571 constructor: AccessibleMegaMenu, 572 init: function () { 573 var settings = this.settings, 574 nav = $(this.element), 575 menu = nav.children("ol,ul").first(), 576 topnavitems = menu.children(), 577 toggleButton = nav.children("button").first(); 578 this.start(settings, nav, menu, topnavitems, toggleButton); 579 }, 580 start: function (settings, nav, menu, topnavitems, toggleButton) { 581 var that = this; 582 this.settings = settings; 583 this.menu = menu; 584 this.topnavitems = topnavitems; 585 this.toggleButton = toggleButton; 586 nav.attr("role", "navigation"); 587 _addUniqueId.call(that, menu); 588 menu.addClass(settings.menuClass); 589 menu.addClass(["js", settings.menuClass].join("-")); 590 topnavitems.each(function (i, topnavitem) { 591 var topnavitemlink, topnavitemdiv, topnavitemul, topnavitemli, topnavitempanel; 592 topnavitem = $(topnavitem); 593 topnavitem.addClass(settings.topNavItemClass); 594 topnavitemul = topnavitem.find("ul"); 595 topnavitemli = topnavitem.find("li"); 596 topnavitemlink = topnavitem.find(":tabbable:first"); 597 topnavitemul.attr( "role", "menu" ); 598 topnavitemli.attr( "role", "menuitem" ); 599 topnavitempanel = topnavitem.children(":not(:tabbable):last"); 600 _addUniqueId.call(that, topnavitemlink); 601 if (topnavitempanel.length) { 602 _addUniqueId.call(that, topnavitempanel); 603 topnavitemlink.attr({ "aria-controls": topnavitempanel.attr("id"), tabindex: 0 }); 604 // UPDATED FOR AXE
605 //topnavitempanel.attr({ role: "region", "aria-hidden": true }).addClass(settings.panelClass).not("[aria-labelledby]").attr("aria-labelledby", topnavitemlink.attr("id")); 606 topnavitempanel.attr("role", "region"); 607 topnavitempanel.addClass(settings.panelClass).not("[aria-labelledby]").attr("aria-labelledby", topnavitemlink.attr("id")); 608 } 609 }); 610 this.panels = menu.find("." + settings.panelClass); 611 menu.find("ul").attr("role", "menu"); 612 menu.find("hr").attr("role", "separator"); 613 toggleButton.addClass(settings.toggleButtonClass); 614 toggleButton.attr({ "aria-controls": menu.attr("id") }); 615 _addEventHandlers.call(this); 616 }, 617 destroy: function () { 618 this.menu.removeClass(["js", this.settings.menuClass].join("-")); 619 _removeEventHandlers.call(this, true); 620 }, 621 getDefaults: function () { 622 return this._defaults; 623 }, 624 getOption: function (opt) { 625 return this.settings[opt]; 626 }, 627 getAllOptions: function () { 628 return this.settings; 629 }, 630 setOption: function (opt, value, reinitialize) { 631 this.settings[opt] = value; 632 if (reinitialize) { 633 this.init(); 634 } 635 }, 636 }; 637 })(); 638 $.fn[pluginName] = function (options) { 639 return this.each(function () { 640 var pluginInstance = $.data(this, "plugin_" + pluginName); 641 if (!pluginInstance) { 642 $.data(this, "plugin_" + pluginName, new $.fn[pluginName].Acce
642ssibleMegaMenu(this, options)); 643 } else if (typeof pluginInstance[options] === "function") { 644 pluginInstance[options].apply(pluginInstance, Array.prototype.slice.call(arguments, 1)); 645 } 646 }); 647 }; 648 $.fn[pluginName].AccessibleMegaMenu = AccessibleMegaMenu; 649 function visible(element) { 650 return ( 651 $.expr.filters.visible(element) && 652 !$(element) 653 .parents() 654 .addBack() 655 .filter(function () { 656 return $.css(this, "visibility") === "hidden"; 657 }).length 658 ); 659 } 660 function focusable(element, isTabIndexNotNaN) { 661 var map, 662 mapName, 663 img, 664 nodeName = element.nodeName.toLowerCase(); 665 if ("area" === nodeName) { 666 map = element.parentNode; 667 mapName = map.name; 668 if (!element.href || !mapName || map.nodeName.toLowerCase() !== "map") { 669 return false; 670 } 671 img = $("img[usemap=#" + mapName + "]")[0]; 672 return !!img && visible(img); 673 } 674 return (/input|select|textarea|button|object/.test(nodeName) ? !element.disabled : "a" === nodeName ? element.href || isTabIndexNotNaN : isTabIndexNotNaN) && visible(element); 675 } 676 $.extend($.expr[":"], { 677 data: $.expr.createPseudo 678 ? $.expr.createPseudo(function (dataName) { 679 return function (elem) { 680 return !!$.data(elem, dataName); 681 }; 682 }) 683 : function (elem, i, match) { 684 return !!$.data(elem, match[3]); 685 }, 686 focusable: function (element) { 687 return focusable(element, !isNaN($.attr(element, "tabindex"))); 688 }, 689 tabbable: function (element) { 690 var tabIndex = $.attr(element, "tabindex"), 691 isTabIndexNaN = isNaN(tabIndex); 692 return (isTabIndexNaN || tabIndex >= 0) && focusable(element, !isTabIndexNaN); 693 }, 694 }); 695})(jQuery, window, document);
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.