/*
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.Tree"]){dojo._hasResource["dijit.Tree"]=true;dojo.provide("dijit.Tree");dojo.require("dojo.fx");dojo.require("dojo.DeferredList");dojo.require("dijit._Widget");dojo.require("dijit._Templated");dojo.require("dijit._Container");dojo.require("dijit._Contained");dojo.require("dijit._CssStateMixin");dojo.require("dojo.cookie");dojo.declare("dijit._TreeNode",[dijit._Widget,dijit._Templated,dijit._Container,dijit._Contained,dijit._CssStateMixin],{item:null,isTreeNode:true,label:"",isExpandable:null,isExpanded:false,state:"UNCHECKED",templateString:dojo.cache("dijit","templates/TreeNode.html","
\n\t\t\t\n\t\t \n\t
\n
\n"),baseClass:"dijitTreeNode",cssStateNodes:{rowNode:"dijitTreeRow",labelNode:"dijitTreeLabel"},attributeMap:dojo.delegate(dijit._Widget.prototype.attributeMap,{label:{node:"labelNode",type:"innerText"},tooltip:{node:"rowNode",type:"attribute",attribute:"title"}}),postCreate:function(){this.inherited(arguments);this._setExpando();this._updateItemClasses(this.item);if(this.isExpandable){dijit.setWaiState(this.labelNode,"expanded",this.isExpanded);}},_setIndentAttr:function(_1){this.indent=_1;var _2=(Math.max(_1,0)*this.tree._nodePixelIndent)+"px";dojo.style(this.domNode,"backgroundPosition",_2+" 0px");dojo.style(this.rowNode,this.isLeftToRight()?"paddingLeft":"paddingRight",_2);dojo.forEach(this.getChildren(),function(_3){_3.set("indent",_1+1);});},markProcessing:function(){this.state="LOADING";this._setExpando(true);},unmarkProcessing:function(){this._setExpando(false);},_updateItemClasses:function(_4){var _5=this.tree,_6=_5.model;if(_5._v10Compat&&_4===_6.root){_4=null;}this._applyClassAndStyle(_4,"icon","Icon");this._applyClassAndStyle(_4,"label","Label");this._applyClassAndStyle(_4,"row","Row");},_applyClassAndStyle:function(_7,_8,_9){var _a="_"+_8+"Class";var _b=_8+"Node";if(this[_a]){dojo.removeClass(this[_b],this[_a]);}this[_a]=this.tree["get"+_9+"Class"](_7,this.isExpanded);if(this[_a]){dojo.addClass(this[_b],this[_a]);}dojo.style(this[_b],this.tree["get"+_9+"Style"](_7,this.isExpanded)||{});},_updateLayout:function(){var _c=this.getParent();if(!_c||_c.rowNode.style.display=="none"){dojo.addClass(this.domNode,"dijitTreeIsRoot");}else{dojo.toggleClass(this.domNode,"dijitTreeIsLast",!this.getNextSibling());}},_setExpando:function(_d){var _e=["dijitTreeExpandoLoading","dijitTreeExpandoOpened","dijitTreeExpandoClosed","dijitTreeExpandoLeaf"],_f=["*","-","+","*"],idx=_d?0:(this.isExpandable?(this.isExpanded?1:2):3);dojo.removeClass(this.expandoNode,_e);dojo.addClass(this.expandoNode,_e[idx]);this.expandoNodeText.innerHTML=_f[idx];},expand:function(){if(this._expandDeferred){return this._expandDeferred;}this._wipeOut&&this._wipeOut.stop();this.isExpanded=true;dijit.setWaiState(this.labelNode,"expanded","true");dijit.setWaiRole(this.containerNode,"group");dojo.addClass(this.contentNode,"dijitTreeContentExpanded");this._setExpando();this._updateItemClasses(this.item);if(this==this.tree.rootNode){dijit.setWaiState(this.tree.domNode,"expanded","true");}var def,_10=dojo.fx.wipeIn({node:this.containerNode,duration:dijit.defaultDuration,onEnd:function(){def.callback(true);}});def=(this._expandDeferred=new dojo.Deferred(function(){_10.stop();}));_10.play();return def;},collapse:function(){if(!this.isExpanded){return;}if(this._expandDeferred){this._expandDeferred.cancel();delete this._expandDeferred;}this.isExpanded=false;dijit.setWaiState(this.labelNode,"expanded","false");if(this==this.tree.rootNode){dijit.setWaiState(this.tree.domNode,"expanded","false");}dojo.removeClass(this.contentNode,"dijitTreeContentExpanded");this._setExpando();this._updateItemClasses(this.item);if(!this._wipeOut){this._wipeOut=dojo.fx.wipeOut({node:this.containerNode,duration:dijit.defaultDuration});}this._wipeOut.play();},indent:0,setChildItems:function(_11){var _12=this.tree,_13=_12.model,_14=[];dojo.forEach(this.getChildren(),function(_15){dijit._Container.prototype.removeChild.call(this,_15);},this);this.state="LOADED";if(_11&&_11.length>0){this.isExpandable=true;dojo.forEach(_11,function(_16){var id=_13.getIdentity(_16),_17=_12._itemNodesMap[id],_18;if(_17){for(var i=0;i<_17.length;i++){if(_17[i]&&!_17[i].getParent()){_18=_17[i];_18.set("indent",this.indent+1);break;}}}if(!_18){_18=this.tree._createTreeNode({item:_16,tree:_12,isExpandable:_13.mayHaveChildren(_16),label:_12.getLabel(_16),tooltip:_12.getTooltip(_16),dir:_12.dir,lang:_12.lang,indent:this.indent+1});if(_17){_17.push(_18);}else{_12._itemNodesMap[id]=[_18];}}this.addChild(_18);if(this.tree.autoExpand||this.tree._state(_16)){_14.push(_12._expandNode(_18));}},this);dojo.forEach(this.getChildren(),function(_19,idx){_19._updateLayout();});}else{this.isExpandable=false;}if(this._setExpando){this._setExpando(false);}this._updateItemClasses(this.item);if(this==_12.rootNode){var fc=this.tree.showRoot?this:this.getChildren()[0];if(fc){fc.setFocusable(true);_12.lastFocused=fc;}else{_12.domNode.setAttribute("tabIndex","0");}}return new dojo.DeferredList(_14);},removeChild:function(_1a){this.inherited(arguments);var _1b=this.getChildren();if(_1b.length==0){this.isExpandable=false;this.collapse();}dojo.forEach(_1b,function(_1c){_1c._updateLayout();});},makeExpandable:function(){this.isExpandable=true;this._setExpando(false);},_onLabelFocus:function(evt){this.tree._onNodeFocus(this);},setSelected:function(_1d){dijit.setWaiState(this.labelNode,"selected",_1d);dojo.toggleClass(this.rowNode,"dijitTreeRowSelected",_1d);},setFocusable:function(_1e){this.labelNode.setAttribute("tabIndex",_1e?"0":"-1");},_onClick:function(evt){this.tree._onClick(this,evt);},_onDblClick:function(evt){this.tree._onDblClick(this,evt);},_onMouseEnter:function(evt){this.tree._onNodeMouseEnter(this,evt);},_onMouseLeave:function(evt){this.tree._onNodeMouseLeave(this,evt);}});dojo.declare("dijit.Tree",[dijit._Widget,dijit._Templated],{store:null,model:null,query:null,label:"",showRoot:true,childrenAttr:["children"],path:[],selectedItem:null,openOnClick:false,openOnDblClick:false,templateString:dojo.cache("dijit","templates/Tree.html","\n"),persist:true,autoExpand:false,dndController:null,dndParams:["onDndDrop","itemCreator","onDndCancel","checkAcceptance","checkItemAcceptance","dragThreshold","betweenThreshold"],onDndDrop:null,itemCreator:null,onDndCancel:null,checkAcceptance:null,checkItemAcceptance:null,dragThreshold:5,betweenThreshold:0,_nodePixelIndent:19,_publish:function(_1f,_20){dojo.publish(this.id,[dojo.mixin({tree:this,event:_1f},_20||{})]);},postMixInProperties:function(){this.tree=this;if(this.autoExpand){this.persist=false;}this._itemNodesMap={};if(!this.cookieName){this.cookieName=this.id+"SaveStateCookie";}this._loadDeferred=new dojo.Deferred();this.inherited(arguments);},postCreate:function(){this._initState();if(!this.model){this._store2model();}this.connect(this.model,"onChange","_onItemChange");this.connect(this.model,"onChildrenChange","_onItemChildrenChange");this.connect(this.model,"onDelete","_onItemDelete");this._load();this.inherited(arguments);if(this.dndController){if(dojo.isString(this.dndController)){this.dndController=dojo.getObject(this.dndController);}var _21={};for(var i=0;i