node-menunav-debug.js revision 100123034ebc324a45f96de8e6a04aa74f41694b
5f40f927dba3cf399373572f6ed6fe59a376376eTodd KlootsYUI.add('node-menunav', function(Y) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots/**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* <p>The MenuNav Node Plugin makes it easy to transform existing list-based
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* markup into traditional, drop down navigational menus that are both accessible
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* and easy to customize, and only require a small set of dependencies.</p>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots*
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots*
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* <p>To use the MenuNav Node Plugin, simply pass a reference to the plugin to a
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* Node instance's <code>plug</code> method.</p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots* <p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <code>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* &#60;script type="text/javascript"&#62; <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // Call the "use" method, passing in "node-menunav". This will <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // load the script and CSS for the MenuNav Node Plugin and all of <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // the required dependencies. <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* YUI().use("node-menunav", function(Y) { <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // Use the "contentready" event to initialize the menu when <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // the subtree of element representing the root menu <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // (&#60;div id="menu-1"&#62;) is ready to be scripted. <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* Y.on("contentready", function () { <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // The scope of the callback will be a Node instance <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // representing the root menu (&#60;div id="menu-1"&#62;). <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // Therefore, since "this" represents a Node instance, it <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // is possible to just call "this.plug" passing in a <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // reference to the MenuNav Node Plugin. <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* this.plug(Y.Plugin.NodeMenuNav); <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* }, "#menu-1"); <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* }); <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* &#60;/script&#62; <br>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* </code>
c73ea722dccc6aae68dc27f7709399507f5ee126Todd Kloots* </p>
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots*
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* <p>The MenuNav Node Plugin has several configuration properties that can be
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* set via an object literal that is passed as a second argument to a Node
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* instance's <code>plug</code> method.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* </p>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots*
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots* <p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <code>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* &#60;script type="text/javascript"&#62; <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // Call the "use" method, passing in "node-menunav". This will <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // load the script and CSS for the MenuNav Node Plugin and all of <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // the required dependencies. <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* YUI().use("node-menunav", function(Y) { <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // Use the "contentready" event to initialize the menu when <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // the subtree of element representing the root menu <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // (&#60;div id="menu-1"&#62;) is ready to be scripted. <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* Y.on("contentready", function () { <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // The scope of the callback will be a Node instance <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // representing the root menu (&#60;div id="menu-1"&#62;). <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // Therefore, since "this" represents a Node instance, it <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // is possible to just call "this.plug" passing in a <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* // reference to the MenuNav Node Plugin. <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* this.plug(Y.Plugin.NodeMenuNav, { mouseOutHideDelay: 1000 });
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* <br><br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* }, "#menu-1"); <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* }); <br>
b659a7f728e509c746e5c15dc6b85034a07eb47bTodd Kloots* <br>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* &#60;/script&#62; <br>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* </code>
c73ea722dccc6aae68dc27f7709399507f5ee126Todd Kloots* </p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots* @module node-menunav
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*/
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Util shortcuts
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar UA = Y.UA,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots later = Y.later,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots getClassName = Y.ClassNameManager.getClassName,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Frequently used strings
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots MENU = "menu",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots MENUITEM = "menuitem",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots HIDDEN = "hidden",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots PARENT_NODE = "parentNode",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CHILDREN = "children",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots OFFSET_HEIGHT = "offsetHeight",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots OFFSET_WIDTH = "offsetWidth",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots PX = "px",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots ID = "id",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots PERIOD = ".",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots HANDLED_MOUSEOUT = "handledMouseOut",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots HANDLED_MOUSEOVER = "handledMouseOver",
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots ACTIVE = "active",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots LABEL = "label",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots LOWERCASE_A = "a",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots MOUSEDOWN = "mousedown",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots KEYDOWN = "keydown",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CLICK = "click",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots EMPTY_STRING = "",
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots FIRST_OF_TYPE = "first-of-type",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots ROLE = "role",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots PRESENTATION = "presentation",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots DESCENDANTS = "descendants",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots UI = "UI",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots ACTIVE_DESCENDANT = "activeDescendant",
269127229912bbc887ad01187105dcbd16133144Todd Kloots USE_ARIA = "useARIA",
269127229912bbc887ad01187105dcbd16133144Todd Kloots ARIA_HIDDEN = "aria-hidden",
269127229912bbc887ad01187105dcbd16133144Todd Kloots CONTENT = "content",
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots HOST = "host",
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots ACTIVE_DESCENDANT_CHANGE = ACTIVE_DESCENDANT + "Change",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots STANDARD_QUERY = ">.yui-menu-content>ul>li>a",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots EXTENDED_QUERY = ">.yui-menu-content>ul>li>.yui-menu-label>a:first-child",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // Attribute keys
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots AUTO_SUBMENU_DISPLAY = "autoSubmenuDisplay",
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots MOUSEOUT_HIDE_DELAY = "mouseOutHideDelay",
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // CSS class names
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CSS_MENU = getClassName(MENU),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CSS_MENU_HIDDEN = getClassName(MENU, HIDDEN),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CSS_MENU_HORIZONTAL = getClassName(MENU, "horizontal"),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CSS_MENU_LABEL = getClassName(MENU, LABEL),
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots CSS_MENU_LABEL_ACTIVE = getClassName(MENU, LABEL, ACTIVE),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CSS_MENU_LABEL_MENUVISIBLE = getClassName(MENU, LABEL, (MENU + "visible")),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots CSS_MENUITEM = getClassName(MENUITEM),
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots CSS_MENUITEM_ACTIVE = getClassName(MENUITEM, ACTIVE),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // CSS selectors
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots MENU_SELECTOR = PERIOD + CSS_MENU,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots MENU_TOGGLE_SELECTOR = (PERIOD + getClassName(MENU, "toggle"));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots// Utility functions
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar getPreviousSibling = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var oPrevious = node.previous(),
269127229912bbc887ad01187105dcbd16133144Todd Kloots oChildren;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!oPrevious) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots oChildren = node.get(PARENT_NODE).get(CHILDREN);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oPrevious = oChildren.item(oChildren.size() - 1);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return oPrevious;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar getNextSibling = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots var oNext = node.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!oNext) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots oNext = node.get(PARENT_NODE).get(CHILDREN).item(0);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return oNext;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar isAnchor = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots var bReturnVal = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bReturnVal = node.get("nodeName").toLowerCase() === LOWERCASE_A;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return bReturnVal;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar isMenuItem = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return node.hasClass(CSS_MENUITEM);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar isMenuLabel = function (node) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return node.hasClass(CSS_MENU_LABEL);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar isHorizontalMenu = function (menu) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return menu.hasClass(CSS_MENU_HORIZONTAL);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar hasVisibleSubmenu = function (menuLabel) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return menuLabel.hasClass(CSS_MENU_LABEL_MENUVISIBLE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getItemAnchor = function (node) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return isAnchor(node) ? node : node.query(LOWERCASE_A);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getNodeWithClass = function (node, className, searchAncestors) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var oItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (node) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (node.hasClass(className)) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = node;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (!oItem && searchAncestors) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = node.ancestor((PERIOD + className));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return oItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar getParentMenu = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return node.ancestor(MENU_SELECTOR);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getMenu = function (node, searchAncestors) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return getNodeWithClass(node, CSS_MENU, searchAncestors);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getMenuItem = function (node, searchAncestors) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var oItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (node) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = getNodeWithClass(node, CSS_MENUITEM, searchAncestors);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return oItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getMenuLabel = function (node, searchAncestors) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var oItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (node) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (searchAncestors) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = getNodeWithClass(node, CSS_MENU_LABEL, searchAncestors);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oItem = getNodeWithClass(node, CSS_MENU_LABEL) ||
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots node.query((PERIOD + CSS_MENU_LABEL));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return oItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getItem = function (node, searchAncestors) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var oItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (node) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oItem = getMenuItem(node, searchAncestors) ||
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots getMenuLabel(node, searchAncestors);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return oItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getFirstItem = function (menu) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return getItem(menu.query("li"));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Klootsvar getActiveClass = function (node) {
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return isMenuItem(node) ? CSS_MENUITEM_ACTIVE : CSS_MENU_LABEL_ACTIVE;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar handleMouseOverForNode = function (node, target) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots return node && !node[HANDLED_MOUSEOVER] &&
100123034ebc324a45f96de8e6a04aa74f41694bTodd Kloots (node.compareTo(target) || node.contains(target));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar handleMouseOutForNode = function (node, relatedTarget) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return node && !node[HANDLED_MOUSEOUT] &&
100123034ebc324a45f96de8e6a04aa74f41694bTodd Kloots (!node.compareTo(relatedTarget) && !node.contains(relatedTarget));
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots};
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
7e393a882441e7ca948333e65841ef6c16311d21Todd Kloots/**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* The NodeMenuNav class is a plugin for a Node instance. The class is used via
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* the <a href="Node.html#method_plug"><code>plug</code></a> method of Node and
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* should not be instantiated directly.
e470bf2f937c08b9fe627a8af9637594cddd40a1Todd Kloots* @namespace plugin
e470bf2f937c08b9fe627a8af9637594cddd40a1Todd Kloots* @class NodeMenuNav
a76888f75bfe3b3fecae528bbe6053e7c1ab353bTodd Kloots*/
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Klootsvar NodeMenuNav = function () {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots NodeMenuNav.superclass.constructor.apply(this, arguments);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
fd84dbd20108044a5ee332d9b02175bc14f55d3cTodd KlootsNodeMenuNav.NAME = "nodeMenuNav";
dcc27ab1cda56d7ad286e36c57f451db77894301Todd KlootsNodeMenuNav.NS = "menuNav";
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots/**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @property NodeMenuNav.SHIM_TEMPLATE_TITLE
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @description String representing the value for the <code>title</code>
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* attribute for the shim used to prevent <code>&#60;select&#62;</code> elements
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* from poking through menus in IE 6.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @default "Menu Stacking Shim"
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @type String
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots*/
dcc27ab1cda56d7ad286e36c57f451db77894301Todd KlootsNodeMenuNav.SHIM_TEMPLATE_TITLE = "Menu Stacking Shim";
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots/**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @property NodeMenuNav.SHIM_TEMPLATE
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @description String representing the HTML used to create the
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* <code>&#60;iframe&#62;</code> shim used to prevent
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* <code>&#60;select&#62;</code> elements from poking through menus in IE 6.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @default &#34;&#60;iframe frameborder=&#34;0&#34; tabindex=&#34;-1&#34;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* class=&#34;yui-shim&#34; title=&#34;Menu Stacking Shim&#34;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* src=&#34;javascript:false;&#34;&#62;&#60;/iframe&#62;&#34;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots* @type String
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots*/
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// <iframe> shim notes:
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots//
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// 1) Need to set the "frameBorder" property to 0 to suppress the default
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// <iframe> border in IE. (Setting the CSS "border" property alone doesn't
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// suppress it.)
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots//
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// 2) The "src" attribute of the <iframe> is set to "javascript:false;" so
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// that it won't load a page inside it, preventing the secure/nonsecure
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// warning in IE when using HTTPS.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots//
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// 3) Since the role of the <iframe> shim is completely presentational, its
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// "tabindex" attribute is set to "-1" and its title attribute is set to
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// "Menu Stacking Shim". Both strategies help users of screen readers to
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots// avoid mistakenly interacting with the <iframe> shim.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd KlootsNodeMenuNav.SHIM_TEMPLATE = '<iframe frameborder="0" tabindex="-1" class="' +
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots getClassName("shim") +
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots '" title="' + NodeMenuNav.SHIM_TEMPLATE_TITLE +
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots '" src="javascript:false;"></iframe>';
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd KlootsNodeMenuNav.ATTRS = {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots /**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * Boolean indicating if use of the WAI-ARIA Roles and States should be
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * enabled for the menu.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots *
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @attribute useARIA
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @readOnly
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @writeOnce
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @default true
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @type boolean
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots */
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots useARIA: {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots value: true,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots writeOnce: true,
dfaa02c184225d346e5acf9653baf4d3bafa69a9Todd Kloots lazyAdd: false,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots setter: function (value) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots var oMenu = this.get(HOST),
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuLabel,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuToggle,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oSubmenu,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sID;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (value) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenu.set(ROLE, MENU);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenu.queryAll("ul,li,." + getClassName(MENU, CONTENT)).set(ROLE, PRESENTATION);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenu.queryAll((PERIOD + getClassName(MENUITEM, CONTENT))).set(ROLE, MENUITEM);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenu.queryAll((PERIOD + CSS_MENU_LABEL)).each(function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuLabel = node;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuToggle = node.query(MENU_TOGGLE_SELECTOR);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (oMenuToggle) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuToggle.set(ROLE, PRESENTATION);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuLabel = oMenuToggle.previous();
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuLabel.set(ROLE, MENUITEM);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenuLabel.set("aria-haspopup", true);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oSubmenu = node.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (oSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oSubmenu.set(ROLE, MENU);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenuLabel = oSubmenu.previous();
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenuToggle = oMenuLabel.query(MENU_TOGGLE_SELECTOR);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (oMenuToggle) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenuLabel = oMenuToggle;
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots sID = Y.stamp(oMenuLabel);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (!oMenuLabel.get(ID)) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenuLabel.set(ID, sID);
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oSubmenu.set("aria-labelledby", sID);
269127229912bbc887ad01187105dcbd16133144Todd Kloots oSubmenu.set(ARIA_HIDDEN, true);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots });
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots },
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots /**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * Boolean indicating if submenus are automatically made visible when the
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * user mouses over the menu's items.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots *
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @attribute autoSubmenuDisplay
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @readOnly
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @writeOnce
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @default true
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @type boolean
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots */
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots autoSubmenuDisplay: {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots value: true,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots writeOnce: true
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots },
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots /**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * Number indicating the time (in milliseconds) that should expire before a
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * submenu is made visible when the user mouses over the menu's label.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots *
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @attribute submenuShowDelay
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @readOnly
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @writeOnce
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @default 250
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @type Number
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots */
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots submenuShowDelay: {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots value: 250,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots writeOnce: true
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots },
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots /**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * Number indicating the time (in milliseconds) that should expire before a
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * submenu is hidden when the user mouses out of a menu label heading in the
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * direction of a submenu.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots *
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @attribute submenuHideDelay
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @readOnly
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @writeOnce
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @default 250
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @type Number
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots */
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots submenuHideDelay: {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots value: 250,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots writeOnce: true
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots },
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots /**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * Number indicating the time (in milliseconds) that should expire before a
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * submenu is hidden when the user mouses out of it.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots *
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @attribute mouseOutHideDelay
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @readOnly
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @writeOnce
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @default 750
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @type Number
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots */
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots mouseOutHideDelay: {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots value: 750,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots writeOnce: true
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots};
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd KlootsY.extend(NodeMenuNav, Y.Plugin.Base, {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Protected properties
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _rootMenu
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description Node instance representing the root menu in the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _rootMenu: null,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _activeItem
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description Node instance representing the menu's active descendent:
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * the menuitem or menu label the user is currently interacting with.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _activeItem: null,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _activeMenu
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description Node instance representing the menu that is the parent of
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * the menu's active descendent.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _activeMenu: null,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _hasFocus
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description Boolean indicating if the menu has focus.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default false
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Boolean
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _hasFocus: false,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // In gecko-based browsers a mouseover and mouseout event will fire even
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // if a DOM element moves out from under the mouse without the user
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots // actually moving the mouse. This bug affects NodeMenuNav because the
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots // user can hit the Esc key to hide a menu, and if the mouse is over the
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots // menu when the user presses Esc, the _onMenuMouseOut handler will be
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots // called. To fix this bug the following flag (_blockMouseEvent) is used
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots // to block the code in the _onMenuMouseOut handler from executing.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _blockMouseEvent
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description Boolean indicating whether or not to handle the
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * "mouseover" event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default false
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Boolean
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _blockMouseEvent: false,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _currentMouseX
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description Number representing the current x coordinate of the mouse
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * inside the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default 0
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Number
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _currentMouseX: 0,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _movingToSubmenu
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description Boolean indicating if the mouse is moving from a menu
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * label to its corresponding submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default false
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Boolean
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _movingToSubmenu: false,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _showSubmenuTimer
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Timer used to show a submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Object
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _showSubmenuTimer: null,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _hideSubmenuTimer
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Timer used to hide a submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Object
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _hideSubmenuTimer: null,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _hideAllSubmenusTimer
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Timer used to hide a all submenus.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Object
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _hideAllSubmenusTimer: null,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _firstItem
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description Node instance representing the first item (menuitem or menu
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * label) in the root menu of a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots _firstItem: null,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots // Public methods
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots initializer: function (config) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots var menuNav = this,
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots oRootMenu = this.get(HOST),
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers = [],
3400b203be7070506f073537f5150b980d363089Todd Kloots oDoc;
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (oRootMenu) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._rootMenu = oRootMenu;
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oRootMenu.queryAll("ul:first-child").addClass(FIRST_OF_TYPE);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots // Hide all visible submenus
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oRootMenu.queryAll(MENU_SELECTOR).addClass(CSS_MENU_HIDDEN);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots // Wire up all event handlers
269127229912bbc887ad01187105dcbd16133144Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on("mouseover", menuNav._onMouseOver, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on("mouseout", menuNav._onMouseOut, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on("mousemove", menuNav._onMouseMove, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on(MOUSEDOWN, menuNav._toggleSubmenuDisplay, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on(KEYDOWN, menuNav._toggleSubmenuDisplay, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on(CLICK, menuNav._toggleSubmenuDisplay, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on("keypress", menuNav._onKeyPress, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oRootMenu.on(KEYDOWN, menuNav._onKeyDown, menuNav));
269127229912bbc887ad01187105dcbd16133144Todd Kloots
3400b203be7070506f073537f5150b980d363089Todd Kloots oDoc = oRootMenu.get("ownerDocument");
269127229912bbc887ad01187105dcbd16133144Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oDoc.on(MOUSEDOWN, menuNav._onDocMouseDown, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots aHandlers.push(oDoc.on("focus", menuNav._onDocFocus, menuNav));
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots this._eventHandlers = aHandlers;
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._initFocusManager();
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots },
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots destructor: function () {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots var aHandlers = this._eventHandlers;
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots if (aHandlers) {
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots Y.Array.each(aHandlers, function (handle) {
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots handle.detach();
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots });
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots this._eventHandlers = null;
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots }
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots this.get(HOST).unplug("focusManager");
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots },
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Protected methods
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _isRoot
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description Returns a boolean indicating if the specified menu is the
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * root menu in the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @return {Boolean} Boolean indicating if the specified menu is the root
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * menu in the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _isRoot: function (menu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return this._rootMenu.compareTo(menu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _getTopmostSubmenu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Returns the topmost submenu of a submenu hierarchy.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @return {Node} Node instance representing a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _getTopmostSubmenu: function (menu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu = getParentMenu(menu),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots returnVal;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!oMenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots returnVal = menu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else if (menuNav._isRoot(oMenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots returnVal = menu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots returnVal = menuNav._getTopmostSubmenu(oMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return returnVal;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _clearActiveItem
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description Clears the menu's active descendent.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _clearActiveItem: function () {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var menuNav = this,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveItem = menuNav._activeItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oActiveItem) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveItem.removeClass(getActiveClass(oActiveItem));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._activeItem = null;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _setActiveItem
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description Sets the specified menuitem or menu label as the menu's
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * active descendent.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} item Node instance representing a menuitem or menu label.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _setActiveItem: function (item) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var menuNav = this;
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (item) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._clearActiveItem();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots item.addClass(getActiveClass(item));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._activeItem = item;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _focusItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Focuses the specified menuitem or menu label.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} item Node instance representing a menuitem or menu label.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _focusItem: function (item) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots var menuNav = this,
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots oMenu,
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots oItem;
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots if (item && menuNav._hasFocus) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots oMenu = getParentMenu(item);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots oItem = getItemAnchor(item);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
100123034ebc324a45f96de8e6a04aa74f41694bTodd Kloots if (oMenu && !oMenu.compareTo(menuNav._activeMenu)) {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._activeMenu = oMenu;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._initFocusManager();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._focusManager.focus(oItem);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots },
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _showMenu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Shows the specified menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _showMenu: function (menu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots var oParentMenu = getParentMenu(menu),
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oLI = menu.get(PARENT_NODE),
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots aXY = oLI.getXY();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (this.get(USE_ARIA)) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots menu.set(ARIA_HIDDEN, false);
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (isHorizontalMenu(oParentMenu)) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots aXY[1] = aXY[1] + oLI.get(OFFSET_HEIGHT);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots aXY[0] = aXY[0] + oLI.get(OFFSET_WIDTH);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menu.setXY(aXY);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (UA.ie < 8) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
fab450bda25d83fc914a6413dcd83d3c9919282dTodd Kloots if (UA.ie === 6 && !menu.hasIFrameShim) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menu.appendChild(Y.Node.create(NodeMenuNav.SHIM_TEMPLATE));
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menu.hasIFrameShim = true;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Clear previous values for height and width
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menu.setStyles({ height: EMPTY_STRING, width: EMPTY_STRING });
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // Set the width and height of the menu's bounding box - this is
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // necessary for IE 6 so that the CSS for the <iframe> shim can
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // simply set the <iframe>'s width and height to 100% to ensure
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // that dimensions of an <iframe> shim are always sync'd to the
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // that of its parent menu. Specifying a width and height also
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // helps when positioning decorator elements (for creating effects
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // like rounded corners) inside a menu's bounding box in IE 7.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menu.setStyles({
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots height: (menu.get(OFFSET_HEIGHT) + PX),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots width: (menu.get(OFFSET_WIDTH) + PX) });
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menu.previous().addClass(CSS_MENU_LABEL_MENUVISIBLE);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menu.removeClass(CSS_MENU_HIDDEN);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _hideMenu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Hides the specified menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @param {Boolean} activateAndFocusLabel Boolean indicating if the label
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * for the specified
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * menu should be focused and set as active.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _hideMenu: function (menu, activateAndFocusLabel) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var menuNav = this,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oLabel = menu.previous(),
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oLabel.removeClass(CSS_MENU_LABEL_MENUVISIBLE);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (activateAndFocusLabel) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._focusItem(oLabel);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(oLabel);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveItem = menu.query((PERIOD + CSS_MENUITEM_ACTIVE));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oActiveItem) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveItem.removeClass(CSS_MENUITEM_ACTIVE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // Clear the values for top and left that were set by the call to
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // "setXY" when the menu was shown so that the hidden position
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // specified in the core CSS file will take affect.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menu.setStyles({ left: EMPTY_STRING, top: EMPTY_STRING });
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menu.addClass(CSS_MENU_HIDDEN);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (menuNav.get(USE_ARIA)) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots menu.set(ARIA_HIDDEN, true);
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _hideAllSubmenus
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Hides all submenus of the specified menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _hideAllSubmenus: function (menu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots var menuNav = this;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menu.queryAll(MENU_SELECTOR).each(Y.bind(function (submenuNode) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._hideMenu(submenuNode);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }, menuNav));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _cancelShowSubmenuTimer
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Cancels the timer used to show a submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _cancelShowSubmenuTimer: function () {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oShowSubmenuTimer = menuNav._showSubmenuTimer;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oShowSubmenuTimer) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oShowSubmenuTimer.cancel();
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._showSubmenuTimer = null;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _cancelHideSubmenuTimer
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Cancels the timer used to hide a submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _cancelHideSubmenuTimer: function () {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oHideSubmenuTimer = menuNav._hideSubmenuTimer;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oHideSubmenuTimer) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oHideSubmenuTimer.cancel();
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._hideSubmenuTimer = null;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots /**
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @method _initFocusManager
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @description Initializes and updates the Focus Manager so that is is
269127229912bbc887ad01187105dcbd16133144Todd Kloots * always managing descendants of the active menu.
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @protected
269127229912bbc887ad01187105dcbd16133144Todd Kloots */
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots _initFocusManager: function () {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots var menuNav = this,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oRootMenu = menuNav._rootMenu,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oMenu = menuNav._activeMenu || oRootMenu,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sSelectorBase =
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._isRoot(oMenu) ? EMPTY_STRING : ("#" + oMenu.get("id")),
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oFocusManager = menuNav._focusManager,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sKeysVal,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sDescendantSelector,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sQuery;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (isHorizontalMenu(oMenu)) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sDescendantSelector = sSelectorBase + STANDARD_QUERY + "," +
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sSelectorBase + EXTENDED_QUERY;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sKeysVal = { next: "down:39", previous: "down:37" };
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots else {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sDescendantSelector = sSelectorBase + STANDARD_QUERY;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sKeysVal = { next: "down:40", previous: "down:38" };
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (!oFocusManager) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oRootMenu.plug(Y.Plugin.NodeFocusManager, {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots descendants: sDescendantSelector,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots keys: sKeysVal,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots circular: true
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots });
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oFocusManager = oRootMenu.focusManager;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots sQuery = "#" + oRootMenu.get("id") + " .yui-menu a," +
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots MENU_TOGGLE_SELECTOR;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oRootMenu.queryAll(sQuery).set("tabIndex", -1);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots oFocusManager.on(ACTIVE_DESCENDANT_CHANGE,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots this._onActiveDescendantChange, oFocusManager, this);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
186030b6cf32f403c5bbd9c51366d2170473b0d2Todd Kloots oFocusManager.after(ACTIVE_DESCENDANT_CHANGE,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots this._afterActiveDescendantChange, oFocusManager, this);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._focusManager = oFocusManager;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots else {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oFocusManager.set(ACTIVE_DESCENDANT, -1);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oFocusManager.set(DESCENDANTS, sDescendantSelector);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oFocusManager.set("keys", sKeysVal);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots },
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots // Event handlers for discrete pieces of pieces of the menu
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots /**
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @method _onActiveDescendantChange
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @description "activeDescendantChange" event handler for menu's
269127229912bbc887ad01187105dcbd16133144Todd Kloots * Focus Manager.
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @protected
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @param {Object} event Object representing the Attribute change event.
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @param {NodeMenuNav} menuNav Object representing the NodeMenuNav instance.
269127229912bbc887ad01187105dcbd16133144Todd Kloots */
269127229912bbc887ad01187105dcbd16133144Todd Kloots _onActiveDescendantChange: function (event, menuNav) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (event.src === UI && menuNav._activeMenu &&
269127229912bbc887ad01187105dcbd16133144Todd Kloots !menuNav._movingToSubmenu) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._hideAllSubmenus(menuNav._activeMenu);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots },
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots /**
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @method _afterActiveDescendantChange
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @description "activeDescendantChange" event handler for menu's
269127229912bbc887ad01187105dcbd16133144Todd Kloots * Focus Manager.
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @protected
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @param {Object} event Object representing the Attribute change event.
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @param {NodeMenuNav} menuNav Object representing the NodeMenuNav instance.
269127229912bbc887ad01187105dcbd16133144Todd Kloots */
269127229912bbc887ad01187105dcbd16133144Todd Kloots _afterActiveDescendantChange: function (event, menuNav) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots var oItem;
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (event.src === UI) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots oItem = getItem(this.get(DESCENDANTS).item(event.newVal), true);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(oItem);
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots },
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots /**
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @method _onDocFocus
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @description "focus" event handler for the owner document of the MenuNav.
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @protected
269127229912bbc887ad01187105dcbd16133144Todd Kloots * @param {Object} event Object representing the DOM event.
269127229912bbc887ad01187105dcbd16133144Todd Kloots */
269127229912bbc887ad01187105dcbd16133144Todd Kloots _onDocFocus: function (event) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots var menuNav = this,
269127229912bbc887ad01187105dcbd16133144Todd Kloots oActiveItem = menuNav._activeItem,
269127229912bbc887ad01187105dcbd16133144Todd Kloots oTarget = event.target,
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenu;
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (menuNav._rootMenu.contains(oTarget)) { // The menu has focus
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (menuNav._hasFocus) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenu = getParentMenu(oTarget);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots // If the element that was focused is a descendant of the
269127229912bbc887ad01187105dcbd16133144Todd Kloots // root menu, but is in a submenu not currently being
269127229912bbc887ad01187105dcbd16133144Todd Kloots // managed by the Focus Manager, update the Focus Manager so
269127229912bbc887ad01187105dcbd16133144Todd Kloots // that it is now managing the submenu that is the parent of
269127229912bbc887ad01187105dcbd16133144Todd Kloots // the element that was focused.
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (!menuNav._activeMenu.compareTo(oMenu)) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._activeMenu = oMenu;
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._initFocusManager();
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._focusManager.set(ACTIVE_DESCENDANT, oTarget);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(getItem(oTarget, true));
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots else { // Initial focus
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots // First time the menu has been focused, need to setup focused
269127229912bbc887ad01187105dcbd16133144Todd Kloots // state and established active active descendant
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._hasFocus = true;
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oActiveItem = getItem(oTarget, true);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (oActiveItem) {
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(oActiveItem);
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots else { // The menu has lost focus
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._clearActiveItem();
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._cancelShowSubmenuTimer();
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._hideAllSubmenus(menuNav._rootMenu);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._activeMenu = menuNav._rootMenu;
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._initFocusManager();
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._focusManager.set(ACTIVE_DESCENDANT, 0);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._hasFocus = false;
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots },
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMenuMouseOver
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseover" event handler for a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _onMenuMouseOver: function (menu, event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oHideAllSubmenusTimer = menuNav._hideAllSubmenusTimer;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oHideAllSubmenusTimer) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oHideAllSubmenusTimer.cancel();
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._hideAllSubmenusTimer = null;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._cancelHideSubmenuTimer();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // Need to update the FocusManager in advance of focus a new
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // Menu in order to avoid the FocusManager thinking that
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // it has lost focus
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
100123034ebc324a45f96de8e6a04aa74f41694bTodd Kloots if (menu && !menu.compareTo(menuNav._activeMenu)) {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._activeMenu = menu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots if (menuNav._hasFocus) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._initFocusManager();
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots }
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (menuNav._movingToSubmenu && isHorizontalMenu(menu)) {
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._movingToSubmenu = false;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots /**
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @method _hideAndFocusLabel
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description Hides all of the submenus of the root menu and focuses the
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * label of the topmost submenu
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @protected
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots */
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots _hideAndFocusLabel: function () {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots var menuNav = this,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oActiveMenu = menuNav._activeMenu,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oSubmenu;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._hideAllSubmenus(menuNav._rootMenu);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (oActiveMenu) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // Focus the label element for the topmost submenu
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oSubmenu = menuNav._getTopmostSubmenu(oActiveMenu);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._focusItem(oSubmenu.previous());
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots },
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMenuMouseOut
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseout" event handler for a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMenuMouseOut: function (menu, event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveMenu = menuNav._activeMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRelatedTarget = event.relatedTarget,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveItem = menuNav._activeItem,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oActiveMenu && !oActiveMenu.contains(oRelatedTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu = getParentMenu(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oParentMenu && !oParentMenu.contains(oRelatedTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (menuNav.get(MOUSEOUT_HIDE_DELAY) > 0) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._cancelShowSubmenuTimer();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenusTimer =
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots later(menuNav.get(MOUSEOUT_HIDE_DELAY),
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav, menuNav._hideAndFocusLabel);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oActiveItem) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu = getParentMenu(oActiveItem);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!menuNav._isRoot(oMenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._focusItem(oMenu.previous());
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMenuLabelMouseOver
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseover" event handler for a menu label.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menuLabel Node instance representing a menu label.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMenuLabelMouseOver: function (menuLabel, event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveMenu = menuNav._activeMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bIsRoot = menuNav._isRoot(oActiveMenu),
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots bUseAutoSubmenuDisplay =
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots (menuNav.get(AUTO_SUBMENU_DISPLAY) && bIsRoot || !bIsRoot),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._focusItem(menuLabel);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(menuLabel);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (bUseAutoSubmenuDisplay && !menuNav._movingToSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._cancelHideSubmenuTimer();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._cancelShowSubmenuTimer();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (!hasVisibleSubmenu(menuLabel)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = menuLabel.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenus(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showSubmenuTimer =
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots later(menuNav.get("submenuShowDelay"), menuNav,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._showMenu, oSubmenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMenuLabelMouseOut
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseout" event handler for a menu label.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menuLabel Node instance representing a menu label.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMenuLabelMouseOut: function (menuLabel, event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bIsRoot = menuNav._isRoot(menuNav._activeMenu),
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots bUseAutoSubmenuDisplay =
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots (menuNav.get(AUTO_SUBMENU_DISPLAY) && bIsRoot || !bIsRoot),
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRelatedTarget = event.relatedTarget,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = menuLabel.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._clearActiveItem();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (bUseAutoSubmenuDisplay) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (menuNav._movingToSubmenu &&
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots !menuNav._showSubmenuTimer && oSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // If the mouse is moving diagonally toward the submenu and
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // another submenu isn't in the process of being displayed
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // (via a timer), then hide the submenu via a timer to give
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // the user some time to reach the submenu.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._hideSubmenuTimer =
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots later(menuNav.get("submenuHideDelay"), menuNav,
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._hideMenu, oSubmenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else if (!menuNav._movingToSubmenu && oSubmenu &&
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots !oSubmenu.contains(oRelatedTarget) &&
100123034ebc324a45f96de8e6a04aa74f41694bTodd Kloots !oRelatedTarget.compareTo(oSubmenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // If the mouse is not moving toward the submenu, cancel any
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // submenus that might be in the process of being displayed
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // (via a timer) and hide this submenu immediately.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._cancelShowSubmenuTimer();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideMenu(oSubmenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMenuItemMouseOver
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseover" event handler for a menuitem.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menuItem Node instance representing a menuitem.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMenuItemMouseOver: function (menuItem, event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveMenu = menuNav._activeMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bIsRoot = menuNav._isRoot(oActiveMenu),
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots bUseAutoSubmenuDisplay =
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots (menuNav.get(AUTO_SUBMENU_DISPLAY) && bIsRoot || !bIsRoot);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._focusItem(menuItem);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(menuItem);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (bUseAutoSubmenuDisplay && !menuNav._movingToSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenus(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMenuItemMouseOut
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseout" event handler for a menuitem.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menuItem Node instance representing a menuitem.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMenuItemMouseOut: function (menuItem, event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots this._clearActiveItem();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onVerticalMenuKeyDown
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description "keydown" event handler for vertical menus.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onVerticalMenuKeyDown: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveMenu = menuNav._activeMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRootMenu = menuNav._rootMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget = event.target,
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots bPreventDefault = false,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots nKeyCode = event.keyCode,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oLI,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots switch (nKeyCode) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 37: // left arrow
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu = getParentMenu(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oParentMenu && isHorizontalMenu(oParentMenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideMenu(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oLI = getPreviousSibling(oActiveMenu.get(PARENT_NODE));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = getItem(oLI);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oItem) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (isMenuLabel(oItem)) { // Menu label
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = oItem.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oSubmenu) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showMenu(oSubmenu);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(getFirstItem(oSubmenu));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(oItem);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._setActiveItem(oItem);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else { // MenuItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else if (!menuNav._isRoot(oActiveMenu)) {
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._hideMenu(oActiveMenu, true);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots bPreventDefault = true;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots break;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 39: // right arrow
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (isMenuLabel(oTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = oTarget.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oSubmenu) {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showMenu(oSubmenu);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(getFirstItem(oSubmenu));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else if (isHorizontalMenu(oRootMenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = menuNav._getTopmostSubmenu(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oLI = getNextSibling(oSubmenu.get(PARENT_NODE));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = getItem(oLI);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenus(oRootMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oItem) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (isMenuLabel(oItem)) { // Menu label
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = oItem.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oSubmenu) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showMenu(oSubmenu);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(getFirstItem(oSubmenu));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
269127229912bbc887ad01187105dcbd16133144Todd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(oItem);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(oItem);
269127229912bbc887ad01187105dcbd16133144Todd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else { // MenuItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots bPreventDefault = true;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots break;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (bPreventDefault) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Prevent the browser from scrolling the window
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots event.preventDefault();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onHorizontalMenuKeyDown
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description "keydown" event handler for horizontal menus.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onHorizontalMenuKeyDown: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveMenu = menuNav._activeMenu,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oTarget = event.target,
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oFocusedItem = getItem(oTarget, true),
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots bPreventDefault = false,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots nKeyCode = event.keyCode,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots if (nKeyCode === 40) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._hideAllSubmenus(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots if (isMenuLabel(oFocusedItem)) {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots oSubmenu = oFocusedItem.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots if (oSubmenu) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._showMenu(oSubmenu);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(getFirstItem(oSubmenu));
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots bPreventDefault = true;
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (bPreventDefault) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Prevent the browser from scrolling the window
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots event.preventDefault();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Generic DOM Event handlers
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMouseMove
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description "mousemove" event handler for the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMouseMove: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var menuNav = this;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // Using a timer to set the value of the "_currentMouseX" property
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // helps improve the reliability of the calculation used to set the
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots // value of the "_movingToSubmenu" property - especially in Opera.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots later(10, menuNav, function () {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._currentMouseX = event.pageX;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots });
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMouseOver
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description "mouseover" event handler for the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMouseOver: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuLabel,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (menuNav._blockMouseEvent) {
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._blockMouseEvent = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget = event.target;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenu = getMenu(oTarget, true);
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuLabel = getMenuLabel(oTarget, true);
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuItem = getMenuItem(oTarget, true);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (handleMouseOverForNode(oMenu, oTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onMenuMouseOver(oMenu, event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenu[HANDLED_MOUSEOVER] = true;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenu[HANDLED_MOUSEOUT] = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu = getParentMenu(oMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oParentMenu) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oParentMenu[HANDLED_MOUSEOUT] = true;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oParentMenu[HANDLED_MOUSEOVER] = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (handleMouseOverForNode(oMenuLabel, oTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onMenuLabelMouseOver(oMenuLabel, event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuLabel[HANDLED_MOUSEOVER] = true;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuLabel[HANDLED_MOUSEOUT] = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (handleMouseOverForNode(oMenuItem, oTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onMenuItemMouseOver(oMenuItem, event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuItem[HANDLED_MOUSEOVER] = true;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuItem[HANDLED_MOUSEOUT] = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMouseOut
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description "mouseout" event handler for the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onMouseOut: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveMenu = menuNav._activeMenu,
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots bMovingToSubmenu = false,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRelatedTarget,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuLabel,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots menuNav._movingToSubmenu =
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots (oActiveMenu && !isHorizontalMenu(oActiveMenu) &&
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots ((event.pageX - 5) > menuNav._currentMouseX));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget = event.target;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRelatedTarget = event.relatedTarget;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenu = getMenu(oTarget, true);
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuLabel = getMenuLabel(oTarget, true);
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuItem = getMenuItem(oTarget, true);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (handleMouseOutForNode(oMenuLabel, oRelatedTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onMenuLabelMouseOut(oMenuLabel, event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuLabel[HANDLED_MOUSEOUT] = true;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuLabel[HANDLED_MOUSEOVER] = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (handleMouseOutForNode(oMenuItem, oRelatedTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onMenuItemMouseOut(oMenuItem, event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuItem[HANDLED_MOUSEOUT] = true;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuItem[HANDLED_MOUSEOVER] = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oMenuLabel) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = oMenuLabel.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (oSubmenu &&
100123034ebc324a45f96de8e6a04aa74f41694bTodd Kloots (oRelatedTarget.compareTo(oSubmenu) ||
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots oSubmenu.contains(oRelatedTarget))) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots bMovingToSubmenu = true;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (handleMouseOutForNode(oMenu, oRelatedTarget) || bMovingToSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onMenuMouseOut(oMenu, event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenu[HANDLED_MOUSEOUT] = true;
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenu[HANDLED_MOUSEOVER] = false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _toggleSubmenuDisplay
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots * @description "mousedown," "keydown," and "click" event handler for the
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * menu used to toggle the display of a submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _toggleSubmenuDisplay: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget = event.target,
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots oMenuLabel = getMenuLabel(oTarget, true),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots sType = event.type,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oAnchor,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots sHref,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots nHashPos,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots nLen,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots sId;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oMenuLabel) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oAnchor = isAnchor(oTarget) ? oTarget : oTarget.ancestor(isAnchor);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oAnchor) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // Need to pass "2" as a second argument to "getAttribute" for
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // IE otherwise IE will return a fully qualified URL for the
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // value of the "href" attribute.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots sHref = oAnchor.getAttribute("href", 2);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots nHashPos = sHref.indexOf("#");
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots nLen = sHref.length;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (nHashPos === 0 && nLen > 1) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots sId = sHref.substr(1, nLen);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = oMenuLabel.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oSubmenu && (oSubmenu.get(ID) === sId)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots if (sType === MOUSEDOWN ||
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots (sType === KEYDOWN && event.keyCode === 13)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // Prevent the target from getting focused by
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // default, since the element to be focused will
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // be determined by weather or not the submenu
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // is visible.
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots event.preventDefault();
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // For Webkit--By default FocusManager will try
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // to focus one of its descendants onMouseDown
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // since Webkit doesn't do that by default. Since
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // we want to explicitly control where focus is
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // going, we need to call
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // "stopImmediatePropagation" to stop the
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // FocusManager from doing its thing.
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots if (Y.UA.webkit) {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots event.stopImmediatePropagation();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // The "_focusItem" method relies on the
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // "_hasFocus" property being set to true. The
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // "_hasFocus" property is normally set via a
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // "focus" event listener, but since we've
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // blocked focus from happening, we need to set
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // this property manually.
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._hasFocus = true;
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (hasVisibleSubmenu(oMenuLabel)) {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideMenu(oSubmenu);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(oMenuLabel);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(oMenuLabel);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenus(menuNav._rootMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showMenu(oSubmenu);
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusItem(getFirstItem(oSubmenu));
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (sType === CLICK) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // Prevent the browser from following the URL of
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots // the anchor element
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots event.preventDefault();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onKeyPress
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description "keypress" event handler for the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onKeyPress: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots switch (event.keyCode) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 37: // left arrow
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 38: // up arrow
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 39: // right arrow
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 40: // down arrow
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Prevent the browser from scrolling the window
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots event.preventDefault();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots break;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onKeyDown
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * @description "keydown" event handler for the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onKeyDown: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveItem = menuNav._activeItem,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oTarget = event.target,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oActiveMenu = getParentMenu(oTarget),
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oSubmenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oActiveMenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._activeMenu = oActiveMenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (isHorizontalMenu(oActiveMenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onHorizontalMenuKeyDown(event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._onVerticalMenuKeyDown(event);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (event.keyCode === 27) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!menuNav._isRoot(oActiveMenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._hideMenu(oActiveMenu, true);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots event.stopPropagation();
ac91eab7de6e2070ada47e7e1e78f1e3051f49abTodd Kloots menuNav._blockMouseEvent = UA.gecko ? true : false;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else if (oActiveItem) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots if (isMenuLabel(oActiveItem) &&
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots hasVisibleSubmenu(oActiveItem)) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oSubmenu = oActiveItem.next();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oSubmenu) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._hideMenu(oSubmenu);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots menuNav._focusManager.blur();
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots // This is necessary for Webkit since blurring the
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots // active menuitem won't result in the document
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots // gaining focus, meaning the that _onDocFocus
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots // listener won't clear the active menuitem.
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots menuNav._clearActiveItem();
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots menuNav._hasFocus = false;
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onDocMouseDown
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots * @description "mousedown" event handler for the owner document of
870e762dff448c62395c1fc5ac36d3235fc486b4Todd Kloots * the menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onDocMouseDown: function (event) {
db1eebead76852e1e0c240caa8fc75402fbe2a0bTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRoot = menuNav._rootMenu,
269127229912bbc887ad01187105dcbd16133144Todd Kloots oTarget = event.target,
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenu;
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (oRoot.compareTo(oTarget) || oRoot.contains(oTarget)) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots oMenu = getParentMenu(oTarget);
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots // If the user mouses down on an element that is a descendant
269127229912bbc887ad01187105dcbd16133144Todd Kloots // of the root menu, but is in a submenu not currently being
269127229912bbc887ad01187105dcbd16133144Todd Kloots // managed by the Focus Manager, update the Focus Manager so
269127229912bbc887ad01187105dcbd16133144Todd Kloots // that it is now managing the submenu that is the parent of the
269127229912bbc887ad01187105dcbd16133144Todd Kloots // element that was the target of the mousedown event.
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots if (!menuNav._activeMenu.compareTo(oMenu)) {
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._activeMenu = oMenu;
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._initFocusManager();
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._focusManager.set(ACTIVE_DESCENDANT, oTarget);
269127229912bbc887ad01187105dcbd16133144Todd Kloots menuNav._setActiveItem(getItem(oTarget, true));
269127229912bbc887ad01187105dcbd16133144Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots }
269127229912bbc887ad01187105dcbd16133144Todd Kloots else {
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots menuNav._hideAllSubmenus(oRoot);
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots // Document doesn't receive focus in Webkit when the user mouses
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots // down on it, so the "_hasFocus" property won't get set to the
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots // correct value. The following line corrects the problem.
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots if (UA.webkit) {
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots menuNav._hasFocus = false;
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots menuNav._clearActiveItem();
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots }
ade849f50753ff5bb0f15dceb5557f4346e9057aTodd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
269127229912bbc887ad01187105dcbd16133144Todd Kloots }
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots});
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd KlootsY.namespace('Plugin');
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd KlootsY.Plugin.NodeMenuNav = NodeMenuNav;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
dcc27ab1cda56d7ad286e36c57f451db77894301Todd Kloots}, '@VERSION@' ,{requires:['node', 'classnamemanager', 'node-focusmanager']});