node-menunav.js revision 05d0664d1cf00f06b4a25a9bda45012e29efe7ef
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* <p>The MenuNav Node Plugin makes it easy to transform existing list-based
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* markup into traditional, drop down navigational menus that are both accessible
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* and easy to customize, and only require a small set of dependencies.</p>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* <p>To use the MenuNav Node Plugin, simply pass a reference to the plugin to a
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* Node instance's <code>plug</code> method.</p>
77c7ff125b9cf3d212f719f5dd1cbe67b51cf8e9Jon A. Cruz* <script type="text/javascript"> <br>
77c7ff125b9cf3d212f719f5dd1cbe67b51cf8e9Jon A. Cruz* // Call the "use" method, passing in "node-menunav". This will <br>
77c7ff125b9cf3d212f719f5dd1cbe67b51cf8e9Jon A. Cruz* // load the script and CSS for the MenuNav Node Plugin and all of <br>
a53fd00014de5e3469827acbab0e4cce9ed39087Jon A. Cruz* // the required dependencies. <br>
a53fd00014de5e3469827acbab0e4cce9ed39087Jon A. Cruz* YUI().use("node-menunav", function(Y) { <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* // Use the "contentready" event to initialize the menu when <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* // the subtree of element representing the root menu <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* // (<div id="menu-1">) is ready to be scripted. <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* Y.on("contentready", function () { <br>
9d2da14dec9f62765544a573f9151d83b85d0909mental* // The scope of the callback will be a Node instance <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* // representing the root menu (<div id="menu-1">). <br>
648401434273d7165b6346f9d04675b138464d2fKris* // Therefore, since "this" represents a Node instance, it <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* // is possible to just call "this.plug" passing in a <br>
715757c20baad0e8e8b54e8ad6742565f923b74cAlex Valavanis* // reference to the MenuNav Node Plugin. <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* this.plug(Y.Plugin.NodeMenuNav); <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* }, "#menu-1"); <br>
1b3a8414f17dc95fc921d999ea715c99d10dd4aaAlex Valavanis* </script> <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* <p>The MenuNav Node Plugin has several configuration properties that can be
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* set via an object literal that is passed as a second argument to a Node
be6c4327fc304962b439fd503536678e029ad51dmental* instance's <code>plug</code> method.
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* <script type="text/javascript"> <br>
9d2da14dec9f62765544a573f9151d83b85d0909mental* // Call the "use" method, passing in "node-menunav". This will <br>
9d2da14dec9f62765544a573f9151d83b85d0909mental* // load the script and CSS for the MenuNav Node Plugin and all of <br>
9d2da14dec9f62765544a573f9151d83b85d0909mental* // the required dependencies. <br>
4524755733342d1f59efec7d655bfb6a47c0ab72John Smith* YUI().use("node-menunav", function(Y) { <br>
17eb9e57e1550f744916bf486947162aa523bddamental* // Use the "contentready" event to initialize the menu when <br>
ad83b521a557c8a2d91c469f74137ca4ff4ab2d1mental* // the subtree of element representing the root menu <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* // (<div id="menu-1">) is ready to be scripted. <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* Y.on("contentready", function () { <br>
648401434273d7165b6346f9d04675b138464d2fKris* // The scope of the callback will be a Node instance <br>
648401434273d7165b6346f9d04675b138464d2fKris* // representing the root menu (<div id="menu-1">). <br>
648401434273d7165b6346f9d04675b138464d2fKris* // Therefore, since "this" represents a Node instance, it <br>
3e3e2a49f82b250cb852586703fbc460b3ca20e4Liam P. White* // is possible to just call "this.plug" passing in a <br>
3e3e2a49f82b250cb852586703fbc460b3ca20e4Liam P. White* // reference to the MenuNav Node Plugin. <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* this.plug(Y.Plugin.NodeMenuNav, { mouseOutHideDelay: 1000 });
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* }, "#menu-1"); <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* </script> <br>
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental* @module node-menunav
526c8bf9bb41b582dc49f54ac192705de9e2edf2mental // Util shortcuts
if (!oPrevious) {
return oPrevious;
if (!oNext) {
return oNext;
var bReturnVal = false;
if (node) {
return bReturnVal;
var oItem;
if (node) {
return oItem;
var oItem;
if (node) {
return oItem;
var oItem;
if (node) {
if (searchAncestors) {
return oItem;
var oItem;
if (node) {
return oItem;
* the <a href="Node.html#method_plug"><code>plug</code></a> method of Node and
var NodeMenuNav = function () {
useARIA: {
value: true,
writeOnce: true,
lazyAdd: false,
sID;
if (value) {
if (oMenuToggle) {
if (oSubmenu) {
if (oMenuToggle) {
value: true,
writeOnce: true
writeOnce: true
writeOnce: true
writeOnce: true
_rootMenu: null,
_activeItem: null,
_activeMenu: null,
_hasFocus: false,
_blockMouseEvent: false,
_movingToSubmenu: false,
_showSubmenuTimer: null,
_hideSubmenuTimer: null,
_hideAllSubmenusTimer: null,
_firstItem: null,
var menuNav = this,
aHandlers = [],
oDoc;
if (oRootMenu) {
destructor: function () {
if (aHandlers) {
this._eventHandlers = null;
var menuNav = this,
if (!oMenu) {
return returnVal;
_clearActiveItem: function () {
var menuNav = this,
if (oActiveItem) {
var menuNav = this;
if (item) {
var menuNav = this,
var menuNav = this,
if (activateAndFocusLabel) {
if (oActiveItem) {
var menuNav = this;
}, menuNav));
_cancelShowSubmenuTimer: function () {
var menuNav = this,
if (oShowSubmenuTimer) {
_cancelHideSubmenuTimer: function () {
var menuNav = this,
if (oHideSubmenuTimer) {
_initFocusManager: function () {
var menuNav = this,
if (!oFocusManager) {
circular: true
var oItem;
var menuNav = this,
if (oActiveItem) {
var menuNav = this,
if (oHideAllSubmenusTimer) {
_hideAndFocusLabel: function () {
var menuNav = this,
if (oActiveMenu) {
var menuNav = this,
if (oActiveItem) {
var menuNav = this,
if (oSubmenu) {
var menuNav = this,
if (bUseAutoSubmenuDisplay) {
var menuNav = this,
this._clearActiveItem();
var menuNav = this,
bPreventDefault = false,
oLI,
switch (nKeyCode) {
if (oItem) {
if (oSubmenu) {
bPreventDefault = true;
if (oSubmenu) {
if (oItem) {
if (oSubmenu) {
bPreventDefault = true;
if (bPreventDefault) {
var menuNav = this,
bPreventDefault = false,
if (oSubmenu) {
bPreventDefault = true;
if (bPreventDefault) {
var menuNav = this;
var menuNav = this,
if (oParentMenu) {
var menuNav = this,
bMovingToSubmenu = false,
if (oMenuLabel) {
if (oSubmenu &&
bMovingToSubmenu = true;
var menuNav = this,
nLen,
sId;
if (oMenuLabel) {
if (oAnchor) {
// http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx
var menuNav = this,
if (oActiveMenu) {
else if (oActiveItem) {
if (oSubmenu) {
var menuNav = this,