node-menunav-debug.js revision ce06fcd5562d725b60692d44fd9deef967a3276c
5f40f927dba3cf399373572f6ed6fe59a376376eTodd KlootsYUI.add('node-menunav', function(Y) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots/**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <p>The MenuNav Node Plugin makes it easy to transform existing list-based markup into traditional,
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots* drop down navigational menus that are both accessible and easy to customize, and only require
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* a small set of dependencies.</p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <p>To use the MenuNav Node Plugin, simply pass a reference to the plugin to a Node instance's
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <code>plug</code> method.</p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots* <p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <code>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* var oMenuNav = Y.Node.get("#productsandservices");<br>
fab450bda25d83fc914a6413dcd83d3c9919282dTodd Kloots* oMenuNav.plug(Y.plugin.NodeMenuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* </code>
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots* <p>
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots*
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <p>The MenuNav Node Plugin has several configuration properties that can be set via an
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* object literal that is passed as a second argument to a Node instance's <code>plug</code> method.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* </p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots* <p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <code>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* var oMenuNav = Y.Node.get("#productsandservices");<br>
fab450bda25d83fc914a6413dcd83d3c9919282dTodd Kloots* oMenuNav.plug(Y.plugin.NodeMenuNav, { mouseOutHideDelay: 1000 });
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* </code>
14b1e9d6653e5b6ec6b2fbd4e30faaf3a74b6cf7Todd Kloots* </p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
5704a55c960a1cb578bb2a13dc757d31b8b45a11Todd Kloots* <p> The complete list of the MenuNav Node Plugin configuration properties are:</p>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dl>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dt>useARIA</dt>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dd>Boolean indicating if use of the WAI-ARIA Roles and States should be enabled for the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* MenuNav. Set to true by default for Firefox 3 and Internet Explorer 8 as currently only
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* these browsers have support for ARIA, and are supported by several screen readers for
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* Windows that also offer support for ARIA.</dd>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dt>autoSubmenuDisplay</dt>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dd>Boolean indicating if submenus are automatically made visible when the user mouses over
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* the menu's items. Set to true by default.</dd>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dt>submenuShowDelay</dt>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dd>Number indicating the time (in milliseconds) that should expire before a submenu is
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* made visible when the user mouses over the menu's label. Set to 250 by default.</dd>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dt>submenuHideDelay</dt>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dd>Number indicating the time (in milliseconds) that should expire before a submenu is
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* hidden when the user mouses out of a menu label heading in the direction of a submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* Set to 250 by default.</dd>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dt>mouseOutHideDelay</dt>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* <dd>Number indicating the time (in milliseconds) that should expire before a submenu is
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* hidden when the user mouses out of it. Set to 750 by default.</dd>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* </dl>
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots* @module node-menunav
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*/
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Util shortcuts
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar UA = Y.UA,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots Lang = Y.Lang,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots later = Y.later,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots getClassName = Y.ClassNameManager.getClassName,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Native types
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots TRUE = true,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots FALSE = false,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots NULL = null,
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 TAB_INDEX = "tabIndex",
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",
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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots MENU_SELECTOR = PERIOD + CSS_MENU;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots// Utility functions
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots// TO DO: Remove once Node implements circular functionality
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar getPreviousSibling = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var oPrevious = node.previous(),
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oParentNode,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oULs,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oUL;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!oPrevious) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oParentNode = node.get(PARENT_NODE);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oULs = oParentNode.get(PARENT_NODE).get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oULs.size() > 1) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oUL = oParentNode.previous();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oUL) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren = oUL.get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren = oULs.item(oULs.size() - 1).get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren = oParentNode.get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oPrevious = oChildren.item(oChildren.size() - 1);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return oPrevious;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots// TO DO: Remove once Node implements circular functionality
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar getNextSibling = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var oNext = node.next(),
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oParentNode,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oULs,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oUL;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!oNext) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oParentNode = node.get(PARENT_NODE);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oULs = oParentNode.get(PARENT_NODE).get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oULs.size() > 1) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oUL = oParentNode.next();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oUL) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren = oUL.get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren = oULs.item(0).get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oChildren = node.get(PARENT_NODE).get(CHILDREN);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oNext = oChildren.item(0);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots return oNext;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar setARIARole = function (node, role) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots node.setAttribute("role", role);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar setARIAProperty = function (node, property, value) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots node.setAttribute(("aria-" + property), value);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar setARIAPresentation = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots setARIARole(node, "presentation");
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar removeFromTabIndex = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots node.set(TAB_INDEX, -1);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar placeInDefaultTabIndex = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots node.set(TAB_INDEX, 0);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar isAnchor = function (node) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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 {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = getNodeWithClass(node, CSS_MENU_LABEL) || 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) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = getMenuItem(node, searchAncestors) || getMenuLabel(node, searchAncestors);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return oItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getNextItem = function (item, previous) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots var oItemLI,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextLI,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (item) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItemLI = isMenuItem(item) ? item : item.get(PARENT_NODE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextLI = previous ? getPreviousSibling(oItemLI) : getNextSibling(oItemLI);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextItem = getItem(oNextLI);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return oNextItem;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar getPreviousItem = function (item) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return getNextItem(item, true);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd 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 blurItem = function (item) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots var oAnchor;
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (item) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oAnchor = getItemAnchor(item);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots // TO DO: Remove once implemented in Node
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots try {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oAnchor.blur();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots catch (ex) { }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar focusItem = function (item) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots var oAnchor;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (item) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oAnchor = getItemAnchor(item);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots // TO DO: Remove once implemented in Node
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots try {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oAnchor.focus();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots catch (ex) { }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots};
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Klootsvar handleMouseOverForNode = function (node, target) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots return node && !node[HANDLED_MOUSEOVER] && (node === 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] &&
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots (node !== relatedTarget && !node.contains(relatedTarget));
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots};
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
d52939b26ae6dd79b98efda6161c0d3a94f574d7Todd Kloots/**
fab450bda25d83fc914a6413dcd83d3c9919282dTodd Kloots* @namespace Y.plugin
a76888f75bfe3b3fecae528bbe6053e7c1ab353bTodd Kloots* @class NodeMenuNav
a76888f75bfe3b3fecae528bbe6053e7c1ab353bTodd Kloots*/
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Klootsvar MenuNav = function (config) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRootMenu = config.owner,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oDocument,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bUseARIA,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bAutoSubmenuDisplay,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots nMouseOutHideDelay,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oMenuNodes,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oFirstItem,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oULs;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oRootMenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bUseARIA = config.useARIA;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bAutoSubmenuDisplay = config.autoSubmenuDisplay;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots nMouseOutHideDelay = config.mouseOutHideDelay;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Enable ARIA for Firefox 3 and IE 8 by default since those are the two browsers
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // that current support ARIA
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._useARIA = Lang.isBoolean(bUseARIA) ?
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bUseARIA : ((UA.gecko && UA.gecko >= 1.9) || (UA.ie && UA.ie >= 8));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._autoSubmenuDisplay =
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots Lang.isBoolean(bAutoSubmenuDisplay) ? bAutoSubmenuDisplay : TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._submenuShowDelay = config.submenuShowDelay || 250;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._submenuHideDelay = config.submenuHideDelay || 250;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._mouseOutHideDelay = Lang.isNumber(nMouseOutHideDelay) ? nMouseOutHideDelay : 750;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Hide all visible submenus
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oMenuNodes = oRootMenu.queryAll(MENU_SELECTOR);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oMenuNodes) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oMenuNodes.addClass(CSS_MENU_HIDDEN);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oULs = oRootMenu.queryAll("ul:" + FIRST_OF_TYPE);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oULs) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oULs.addClass(FIRST_OF_TYPE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Wire up all event handlers
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on("mouseover", menuNav._onMouseOver, menuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on("mouseout", menuNav._onMouseOut, menuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on("mousemove", menuNav._onMouseMove, menuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on(MOUSEDOWN, menuNav._toggleSubmenuDisplay, menuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on(KEYDOWN, menuNav._toggleSubmenuDisplay, menuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on(CLICK, menuNav._toggleSubmenuDisplay, menuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on("keypress", menuNav._onKeyPress, menuNav);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oRootMenu.on(KEYDOWN, menuNav._onKeyDown, menuNav);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oDocument = oRootMenu.get("ownerDocument");
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oDocument.on(MOUSEDOWN, menuNav._onDocMouseDown, menuNav);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
a76888f75bfe3b3fecae528bbe6053e7c1ab353bTodd Kloots Y.on("focus", Y.bind(menuNav._onDocFocus, menuNav), oDocument);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._rootMenu = oRootMenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (menuNav._useARIA) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._applyARIA(oRootMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oFirstItem = getFirstItem(oRootMenu);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oFirstItem) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots placeInDefaultTabIndex(getItemAnchor(oFirstItem));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._firstItem = oFirstItem;
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd KlootsMenuNav.NS = "MenuNav";
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots/**
979600728148238bdf1eee52b1457d1d180c126eTodd Kloots* @property NodeMenuNav.SHIM_TEMPLATE_TITLE
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots* @description String representing the value for the <code>title</code> attribute for the shim used
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots* to prevent <code>&#60;select&#62;</code> elements from poking through menus in IE 6.
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots* @default "Menu Stacking Shim"
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots* @type String
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots*/
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd KlootsMenuNav.SHIM_TEMPLATE_TITLE = "Menu Stacking Shim";
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots/**
979600728148238bdf1eee52b1457d1d180c126eTodd Kloots* @property NodeMenuNav.SHIM_TEMPLATE
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @description String representing the HTML used to create the <code>&#60;iframe&#62;</code> shim
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots* used to prevent <code>&#60;select&#62;</code> elements from poking through menus in IE 6.
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots* @default &#34;&#60;iframe frameborder=&#34;0&#34; tabindex=&#34;-1&#34;
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots* class=&#34;yui-shim&#34; title=&#34;Menu Stacking Shim&#34;
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots* src=&#34;javascript:false;&#34;&#62;&#60;/iframe&#62;&#34;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots* @type String
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots*/
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// <iframe> shim notes:
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots//
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// 1) Need to set the "frameBorder" property to 0 to suppress the default <iframe> border in IE.
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// (Setting the CSS "border" property alone doesn't suppress it.)
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots//
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// 2) The "src" attribute of the <iframe> is set to "javascript:false;" so that it won't load a
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// page inside it, preventing the secure/nonsecure warning in IE when using HTTPS.
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots//
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// 3) Since the role of the <iframe> shim is completely presentational, its "tabindex" attribute
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// is set to "-1" and its title attribute is set to "Menu Stacking Shim". Both strategies help
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots// users of screen readers to avoid mistakenly interacting with the <iframe> shim.
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd Kloots
8a4137ab24ac4a19400c698a65cf8ca511b081c5Todd KlootsMenuNav.SHIM_TEMPLATE = '<iframe frameborder="0" tabindex="-1" class="' +
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots getClassName("shim") +
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots '" title="' + MenuNav.SHIM_TEMPLATE_TITLE +
a82da1da5f01d59992c338f04dcbc9dd34002d63Todd Kloots '" src="javascript:false;"></iframe>';
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd KlootsMenuNav.prototype = {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Protected properties
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _rootMenu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Node instance representing the root menu in the MenuNav.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _rootMenu: NULL,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _activeItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Node instance representing the MenuNav's active descendent - the menuitem or
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * menu label the user is currently interacting with.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _activeItem: NULL,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _activeMenu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Node instance representing the menu that is the parent of the MenuNav's
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * active descendent.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _activeMenu: NULL,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _hasFocus
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Boolean indicating if the MenuNav has focus.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default false
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Boolean
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _hasFocus: FALSE,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // In gecko-based browsers a mouseover and mouseout event will fire even
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // if a DOM element moves out from under the mouse without the user actually
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // moving the mouse. This bug affects MenuNav because the user can hit the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Esc key to hide a menu, and if the mouse is over the menu when the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // user presses Esc, the _onMenuMouseOut handler will be called. To fix this
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // bug the following flag (_blockMouseEvent) is used to block the code in the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // _onMenuMouseOut handler from executing.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _blockMouseEvent
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Boolean indicating whether or not to handle the "mouseover" event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default false
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Boolean
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _blockMouseEvent: FALSE,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _currentMouseX
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Number representing the current x coordinate of the mouse inside the MenuNav.
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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Boolean indicating if the mouse is moving from a menu label to its
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * corresponding submenu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default false
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Boolean
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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 */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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 */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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 */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _hideAllSubmenusTimer: NULL,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _firstItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Node instance representing the first item (menuitem or menu label) in the root
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * menu of a MenuNav.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default null
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Node
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots _firstItem: NULL,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @property _autoSubmenuDisplay
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Boolean indicating if submenus are automatically made visible when the user
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * mouses over the menu's items.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @default true
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @type Boolean
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _autoSubmenuDisplay: TRUE,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Protected methods
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _isRoot
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Returns a boolean indicating if the specified menu is the root menu in
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * the MenuNav.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Node} menu Node instance representing a menu.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @return {Boolean} Boolean indicating if the specified menu is the root menu in the MenuNav.
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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Clears the MenuNav'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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveItem.removeClass(getActiveClass(oActiveItem));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (menuNav._useARIA) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots removeFromTabIndex(getItemAnchor(oActiveItem));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._activeItem = NULL;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _setActiveItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description Sets the specified menuitem or menu label as the MenuNav's 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 if (menuNav._useARIA) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots placeInDefaultTabIndex(getItemAnchor(item));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
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
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (item && this._hasFocus) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Need to focus using a zero-second timeout to get Apple's VoiceOver to
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // recognize that the focused item has changed
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots later(0, null, focusItem, item);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots /**
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots * @method _applyARIA
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots * @description Applies the ARIA Roles, States and Properties to the supplied menu.
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots * @protected
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots * @param {Node} menu Node instance representing a menu.
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots */
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots _applyARIA: function (menu) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots var menuNav = this,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots bIsRoot = menuNav._isRoot(menu),
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabel,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuToggle,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oListNodes,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuItemContentNodes,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabelNodes,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oSubmenu,
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots sID;
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIARole(menu, (bIsRoot ? "menubar" : MENU));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (!bIsRoot) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabel = menu.previous();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuToggle = oMenuLabel.query(PERIOD + getClassName(MENU, "toggle"));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oMenuToggle) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabel = oMenuToggle;
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots sID = oMenuLabel.get(ID);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (!sID) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots sID = Y.guid();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabel.set(ID, sID);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIAProperty(menu, "labelledby", sID);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIAProperty(menu, HIDDEN, TRUE);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oListNodes = menu.queryAll("ul,li");
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oListNodes) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oListNodes.each(function (node) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIAPresentation(node);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots });
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuItemContentNodes = menu.queryAll((PERIOD + getClassName(MENUITEM, "content")));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oMenuItemContentNodes) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuItemContentNodes.each(function (node) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots removeFromTabIndex(node);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIARole(node, MENUITEM);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots });
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabelNodes = menu.queryAll((PERIOD + CSS_MENU_LABEL));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oMenuLabelNodes) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabelNodes.each(function (node) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabel = node;
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuToggle = node.query((PERIOD + getClassName(MENU, "toggle")));
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oMenuToggle) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIAPresentation(oMenuToggle);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots removeFromTabIndex(oMenuToggle);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oMenuLabel = oMenuToggle.previous();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIARole(oMenuLabel, MENUITEM);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIAProperty(oMenuLabel, "haspopup", TRUE);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots removeFromTabIndex(oMenuLabel);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots oSubmenu = node.next();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (oSubmenu) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._applyARIA(oSubmenu);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots });
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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu = getParentMenu(menu),
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oLI = menu.get(PARENT_NODE),
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots aXY = oLI.getXY(),
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (menuNav._useARIA) {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots setARIAProperty(menu, HIDDEN, FALSE);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menu.appendChild(Y.Node.create(MenuNav.SHIM_TEMPLATE));
fab450bda25d83fc914a6413dcd83d3c9919282dTodd 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Set the width and height of the menu's bounding box - this is necessary for IE 6
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // so that the CSS for the <iframe> shim can simply set the <iframe>'s width and height
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // to 100% to ensure that dimensions of an <iframe> shim are always sync'd to the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // that of its parent menu. Specifying a width and height also helps when positioning
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // decorator elements (for creating effects like rounded corners) inside a menu's
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oItem = getFirstItem(menu);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._focusItem(oItem);
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.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Boolean} activateAndFocusLabel Boolean indicating if the label 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._setActiveItem(oLabel);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._focusItem(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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Clear the values for top and left that were set by the call to "setXY" when the menu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // was shown so that the hidden position 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);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots setARIAProperty(menu, HIDDEN, TRUE);
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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenus = menu.queryAll(MENU_SELECTOR);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oSubmenus) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oSubmenus.each(Y.bind(function (submenuNode) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hideMenu(submenuNode);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }, menuNav));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
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();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideSubmenuTimer = NULL;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Event handlers for discrete pieces of pieces of the menu
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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();
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hideAllSubmenusTimer = NULL;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._cancelHideSubmenuTimer();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._activeMenu = menu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (menuNav._movingToSubmenu && isHorizontalMenu(menu)) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._movingToSubmenu = FALSE;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (menuNav._mouseOutHideDelay > 0) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._cancelShowSubmenuTimer();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenusTimer =
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots later(menuNav._mouseOutHideDelay, menuNav, function () {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var oSubmenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveMenu = menuNav._activeMenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenus(menuNav._rootMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oActiveMenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Focus the label element for the topmost submenu
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = menuNav._getTopmostSubmenu(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._focusItem(oSubmenu.previous());
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots });
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),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bUseAutoSubmenuDisplay = (menuNav._autoSubmenuDisplay && bIsRoot || !bIsRoot),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(menuLabel);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._focusItem(menuLabel);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd 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 =
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots later(menuNav._submenuShowDelay, menuNav,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bUseAutoSubmenuDisplay = (menuNav._autoSubmenuDisplay && bIsRoot || !bIsRoot),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRelatedTarget = event.relatedTarget,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu = menuLabel.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._clearActiveItem();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (bUseAutoSubmenuDisplay) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (menuNav._movingToSubmenu && !menuNav._showSubmenuTimer && oSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // If the mouse is moving diagonally toward the submenu and another submenu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // isn't in the process of being displayed (via a timer), then hide the submenu
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // via a timer to give the user some time to reach the submenu.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hideSubmenuTimer = later(menuNav._submenuHideDelay, menuNav,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideMenu, oSubmenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else if (!menuNav._movingToSubmenu && oSubmenu &&
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots !oSubmenu.contains(oRelatedTarget) && oRelatedTarget !== oSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // If the mouse is not moving toward the submenu, cancel any submenus that
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // might be in the process of being displayed (via a timer) and hide this
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // 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),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bUseAutoSubmenuDisplay = (menuNav._autoSubmenuDisplay && bIsRoot || !bIsRoot);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(menuItem);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._focusItem(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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "keydown" event handler for vertical menus of a MenuNav.
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,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oFocusedItem = getItem(oTarget, TRUE),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bPreventDefault = FALSE,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots nKeyCode = event.keyCode,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oLI,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextItem,
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);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._setActiveItem(oItem);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots focusItem(oItem);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else { // MenuItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots focusItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else if (!menuNav._isRoot(oActiveMenu)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideMenu(oActiveMenu, TRUE);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showMenu(oSubmenu);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
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);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots else {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._setActiveItem(oItem);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots focusItem(oItem);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else { // MenuItem
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots focusItem(oItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bPreventDefault = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots break;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 38: // up arrow
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 40: // down arrow
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hideAllSubmenus(oActiveMenu);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextItem = nKeyCode === 38 ?
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots getPreviousItem(oFocusedItem) : getNextItem(oFocusedItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(oNextItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots focusItem(oNextItem);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "keydown" event handler for horizontal menus of a MenuNav.
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,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oFocusedItem = getItem(oTarget, TRUE),
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bPreventDefault = FALSE,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots nKeyCode = event.keyCode,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextItem,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oSubmenu;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots switch (nKeyCode) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 37: // left arrow
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 39: // right arrow
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hideAllSubmenus(oActiveMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oNextItem = nKeyCode === 37 ?
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots getPreviousItem(oFocusedItem) : getNextItem(oFocusedItem);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(oNextItem);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots focusItem(oNextItem);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bPreventDefault = TRUE;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots break;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots case 40: // down arrow
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hideAllSubmenus(oActiveMenu);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (isMenuLabel(oFocusedItem)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oSubmenu = oFocusedItem.next();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oSubmenu) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showMenu(oSubmenu);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(getFirstItem(oSubmenu));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bPreventDefault = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
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 // Generic DOM Event handlers
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onMouseMove
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mousemove" event handler for the MenuNav.
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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Using a timer to set the value of the "_currentMouseX" property helps improve the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // reliability of the calculation used to set the value of the "_movingToSubmenu"
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseover" event handler for the MenuNav.
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) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._blockMouseEvent = FALSE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget = event.target;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oMenu = getMenu(oTarget, TRUE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oMenuLabel = getMenuLabel(oTarget, TRUE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu[HANDLED_MOUSEOVER] = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu[HANDLED_MOUSEOUT] = FALSE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu = getParentMenu(oMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (oParentMenu) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oParentMenu[HANDLED_MOUSEOUT] = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuLabel[HANDLED_MOUSEOVER] = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuItem[HANDLED_MOUSEOVER] = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mouseout" event handler for the MenuNav.
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,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._movingToSubmenu = (oActiveMenu && !isHorizontalMenu(oActiveMenu) &&
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots ((event.pageX - 5) > menuNav._currentMouseX));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget = event.target;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRelatedTarget = event.relatedTarget;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oMenu = getMenu(oTarget, TRUE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oMenuLabel = getMenuLabel(oTarget, TRUE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuLabel[HANDLED_MOUSEOUT] = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenuItem[HANDLED_MOUSEOUT] = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oSubmenu && (oRelatedTarget === oSubmenu || oSubmenu.contains(oRelatedTarget))) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu[HANDLED_MOUSEOUT] = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oMenu[HANDLED_MOUSEOVER] = FALSE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _toggleSubmenuDisplay
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mousedown," "keydown," and "click" event handler for the MenuNav used to
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * 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,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // Need to pass "2" as a second argument to "getAttribute" for IE otherwise IE
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // will return a fully qualified URL for the 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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (sType === MOUSEDOWN || (sType === KEYDOWN && event.keyCode === 13)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // The call to "preventDefault" below results in the element
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // serving as the menu's label to not receive focus in Webkit,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // therefore the "_hasFocus" flag never gets set to true, meaning the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // first item in the submenu isn't focused when the submenu is
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // displayed. To fix this issue, it is necessary to set the
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // "_hasFocus" flag to true.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (UA.webkit && !menuNav._hasFocus) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hasFocus = TRUE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (hasVisibleSubmenu(oMenuLabel)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideMenu(oSubmenu);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots focusItem(oMenuLabel);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenus(menuNav._rootMenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._showMenu(oSubmenu);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (sType === CLICK) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // Prevent the browser from following the URL of 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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "keypress" event handler for the MenuNav.
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
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "keydown" event handler for the MenuNav.
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
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideMenu(oActiveMenu, TRUE);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots event.stopPropagation();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._blockMouseEvent = UA.gecko ? TRUE : FALSE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots else if (oActiveItem) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots if (isMenuLabel(oActiveItem) && 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 {
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots blurItem(oTarget);
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots menuNav._clearActiveItem();
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots
ce06fcd5562d725b60692d44fd9deef967a3276cTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onDocMouseDown
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "mousedown" event handler for the owner document of the MenuNav.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onDocMouseDown: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oRoot = menuNav._rootMenu,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oTarget = event.target;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (!oRoot.compareTo(oTarget) && !oRoot.contains(oTarget)) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hideAllSubmenus(oRoot);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots // Document doesn't receive focus in Webkit when the user mouses down on it,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // so the "_hasFocus" property won't get set to the correct value. The
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // following line corrects the problem.
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots if (UA.webkit) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots menuNav._hasFocus = FALSE;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._clearActiveItem();
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots },
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots /**
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @method _onDocFocus
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @description "focus" event handler for the owner document of the MenuNav.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @protected
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots * @param {Object} event Object representing the DOM event.
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots */
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots _onDocFocus: function (event) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots var menuNav = this,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots bUseARIA = menuNav._useARIA,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oFirstItem = menuNav._firstItem,
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots oActiveItem = menuNav._activeItem,
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oTarget = event.target;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (menuNav._rootMenu.contains(oTarget)) { // The menu has focus
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (!menuNav._hasFocus) { // Initial focus
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // First time the menu has been focused, need to setup focused state and
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots // established active active descendant
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hasFocus = TRUE;
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots oActiveItem = getItem(oTarget, TRUE);
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oActiveItem) {
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._setActiveItem(oActiveItem);
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots }
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots else { // The menu has lost focus
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._clearActiveItem();
de413b3e25c9cba63ab4b3003f5a4524d49f9f05Todd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots menuNav._hasFocus = FALSE;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots if (oFirstItem && bUseARIA) {
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
9a2430d08e4d1b8b870cd3ba6c17ffc7881d16a6Todd Kloots placeInDefaultTabIndex(getItemAnchor(oFirstItem));
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots }
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots};
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
fab450bda25d83fc914a6413dcd83d3c9919282dTodd KlootsY.namespace('plugin');
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
fab450bda25d83fc914a6413dcd83d3c9919282dTodd KlootsY.plugin.NodeMenuNav = MenuNav;
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots
5f40f927dba3cf399373572f6ed6fe59a376376eTodd Kloots}, '@VERSION@' ,{requires:['node', 'classnamemanager']});