node-menunav-debug.js revision 8a4137ab24ac4a19400c698a65cf8ca511b081c5
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <p>The MenuNav Node Plugin makes it easy to transform existing list-based markup into traditional,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* drop down navigational menus that are both accessible and easy to customize, and only require
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* a small set of dependencies.</p>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <p>To use the MenuNav Node Plugin, simply pass a reference to the plugin to a Node instance's
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <code>plug</code> method.</p>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* var oMenuNav = Y.Node.get("#productsandservices");<br>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* oMenuNav.plug(Y.Plugin.NodeMenuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <p>The MenuNav Node Plugin has several configuration properties that can be set via an
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* object literal that is passed as a second argument to a Node instance's <code>plug</code> method.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* var oMenuNav = Y.Node.get("#productsandservices");<br>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* oMenuNav.plug(Y.Plugin.NodeMenuNav, { mouseOutHideDelay: 1000 });
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <p> The complete list of the MenuNav Node Plugin configuration properties are:</p>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dt>useARIA</dt>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dd>Boolean indicating if use of the WAI-ARIA Roles and States should be enabled for the
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* MenuNav. Set to true by default for Firefox 3 and Internet Explorer 8 as currently only
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* these browsers have support for ARIA, and are supported by several screen readers for
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* Windows that also offer support for ARIA.</dd>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dt>autoSubmenuDisplay</dt>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dd>Boolean indicating if submenus are automatically made visible when the user mouses over
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* the menu's items. Set to true by default.</dd>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dt>submenuShowDelay</dt>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dd>Number indicating the time (in milliseconds) that should expire before a submenu is
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* made visible when the user mouses over the menu's label. Set to 250 by default.</dd>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dt>submenuHideDelay</dt>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dd>Number indicating the time (in milliseconds) that should expire before a submenu is
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* hidden when the user mouses out of a menu label heading in the direction of a submenu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* Set to 250 by default.</dd>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dt>mouseOutHideDelay</dt>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* <dd>Number indicating the time (in milliseconds) that should expire before a submenu is
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* hidden when the user mouses out of it. Set to 750 by default.</dd>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @module node-menunav
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Util shortcuts
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Native types
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Frequently used strings
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // CSS class names
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync CSS_MENU_HORIZONTAL = getClassName(MENU, "horizontal"),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync CSS_MENU_LABEL_ACTIVE = getClassName(MENU, LABEL, ACTIVE),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync CSS_MENU_LABEL_MENUVISIBLE = getClassName(MENU, LABEL, (MENU + "visible")),
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync CSS_MENUITEM_ACTIVE = getClassName(MENUITEM, ACTIVE),
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync // CSS selectors
64863d3a0ffadf1ac248b295b78be5d55db6ee13vboxsync// Utility functions
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// TO DO: Remove once Node implements circular functionality
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// TO DO: Remove once Node implements circular functionality
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncvar setARIAProperty = function (node, property, value) {
241adddf415cbdf66230864a215b24415f482e72vboxsync bReturnVal = node.get("nodeName").toLowerCase() === LOWERCASE_A;
241adddf415cbdf66230864a215b24415f482e72vboxsync return menuLabel.hasClass(CSS_MENU_LABEL_MENUVISIBLE);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync return isAnchor(node) ? node : node.query(LOWERCASE_A);
a8ce9568e18b8c1a49833bf3b3ac2b2cc634b13cvboxsyncvar getNodeWithClass = function (node, className, searchAncestors) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync return getNodeWithClass(node, CSS_MENU, searchAncestors);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncvar getMenuItem = function (node, searchAncestors) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oItem = getNodeWithClass(node, CSS_MENUITEM, searchAncestors);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncvar getMenuLabel = function (node, searchAncestors) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oItem = getNodeWithClass(node, CSS_MENU_LABEL, searchAncestors);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oItem = getNodeWithClass(node, CSS_MENU_LABEL) || node.query((PERIOD + CSS_MENU_LABEL));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oItem = getMenuItem(node, searchAncestors) || getMenuLabel(node, searchAncestors);
4791a729647f035b6561d292c9f848dd1fc797a9vboxsync oItemLI = isMenuItem(item) ? item : item.get(PARENT_NODE);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oNextLI = previous ? getPreviousSibling(oItemLI) : getNextSibling(oItemLI);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync return isMenuItem(node) ? CSS_MENUITEM_ACTIVE : CSS_MENU_LABEL_ACTIVE;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // TO DO: Remove once implemented in Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync catch (ex) { }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // TO DO: Remove once implemented in Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync catch (ex) { }
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncvar handleMouseOverForNode = function (node, target) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync return node && !node[HANDLED_MOUSEOVER] && (node === target || node.contains(target));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncvar handleMouseOutForNode = function (node, relatedTarget) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync (node !== relatedTarget && !node.contains(relatedTarget));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @namespace Y.Plugin
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @class NodeMenuNav
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Enable ARIA for Firefox 3 and IE 8 by default since those are the two browsers
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // that current support ARIA
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync bUseARIA : ((UA.gecko && UA.gecko >= 1.9) || (UA.ie && UA.ie >= 8));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync Lang.isBoolean(bAutoSubmenuDisplay) ? bAutoSubmenuDisplay : TRUE;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menuNav._submenuShowDelay = config.submenuShowDelay || 250;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menuNav._submenuHideDelay = config.submenuHideDelay || 250;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menuNav._mouseOutHideDelay = Lang.isNumber(nMouseOutHideDelay) ? nMouseOutHideDelay : 750;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Hide all visible submenus
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Wire up all event handlers
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on("mouseover", menuNav._onMouseOver, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on("mouseout", menuNav._onMouseOut, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on("mousemove", menuNav._onMouseMove, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on(MOUSEDOWN, menuNav._toggleSubmenuDisplay, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on(KEYDOWN, menuNav._toggleSubmenuDisplay, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on(CLICK, menuNav._toggleSubmenuDisplay, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on("keypress", menuNav._onKeyPress, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oRootMenu.on(KEYDOWN, menuNav._onKeyDown, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oDocument.on(MOUSEDOWN, menuNav._onDocMouseDown, menuNav);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync Y.on("focus", Y.bind(menuNav._onDocFocus, menuNav), oDocument);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oMenuItemContentNodes = oRootMenu.queryAll((PERIOD + getClassName(MENUITEM, "content")));
223935479ac42db56b7b7a7d16548d590022996avboxsync oMenuLabelNodes = oRootMenu.queryAll((PERIOD + CSS_MENU_LABEL));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oMenuToggle = node.query((PERIOD + getClassName(MENU, "toggle")));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @property menuNav.SHIM_TEMPLATE_TITLE
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @description String representing the value for the <code>title</code> attribute for the shim used
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* to prevent <code><select></code> elements from poking through menus in IE 6.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @default "Menu Stacking Shim"
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @type String
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @property menuNav.SHIM_TEMPLATE
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @description String representing the HTML used to create the <code><iframe></code> shim
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* used to prevent <code><select></code> elements from poking through menus in IE 6.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @default "<iframe frameborder="0" tabindex="-1"
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* class="yui-shim" title="Menu Stacking Shim"
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* src="javascript:false;"></iframe>"
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync* @type String
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// <iframe> shim notes:
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// 1) Need to set the "frameBorder" property to 0 to suppress the default <iframe> border in IE.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// (Setting the CSS "border" property alone doesn't suppress it.)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// 2) The "src" attribute of the <iframe> is set to "javascript:false;" so that it won't load a
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// page inside it, preventing the secure/nonsecure warning in IE when using HTTPS.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// 3) Since the role of the <iframe> shim is completely presentational, its "tabindex" attribute
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// is set to "-1" and its title attribute is set to "Menu Stacking Shim". Both strategies help
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync// users of screen readers to avoid mistakenly interacting with the <iframe> shim.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncMenuNav.SHIM_TEMPLATE = '<iframe frameborder="0" tabindex="-1" class="' +
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync '" src="javascript:false;"></iframe>';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Protected properties
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _rootMenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Node instance representing the root menu in the MenuNav.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default null
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _activeItem
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Node instance representing the MenuNav's active descendent - the menuitem or
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * menu label the user is currently interacting with.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default null
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _activeMenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Node instance representing the menu that is the parent of the MenuNav's
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * active descendent.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default null
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _hasFocus
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Boolean indicating if the MenuNav has focus.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default false
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Boolean
447cbf113f44132911fc13dc33cb26603759b82evboxsync // In gecko-based browsers a mouseover and mouseout event will fire even
447cbf113f44132911fc13dc33cb26603759b82evboxsync // if a DOM element moves out from under the mouse without the user actually
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // moving the mouse. This bug affects MenuNav because the user can hit the
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Esc key to hide a menu, and if the mouse is over the menu when the
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // user presses Esc, the _onMenuMouseOut handler will be called. To fix this
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // bug the following flag (_blockMouseEvent) is used to block the code in the
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // _onMenuMouseOut handler from executing.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _blockMouseEvent
447cbf113f44132911fc13dc33cb26603759b82evboxsync * @description Boolean indicating whether or not to handle the "mouseover" event.
447cbf113f44132911fc13dc33cb26603759b82evboxsync * @default false
447cbf113f44132911fc13dc33cb26603759b82evboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Boolean
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _currentMouseX
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Number representing the current x coordinate of the mouse inside the MenuNav.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default 0
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Number
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _movingToSubmenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Boolean indicating if the mouse is moving from a menu label to its
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * corresponding submenu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default false
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Boolean
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _showSubmenuTimer
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Timer used to show a submenu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default null
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Object
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _hideSubmenuTimer
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Timer used to hide a submenu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default null
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Object
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _hideAllSubmenusTimer
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Timer used to hide a all submenus.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default null
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Object
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _firstItem
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Node instance representing the first item (menuitem or menu label) in the root
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * menu of a MenuNav.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default null
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @property _autoSubmenuDisplay
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Boolean indicating if submenus are automatically made visible when the user
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * mouses over the menu's items.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @default true
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @type Boolean
447cbf113f44132911fc13dc33cb26603759b82evboxsync // Protected methods
4fac78486305f1f002adbf23953382e5d832af94vboxsync * @method _isRoot
447cbf113f44132911fc13dc33cb26603759b82evboxsync * @description Returns a boolean indicating if the specified menu is the root menu in
4fac78486305f1f002adbf23953382e5d832af94vboxsync * the MenuNav.
447cbf113f44132911fc13dc33cb26603759b82evboxsync * @protected
447cbf113f44132911fc13dc33cb26603759b82evboxsync * @param {Node} menu Node instance representing a menu.
447cbf113f44132911fc13dc33cb26603759b82evboxsync * @return {Boolean} Boolean indicating if the specified menu is the root menu in the MenuNav.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _getTopmostSubmenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Returns the topmost submenu of a submenu hierarchy.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menu Node instance representing a menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @return {Node} Node instance representing a menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _clearActiveItem
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Clears the MenuNav's active descendent.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _clearActiveItem: function () {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oActiveItem.removeClass(getActiveClass(oActiveItem));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _setActiveItem
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Sets the specified menuitem or menu label as the MenuNav's active descendent.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} item Node instance representing a menuitem or menu label.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _focusItem
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Focuses the specified menuitem or menu label.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} item Node instance representing a menuitem or menu label.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Need to focus using a zero-second timeout to get Apple's VoiceOver to
859c9a7cc74066a52cf7e76d54169859e7705c3dvboxsync // recognize that the focused item has changed
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _showMenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Shows the specified menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menu Node instance representing a menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menu.appendChild(Y.Node.create(MenuNav.SHIM_TEMPLATE));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Clear previous values for height and width
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menu.setStyles({ height: EMPTY_STRING, width: EMPTY_STRING });
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Set the width and height of the menu's bounding box - this is necessary for IE 6
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // so that the CSS for the <iframe> shim can simply set the <iframe>'s width and height
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // to 100% to ensure that dimensions of an <iframe> shim are always sync'd to the
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // that of its parent menu. Specifying a width and height also helps when positioning
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // decorator elements (for creating effects like rounded corners) inside a menu's
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // bounding box in IE 7.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menu.previous().addClass(CSS_MENU_LABEL_MENUVISIBLE);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _hideMenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Hides the specified menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menu Node instance representing a menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Boolean} activateAndFocusLabel Boolean indicating if the label for the specified
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * menu should be focused and set as active.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _hideMenu: function (menu, activateAndFocusLabel) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oActiveItem = menu.query((PERIOD + CSS_MENUITEM_ACTIVE));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Clear the values for top and left that were set by the call to "setXY" when the menu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // was shown so that the hidden position specified in the core CSS file will take affect.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menu.setStyles({ left: EMPTY_STRING, top: EMPTY_STRING });
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _hideAllSubmenus
4791a729647f035b6561d292c9f848dd1fc797a9vboxsync * @description Hides all submenus of the specified menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menu Node instance representing a menu.
9c0076729ec8138e89ce8a6af9a772b68f1f8dc7vboxsync * @method _cancelShowSubmenuTimer
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Cancels the timer used to show a submenu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _cancelHideSubmenuTimer
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description Cancels the timer used to hide a submenu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Event handlers for discrete pieces of pieces of the menu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _onMenuMouseOver
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description "mouseover" event handler for a menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menu Node instance representing a menu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oHideAllSubmenusTimer = menuNav._hideAllSubmenusTimer;
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (menuNav._movingToSubmenu && isHorizontalMenu(menu)) {
ae56268ed43efa582cc3605ea0270106562a306dvboxsync * @method _onMenuMouseOut
ae56268ed43efa582cc3605ea0270106562a306dvboxsync * @description "mouseout" event handler for a menu.
ae56268ed43efa582cc3605ea0270106562a306dvboxsync * @protected
ae56268ed43efa582cc3605ea0270106562a306dvboxsync * @param {Node} menu Node instance representing a menu.
ae56268ed43efa582cc3605ea0270106562a306dvboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (oActiveMenu && !oActiveMenu.contains(oRelatedTarget)) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (oParentMenu && !oParentMenu.contains(oRelatedTarget)) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync later(menuNav._mouseOutHideDelay, menuNav, function () {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Focus the label element for the topmost submenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oSubmenu = menuNav._getTopmostSubmenu(oActiveMenu);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _onMenuLabelMouseOver
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description "mouseover" event handler for a menu label.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menuLabel Node instance representing a menu label.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _onMenuLabelMouseOver: function (menuLabel, event) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync bUseAutoSubmenuDisplay = (menuNav._autoSubmenuDisplay && bIsRoot || !bIsRoot),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (bUseAutoSubmenuDisplay && !menuNav._movingToSubmenu) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _onMenuLabelMouseOut
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description "mouseout" event handler for a menu label.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menuLabel Node instance representing a menu label.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync _onMenuLabelMouseOut: function (menuLabel, event) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync bUseAutoSubmenuDisplay = (menuNav._autoSubmenuDisplay && bIsRoot || !bIsRoot),
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (menuNav._movingToSubmenu && !menuNav._showSubmenuTimer && oSubmenu) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // If the mouse is moving diagonally toward the submenu and another submenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // isn't in the process of being displayed (via a timer), then hide the submenu
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // via a timer to give the user some time to reach the submenu.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync menuNav._hideSubmenuTimer = later(menuNav._submenuHideDelay, menuNav,
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync !oSubmenu.contains(oRelatedTarget) && oRelatedTarget !== oSubmenu) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // If the mouse is not moving toward the submenu, cancel any submenus that
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // might be in the process of being displayed (via a timer) and hide this
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // submenu immediately.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _onMenuItemMouseOver
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description "mouseover" event handler for a menuitem.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menuItem Node instance representing a menuitem.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync bUseAutoSubmenuDisplay = (menuNav._autoSubmenuDisplay && bIsRoot || !bIsRoot);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (bUseAutoSubmenuDisplay && !menuNav._movingToSubmenu) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _onMenuItemMouseOut
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description "mouseout" event handler for a menuitem.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Node} menuItem Node instance representing a menuitem.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @method _onVerticalMenuKeyDown
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @description "keydown" event handler for vertical menus of a MenuNav.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (oParentMenu && isHorizontalMenu(oParentMenu)) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oLI = getPreviousSibling(oActiveMenu.get(PARENT_NODE));
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync else { // MenuItem
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync oSubmenu = menuNav._getTopmostSubmenu(oActiveMenu);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync else { // MenuItem
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync getPreviousItem(oFocusedItem) : getNextItem(oFocusedItem);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // Prevent the browser from scrolling the window
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @method _onHorizontalMenuKeyDown
d36016c7e22c0a816c7eae1b6d53f46b7d180589vboxsync * @description "keydown" event handler for horizontal menus of a MenuNav.
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @protected
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @param {Object} event Object representing the DOM event.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync getPreviousItem(oFocusedItem) : getNextItem(oFocusedItem);
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync // Prevent the browser from scrolling the window
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync // Generic DOM Event handlers
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @method _onMouseMove
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @description "mousemove" event handler for the MenuNav.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @param {Object} event Object representing the DOM event.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // Using a timer to set the value of the "_currentMouseX" property helps improve the
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync // reliability of the calculation used to set the value of the "_movingToSubmenu"
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // property - especially in Opera.
1e9377d042fa2ea3e2cd78805678f23f64db55f6vboxsync * @method _onMouseOver
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @description "mouseover" event handler for the MenuNav.
fa2d3f7a92b98db2c47964694f4b7e1aa67a3b10vboxsync * @protected
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @param {Object} event Object representing the DOM event.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @method _onMouseOut
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @description "mouseout" event handler for the MenuNav.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @protected
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @param {Object} event Object representing the DOM event.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync menuNav._movingToSubmenu = (oActiveMenu && !isHorizontalMenu(oActiveMenu) &&
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync if (handleMouseOutForNode(oMenuLabel, oRelatedTarget)) {
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync if (handleMouseOutForNode(oMenuItem, oRelatedTarget)) {
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync if (oSubmenu && (oRelatedTarget === oSubmenu || oSubmenu.contains(oRelatedTarget))) {
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync if (handleMouseOutForNode(oMenu, oRelatedTarget) || bMovingToSubmenu) {
80e46f984efd827517661c0e081a36014ca41af8vboxsync * @method _toggleSubmenuDisplay
80e46f984efd827517661c0e081a36014ca41af8vboxsync * @description "mousedown," "keydown," and "click" event handler for the MenuNav used to
80e46f984efd827517661c0e081a36014ca41af8vboxsync * toggle the display of a submenu.
80e46f984efd827517661c0e081a36014ca41af8vboxsync * @protected
80e46f984efd827517661c0e081a36014ca41af8vboxsync * @param {Object} event Object representing the DOM event.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync oAnchor = isAnchor(oTarget) ? oTarget : oTarget.ancestor(isAnchor);
1e9377d042fa2ea3e2cd78805678f23f64db55f6vboxsync // Need to pass "2" as a second argument to "getAttribute" for IE otherwise IE
1e9377d042fa2ea3e2cd78805678f23f64db55f6vboxsync // will return a fully qualified URL for the value of the "href" attribute.
1e9377d042fa2ea3e2cd78805678f23f64db55f6vboxsync // http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync if (sType === MOUSEDOWN || (sType === KEYDOWN && event.keyCode === 13)) {
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // The call to "preventDefault" below results in the element
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // serving as the menu's label to not receive focus in Webkit,
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // therefore the "_hasFocus" flag never gets set to true, meaning the
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // first item in the submenu isn't focused when the submenu is
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // displayed. To fix this issue, it is necessary to set the
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // "_hasFocus" flag to true.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // Prevent the browser from following the URL of the anchor element
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @method _onKeyPress
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @description "keypress" event handler for the MenuNav.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @protected
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @param {Object} event Object representing the DOM event.
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync // Prevent the browser from scrolling the window
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @method _onKeyDown
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync * @description "keydown" event handler for the MenuNav.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @protected
d36016c7e22c0a816c7eae1b6d53f46b7d180589vboxsync * @param {Object} event Object representing the DOM event.
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync menuNav._blockMouseEvent = UA.gecko ? TRUE : FALSE;
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @method _onDocMouseDown
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @description "mousedown" event handler for the owner document of the MenuNav.
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @protected
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @param {Object} event Object representing the DOM event.
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync if (!oRoot.compareTo(oTarget) && !oRoot.contains(oTarget)) {
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync // Document doesn't receive focus in Webkit when the user mouses down on it,
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync // so the "_hasFocus" property won't get set to the correct value. The
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync // following line corrects the problem.
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @method _onDocFocus
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @description "focus" event handler for the owner document of the MenuNav.
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @protected
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync * @param {Object} event Object representing the DOM event.
0839fbd6b31c4c9a2ea76750df48a30dffd4ad77vboxsync if (menuNav._rootMenu.contains(oTarget)) { // The menu has focus
0839fbd6b31c4c9a2ea76750df48a30dffd4ad77vboxsync // First time the menu has been focused, need to setup focused state and
30a7a1ba4558de8e809ab4bdbd82a713d67e59abvboxsync // established active active descendant
cf289c84a0ecd24e5808b46b70d545cdc2c8805cvboxsync else { // The menu has lost focus
fa2d3f7a92b98db2c47964694f4b7e1aa67a3b10vboxsync}, '@VERSION@' ,{requires:['node', 'classnamemanager']});