node-menunav-min.js revision f1ae5a093446a8d9906da2854617681059bd7718
YUI.add("node-menunav",function(D){var k=D.UA,r=D.later,AJ=D.ClassNameManager.getClassName,R="menu",G="menuitem",AF="hidden",S="parentNode",V="children",x="offsetHeight",AA="offsetWidth",AL="px",f="id",I=".",E="handledMouseOut",p="handledMouseOver",a="active",AH="label",c="a",u="mousedown",AM="keydown",z="click",Q="",U="first-of-type",AN="role",N="presentation",AB="descendants",h="UI",s="activeDescendant",J="useARIA",v="aria-hidden",w="content",AK=">.yui-menu-content>ul>li>a",O=">.yui-menu-content>ul>li>.yui-menu-label>a:first-child",t="autoSubmenuDisplay",T="mouseOutHideDelay",j=AJ(R),AD=AJ(R,AF),Z=AJ(R,"horizontal"),AG=AJ(R,AH),i=AJ(R,AH,a),X=AJ(R,AH,(R+"visible")),K=AJ(G),A=AJ(G,a),g=I+j,AE=(I+AJ(R,"toggle"));var L=function(Y){var AP=Y.previous(),AO;if(!AP){AO=Y.get(S).get(V);AP=AO.item(AO.size()-1);}return AP;};var b=function(Y){var AO=Y.next();if(!AO){AO=Y.get(S).get(V).item(0);}return AO;};var F=function(Y){var AO=false;if(Y){AO=Y.get("nodeName").toLowerCase()===c;}return AO;};var P=function(Y){return Y.hasClass(K);};var q=function(Y){return Y.hasClass(AG);};var o=function(Y){return Y.hasClass(Z);};var l=function(Y){return Y.hasClass(X);};var n=function(Y){return F(Y)?Y:Y.query(c);};var y=function(AP,AO,Y){var AQ;if(AP){if(AP.hasClass(AO)){AQ=AP;}if(!AQ&&Y){AQ=AP.ancestor((I+AO));}}return AQ;};var M=function(Y){return Y.ancestor(g);};var W=function(AO,Y){return y(AO,j,Y);};var AC=function(AO,Y){var AP;if(AO){AP=y(AO,K,Y);}return AP;};var m=function(AO,Y){var AP;if(AO){if(Y){AP=y(AO,AG,Y);}else{AP=y(AO,AG)||AO.query((I+AG));}}return AP;};var B=function(AO,Y){var AP;if(AO){AP=AC(AO,Y)||m(AO,Y);}return AP;};var C=function(Y){return B(Y.query("li"));};var e=function(Y){return P(Y)?A:i;};var d=function(Y,AO){return Y&&!Y[p]&&(Y===AO||Y.contains(AO));};var H=function(AO,Y){return AO&&!AO[E]&&(AO!==Y&&!AO.contains(Y));};var AI=function(){AI.superclass.constructor.apply(this,arguments);};AI.NAME="nodeMenuNav";AI.NS="menuNav";AI.SHIM_TEMPLATE_TITLE="Menu Stacking Shim";AI.SHIM_TEMPLATE='<iframe frameborder="0" tabindex="-1" class="'+AJ("shim")+'" title="'+AI.SHIM_TEMPLATE_TITLE+'" src="javascript:false;"></iframe>';AI.ATTRS={useARIA:{value:true,writeOnce:true,setter:function(AR){var AO=this.get("host"),AS,Y,AQ,AP;if(AR){AO.set(AN,R);AO.queryAll("ul,li,."+AJ(R,w)).set(AN,N);AO.queryAll((I+AJ(G,w))).set(AN,G);AO.queryAll((I+AG)).each(function(AT){AS=AT;Y=AT.query(AE);if(Y){Y.set(AN,N);AS=Y.previous();}AS.set(AN,G);AS.set("aria-haspopup",true);AQ=AT.next();if(AQ){AQ.set(AN,R);AS=AQ.previous();Y=AS.query(AE);if(Y){AS=Y;}AP=D.stamp(AS);if(!AS.get(f)){AS.set(f,AP);}AQ.set("aria-labelledby",AP);AQ.set(v,true);}});}}},autoSubmenuDisplay:{value:true,writeOnce:true},submenuShowDelay:{value:250,writeOnce:true},submenuHideDelay:{value:250,writeOnce:true},mouseOutHideDelay:{value:750,writeOnce:true}};D.extend(AI,D.Plugin.Base,{_rootMenu:null,_activeItem:null,_activeMenu:null,_hasFocus:false,_blockMouseEvent:false,_currentMouseX:0,_movingToSubmenu:false,_showSubmenuTimer:null,_hideSubmenuTimer:null,_hideAllSubmenusTimer:null,_firstItem:null,initializer:function(AO){var AP=this,AQ=this.get("host"),Y;if(AQ){AP._rootMenu=AQ;AQ.queryAll("ul:first-child").addClass(U);AQ.queryAll(g).addClass(AD);AQ.on("mouseover",AP._onMouseOver,AP);AQ.on("mouseout",AP._onMouseOut,AP);AQ.on("mousemove",AP._onMouseMove,AP);AQ.on(u,AP._toggleSubmenuDisplay,AP);AQ.on(AM,AP._toggleSubmenuDisplay,AP);AQ.on(z,AP._toggleSubmenuDisplay,AP);AQ.on("keypress",AP._onKeyPress,AP);AQ.on(AM,AP._onKeyDown,AP);Y=AQ.get("ownerDocument");Y.on(u,AP._onDocMouseDown,AP);Y.on("focus",AP._onDocFocus,AP);AP._initFocusManager();}},destructor:function(){},_isRoot:function(Y){return this._rootMenu.compareTo(Y);},_getTopmostSubmenu:function(AQ){var AP=this,Y=M(AQ),AO;if(!Y){AO=AQ;}else{if(AP._isRoot(Y)){AO=AQ;}else{AO=AP._getTopmostSubmenu(Y);}}return AO;},_clearActiveItem:function(){var AO=this,Y=AO._activeItem;if(Y){Y.removeClass(e(Y));}AO._activeItem=null;},_setActiveItem:function(AO){var Y=this;if(AO){Y._clearActiveItem();AO.addClass(e(AO));Y._activeItem=AO;}},_focusItem:function(AP){var AO=this,Y,AQ;if(AP&&AO._hasFocus){Y=M(AP);AQ=n(AP);if(AO._activeMenu!==Y){AO._activeMenu=Y;AO._initFocusManager();}AO._focusManager.focus(AQ);}},_showMenu:function(AQ){var Y=M(AQ),AP=AQ.get(S),AO=AP.getXY();if(this.get(J)){AQ.set(v,false);}if(o(Y)){AO[1]=AO[1]+AP.get(x);}else{AO[0]=AO[0]+AP.get(AA);}AQ.setXY(AO);if(k.ie<8){if(k.ie===6&&!AQ.hasIFrameShim){AQ.appendChild(D.Node.create(AI.SHIM_TEMPLATE));AQ.hasIFrameShim=true;}AQ.setStyles({height:Q,width:Q});AQ.setStyles({height:(AQ.get(x)+AL),width:(AQ.get(AA)+AL)});}AQ.previous().addClass(X);AQ.removeClass(AD);},_hideMenu:function(AQ,AO){var AP=this,AR=AQ.previous(),Y;AR.removeClass(X);if(AO){AP._focusItem(AR);AP._setActiveItem(AR);}Y=AQ.query((I+A));if(Y){Y.removeClass(A);}AQ.setStyles({left:Q,top:Q});AQ.addClass(AD);if(AP.get(J)){AQ.set(v,true);}},_hideAllSubmenus:function(AO){var Y=this;AO.queryAll(g).each(D.bind(function(AP){Y._hideMenu(AP);},Y));},_cancelShowSubmenuTimer:function(){var AO=this,Y=AO._showSubmenuTimer;if(Y){Y.cancel();AO._showSubmenuTimer=null;}},_cancelHideSubmenuTimer:function(){var Y=this,AO=Y._hideSubmenuTimer;if(AO){AO.cancel();Y._hideSubmenuTimer=null;}},_initFocusManager:function(){var AQ=this,AS=AQ._rootMenu,AO=AQ._activeMenu||AS,AR=AQ._isRoot(AO)?Q:("#"+AO.get("id")),Y=AQ._focusManager,AP,AT,AU;if(o(AO)){AT=AR+AK+","+AR+O;AP={next:"down:39",previous:"down:37"};}else{AT=AR+AK;AP={next:"down:40",previous:"down:38"};}if(!Y){AS.plug(D.Plugin.NodeFocusManager,{descendants:AT,keys:AP,circular:true});Y=AS.focusManager;AU="#"+AS.get("id")+" .yui-menu a,"+AE;AS.queryAll(AU).set("tabIndex",-1);Y.on("activeDescendantChange",this._onActiveDescendantChange,Y,this);Y.after("activeDescendantChange",this._afterActiveDescendantChange,Y,this);AQ._focusManager=Y;}else{Y.set(s,-1);Y.set(AB,AT);Y.set("keys",AP);}},_onActiveDescendantChange:function(AO,Y){if(AO.src===h&&Y._activeMenu&&!Y._movingToSubmenu){Y._hideAllSubmenus(Y._activeMenu);
}},_afterActiveDescendantChange:function(AO,Y){var AP;if(AO.src===h){AP=B(this.get(AB).item(AO.newVal),true);Y._setActiveItem(AP);}},_onDocFocus:function(AR){var AQ=this,Y=AQ._activeItem,AP=AR.target,AO;if(AQ._rootMenu.contains(AP)){if(AQ._hasFocus){AO=M(AP);if(!AQ._activeMenu.compareTo(AO)){AQ._activeMenu=AO;AQ._initFocusManager();AQ._focusManager.set(s,AP);AQ._setActiveItem(B(AP,true));}}else{AQ._hasFocus=true;Y=B(AP,true);if(Y){AQ._setActiveItem(Y);}}}else{AQ._clearActiveItem();AQ._cancelShowSubmenuTimer();AQ._hideAllSubmenus(AQ._rootMenu);AQ._activeMenu=AQ._rootMenu;AQ._initFocusManager();AQ._focusManager.set(s,0);AQ._hasFocus=false;}},_onMenuMouseOver:function(AQ,AP){var AO=this,Y=AO._hideAllSubmenusTimer;if(Y){Y.cancel();AO._hideAllSubmenusTimer=null;}AO._cancelHideSubmenuTimer();if(AO._activeMenu!==AQ){AO._activeMenu=AQ;if(AO._hasFocus){AO._initFocusManager();}}if(AO._movingToSubmenu&&o(AQ)){AO._movingToSubmenu=false;}},_hideAndFocusLabel:function(){var AP=this,AO=AP._activeMenu,Y;AP._hideAllSubmenus(AP._rootMenu);if(AO){Y=AP._getTopmostSubmenu(AO);AP._focusItem(Y.previous());}},_onMenuMouseOut:function(AU,AS){var AR=this,AP=AR._activeMenu,AT=AS.relatedTarget,Y=AR._activeItem,AQ,AO;if(AP&&!AP.contains(AT)){AQ=M(AP);if(AQ&&!AQ.contains(AT)){if(AR.get(T)>0){AR._cancelShowSubmenuTimer();AR._hideAllSubmenusTimer=r(AR.get(T),AR,AR._hideAndFocusLabel);}}else{if(Y){AO=M(Y);if(!AR._isRoot(AO)){AR._focusItem(AO.previous());}}}}},_onMenuLabelMouseOver:function(AR,AT){var AS=this,AQ=AS._activeMenu,Y=AS._isRoot(AQ),AP=(AS.get(t)&&Y||!Y),AO;AS._focusItem(AR);AS._setActiveItem(AR);if(AP&&!AS._movingToSubmenu){AS._cancelHideSubmenuTimer();AS._cancelShowSubmenuTimer();if(!l(AR)){AO=AR.next();if(AO){AS._hideAllSubmenus(AQ);AS._showSubmenuTimer=r(AS.get("submenuShowDelay"),AS,AS._showMenu,AO);}}}},_onMenuLabelMouseOut:function(AQ,AS){var AR=this,Y=AR._isRoot(AR._activeMenu),AP=(AR.get(t)&&Y||!Y),AT=AS.relatedTarget,AO=AQ.next();AR._clearActiveItem();if(AP){if(AR._movingToSubmenu&&!AR._showSubmenuTimer&&AO){AR._hideSubmenuTimer=r(AR.get("submenuHideDelay"),AR,AR._hideMenu,AO);}else{if(!AR._movingToSubmenu&&AO&&!AO.contains(AT)&&AT!==AO){AR._cancelShowSubmenuTimer();AR._hideMenu(AO);}}}},_onMenuItemMouseOver:function(AQ,AS){var AR=this,AP=AR._activeMenu,Y=AR._isRoot(AP),AO=(AR.get(t)&&Y||!Y);AR._focusItem(AQ);AR._setActiveItem(AQ);if(AO&&!AR._movingToSubmenu){AR._hideAllSubmenus(AP);}},_onMenuItemMouseOut:function(Y,AO){this._clearActiveItem();},_onVerticalMenuKeyDown:function(Y){var AO=this,AS=AO._activeMenu,AX=AO._rootMenu,AP=Y.target,AR=false,AW=Y.keyCode,AU,AQ,AT,AV;switch(AW){case 37:AQ=M(AS);if(AQ&&o(AQ)){AO._hideMenu(AS);AT=L(AS.get(S));AV=B(AT);if(AV){if(q(AV)){AU=AV.next();if(AU){AO._showMenu(AU);AO._focusItem(C(AU));AO._setActiveItem(C(AU));}else{AO._focusItem(AV);AO._setActiveItem(AV);}}else{AO._focusItem(AV);AO._setActiveItem(AV);}}}else{if(!AO._isRoot(AS)){AO._hideMenu(AS,true);}}AR=true;break;case 39:if(q(AP)){AU=AP.next();if(AU){AO._showMenu(AU);AO._focusItem(C(AU));AO._setActiveItem(C(AU));}}else{if(o(AX)){AU=AO._getTopmostSubmenu(AS);AT=b(AU.get(S));AV=B(AT);AO._hideAllSubmenus(AX);if(AV){if(q(AV)){AU=AV.next();if(AU){AO._showMenu(AU);AO._focusItem(C(AU));AO._setActiveItem(C(AU));}else{AO._focusItem(AV);AO._setActiveItem(AV);}}else{AO._focusItem(AV);AO._setActiveItem(AV);}}}}AR=true;break;}if(AR){Y.preventDefault();}},_onHorizontalMenuKeyDown:function(AT){var AS=this,AQ=AS._activeMenu,AO=AT.target,Y=B(AO,true),AR=false,AU=AT.keyCode,AP;if(AU===40){AS._hideAllSubmenus(AQ);if(q(Y)){AP=Y.next();if(AP){AS._showMenu(AP);AS._focusItem(C(AP));AS._setActiveItem(C(AP));}AR=true;}}if(AR){AT.preventDefault();}},_onMouseMove:function(AO){var Y=this;r(10,Y,function(){Y._currentMouseX=AO.pageX;});},_onMouseOver:function(AR){var AQ=this,AO,Y,AT,AP,AS;if(AQ._blockMouseEvent){AQ._blockMouseEvent=false;}else{AO=AR.target;Y=W(AO,true);AT=m(AO,true);AS=AC(AO,true);if(d(Y,AO)){AQ._onMenuMouseOver(Y,AR);Y[p]=true;Y[E]=false;AP=M(Y);if(AP){AP[E]=true;AP[p]=false;}}if(d(AT,AO)){AQ._onMenuLabelMouseOver(AT,AR);AT[p]=true;AT[E]=false;}if(d(AS,AO)){AQ._onMenuItemMouseOver(AS,AR);AS[p]=true;AS[E]=false;}}},_onMouseOut:function(AO){var AP=this,AR=AP._activeMenu,AW=false,AQ,AS,AU,Y,AT,AV;AP._movingToSubmenu=(AR&&!o(AR)&&((AO.pageX-5)>AP._currentMouseX));AQ=AO.target;AS=AO.relatedTarget;AU=W(AQ,true);Y=m(AQ,true);AV=AC(AQ,true);if(H(Y,AS)){AP._onMenuLabelMouseOut(Y,AO);Y[E]=true;Y[p]=false;}if(H(AV,AS)){AP._onMenuItemMouseOut(AV,AO);AV[E]=true;AV[p]=false;}if(Y){AT=Y.next();if(AT&&(AS===AT||AT.contains(AS))){AW=true;}}if(H(AU,AS)||AW){AP._onMenuMouseOut(AU,AO);AU[E]=true;AU[p]=false;}},_toggleSubmenuDisplay:function(AP){var AQ=this,AR=AP.target,AO=m(AR,true),Y=AP.type,AV,AU,AT,AW,AX,AS;if(AO){AV=F(AR)?AR:AR.ancestor(F);if(AV){AT=AV.getAttribute("href",2);AW=AT.indexOf("#");AX=AT.length;if(AW===0&&AX>1){AS=AT.substr(1,AX);AU=AO.next();if(AU&&(AU.get(f)===AS)){if(Y===u||(Y===AM&&AP.keyCode===13)){AP.preventDefault();if(D.UA.webkit){AP.stopImmediatePropagation();}AQ._hasFocus=true;if(l(AO)){AQ._hideMenu(AU);AQ._focusItem(AO);AQ._setActiveItem(AO);}else{AQ._hideAllSubmenus(AQ._rootMenu);AQ._showMenu(AU);AQ._focusItem(C(AU));AQ._setActiveItem(C(AU));}}if(Y===z){AP.preventDefault();}}}}}},_onKeyPress:function(Y){switch(Y.keyCode){case 37:case 38:case 39:case 40:Y.preventDefault();break;}},_onKeyDown:function(AS){var AR=this,Y=AR._activeItem,AO=AS.target,AQ=M(AO),AP;if(AQ){AR._activeMenu=AQ;if(o(AQ)){AR._onHorizontalMenuKeyDown(AS);}else{AR._onVerticalMenuKeyDown(AS);}if(AS.keyCode===27){if(!AR._isRoot(AQ)){AR._hideMenu(AQ,true);AS.stopPropagation();AR._blockMouseEvent=k.gecko?true:false;}else{if(Y){if(q(Y)&&l(Y)){AP=Y.next();if(AP){AR._hideMenu(AP);}}else{AR._focusManager.blur();AR._clearActiveItem();AR._hasFocus=false;}}}}}},_onDocMouseDown:function(AR){var AQ=this,AP=AQ._rootMenu,AO=AR.target,Y;if(AP.compareTo(AO)||AP.contains(AO)){Y=M(AO);if(!AQ._activeMenu.compareTo(Y)){AQ._activeMenu=Y;AQ._initFocusManager();AQ._focusManager.set(s,AO);
AQ._setActiveItem(B(AO,true));}}else{AQ._hideAllSubmenus(AP);if(k.webkit){AQ._hasFocus=false;AQ._clearActiveItem();}}}});D.namespace("Plugin");D.Plugin.NodeMenuNav=AI;},"@VERSION@",{requires:["node","classnamemanager","node-focusmanager"]});