📄 dhtmlxtree.js
字号:
itemObject.parentObject.htmlNode.childNodes[0].removeChild(itemObject.tr);if ((!beforeNode)||(targetObject!=itemObject.parentObject)){for (var i=0;i<z.childsCount;i++){if (z.childNodes[i].id==itemObject.id){z.childNodes[i]=0;break}}}else z.childNodes[z.childsCount-1]=0;oldTree._compressChildList(z.childsCount,z.childNodes);z.childsCount--};if ((!framesMove)&&(!oldTree.dpcpy)) {itemObject.tr=tr;tr.nodem=itemObject;itemObject.parentObject=targetObject;if (oldTree!=targetObject.treeNod){if(itemObject.treeNod._registerBranch(itemObject,oldTree)) return;this._clearStyles(itemObject);this._redrawFrom(this,itemObject.parentObject)};this._correctPlus(targetObject);this._correctLine(targetObject);this._correctLine(itemObject);this._correctPlus(itemObject);if (beforeNode){this._correctPlus(beforeNode)}else
if (targetObject.childsCount>=2){this._correctPlus(Nodes[targetObject.childsCount-2]);this._correctLine(Nodes[targetObject.childsCount-2])};this._correctPlus(Nodes[targetObject.childsCount-1]);if (this.tscheck)this._correctCheckStates(targetObject);if (oldTree.tscheck)oldTree._correctCheckStates(z)};if (c>1){oldTree._correctPlus(z.childNodes[c-2]);oldTree._correctLine(z.childNodes[c-2])};oldTree._correctPlus(z);oldTree._correctLine(z);this.callEvent("onDrop",[itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),oldTree,targetObject.treeNod]);return itemObject.id};dhtmlXTreeObject.prototype._clearStyles=function(itemObject){var td1=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[1];var td3=td1.nextSibling.nextSibling;itemObject.span.innerHTML=itemObject.label;itemObject.i_sel=false;if (itemObject._aimgs)this.dragger.removeDraggableItem(td1.nextSibling);if (this.checkBoxOff){td1.childNodes[0].style.display="";td1.childNodes[0].onclick=this.onCheckBoxClick;this._setSrc(td1.childNodes[0],this.imPath+this.checkArray[itemObject.checkstate])}else td1.childNodes[0].style.display="none";td1.childNodes[0].treeNod=this;this.dragger.removeDraggableItem(td3);if (this.dragAndDropOff)this.dragger.addDraggableItem(td3,this);if (this._aimgs)this.dragger.addDraggableItem(td1.nextSibling,this);td3.childNodes[0].className="standartTreeRow";td3.onclick=this.onRowSelect;td3.ondblclick=this.onRowClick2;td1.previousSibling.onclick=this.onRowClick;this._correctLine(itemObject);this._correctPlus(itemObject);for (var i=0;i<itemObject.childsCount;i++)this._clearStyles(itemObject.childNodes[i])};dhtmlXTreeObject.prototype._registerBranch=function(itemObject,oldTree){if (oldTree)oldTree._globalIdStorageSub(itemObject.id);itemObject.id=this._globalIdStorageAdd(itemObject.id,itemObject);itemObject.treeNod=this;for (var i=0;i<itemObject.childsCount;i++)this._registerBranch(itemObject.childNodes[i],oldTree);return 0};dhtmlXTreeObject.prototype.enableThreeStateCheckboxes=function(mode) {this.tscheck=convertStringToBoolean(mode)};dhtmlXTreeObject.prototype.setOnMouseInHandler=function(func){this.ehlt=true;this.attachEvent("onMouseIn",func)};dhtmlXTreeObject.prototype.setOnMouseOutHandler=function(func){this.ehlt=true;this.attachEvent("onMouseOut",func)};dhtmlXTreeObject.prototype.enableTreeImages=function(mode) {this.timgen=convertStringToBoolean(mode)};dhtmlXTreeObject.prototype.enableFixedMode=function(mode) {this.hfMode=convertStringToBoolean(mode)};dhtmlXTreeObject.prototype.enableCheckBoxes=function(mode, hidden){this.checkBoxOff=convertStringToBoolean(mode);this.cBROf=(!(this.checkBoxOff||convertStringToBoolean(hidden)))};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._globalIdStorageFind(itemId);if (!temp)return 0;else return this._openItem(temp)};dhtmlXTreeObject.prototype._openItem=function(item){var state=this._getOpenState(item);if ((state<0)||(((this.XMLsource)&&(!item.XMLload)))){if (!this.callEvent("onOpenStart",[item.id,state])) return 0;this._HideShow(item,2);if (this.checkEvent("onOpenEnd")){if (this.onXLE==this._epnFHe)this._epnFHe(this,item.id,true);if (!this.xmlstate || !this.XMLsource)this.callEvent("onOpenEnd",[item.id,this._getOpenState(item)]);else{this._oie_onXLE.push(this.onXLE);this.onXLE=this._epnFHe}}};if (item.parentObject)this._openItem(item.parentObject)};dhtmlXTreeObject.prototype.closeItem=function(itemId){if (this.rootId==itemId)return 0;var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;if (temp.closeble)this._HideShow(temp,1)};dhtmlXTreeObject.prototype.getLevel=function(itemId){var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;return this._getNodeLevel(temp,0)};dhtmlXTreeObject.prototype.setItemCloseable=function(itemId,flag)
{flag=convertStringToBoolean(flag);if ((itemId)&&(itemId.span))
var temp=itemId;else
var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;temp.closeble=flag};dhtmlXTreeObject.prototype._getNodeLevel=function(itemObject,count){if (itemObject.parentObject)return this._getNodeLevel(itemObject.parentObject,count+1);return(count)};dhtmlXTreeObject.prototype.hasChildren=function(itemId){var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;else
{if ( (this.XMLsource)&&(!temp.XMLload) ) return true;else
return temp.childsCount}};dhtmlXTreeObject.prototype._getLeafCount=function(itemNode){var a=0;for (var b=0;b<itemNode.childsCount;b++)if (itemNode.childNodes[b].childsCount==0)a++;return a};dhtmlXTreeObject.prototype.setItemText=function(itemId,newLabel,newTooltip)
{var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;temp.label=newLabel;temp.span.innerHTML=newLabel;temp.span.parentNode.parentNode.title=newTooltip||""};dhtmlXTreeObject.prototype.getItemTooltip=function(itemId){var temp=this._globalIdStorageFind(itemId);if (!temp)return "";return (temp.span.parentNode.parentNode._dhx_title||temp.span.parentNode.parentNode.title||"")};dhtmlXTreeObject.prototype.refreshItem=function(itemId){if (!itemId)itemId=this.rootId;var temp=this._globalIdStorageFind(itemId);this.deleteChildItems(itemId);this._loadDynXML(itemId)};dhtmlXTreeObject.prototype.setItemImage2=function(itemId, image1,image2,image3){var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;temp.images[1]=image2;temp.images[2]=image3;temp.images[0]=image1;this._correctPlus(temp)};dhtmlXTreeObject.prototype.setItemImage=function(itemId,image1,image2)
{var temp=this._globalIdStorageFind(itemId);if (!temp)return 0;if (image2){temp.images[1]=image1;temp.images[2]=image2}else temp.images[0]=image1;this._correctPlus(temp)};dhtmlXTreeObject.prototype.getSubItems =function(itemId)
{var temp=this._globalIdStorageFind(itemId,0,1);if (!temp)return 0;var z="";for (i=0;i<temp.childsCount;i++){if (!z)z=temp.childNodes[i].id;else z+=this.dlmtr+temp.childNodes[i].id};return z};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._getAllSubItems =function(itemId,z,node)
{if (node)temp=node;else {var temp=this._globalIdStorageFind(itemId)};if (!temp)return 0;z="";for (var i=0;i<temp.childsCount;i++){if (!z)z=temp.childNodes[i].id;else z+=this.dlmtr+temp.childNodes[i].id;var zb=this._getAllSubItems(0,z,temp.childNodes[i])
if (zb)z+=this.dlmtr+zb};return z};dhtmlXTreeObject.prototype.selectItem=function(itemId,mode,preserve){mode=convertStringToBoolean(mode);var temp=this._globalIdStorageFind(itemId);if ((!temp)||(!temp.parentObject)) return 0;if (this.XMLloadingWarning)temp.parentObject.openMe=1;else
this._openItem(temp.parentObject);var ze=null;if (preserve){ze=new Object;ze.ctrlKey=true;if (temp.i_sel)ze.skipUnSel=true};if (mode)this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],false);else
this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],true)};dhtmlXTreeObject.prototype.getSelectedItemText=function()
{var str=new Array();for (var i=0;i<this._selected.length;i++)str[i]=this._selected[i].span.innerHTML;return (str.join(this.dlmtr))};dhtmlXTreeObject.prototype._compressChildList=function(Count,Nodes)
{Count--;for (var i=0;i<Count;i++){if (Nodes[i]==0){Nodes[i]=Nodes[i+1];Nodes[i+1]=0}}};dhtmlXTreeObject.prototype._deleteNode=function(itemId,htmlObject,skip){if ((!htmlObject)||(!htmlObject.parentObject)) return 0;var tempos=0;var tempos2=0;if (htmlObject.tr.nextSibling)tempos=htmlObject.tr.nextSibling.nodem;if (htmlObject.tr.previousSibling)tempos2=htmlObject.tr.previousSibling.nodem;var sN=htmlObject.parentObject;var Count=sN.childsCount;var Nodes=sN.childNodes;for (var i=0;i<Count;i++){if (Nodes[i].id==itemId){if (!skip)sN.htmlNode.childNodes[0].removeChild(Nodes[i].tr);Nodes[i]=0;break}};this._compressChildList(Count,Nodes);if (!skip){sN.childsCount--};if (tempos){this._correctPlus(tempos);this._correctLine(tempos)};if (tempos2){this._correctPlus(tempos2);this._correctLine(tempos2)};if (this.tscheck)this._correctCheckStates(sN);if (!skip){this._globalIdStorageRecSub(htmlObject)}};dhtmlXTreeObject.prototype.setCheck=function(itemId,state){var sNode=this._globalIdStorageFind(itemId,0,1);if (!sNode)return;if (state==="unsure")this._setCheck(sNode,state);else
{state=convertStringToBoolean(state);if ((this.tscheck)&&(this.smcheck)) this._setSubChecked(state,sNode);else this._setCheck(sNode,state)};if (this.smcheck)this._correctCheckStates(sNode.parentObject)};dhtmlXTreeObject.prototype._setCheck=function(sNode,state){if (!sNode)return;if (((sNode.parentObject._r_logic)||(this._frbtr))&&(state))
if (this._frbtrs){if (this._frbtrL)this._setCheck(this._frbtrL,0);this._frbtrL=sNode}else
for (var i=0;i<sNode.parentObject.childsCount;i++)this._setCheck(sNode.parentObject.childNodes[i],0);var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];if (state=="unsure")sNode.checkstate=2;else if (state)sNode.checkstate=1;else sNode.checkstate=0;if (sNode.dscheck)sNode.checkstate=sNode.dscheck;this._setSrc(z,this.imPath+((sNode.parentObject._r_logic||this._frbtr)?this.radioArray:this.checkArray)[sNode.checkstate])};dhtmlXTreeObject.prototype.setSubChecked=function(itemId,state){var sNode=this._globalIdStorageFind(itemId);this._setSubChecked(state,sNode);this._correctCheckStates(sNode.parentObject)};dhtmlXTreeObject.prototype._setSubChecked=function(state,sNode){state=convertStringToBoolean(state);if (!sNode)return;if (((sNode.parentObject._r_logic)||(this._frbtr))&&(state))
for (var i=0;i<sNode.parentObject.childsCount;i++)this._setSubChecked(0,sNode.parentObject.childNodes[i]);if (sNode._r_logic||this._frbtr)this._setSubChecked(state,sNode.childNodes[0]);else
for (var i=0;i<sNode.childsCount;i++){this._setSubChecked(state,sNode.childNodes[i])};var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];if (state)sNode.checkstate=1;else sNode.checkstate=0;if (sNode.dscheck)sNode.checkstate=sNode.dscheck;this._setSrc(z,this.imPath+((sNode.parentObject._r_logic||this._frbtr)?this.radioArray:this.checkArray)[sNode.checkstate])};dhtmlXTreeObject.prototype.isItemChecked=function(itemId){var sNode=this._globalIdStorageFind(itemId);if (!sNode)return;return sNode.checkstate};dhtmlXTreeObject.prototype.deleteChildItems=function(itemId)
{var sNode=this._globalIdStorageFind(itemId);if (!sNode)return;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);var zTemp=sNode.parentObject;this._deleteNode(itemId,sNode,skip);this._correctPlus(zTemp);this._correctLine(zTemp);if ((selectParent)&&(pid!=this.rootId)) this.selectItem(pid,1);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);var z=itemObject;z.span=null;z.tr.nodem=null;z.tr=null;z.htmlNode=null};dhtmlXTreeObject.prototype.insertNewNext=function(itemId,newItemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){var sNode=this._globalIdStorageFind(itemId);if ((!sNode)||(!sNode.parentObject)) return (0);var nodez=this._attachChildNode(0,newItemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children,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){this.attachEvent("onDrag",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}};dhtmlXTreeObject.prototype._autoScroll=function(node,a1,a2){if (this.autoScroll){if (node){a1=getAbsoluteTop(node);a2=getAbsoluteTop(this.allTree)};if ( (a1-a2-parseInt(this.allTree.scrollTop))>(parseInt(this.allTree.offsetHeight)-50) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -