/* Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ if(!dojo._hasResource["dijit.Menu"]){ dojo._hasResource["dijit.Menu"]=true; dojo.provide("dijit.Menu"); dojo.require("dojo.window"); dojo.require("dijit._Widget"); dojo.require("dijit._KeyNavContainer"); dojo.require("dijit._Templated"); dojo.declare("dijit._MenuBase",[dijit._Widget,dijit._Templated,dijit._KeyNavContainer],{parentMenu:null,popupDelay:500,startup:function(){ if(this._started){ return; } dojo.forEach(this.getChildren(),function(_1){ _1.startup(); }); this.startupKeyNavChildren(); this.inherited(arguments); },onExecute:function(){ },onCancel:function(_2){ },_moveToPopup:function(_3){ if(this.focusedChild&&this.focusedChild.popup&&!this.focusedChild.disabled){ this.focusedChild._onClick(_3); }else{ var _4=this._getTopMenu(); if(_4&&_4._isMenuBar){ _4.focusNext(); } } },_onPopupHover:function(_5){ if(this.currentPopup&&this.currentPopup._pendingClose_timer){ var _6=this.currentPopup.parentMenu; if(_6.focusedChild){ _6.focusedChild._setSelected(false); } _6.focusedChild=this.currentPopup.from_item; _6.focusedChild._setSelected(true); this._stopPendingCloseTimer(this.currentPopup); } },onItemHover:function(_7){ if(this.isActive){ this.focusChild(_7); if(this.focusedChild.popup&&!this.focusedChild.disabled&&!this.hover_timer){ this.hover_timer=setTimeout(dojo.hitch(this,"_openPopup"),this.popupDelay); } } if(this.focusedChild){ this.focusChild(_7); } this._hoveredChild=_7; },_onChildBlur:function(_8){ this._stopPopupTimer(); _8._setSelected(false); var _9=_8.popup; if(_9){ this._stopPendingCloseTimer(_9); _9._pendingClose_timer=setTimeout(function(){ _9._pendingClose_timer=null; if(_9.parentMenu){ _9.parentMenu.currentPopup=null; } dijit.popup.close(_9); },this.popupDelay); } },onItemUnhover:function(_a){ if(this.isActive){ this._stopPopupTimer(); } if(this._hoveredChild==_a){ this._hoveredChild=null; } },_stopPopupTimer:function(){ if(this.hover_timer){ clearTimeout(this.hover_timer); this.hover_timer=null; } },_stopPendingCloseTimer:function(_b){ if(_b._pendingClose_timer){ clearTimeout(_b._pendingClose_timer); _b._pendingClose_timer=null; } },_stopFocusTimer:function(){ if(this._focus_timer){ clearTimeout(this._focus_timer); this._focus_timer=null; } },_getTopMenu:function(){ for(var _c=this;_c.parentMenu;_c=_c.parentMenu){ } return _c; },onItemClick:function(_d,_e){ if(typeof this.isShowingNow=="undefined"){ this._markActive(); } this.focusChild(_d); if(_d.disabled){ return false; } if(_d.popup){ this._openPopup(); }else{ this.onExecute(); _d.onClick(_e); } },_openPopup:function(){ this._stopPopupTimer(); var _f=this.focusedChild; if(!_f){ return; } var _10=_f.popup; if(_10.isShowingNow){ return; } if(this.currentPopup){ this._stopPendingCloseTimer(this.currentPopup); dijit.popup.close(this.currentPopup); } _10.parentMenu=this; _10.from_item=_f; var _11=this; dijit.popup.open({parent:this,popup:_10,around:_f.domNode,orient:this._orient||(this.isLeftToRight()?{"TR":"TL","TL":"TR","BR":"BL","BL":"BR"}:{"TL":"TR","TR":"TL","BL":"BR","BR":"BL"}),onCancel:function(){ _11.focusChild(_f); _11._cleanUp(); _f._setSelected(true); _11.focusedChild=_f; },onExecute:dojo.hitch(this,"_cleanUp")}); this.currentPopup=_10; _10.connect(_10.domNode,"onmouseenter",dojo.hitch(_11,"_onPopupHover")); if(_10.focus){ _10._focus_timer=setTimeout(dojo.hitch(_10,function(){ this._focus_timer=null; this.focus(); }),0); } },_markActive:function(){ this.isActive=true; dojo.addClass(this.domNode,"dijitMenuActive"); dojo.removeClass(this.domNode,"dijitMenuPassive"); },onOpen:function(e){ this.isShowingNow=true; this._markActive(); },_markInactive:function(){ this.isActive=false; dojo.removeClass(this.domNode,"dijitMenuActive"); dojo.addClass(this.domNode,"dijitMenuPassive"); },onClose:function(){ this._stopFocusTimer(); this._markInactive(); this.isShowingNow=false; this.parentMenu=null; },_closeChild:function(){ this._stopPopupTimer(); if(this.focusedChild){ this.focusedChild._setSelected(false); this.focusedChild._onUnhover(); this.focusedChild=null; } if(this.currentPopup){ dijit.popup.close(this.currentPopup); this.currentPopup=null; } },_onItemFocus:function(_12){ if(this._hoveredChild&&this._hoveredChild!=_12){ this._hoveredChild._onUnhover(); } },_onBlur:function(){ this._cleanUp(); this.inherited(arguments); },_cleanUp:function(){ this._closeChild(); if(typeof this.isShowingNow=="undefined"){ this._markInactive(); } }}); dojo.declare("dijit.Menu",dijit._MenuBase,{constructor:function(){ this._bindings=[]; },templateString:dojo.cache("dijit","templates/Menu.html","