📄 dhtmlxtree.js
字号:
var newNode=dhtmlObject.updateItem(cId,name,im0,im1,im2,achecked);else{if (npl==0)zST+=",TOP";else preNode=temp.childNodes[npl];var newNode=dhtmlObject._attachChildNode(temp,cId,name,0,im0,im1,im2,zST,chd,0,preNode);preNode=null;};}else
var newNode=dhtmlObject._attachChildNode(temp,cId,name,0,im0,im1,im2,zST,chd,0,preNode);if (tooltip)newNode.span.parentNode.parentNode.title=tooltip;if (style)if (newNode.span.style.cssText)newNode.span.style.cssText+=(";"+style);else
newNode.span.setAttribute("style",newNode.span.getAttribute("style")+";"+style);if (aradio)newNode._r_logic=true;if (nocheckbox){newNode.span.parentNode.previousSibling.previousSibling.childNodes[0].style.display='none';newNode.nocheckbox=true;};if (disheckbox){if (achecked!=null)dhtmlObject._setCheck(newNode,convertStringToBoolean(achecked));dhtmlObject.disableCheckbox(newNode,1);};newNode._acc=chd||0;if (dhtmlObject.parserExtension)dhtmlObject.parserExtension._parseExtension(node.childNodes[i],dhtmlObject.parserExtension,cId,parentId);dhtmlObject.setItemColor(newNode,aColor,sColor);if (locked=="1")dhtmlObject._lockItem(newNode,true,true);if ((imw)||(imh)) dhtmlObject.setIconSize(imw,imh,newNode);if ((closeable=="0")||(closeable=="1")) dhtmlObject.setItemCloseable(newNode,closeable);var zcall="";if (topoffset)dhtmlObject.setItemTopOffset(newNode,topoffset);if ((!dhtmlObject.slowParse)&&(!dhtmlObject.waitUpdateXML))
zcall=dhtmlObject._parseXMLTree(dhtmlObject,node.childNodes[i],cId,1,xml_obj);if (zcall!="")nodeAskingCall=zcall;npl++;}else
dhtmlObject.checkUserData(node.childNodes[i],parentId);};if (!level){if (dhtmlObject.waitUpdateXML){dhtmlObject.waitUpdateXML=false;for (var i=temp.childsCount-1;i>=0;i--)if (temp.childNodes[i]._dmark)dhtmlObject.deleteItem(temp.childNodes[i].id);};var parsedNodeTop=dhtmlObject._globalIdStorageFind(dhtmlObject.parsingOn);for (var i=0;i<dhtmlObject.parsedArray.length;i++)parsedNodeTop.htmlNode.childNodes[0].appendChild(dhtmlObject.parsedArray[i]);dhtmlObject.lastLoadedXMLId=parentId;dhtmlObject.XMLloadingWarning=0;var chArr=dhtmlObject.setCheckList.split(dhtmlObject.dlmtr);for (var n=0;n<chArr.length;n++)if (chArr[n])dhtmlObject.setCheck(chArr[n],1);if ((dhtmlObject.XMLsource)&&(dhtmlObject.tscheck)&&(dhtmlObject.smcheck)&&(temp.id!=dhtmlObject.rootId)){if (temp.checkstate===0)dhtmlObject._setSubChecked(0,temp);else if (temp.checkstate===1)dhtmlObject._setSubChecked(1,temp);};if(navigator.appVersion.indexOf("MSIE")!=-1 && navigator.appVersion.indexOf("5.5")!=-1){window.setTimeout(function(){dhtmlObject._redrawFrom(dhtmlObject,null,start)},10);}else{dhtmlObject._redrawFrom(dhtmlObject,null,start)
};if (nodeAskingCall!="")dhtmlObject.selectItem(nodeAskingCall,true);if (dhtmlObject._branchUpdate)dhtmlObject._branchUpdateNext(node);};if (dhtmlObject.parsCount==1){dhtmlObject.parsingOn=null;if ((!dhtmlObject._edsbps)||(!dhtmlObject._edsbpsA.length)){window.setTimeout( function(){if (dhtmlObject.onXLE)dhtmlObject.onXLE(dhtmlObject,parentId);dhtmlObject.callEvent("onXLE",[dhtmlObject,parentId]);},1);dhtmlObject.xmlstate=0;};dhtmlObject.skipLock=false;};dhtmlObject.parsCount--;if ((dhtmlObject._epgps)&&(start))
this._setPrevPageSign(temp,(start||0),level,node);return nodeAskingCall;};dhtmlXTreeObject.prototype._branchUpdateNext=function(node){var items=this.XMLLoader.doXPath("./item",node);for (var i=0;i<items.length;i++){this._branchUpdate++;this.smartRefreshItem(items[i].getAttribute("id"),items[i]);};this._branchUpdate--;};dhtmlXTreeObject.prototype.checkUserData=function(node,parentId){if ((node.nodeType==1)&&(node.tagName == "userdata"))
{var name=node.getAttribute("name");if ((name)&&(node.childNodes[0]))
this.setUserData(parentId,name,node.childNodes[0].data);};};dhtmlXTreeObject.prototype._redrawFrom=function(dhtmlObject,itemObject,start,visMode){if (!itemObject){var tempx=dhtmlObject._globalIdStorageFind(dhtmlObject.lastLoadedXMLId);dhtmlObject.lastLoadedXMLId=-1;if (!tempx)return 0;}else tempx=itemObject;var acc=0;for (var i=(start?start-1:0);i<tempx.childsCount;i++)
{if ((!this._branchUpdate)||(this._getOpenState(tempx)==1))
if ((!itemObject)||(visMode==1)) tempx.childNodes[i].htmlNode.parentNode.parentNode.style.display="";if (tempx.childNodes[i].openMe==1){this._openItem(tempx.childNodes[i]);tempx.childNodes[i].openMe=0;};dhtmlObject._redrawFrom(dhtmlObject,tempx.childNodes[i]);};if ((!tempx.unParsed)&&((tempx.XMLload)||(!this.XMLsource)))
tempx._acc=acc;dhtmlObject._correctLine(tempx);dhtmlObject._correctPlus(tempx);};dhtmlXTreeObject.prototype._createSelf=function(){var div=document.createElement('div');div.className="containerTableStyle";div.style.width=this.width;div.style.height=this.height;this.parentObject.appendChild(div);return div;};dhtmlXTreeObject.prototype._xcloseAll=function(itemObject)
{if (itemObject.unParsed)return;if (this.rootId!=itemObject.id){var Nodes=itemObject.htmlNode.childNodes[0].childNodes;var Count=Nodes.length;for (var i=1;i<Count;i++)Nodes[i].style.display="none";this._correctPlus(itemObject);};for (var i=0;i<itemObject.childsCount;i++)if (itemObject.childNodes[i].childsCount)this._xcloseAll(itemObject.childNodes[i]);};dhtmlXTreeObject.prototype._xopenAll=function(itemObject)
{this._HideShow(itemObject,2);for (var i=0;i<itemObject.childsCount;i++)this._xopenAll(itemObject.childNodes[i]);};dhtmlXTreeObject.prototype._correctPlus=function(itemObject){var imsrc=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[0].lastChild;var imsrc2=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[2].childNodes[0];var workArray=this.lineArray;if ((this.XMLsource)&&(!itemObject.XMLload))
{var workArray=this.plusArray;this._setSrc(imsrc2,this.imPath+itemObject.images[2]);if (this._txtimg)return (imsrc.innerHTML="[+]");}else
if ((itemObject.childsCount)||(itemObject.unParsed))
{if ((itemObject.htmlNode.childNodes[0].childNodes[1])&&( itemObject.htmlNode.childNodes[0].childNodes[1].style.display!="none" ))
{if (!itemObject.wsign)var workArray=this.minusArray;this._setSrc(imsrc2,this.imPath+itemObject.images[1]);if (this._txtimg)return (imsrc.innerHTML="[-]");}else
{if (!itemObject.wsign)var workArray=this.plusArray;this._setSrc(imsrc2,this.imPath+itemObject.images[2]);if (this._txtimg)return (imsrc.innerHTML="[+]");};}else
{this._setSrc(imsrc2,this.imPath+itemObject.images[0]);};var tempNum=2;if (!itemObject.treeNod.treeLinesOn)this._setSrc(imsrc,this.imPath+workArray[3]);else {if (itemObject.parentObject)tempNum=this._getCountStatus(itemObject.id,itemObject.parentObject);this._setSrc(imsrc,this.imPath+workArray[tempNum]);};};dhtmlXTreeObject.prototype._correctLine=function(itemObject){var sNode=itemObject.parentObject;if (sNode)if ((this._getLineStatus(itemObject.id,sNode)==0)||(!this.treeLinesOn))
for(var i=1;i<=itemObject.childsCount;i++){itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundImage="";itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundRepeat="";}else
for(var i=1;i<=itemObject.childsCount;i++){itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundImage="url("+this.imPath+this.lineArray[5]+")";itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundRepeat="repeat-y";};};dhtmlXTreeObject.prototype._getCountStatus=function(itemId,itemObject){if (itemObject.childsCount<=1){if (itemObject.id==this.rootId)return 4;else return 0;};if (itemObject.childNodes[0].id==itemId)if (!itemObject.id)return 2;else return 1;if (itemObject.childNodes[itemObject.childsCount-1].id==itemId)return 0;return 1;};dhtmlXTreeObject.prototype._getLineStatus =function(itemId,itemObject){if (itemObject.childNodes[itemObject.childsCount-1].id==itemId)return 0;return 1;};dhtmlXTreeObject.prototype._HideShow=function(itemObject,mode){if ((this.XMLsource)&&(!itemObject.XMLload)) {if (mode==1)return;itemObject.XMLload=1;this._loadDynXML(itemObject.id);return;};var Nodes=itemObject.htmlNode.childNodes[0].childNodes;var Count=Nodes.length;if (Count>1){if ( ( (Nodes[1].style.display!="none")|| (mode==1) ) && (mode!=2) ) {this.allTree.childNodes[0].border = "1";this.allTree.childNodes[0].border = "0";nodestyle="none";}else nodestyle="";for (var i=1;i<Count;i++)Nodes[i].style.display=nodestyle;};this._correctPlus(itemObject);};dhtmlXTreeObject.prototype._getOpenState=function(itemObject){var z=itemObject.htmlNode.childNodes[0].childNodes;if (z.length<=1)return 0;if (z[1].style.display!="none")return 1;else return -1;};dhtmlXTreeObject.prototype.onRowClick2=function(){var that=this.parentObject.treeNod;if (!that.callEvent("onDblClick",[this.parentObject.id,that])) return 0;if ((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
that._HideShow(this.parentObject);else
that._HideShow(this.parentObject,2);if (that.checkEvent("onOpenEnd"))
if (!that.xmlstate)that.callEvent("onOpenEnd",[this.parentObject.id,that._getOpenState(this.parentObject)]);else{that._oie_onXLE=that.onXLE;that.onXLE=that._epnFHe;};};dhtmlXTreeObject.prototype.onRowClick=function(){var that=this.parentObject.treeNod;if (!that.callEvent("onOpenStart",[this.parentObject.id,that._getOpenState(this.parentObject)])) return 0;if ((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
that._HideShow(this.parentObject);else
that._HideShow(this.parentObject,2);if (that.checkEvent("onOpenEnd"))
if (!that.xmlstate)that.callEvent("onOpenEnd",[this.parentObject.id,that._getOpenState(this.parentObject)]);else{that._oie_onXLE=that.onXLE;that.onXLE=that._epnFHe;};};dhtmlXTreeObject.prototype._epnFHe=function(that,id,flag){if (id!=this.rootId)this.callEvent("onOpenEnd",[id,that.getOpenState(id)]);that.onXLE=that._oie_onXLE;if (!flag)if (that.onXLE)that.onXLE(that,id);};dhtmlXTreeObject.prototype.onRowClickDown=function(e){e=e||window.event;var that=this.parentObject.treeNod;that._selectItem(this.parentObject,e);};dhtmlXTreeObject.prototype.getSelectedItemId=function()
{var str=new Array();for (var i=0;i<this._selected.length;i++)str[i]=this._selected[i].id;return (str.join(this.dlmtr));};dhtmlXTreeObject.prototype._selectItem=function(node,e){if (this._onSSCF)this._onSSCFold=this.getSelectedItemId();this._unselectItems();this._markItem(node);if (this._onSSCF){var z=this.getSelectedItemId();if (z!=this._onSSCFold)this.callEvent("onSelect",[z]);};};dhtmlXTreeObject.prototype._markItem=function(node){if (node.scolor)node.span.style.color=node.scolor;node.span.className="selectedTreeRow";node.i_sel=true;this._selected[this._selected.length]=node;};dhtmlXTreeObject.prototype.getIndexById=function(itemId){var z=this._globalIdStorageFind(itemId);if (!z)return null;return this._getIndex(z);};dhtmlXTreeObject.prototype._getIndex=function(w){var z=w.parentObject;for (var i=0;i<z.childsCount;i++)if (z.childNodes[i]==w)return i;};dhtmlXTreeObject.prototype._unselectItem=function(node){if ((node)&&(node.i_sel))
{node.span.className="standartTreeRow";if (node.acolor)node.span.style.color=node.acolor;node.i_sel=false;for (var i=0;i<this._selected.length;i++)if (!this._selected[i].i_sel){this._selected.splice(i,1);break;};};};dhtmlXTreeObject.prototype._unselectItems=function(){for (var i=0;i<this._selected.length;i++){var node=this._selected[i];node.span.className="standartTreeRow";if (node.acolor)node.span.style.color=node.acolor;node.i_sel=false;};this._selected=new Array();};dhtmlXTreeObject.prototype.onRowSelect=function(e,htmlObject,mode){e=e||window.event;var obj=this.parentObject;if (htmlObject)obj=htmlObject.parentObject;var that=obj.treeNod;var lastId=that.getSelectedItemId();if ((!e)||(!e.skipUnSel))
that._selectItem(obj,e);if (!mode){if ((e)&&(e.button==2))
that.callEvent("onRightClick",[obj.id,e]);if (obj.actionHandler)obj.actionHandler(obj.id,lastId);else that.callEvent("onClick",[obj.id,lastId]);};};dhtmlXTreeObject.prototype._correctCheckStates=function(dhtmlObject){if (!this.tscheck)return;if (dhtmlObject.id==this.rootId)return;var act=dhtmlObject.childNodes;var flag1=0;var flag2=0;if (dhtmlObject.childsCount==0)return;for (var i=0;i<dhtmlObject.childsCount;i++){if (act[i].dscheck)continue;if (act[i].checkstate==0)flag1=1;else if (act[i].checkstate==1)flag2=1;else {flag1=1;flag2=1;break;};};if ((flag1)&&(flag2)) this._setCheck(dhtmlObject,"unsure");else if (flag1)this._setCheck(dhtmlObject,false);else this._setCheck(dhtmlObject,true);this._correctCheckStates(dhtmlObject.parentObject);};dhtmlXTreeObject.prototype.onCheckBoxClick=function(e) {if (this.parentObject.dscheck)return true;if (this.treeNod.tscheck)if (this.parentObject.checkstate==1)this.treeNod._setSubChecked(false,this.parentObject);else this.treeNod._setSubChecked(true,this.parentObject);else
if (this.parentObject.checkstate==1)this.treeNod._setCheck(this.parentObject,false);else this.treeNod._setCheck(this.parentObject,true);this.treeNod._correctCheckStates(this.parentObject.parentObject);return this.treeNod.callEvent("onCheck",[this.parentObject.id,this.parentObject.checkstate]);};dhtmlXTreeObject.prototype._createItem=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";if(this._txtimg){var img0=document.createElement("div");td1.appendChild(img0);img0.className="dhx_tree_textSign";}else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -