📄 dhtmlxtree.js
字号:
parentObject.childsCount++;
var tr=this._drawNewTr(Nodes[Count].htmlNode);
if ((this.XMLloadingWarning)||(this._hAdI))
Nodes[Count].htmlNode.parentNode.parentNode.style.display="none";
if ((beforeNode)&&(beforeNode.tr.nextSibling))
parentObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr.nextSibling);
else
if (this.parsingOn==parentObject.id){
this.parsedArray[this.parsedArray.length]=tr;
}
else
parentObject.htmlNode.childNodes[0].appendChild(tr);
if ((beforeNode)&&(!beforeNode.span)) beforeNode=null;
if (this.XMLsource) if ((childs)&&(childs!=0)) Nodes[Count].XMLload=0; else Nodes[Count].XMLload=1;
Nodes[Count].tr=tr;
tr.nodem=Nodes[Count];
if (parentObject.itemId==0)
tr.childNodes[0].className="hiddenRow";
if ((parentObject._r_logic)||(this._frbtr))
Nodes[Count].htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0].src=this.imPath+this.radioArray[0];
if (optionStr) {
var tempStr=optionStr.split(",");
for (var i=0; i<tempStr.length; i++)
{
switch(tempStr[i])
{
case "SELECT": this.selectItem(itemId,false); break;
case "CALL": this.selectItem(itemId,true); break;
case "CHILD": Nodes[Count].XMLload=0; break;
case "CHECKED":
if (this.XMLloadingWarning)
this.setCheckList+=this.dlmtr+itemId;
else
this.setCheck(itemId,1);
break;
case "HCHECKED":
this._setCheck(Nodes[Count],"unsure");
break;
case "OPEN": Nodes[Count].openMe=1; break;
}
};
};
if (!this.XMLloadingWarning)
{
if ((this._getOpenState(parentObject)<0)&&(!this._hAdI)) this.openItem(parentObject.id);
if (beforeNode)
{
this._correctPlus(beforeNode);
this._correctLine(beforeNode);
}
this._correctPlus(parentObject);
this._correctLine(parentObject);
this._correctPlus(Nodes[Count]);
if (parentObject.childsCount>=2)
{
this._correctPlus(Nodes[parentObject.childsCount-2]);
this._correctLine(Nodes[parentObject.childsCount-2]);
}
if (parentObject.childsCount!=2) this._correctPlus(Nodes[0]);
if (this.tscheck) this._correctCheckStates(parentObject);
if (this._onradh) {
if (this.xmlstate==1){
var old=this.onXLE;
this.onXLE=function(id){ this._onradh(itemId); if (old) old(id); }
}
else
this._onradh(itemId);
}
}
return Nodes[Count];
};
/**
* @desc: create new node as a child to specified with parentId
* @type: deprecated
* @param: parentId - parent node id
* @param: itemId - new node id
* @param: itemText - new node text
* @param: itemActionHandler - function fired on node select event (optional)
* @param: image1 - image for node without childrens; (optional)
* @param: image2 - image for closed node; (optional)
* @param: image3 - image for opened node (optional)
* @param: optionStr - options string (optional)
* @param: childs - node childs flag (for dynamical trees) (optional)
* @topic: 2
*/
dhtmlXTreeObject.prototype.insertNewItem=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs){
var parentObject=this._globalIdStorageFind(parentId);
if (!parentObject) return (-1);
var nodez=this._attachChildNode(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs);
return nodez;
};
/**
* @desc: create new node as a child to specified with parentId
* @type: public
* @param: parentId - parent node id
* @param: itemId - new node id
* @param: itemText - new node label
* @param: itemActionHandler - function fired on node select event (optional)
* @param: image1 - image for node without childrens; (optional)
* @param: image2 - image for closed node; (optional)
* @param: image3 - image for opened node (optional)
* @param: optionStr - options string (optional)
* @param: childs - node children flag (for dynamical trees) (optional)
* @topic: 2
*/
dhtmlXTreeObject.prototype.insertNewChild=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs){
return this.insertNewItem(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs);
}
/**
* @desc: parse xml
* @type: private
* @param: dhtmlObject - jsTree object
* @param: node - top XML node
* @param: parentId - parent node id
* @param: level - level of tree
* @topic: 2
*/
dhtmlXTreeObject.prototype._parseXMLTree=function(dhtmlObject,node,parentId,level,xml_obj,start){
if (!xml_obj) xml_obj=dhtmlObject.XMLLoader;
dhtmlObject.skipLock=true;
if (!dhtmlObject.parsCount) dhtmlObject.parsCount=1; else dhtmlObject.parsCount++;
dhtmlObject.XMLloadingWarning=1;
var nodeAskingCall="";
if (!node) {
node=xml_obj.getXMLTopNode("tree");
parentId=node.getAttribute("id");
if (node.getAttribute("radio"))
dhtmlObject.htmlNode._r_logic=true;
dhtmlObject.parsingOn=parentId;
dhtmlObject.parsedArray=new Array();
dhtmlObject.setCheckList="";
}
var temp=dhtmlObject._globalIdStorageFind(parentId);
if ((temp.childsCount)&&(!start)&&(!dhtmlObject._edsbps)&&(!temp._has_top))
var preNode=temp.childNodes[temp.childsCount-1];
else
var preNode=0;
if (node.getAttribute("order"))
dhtmlObject._reorderXMLBranch(node);
var npl=0;
for(var i=start||0; i<node.childNodes.length; i++)
{
if ((node.childNodes[i].nodeType==1)&&(node.childNodes[i].tagName == "item"))
{
temp.XMLload=1;
if ((dhtmlObject._epgps)&&(dhtmlObject._epgpsC==npl)){
this._setNextPageSign(temp,npl+1*(start||0),level,node);
break;
}
var nodx=node.childNodes[i];
var name=nodx.getAttribute("text");
var cId=nodx.getAttribute("id");
if ((typeof(dhtmlObject.waitUpdateXML)=="object")&&(!dhtmlObject.waitUpdateXML[cId])){
dhtmlObject._parseXMLTree(dhtmlObject,node.childNodes[i],cId,1,xml_obj);
continue;
}
var im0=nodx.getAttribute("im0");
var im1=nodx.getAttribute("im1");
var im2=nodx.getAttribute("im2");
var aColor=nodx.getAttribute("aCol");
var sColor=nodx.getAttribute("sCol");
var chd=nodx.getAttribute("child");
var imw=nodx.getAttribute("imwidth");
var imh=nodx.getAttribute("imheight");
var atop=nodx.getAttribute("top");
var aradio=nodx.getAttribute("radio");
var topoffset=nodx.getAttribute("topoffset");
var aopen=nodx.getAttribute("open"); //can be disabled, because we have another code for open via Xpaths
var aselect=nodx.getAttribute("select");
var acall=nodx.getAttribute("call");
var achecked=nodx.getAttribute("checked");
var closeable=nodx.getAttribute("closeable");
var tooltip = nodx.getAttribute("tooltip");
var nocheckbox = nodx.getAttribute("nocheckbox");
var disheckbox = nodx.getAttribute("disabled");
var style = nodx.getAttribute("style");
var locked = nodx.getAttribute("locked");
var zST="";
if (aselect) zST+=",SELECT";
if (atop) zST+=",TOP";
//if (acall) zST+=",CALL";
if (acall) nodeAskingCall=cId;
if (achecked==-1) zST+=",HCHECKED";
else if (achecked) zST+=",CHECKED";
if (aopen) zST+=",OPEN";
if (dhtmlObject.waitUpdateXML){
if (dhtmlObject._globalIdStorageFind(cId))
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.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) this.setItemTopOffset(newNode,topoffset);
if (!dhtmlObject.slowParse)
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);
}
//special realization for IE 5.5 (should avoid IE crash for autoloading. In other cases probably will not help)
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.parsCount==1) {
dhtmlObject.parsingOn=null;
if ((!dhtmlObject._edsbps)||(!dhtmlObject._edsbpsA.length)){
if (dhtmlObject.onXLE)
window.setTimeout( function(){dhtmlObject.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.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);
}
}
/**
* @desc: reset tree images from selected level
* @type: private
* @param: dhtmlObject - tree
* @param: itemObject - current item
* @topic: 6
*/
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++)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -