⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhtmlxtree.js

📁 用js做的树 用js做的树 用js做的树
💻 JS
📖 第 1 页 / 共 5 页
字号:
 var j=sNode.childsCount;
 for(var i=0;i<j;i++)
{
 this._deleteNode(sNode.childNodes[0].id,sNode.childNodes[0]);
};
};

 
dhtmlXTreeObject.prototype.deleteItem=function(itemId,selectParent){
 if((!this._onrdlh)||(this._onrdlh(itemId))){
 var z=this._deleteItem(itemId,selectParent);

}

  this.allTree.childNodes[0].border = "1";
 this.allTree.childNodes[0].border = "0";
}
 
dhtmlXTreeObject.prototype._deleteItem=function(itemId,selectParent,skip){
 selectParent=convertStringToBoolean(selectParent);
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return;
 var pid=this.getParentId(itemId);
 if((selectParent)&&(pid!=this.rootId))this.selectItem(pid,1);
 else
 this._unselectItem(sNode);

 if(!skip)
 this._globalIdStorageRecSub(sNode);

 var zTemp=sNode.parentObject;
 this._deleteNode(itemId,sNode,skip);
 this._correctPlus(zTemp);
 this._correctLine(zTemp);
 return zTemp;
};

 
 dhtmlXTreeObject.prototype._globalIdStorageRecSub=function(itemObject){
 for(var i=0;i<itemObject.childsCount;i++)
{
 this._globalIdStorageRecSub(itemObject.childNodes[i]);
 this._globalIdStorageSub(itemObject.childNodes[i].id);
};
 this._globalIdStorageSub(itemObject.id);
};

 
 dhtmlXTreeObject.prototype.insertNewNext=function(itemId,newItemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs){
 var sNode=this._globalIdStorageFind(itemId);
 if((!sNode)||(!sNode.parentObject))return(0);

 var nodez=this._attachChildNode(0,newItemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,sNode);

 return nodez;
};


 
 
 dhtmlXTreeObject.prototype.getItemIdByIndex=function(itemId,index){
 var z=this._globalIdStorageFind(itemId);
 if((!z)||(index>z.childsCount))return null;
 return z.childNodes[index].id;
};

 
 dhtmlXTreeObject.prototype.getChildItemIdByIndex=function(itemId,index){
 var z=this._globalIdStorageFind(itemId);
 if((!z)||(index>=z.childsCount))return null;
 return z.childNodes[index].id;
};



 

 
 dhtmlXTreeObject.prototype.setDragHandler=function(func){if(typeof(func)=="function")this.dragFunc=func;else this.dragFunc=eval(func);};
 
 
 dhtmlXTreeObject.prototype._clearMove=function(){
 if(this._lastMark){
 this._lastMark.className=this._lastMark.className.replace(/dragAndDropRow/g,"");
 this._lastMark=null;
}

 this.allTree.className=this.allTree.className.replace(" selectionBox","");
};

 
 dhtmlXTreeObject.prototype.enableDragAndDrop=function(mode,rmode){
 if(mode=="temporary_disabled"){
 this.dADTempOff=false;
 mode=true;}
 else
 this.dADTempOff=true;

 this.dragAndDropOff=convertStringToBoolean(mode);
 if(this.dragAndDropOff)this.dragger.addDragLanding(this.allTree,this);
 if(arguments.length>1)
 this._ddronr=(!convertStringToBoolean(rmode));
};

 
 dhtmlXTreeObject.prototype._setMove=function(htmlNode,x,y){
 if(htmlNode.parentObject.span){
  var a1=getAbsoluteTop(htmlNode);
 var a2=getAbsoluteTop(this.allTree);

 this.dadmodec=this.dadmode; this.dadmodefix=0;


 var zN=htmlNode.parentObject.span;
 zN.className+=" dragAndDropRow";
 this._lastMark=zN;

 if(this.autoScroll)
{
  if((a1-a2-parseInt(this.allTree.scrollTop))>(parseInt(this.allTree.offsetHeight)-50))
 this.allTree.scrollTop=parseInt(this.allTree.scrollTop)+20;
  if((a1-a2)<(parseInt(this.allTree.scrollTop)+30))
 this.allTree.scrollTop=parseInt(this.allTree.scrollTop)-20;
}
}
};



 
dhtmlXTreeObject.prototype._createDragNode=function(htmlObject,e){
 if(!this.dADTempOff)return null;

 var obj=htmlObject.parentObject;
 if(!obj.i_sel)
 this._selectItem(obj,e);


 var dragSpan=document.createElement('div');

 var text=new Array();
 if(this._itim_dg)
 for(var i=0;i<this._selected.length;i++)
 text[i]="<table cellspacing='0' cellpadding='0'><tr><td><img width='18px' height='18px' src='"+this._selected[i].span.parentNode.previousSibling.childNodes[0].src+"'></td><td>"+this._selected[i].span.innerHTML+"</td></tr><table>";
 else
 text=this.getSelectedItemText().split(this.dlmtr);

 dragSpan.innerHTML=text.join("");
 dragSpan.style.position="absolute";
 dragSpan.className="dragSpanDiv";
 this._dragged=(new Array()).concat(this._selected);
 return dragSpan;
}



 
dhtmlXTreeObject.prototype._focusNode=function(item){
 var z=getAbsoluteTop(item.htmlNode)-getAbsoluteTop(this.allTree);
 if((z>(this.allTree.scrollTop+this.allTree.offsetHeight-30))||(z<this.allTree.scrollTop))
 this.allTree.scrollTop=z;
};




 








 
dhtmlXTreeObject.prototype._preventNsDrag=function(e){
 if((e)&&(e.preventDefault)){e.preventDefault();return false;}
 return false;
}

dhtmlXTreeObject.prototype._drag=function(sourceHtmlObject,dhtmlObject,targetHtmlObject){

 if(this._autoOpenTimer)clearTimeout(this._autoOpenTimer);

 if(!targetHtmlObject.parentObject){
 targetHtmlObject=this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
 this.dadmodec=0;
}

 this._clearMove();
 var z=sourceHtmlObject.parentObject.treeNod;
 if((z)&&(z._clearMove))z._clearMove("");

 if((!this.dragMove)||(this.dragMove()))
{
 if((!z)||(!z._clearMove)||(!z._dragged))var col=new Array(sourceHtmlObject.parentObject);
 else var col=z._dragged;

 for(var i=0;i<col.length;i++){
 var newID=this._moveNode(col[i],targetHtmlObject.parentObject);

 if((newID)&&(!this._sADnD))this.selectItem(newID,0,1);
}

}
 if(z)z._dragged=new Array();


}

dhtmlXTreeObject.prototype._dragIn=function(htmlObject,shtmlObject,x,y){

 if(!this.dADTempOff)return 0;
 var fobj=shtmlObject.parentObject;
 var tobj=htmlObject.parentObject;
 if((!tobj)&&(this._ddronr))return;
 if((this._onDrInFunc)&&(!this._onDrInFunc(fobj.id,tobj?tobj.id:null,fobj.treeNod,this)))
 return 0;


 if(!tobj)
 this.allTree.className+=" selectionBox";
 else
{
 if(fobj.childNodes==null){
 this._setMove(htmlObject,x,y);
 return htmlObject;
}

 var stree=fobj.treeNod;
 for(var i=0;i<stree._dragged.length;i++)
 if(this._checkPNodes(tobj,stree._dragged[i]))
 return 0;

 this._setMove(htmlObject,x,y);
 if(this._getOpenState(tobj)<=0){
 this._autoOpenId=tobj.id;
 this._autoOpenTimer=window.setTimeout(new callerFunction(this._autoOpenItem,this),1000);
}
}

 return htmlObject;

}
dhtmlXTreeObject.prototype._autoOpenItem=function(e,treeObject){
 treeObject.openItem(treeObject._autoOpenId);
};
dhtmlXTreeObject.prototype._dragOut=function(htmlObject){
this._clearMove();
if(this._autoOpenTimer)clearTimeout(this._autoOpenTimer);
}












 
 dhtmlXTreeObject.prototype._loadDynXML=function(id,src){
 src=src||this.XMLsource;
 var sn=(new Date()).valueOf();
 this._ld_id=id;

 this.loadXML(src+getUrlSymbol(src)+"uid="+sn+"&id="+this._escape(id));
};







 
 dhtmlXTreeObject.prototype._checkPNodes=function(item1,item2){
 if(item2==item1)return 1
 if(item1.parentObject)return this._checkPNodes(item1.parentObject,item2);else return 0;
};










 
dhtmlXTreeObject.prototype.preventIECashing=function(mode){
 this.no_cashe = convertStringToBoolean(mode);
 this.XMLLoader.rSeed=this.no_cashe;
}



 


 
 dhtmlXTreeObject.prototype.setEscapingMode=function(mode){
 this.utfesc=mode;
}


 
 dhtmlXTreeObject.prototype.enableHighlighting=function(mode){this.ehlt=true;this.ehlta=convertStringToBoolean(mode);};

 
 dhtmlXTreeObject.prototype._itemMouseOut=function(){
 var that=this.childNodes[3].parentObject;
 var tree=that.treeNod;
 if(tree._onMSO)that.treeNod._onMSO(that.id);
 if(that.id==tree._l_onMSI)tree._l_onMSI=null;
 if(!tree.ehlt)return;
 that.span.className=that.span.className.replace("_lor","");
}
 
 dhtmlXTreeObject.prototype._itemMouseIn=function(){
 var that=this.childNodes[3].parentObject;
 var tree=that.treeNod;

 if((tree._onMSI)&&(tree._l_onMSI!=that.id))tree._onMSI(that.id);
 tree._l_onMSI=that.id;
 if(!tree.ehlt)return;
 that.span.className=that.span.className.replace("_lor","");
 that.span.className=that.span.className.replace(/((standart|selected)TreeRow)/,"$1_lor");
}

 
 dhtmlXTreeObject.prototype.enableActiveImages=function(mode){this._aimgs=convertStringToBoolean(mode);};

 
