/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */ YAHOO.widget.Node=function(oData,oParent,expanded){if(oParent){this.init(oData,oParent,expanded);}};YAHOO.widget.Node.prototype={index:0,children:null,tree:null,data:null,parent:null,depth:-1,href:null,target:"_self",expanded:false,multiExpand:true,renderHidden:false,childrenRendered:false,previousSibling:null,nextSibling:null,_dynLoad:false,dataLoader:null,isLoading:false,hasIcon:true,init:function(oData,oParent,expanded){this.data=oData;this.children=[];this.index=YAHOO.widget.TreeView.nodeCount;++YAHOO.widget.TreeView.nodeCount;this.logger=new ygLogger("Node");this.expanded=expanded;if(oParent){this.tree=oParent.tree;this.parent=oParent;this.href="javascript:"+this.getToggleLink();this.depth=oParent.depth+1;this.multiExpand=oParent.multiExpand;oParent.appendChild(this);}},appendChild:function(node){if(this.hasChildren()){var sib=this.children[this.children.length-1];sib.nextSibling=node;node.previousSibling=sib;} this.tree.regNode(node);this.children[this.children.length]=node;return node;},getSiblings:function(){return this.parent.children;},showChildren:function(){if(!this.tree.animateExpand(this.getChildrenEl())){if(this.hasChildren()){this.getChildrenEl().style.display="";}}},hideChildren:function(){this.logger.debug("hiding "+this.index);if(!this.tree.animateCollapse(this.getChildrenEl())){this.getChildrenEl().style.display="none";}},getElId:function(){return"ygtv"+this.index;},getChildrenElId:function(){return"ygtvc"+this.index;},getToggleElId:function(){return"ygtvt"+this.index;},getEl:function(){return document.getElementById(this.getElId());},getChildrenEl:function(){return document.getElementById(this.getChildrenElId());},getToggleEl:function(){return document.getElementById(this.getToggleElId());},getToggleLink:function(){return"YAHOO.widget.TreeView.getNode(\'"+this.tree.id+"\',"+ this.index+").toggle()";},collapse:function(){if(!this.expanded){return;} if(!this.getEl()){this.expanded=false;return;} this.hideChildren();this.expanded=false;if(this.hasIcon){this.getToggleEl().className=this.getStyle();} this.tree.onCollapse(this);},expand:function(){if(this.expanded){return;} if(!this.getEl()){this.expanded=true;return;} if(!this.childrenRendered){this.getChildrenEl().innerHTML=this.renderChildren();} this.expanded=true;if(this.hasIcon){this.getToggleEl().className=this.getStyle();} if(this.isLoading){this.expanded=false;return;} if(!this.multiExpand){var sibs=this.getSiblings();for(var i=0;i0||(checkForLazyLoad&&this.isDynamic()&&!this.childrenRendered));},toggle:function(){if(!this.tree.locked&&(this.hasChildren(true)||this.isDynamic())){if(this.expanded){this.collapse();}else{this.expand();}}},getHtml:function(){var sb=[];sb[sb.length]='
';sb[sb.length]=this.getNodeHtml();sb[sb.length]=this.getChildrenHtml();sb[sb.length]='
';return sb.join("");},getChildrenHtml:function(){var sb=[];sb[sb.length]='
=this.depth||depth<0){this.logger.debug("illegal getAncestor depth: "+depth);return null;} var p=this.parent;while(p.depth>depth){p=p.parent;} return p;},getDepthStyle:function(depth){return(this.getAncestor(depth).nextSibling)?"ygtvdepthcell":"ygtvblankdepthcell";},getNodeHtml:function(){return"";}};