/* Product Name: dhtmlxSuite Version: 4.0.3 Edition: Professional License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact sales@dhtmlx.com Copyright UAB Dinamenta http://www.dhtmlx.com */ /*_TOPICS_ @0:Initialization @1:Selection control @2:Add/delete @3:Private @4:Node/level control @5:Checkboxes/user data manipulation @6:Appearence control @7: Handlers */ function xmlPointer(data){ this.d=data; } xmlPointer.prototype={ text:function(){ if (!_isFF) return this.d.xml; var x = new XMLSerializer(); return x.serializeToString(this.d); }, get:function(name){return this.d.getAttribute(name); }, exists:function(){return !!this.d }, content:function(){return this.d.firstChild?(this.d.firstChild.wholeText||this.d.firstChild.data):""; }, // <4k in FF each:function(name,f,t,i){ var a=this.d.childNodes; var c=new xmlPointer(); if (a.length) for (i=i||0; i0) { beforeNode=new Object; beforeNode.tr=parentObject.childNodes[0].tr.previousSibling; } parentObject._has_top=true; for (ik=Count; ik>0; ik--) Nodes[ik]=Nodes[ik-1]; Count=0; break; } }; }; var n; if (!(n=this._idpull[itemId]) || n.span!=-1){ n=Nodes[Count]=new dhtmlXTreeItemObject(itemId,itemText,parentObject,this,itemActionHandler,1); itemId = Nodes[Count].id; parentObject.childsCount++; } if(!n.htmlNode) { n.label=itemText; n.htmlNode=this._createItem((this.checkBoxOff?1:0),n); n.htmlNode.objBelong=n; } if(image1) n.images[0]=image1; if(image2) n.images[1]=image2; if(image3) n.images[2]=image3; var tr=this._drawNewTr(n.htmlNode); if ((this.XMLloadingWarning)||(this._hAdI)) n.htmlNode.parentNode.parentNode.style.display="none"; if ((beforeNode)&&beforeNode.tr&&(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)) n.XMLload=0; else n.XMLload=1; n.tr=tr; tr.nodem=n; if (parentObject.itemId==0) tr.childNodes[0].className="hiddenRow"; if ((parentObject._r_logic)||(this._frbtr)) this._setSrc(n.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0],this.imPath+this.radioArray[0]); if (optionStr) { var tempStr=optionStr.split(","); for (var i=0; i=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 n; }; //#__pro_feature:01112006{ //#context_menu:01112006{ /** * @desc: enable context menu * @param: menu - dhtmlXMenu object * @edition: Professional * @type: public * @topic: 0 */ dhtmlXTreeObject.prototype.enableContextMenu=function(menu){ if (menu) this.cMenu=menu; }; /** * @desc: set context menu to individual nodes * @type: public * @param: itemId - node id * @param: cMenu - context menu object * @edition: Professional * @topic: 2 */ dhtmlXTreeObject.prototype.setItemContextMenu=function(itemId,cMenu){ var l=itemId.toString().split(this.dlmtr); for (var i=0; i=0; i--) if (temp.childNodes[i]._dmark) this.deleteItem(temp.childNodes[i].id); } var parsedNodeTop=this._globalIdStorageFind(this.parsingOn); for (var i=0; i1){ if ( ( (Nodes[1].style.display!="none") || (mode==1) ) && (mode!=2) ) { //nb:solves standard doctype prb in IE this.allTree.childNodes[0].border = "1"; this.allTree.childNodes[0].border = "0"; nodestyle="none"; } else nodestyle=""; for (var i=1; i7) td2.style.width="999999px"; else if (!window._KHTMLrv) td2.style.width="100%"; // itemObject.span.appendChild(document.createTextNode(itemObject.label)); itemObject.span.innerHTML=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.ettip) tr.title=itemObject.label; if (this.dragAndDropOff) { if (this._aimgs) { this.dragger.addDraggableItem(td12,this); td12.parentObject=itemObject; } this.dragger.addDraggableItem(td2,this); } itemObject.span.style.paddingLeft="5px"; itemObject.span.style.paddingRight="5px"; td2.style.verticalAlign=""; td2.style.fontSize="10pt"; td2.style.cursor=this.style_pointer; tr.appendChild(td1); tr.appendChild(td11); tr.appendChild(td12); tr.appendChild(td2); tbody.appendChild(tr); table.appendChild(tbody); if (this.ehlt || this.checkEvent("onMouseIn") || this.checkEvent("onMouseOut")){//highlighting tr.onmousemove=this._itemMouseIn; tr[(_isIE)?"onmouseleave":"onmouseout"]=this._itemMouseOut; } return table; }; /** * @desc: set path to images directory * @param: newPath - path to images directory (related to the page with tree or absolute http url) * @type: public * @topic: 0 */ dhtmlXTreeObject.prototype.setImagePath=function( newPath ){ this.imPath=newPath; this.iconURL=newPath; }; /** * @desc: set path to external images used as tree icons * @type: public * @param: path - url (or relative path) of images folder with closing "/" * @topic: 0,7 */ dhtmlXTreeObject.prototype.setIconPath=function(path){ this.iconURL=path; } //#__pro_feature:01112006{ //#child_calc:01112006{ /** * @desc: return count of leafs * @param: itemNode - node object * @type: private * @edition: Professional * @topic: 4 */ dhtmlXTreeObject.prototype._getLeafCount=function(itemNode){ var a=0; for (var b=0; bthis._getNodeLevel(nodeB,0)) { if (!this.dropLower) return this._moveNodeTo(itemObject,nodeA.parentObject); else if (nodeB.id!=this.rootId) return this._moveNodeTo(itemObject,nodeB.parentObject,nodeB); else return this._moveNodeTo(itemObject,this.htmlNode,null); } else { return this._moveNodeTo(itemObject,nodeB.parentObject,nodeB); } } else //#} //#} return this._moveNodeTo(itemObject,targetObject); } /** * @desc: fix order of nodes in collection * @type: private * @param: target - parent item node * @param: zParent - before node * @edition: Professional * @topic: 2 */ dhtmlXTreeObject.prototype._fixNodesCollection=function(target,zParent){ var flag=0; var icount=0; var Nodes=target.childNodes; var Count=target.childsCount-1; if (zParent==Nodes[Count]) return; for (var i=0; i=2) { this._correctPlus(Nodes[targetObject.childsCount-2]); this._correctLine(Nodes[targetObject.childsCount-2]); } this._correctPlus(Nodes[targetObject.childsCount-1]); //this._correctLine(Nodes[targetObject.childsCount-1]); if (this.tscheck) this._correctCheckStates(targetObject); if (oldTree.tscheck) oldTree._correctCheckStates(z); } //fix source parent if (c>1) { oldTree._correctPlus(z.childNodes[c-2]); oldTree._correctLine(z.childNodes[c-2]); } // if (z.childsCount==0) oldTree._correctPlus(z); oldTree._correctLine(z); //#__pro_feature:01112006{ //#child_calc:01112006{ this._fixChildCountLabel(targetObject); oldTree._fixChildCountLabel(z); //#} //#} this.callEvent("onDrop",[itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),oldTree,targetObject.treeNod]); return itemObject.id; }; /** * @desc: recursive set default styles for node * @type: private * @param: itemObject - target node object * @topic: 6 */ dhtmlXTreeObject.prototype._clearStyles=function(itemObject){ if (!itemObject.htmlNode) return; //some weird case in SRND mode 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.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