YAHOO.widget.TaskNode=function(_1,_2,_3,_4){
YAHOO.widget.TaskNode.superclass.constructor.call(this,_1,_2,_3);
this.setUpCheck(_4||_1.checked);
};
YAHOO.extend(YAHOO.widget.TaskNode,YAHOO.widget.TextNode,{checked:false,checkState:0,_type:"TaskNode",taskNodeParentChange:function(){
},setUpCheck:function(_5){
if(_5&&_5===true){
this.check();
}else{
if(this.parent&&2===this.parent.checkState){
this.updateParent();
}
}
if(this.tree&&!this.tree.hasEvent("checkClick")){
this.tree.createEvent("checkClick",this.tree);
}
this.tree.subscribe("clickEvent",this.checkClick);
this.subscribe("parentChange",this.taskNodeParentChange);
},getCheckElId:function(){
return "ygtvcheck"+this.index;
},getCheckEl:function(){
return document.getElementById(this.getCheckElId());
},getCheckStyle:function(){
return "ygtvcheck"+this.checkState;
},checkClick:function(_6){
var _7=_6.node;
var _8=YAHOO.util.Event.getTarget(_6.event);
YAHOO.log("previous checkstate: "+_7.checkState);
if(_7.checkState===0){
_7.check();
}else{
_7.uncheck();
}
_7.onCheckClick(_7);
this.fireEvent("checkClick",_7);
return false;
},onCheckClick:function(){
YAHOO.log("onCheckClick: "+this);
},updateParent:function(){
var p=this.parent;
if(!p||!p.updateParent){
YAHOO.log("Abort udpate parent: "+this.index);
return;
}
var _a=false;
var _b=false;
for(var i=0,l=p.children.length;i<l;i=i+1){
var n=p.children[i];
if("checked" in n){
if(n.checked){
_a=true;
if(n.checkState===1){
_b=true;
}
}else{
_b=true;
}
}
}
if(_a){
p.setCheckState((_b)?1:2);
}else{
p.setCheckState(0);
}
p.updateCheckHtml();
p.updateParent();
},updateCheckHtml:function(){
if(this.parent&&this.parent.childrenRendered){
this.getCheckEl().className=this.getCheckStyle();
}
},setCheckState:function(_f){
this.checkState=_f;
this.checked=(_f>0);
},check:function(){
YAHOO.log("check");
this.setCheckState(2);
for(var i=0,l=this.children.length;i<l;i=i+1){
var c=this.children[i];
if(c.check){
c.check();
}
}
this.updateCheckHtml();
this.updateParent();
},uncheck:function(){
this.setCheckState(0);
for(var i=0,l=this.children.length;i<l;i=i+1){
var c=this.children[i];
if(c.uncheck){
c.uncheck();
}
}
this.updateCheckHtml();
this.updateParent();
},getContentHtml:function(){
var sb=[];
sb[sb.length]="<td";
sb[sb.length]=" id=\""+this.getCheckElId()+"\"";
sb[sb.length]=" class=\""+this.getCheckStyle()+"\"";
sb[sb.length]=">";
sb[sb.length]="<div class=\"ygtvspacer\"></div></td>";
sb[sb.length]="<td><span";
sb[sb.length]=" id=\""+this.labelElId+"\"";
if(this.title){
sb[sb.length]=" title=\""+this.title+"\"";
}
sb[sb.length]=" class=\""+this.labelStyle+"\"";
sb[sb.length]=" >";
sb[sb.length]=this.label;
sb[sb.length]="</span></td>";
return sb.join("");
}});