dhtmlXTreeObject.prototype.focusItem=function(itemId){
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return(0);
 this._focusNode(sNode);
};


 
 dhtmlXTreeObject.prototype.getAllSubItems =function(itemId){
 return this._getAllSubItems(itemId);
}

 
 dhtmlXTreeObject.prototype.getAllChildless =function(){
 return this._getAllScraggyItems(this.htmlNode);
}
 dhtmlXTreeObject.prototype.getAllLeafs=dhtmlXTreeObject.prototype.getAllChildless;


 
 dhtmlXTreeObject.prototype._getAllScraggyItems =function(node)
{
 var z="";
 for(var i=0;i<node.childsCount;i++)
{
 if((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
{
 if(node.childNodes[i].unParsed)
 var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);
 else
 var zb=this._getAllScraggyItems(node.childNodes[i])

 if(zb)
 if(z)z+=this.dlmtr+zb;
 else z=zb;
}
 else
 if(!z)z=node.childNodes[i].id;
 else z+=this.dlmtr+node.childNodes[i].id;
}
 return z;
};





 
 dhtmlXTreeObject.prototype._getAllFatItems =function(node)
{
 var z="";
 for(var i=0;i<node.childsCount;i++)
{
 if((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
{
 if(!z)z=node.childNodes[i].id;
 else z+=this.dlmtr+node.childNodes[i].id;

 if(node.childNodes[i].unParsed)
 var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);
 else
 var zb=this._getAllFatItems(node.childNodes[i])

 if(zb)z+=this.dlmtr+zb;
}
}
 return z;
};

 
 dhtmlXTreeObject.prototype.getAllItemsWithKids =function(){
 return this._getAllFatItems(this.htmlNode);
}
 dhtmlXTreeObject.prototype.getAllFatItems=dhtmlXTreeObject.prototype.getAllItemsWithKids;



 
 dhtmlXTreeObject.prototype.getAllChecked=function(){
 return this._getAllChecked("","",1);
}
 
 dhtmlXTreeObject.prototype.getAllUnchecked=function(itemId){
 if(itemId)
 itemId=this._globalIdStorageFind(itemId);
 return this._getAllChecked(itemId,"",0);
}


 
 dhtmlXTreeObject.prototype.getAllPartiallyChecked=function(){
 return this._getAllChecked("","",2);
}


 
 dhtmlXTreeObject.prototype.getAllCheckedBranches=function(){
 var temp= this._getAllChecked("","",1);
 if(temp!="")temp+=this.dlmtr;
 return temp+this._getAllChecked("","",2);
}

 
 dhtmlXTreeObject.prototype._getAllChecked=function(htmlNode,list,mode){
 if(!htmlNode)htmlNode=this.htmlNode;

 if(htmlNode.checkstate==mode)
 if(!htmlNode.nocheckbox){if(list)list+=this.dlmtr+htmlNode.id;else list=htmlNode.id;}
 var j=htmlNode.childsCount;
 for(var i=0;i<j;i++)
{
 list=this._getAllChecked(htmlNode.childNodes[i],list,mode);
};


 if(list)return list;else return "";
};

 
dhtmlXTreeObject.prototype.setItemStyle=function(itemId,style_string){
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 if(!temp.span.style.cssText)
 temp.span.setAttribute("style",temp.span.getAttribute("style")+";"+style_string);
 else
 temp.span.style.cssText+=(";"+style_string);
}

 
dhtmlXTreeObject.prototype.enableImageDrag=function(mode){
 this._itim_dg=convertStringToBoolean(mode);
}

 
 dhtmlXTreeObject.prototype.setOnDragIn=function(func){
 if(typeof(func)=="function")this._onDrInFunc=func;else this._onDrInFunc=eval(func);
};

 
 dhtmlXTreeObject.prototype.enableDragAndDropScrolling=function(mode){this.autoScroll=convertStringToBoolean(mode);};

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -