📄 dhtmlxtreefake.js
字号:
dhtmlXTreeObject.prototype.onRowClick2=function(){
if(this.parentObject.treeNod.dblclickFuncHandler)if(!this.parentObject.treeNod.dblclickFuncHandler(this.parentObject.id))return 0;
if((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
this.parentObject.treeNod.a15(this.parentObject);
else
this.parentObject.treeNod.a15(this.parentObject,2);
};
dhtmlXTreeObject.prototype.onRowClick=function(){
if(this.parentObject.treeNod.openFuncHandler)if(!this.parentObject.treeNod.openFuncHandler(this.parentObject.id,this.parentObject.treeNod.a9(this.parentObject)))return 0;
if((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
this.parentObject.treeNod.a15(this.parentObject);
else
this.parentObject.treeNod.a15(this.parentObject,2);
};
dhtmlXTreeObject.prototype.onRowSelect=function(e,htmlObject,mode){
if(!htmlObject)htmlObject=this;
htmlObject.childNodes[0].className="selectedTreeRow";
if(htmlObject.parentObject.scolor)htmlObject.parentObject.span.style.color=htmlObject.parentObject.scolor;
if((htmlObject.parentObject.treeNod.lastSelected)&&(htmlObject.parentObject.treeNod.lastSelected!=htmlObject))
{
htmlObject.parentObject.treeNod.lastSelected.childNodes[0].className="standartTreeRow";
if(htmlObject.parentObject.treeNod.lastSelected.parentObject.acolor)htmlObject.parentObject.treeNod.lastSelected.parentObject.span.style.color=htmlObject.parentObject.treeNod.lastSelected.parentObject.acolor;
}
htmlObject.parentObject.treeNod.lastSelected=htmlObject;
if(!mode){if(htmlObject.parentObject.actionHandler)htmlObject.parentObject.actionHandler(htmlObject.parentObject.id);}
};
dhtmlXTreeObject.prototype.a12=function(dhtmlObject){
if(!this.tscheck)return;
if(dhtmlObject.id==this.rootId)return;
var act=dhtmlObject.htmlNode.childNodes[0].childNodes;
var flag1=0;var flag2=0;
for(var i=1;i<act.length;i++)
if(act[i].nodem.checkstate==0)flag1=1;
else if(act[i].nodem.checkstate==1)flag2=1;
else{flag1=1;flag2=1;break;}
if((flag1)&&(flag2))this.a19(dhtmlObject,"notsure");
else if(flag1)this.a19(dhtmlObject,false);
else this.a19(dhtmlObject,true);
this.a12(dhtmlObject.parentObject);
}
dhtmlXTreeObject.prototype.onCheckBoxClick=function(e){
if(this.treeNod.tscheck)
if(this.parentObject.checkstate==1)this.treeNod.a31(false,this.parentObject);
else this.treeNod.a31(true,this.parentObject);
else
if(this.parentObject.checkstate==1)this.treeNod.a19(this.parentObject,false);
else this.treeNod.a19(this.parentObject,true);
this.treeNod.a12(this.parentObject.parentObject);
if(this.treeNod.checkFuncHandler)return(this.treeNod.checkFuncHandler(this.parentObject.id,this.parentObject.checkstate));
else return true;
};
dhtmlXTreeObject.prototype.a20=function(acheck,itemObject,mode){
var table=document.createElement('table');
table.cellSpacing=0;table.cellPadding=0;
table.border=0;
if(this.hfMode)table.style.tableLayout="fixed";
table.style.margin=0;table.style.padding=0;
var tbody=document.createElement('tbody');
var tr=document.createElement('tr');
var td1=document.createElement('td');
td1.className="standartTreeImage";
var img0=document.createElement("img");
img0.border="0";td1.appendChild(img0);img0.style.padding=0;img0.style.margin=0;
var td11=document.createElement('td');
var inp=document.createElement("img");inp.checked=0;inp.src=this.imPath+this.checkArray[0];inp.style.width="16px";inp.style.height="16px";
if(!acheck)inp.style.display="none";
td11.appendChild(inp);
inp.onclick=this.onCheckBoxClick;
inp.treeNod=this;
inp.parentObject=itemObject;
var td12=document.createElement('td');
td12.className="standartTreeImage";
var img=document.createElement("img");
img.border="0";
if(!mode)img.src=this.imPath+this.imageArray[0];
td12.appendChild(img);img.style.padding=0;img.style.margin=0;
img.style.width="18px";img.style.height="18px";
var td2=document.createElement('td');
td2.className="standartTreeRow";
td2.noWrap=true;
itemObject.span=document.createElement('span');
itemObject.span.className="standartTreeRow";
td2.style.width="100%";
itemObject.span.appendChild(document.createTextNode(itemObject.label));
td2.appendChild(itemObject.span);
td2.parentObject=itemObject;td1.parentObject=itemObject;
td2.onclick=this.onRowSelect;td1.onclick=this.onRowClick;td2.ondblclick=this.onRowClick2;
if(this.dragAndDropOff)this.dragger.addDraggableItem(td2,this);
itemObject.span.style.paddingLeft="5px";itemObject.span.style.paddinRight="5px";td2.style.verticalAlign="";
td2.style.fontSize="10pt";td2.style.cursor="pointer";
tr.appendChild(td1);tr.appendChild(td11);tr.appendChild(td12);
tr.appendChild(td2);
tbody.appendChild(tr);
table.appendChild(tbody);
return table;
};
dhtmlXTreeObject.prototype.setImagePath=function(newPath){this.imPath=newPath;};
dhtmlXTreeObject.prototype.setOnClickHandler=function(func){if(typeof(func)=="function")this.aFunc=func;else this.aFunc=eval(func);};
dhtmlXTreeObject.prototype.setXMLAutoLoading=function(filePath){this.XMLsource=filePath;};
dhtmlXTreeObject.prototype.setOnCheckHandler=function(func){if(typeof(func)=="function")this.checkFuncHandler=func;else this.checkFuncHandler=eval(func);};
dhtmlXTreeObject.prototype.setOnOpenHandler=function(func){if(typeof(func)=="function")this.openFuncHandler=func;else this.openFuncHandler=eval(func);};
dhtmlXTreeObject.prototype.setOnDblClickHandler=function(func){if(typeof(func)=="function")this.dblclickFuncHandler=func;else this.dblclickFuncHandler=eval(func);};
dhtmlXTreeObject.prototype.openAllItems=function(itemId)
{
var temp=this.a0Find(itemId);
if(!temp)return 0;
this.a16(temp);
};
dhtmlXTreeObject.prototype.closeAllItems=function(itemId)
{
if(this.rootId==itemId)return 0;
var temp=this.a0Find(itemId);
if(!temp)return 0;
this.a14(temp);
};
dhtmlXTreeObject.prototype.setUserData=function(itemId,name,value){
var sNode=this.a0Find(itemId);
if(!sNode)return;
if(name=="hint")sNode.htmlNode.childNodes[0].childNodes[0].title=value;
sNode[name]=value;
};
dhtmlXTreeObject.prototype.getUserData=function(itemId,name){
var sNode=this.a0Find(itemId);
if(!sNode)return;
return eval("sNode."+name);
};
dhtmlXTreeObject.prototype.getSelectedItemId=function()
{
if(this.lastSelected)
return this.lastSelected.parentObject.id;
else return("");
};
dhtmlXTreeObject.prototype.getItemColor=function(itemId)
{
var temp=this.a0Find(itemId);
if(!temp)return 0;
if(temp.acolor)return temp.acolor;
else return "";
};
dhtmlXTreeObject.prototype.setItemColor=function(itemId,defaultColor,selectedColor)
{
var temp=this.a0Find(itemId);
if(!temp)return 0;
else{
if((this.lastSelected)&&(temp.tr==this.lastSelected.parentObject.tr))
{if(selectedColor)temp.span.style.color=selectedColor;}
else
{if(defaultColor)temp.span.style.color=defaultColor;}
if(selectedColor)temp.scolor=selectedColor;
if(defaultColor)temp.acolor=defaultColor;
}
};
dhtmlXTreeObject.prototype.getItemText=function(itemId)
{
var temp=this.a0Find(itemId);
if(!temp)return 0;
return(temp.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML);
};
dhtmlXTreeObject.prototype.getParentId=function(itemId)
{
var temp=this.a0Find(itemId);
if((!temp)||(!temp.parentObject))return "";
return temp.parentObject.id;
};
dhtmlXTreeObject.prototype.changeItemId=function(itemId,newItemId)
{
var temp=this.a0Find(itemId);
if(!temp)return 0;
temp.id=newItemId;
for(var i=0;i<this.a0Size;i++)
if(this.a0[i]==itemId)
{
this.a0[i]=newItemId;
}
};
dhtmlXTreeObject.prototype.doCut=function(){
if(this.nodeCut)this.clearCut();
this.nodeCut=this.lastSelected;
if(this.nodeCut)
{
var tempa=this.nodeCut.parentObject;
this.cutImg[0]=tempa.images[0];
this.cutImg[1]=tempa.images[1];
this.cutImg[2]=tempa.images[2];
tempa.images[0]=tempa.images[1]=tempa.images[2]=this.cutImage;
this.a10(tempa);
}
};
dhtmlXTreeObject.prototype.doPaste=function(itemId){
var temp=this.a0Find(itemId);
if(!temp)return 0;
if(this.nodeCut){
if((!this.a21(this.nodeCut.parentObject.id,temp))&&(id!=this.nodeCut.parentObject.parentObject.id))
this.a22(temp,this.nodeCut.parentObject);
this.clearCut();
}
};
dhtmlXTreeObject.prototype.clearCut=function(){
if(this.nodeCut)
{
var tempa=this.nodeCut.parentObject;
tempa.images[0]=this.cutImg[0];
tempa.images[1]=this.cutImg[1];
tempa.images[2]=this.cutImg[2];
if(tempa.parentObject)this.a10(tempa);
if(tempa.parentObject)this.a11(tempa);
this.nodeCut=0;
}
};
dhtmlXTreeObject.prototype.a22=function(itemObject,targetObject){
if(this.dragFunc)if(!this.dragFunc(itemObject.id,targetObject.id))return;
if((targetObject.XMLload==0)&&(this.XMLsource))
{
this.saveParentObject=pNode.id;
targetObject.XMLload=1;this.loadXML(this.XMLsource+getUrlSymbol(this.XMLsource)+"id="+escape(pNode.id));
}
this.openItem(targetObject.id);
var oldTree=itemObject.treeNod;
var c=itemObject.parentObject.childsCount;
var z=itemObject.parentObject;
var Count=targetObject.childsCount;var Nodes=targetObject.childNodes;
Nodes[Count]=itemObject;
itemObject.treeNod=targetObject.treeNod;
targetObject.childsCount++;
var tr=this.a7(Nodes[Count].htmlNode);
targetObject.htmlNode.childNodes[0].appendChild(tr);
itemObject.parentObject.htmlNode.childNodes[0].removeChild(itemObject.tr);
for(var i=0;i<z.childsCount;i++)
if(z.childNodes[i].id==itemObject.itemId){
Nodes[i]=0;
break;}
oldTree.a28(z.childsCount,z.childNodes);
z.childsCount--;
itemObject.tr=tr;
tr.nodem=itemObject;
itemObject.parentObject=targetObject;
if(oldTree!=targetObject.treeNod){if(itemObject.treeNod.a25(itemObject,oldTree))return;this.a24(itemObject);};
if(c>1){oldTree.a10(z.childNodes[c-2]);
oldTree.a11(z.childNodes[c-2]);}
this.a10(targetObject);
this.a11(targetObject);
oldTree.a10(z);
this.a11(itemObject);
this.a10(Nodes[Count]);
if(targetObject.childsCount>=2)
{
this.a10(Nodes[targetObject.childsCount-2]);
this.a11(Nodes[targetObject.childsCount-2]);
}
if(this.tscheck)this.a12(targetObject);
if(oldTree.tscheck)oldTree.a12(z);
};
dhtmlXTreeObject.prototype.a21=function(itemId,htmlObject){
if(htmlObject.id==itemId)return 1;
if(htmlObject.parentObject)return this.a21(itemId,htmlObject.parentObject);else return 0;
};
dhtmlXTreeObject.prototype.a24=function(itemObject){
var td1=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[1];
var td3=td1.nextSibling.nextSibling;
if(this.checkBoxOff){td1.childNodes[0].style.display="";td1.childNodes[0].onclick=this.onCheckBoxClick;}
else td1.childNodes[0].style.display="none";
td1.childNodes[0].treeNod=this;
this.dragger.removeDraggableItem(td3);
if(this.dragAndDropOff)this.dragger.addDraggableItem(td3,this);
td3.childNodes[0].className="standartTreeRow";
td3.onclick=this.onRowSelect;td3.ondblclick=this.onRowClick2;
td1.previousSibling.onclick=this.onRowClick;
this.a11(itemObject);
this.a10(itemObject);
for(var i=0;i<itemObject.childsCount;i++)this.a24(itemObject.childNodes[i]);
};
dhtmlXTreeObject.prototype.a25=function(itemObject,oldTree){
itemObject.id=this.a0Add(itemObject.id,itemObject);
itemObject.treeNod=this;
if(oldTree)oldTree.a0Sub(itemObject.id);
for(var i=0;i<itemObject.childsCount;i++)
this.a25(itemObject.childNodes[i],oldTree);
return 0;
};
dhtmlXTreeObject.prototype.enableThreeStateCheckboxes=function(mode){this.tscheck=convertStringToBoolean(mode);};
dhtmlXTreeObject.prototype.enableFixedMode=function(mode){this.hfMode=convertStringToBoolean(mode);};
dhtmlXTreeObject.prototype.enableCheckBoxes=function(mode){this.checkBoxOff=convertStringToBoolean(mode);};
dhtmlXTreeObject.prototype.setStdimages=function(image1,image2,image3){
this.imageArray[0]=image1;this.imageArray[1]=image2;this.imageArray[2]=image3;};
dhtmlXTreeObject.prototype.enableTreeLines=function(mode){
this.treeLinesOn=convertStringToBoolean(mode);
}
dhtmlXTreeObject.prototype.setImageArrays=function(arrayName,image1,image2,image3,image4,image5){
switch(arrayName){
case "plus": this.plusArray[0]=image1;this.plusArray[1]=image2;this.plusArray[2]=image3;this.plusArray[3]=image4;this.plusArray[4]=image5;break;
case "minus": this.minusArray[0]=image1;this.minusArray[1]=image2;this.minusArray[2]=image3;this.minusArray[3]=image4;this.minusArray[4]=image5;break;
}
};
dhtmlXTreeObject.prototype.openItem=function(itemId){
var temp=this.a0Find(itemId);
if(!temp)return 0;
this.a15(temp,2);
if((temp.parentObject)&&(this.a9(temp.parentObject)<0))
this.openItem(temp.parentObject.id);
};
dhtmlXTreeObject.prototype.closeItem=function(itemId){
if(this.rootId==itemId)return 0;
var temp=this.a0Find(itemId);
if(!temp)return 0;
if(temp.closeble)
this.a15(temp,1);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -