4
Copyright DHTMLX LTD. http://www.dhtmlx.com
5
You allowed to use this component or parts of it under GPL terms
6
To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
14
@5:Checkboxes/user data manipulation
19
function xmlPointer(data){
22
xmlPointer.prototype={
23
text:function(){ if (!_isFF) return this.d.xml; var x = new XMLSerializer(); return x.serializeToString(this.d); },
24
get:function(name){return this.d.getAttribute(name); },
25
exists:function(){return !!this.d },
26
content:function(){return this.d.firstChild?this.d.firstChild.data:""; }, // <4k in FF
27
each:function(name,f,t,i){ var a=this.d.childNodes; var c=new xmlPointer(); if (a.length) for (i=i||0; i<a.length; i++) if (a[i].tagName==name) { c.d=a[i]; if(f.apply(t,[c,i])==-1) return; } },
28
get_all:function(){ var a={}; var b=this.d.attributes; for (var i=0; i<b.length; i++) a[b[i].name]=b[i].value; return a; },
29
sub:function(name){ var a=this.d.childNodes; var c=new xmlPointer(); if (a.length) for (var i=0; i<a.length; i++) if (a[i].tagName==name) { c.d=a[i]; return c; } },
30
up:function(name){ return new xmlPointer(this.d.parentNode); },
31
set:function(name,val){ this.d.setAttribute(name,val); },
32
clone:function(name){ return new xmlPointer(this.d); },
33
sub_exists:function(name){ var a=this.d.childNodes; if (a.length) for (var i=0; i<a.length; i++) if (a[i].tagName==name) return true; return false; },
34
through:function(name,rule,v,f,t){ var a=this.d.childNodes; if (a.length) for (var i=0; i<a.length; i++) { if (a[i].tagName==name && a[i].getAttribute(rule)!=null && a[i].getAttribute(rule)!="" && (!v || a[i].getAttribute(rule)==v )) { var c=new xmlPointer(a[i]); f.apply(t,[c,i]); } var w=this.d; this.d=a[i]; this.through(name,rule,v,f,t); this.d=w; } }
40
* @desc: tree constructor
41
* @param: htmlObject - parent html object or id of parent html object
42
* @param: width - tree width
43
* @param: height - tree height
44
* @param: rootId - id of virtual root node (same as tree node id attribute in xml)
48
function dhtmlXTreeObject(htmlObject, width, height, rootId){
49
if (_isIE) try { document.execCommand("BackgroundImageCache", false, true); } catch (e){}
50
if (typeof(htmlObject)!="object")
51
this.parentObject=document.getElementById(htmlObject);
53
this.parentObject=htmlObject;
55
this.parentObject.style.overflow="hidden";
59
this.enableIEImageFix();
63
this.smcheck=true; //smart checkboxes
68
this.def_img_x="18px";
69
this.def_img_y="18px";
70
this.def_line_img_x="18px";
71
this.def_line_img_y="18px";
73
this._dragged=new Array();
74
this._selected=new Array();
76
this.style_pointer="pointer";
77
if (_isIE) this.style_pointer="hand";
90
this.nodeCut=new Array();
92
this.XMLloadingWarning=0;
95
this.treeLinesOn=true;
101
this.imPath="treeGfx/";
102
this.checkArray=new Array("iconUncheckAll.gif","iconCheckAll.gif","iconCheckGray.gif","iconUncheckDis.gif","iconCheckDis.gif","iconCheckDis.gif");
103
this.radioArray=new Array("radio_off.gif","radio_on.gif","radio_on.gif","radio_off.gif","radio_on.gif","radio_on.gif");
105
this.lineArray=new Array("line2.gif","line3.gif","line4.gif","blank.gif","blank.gif","line1.gif");
106
this.minusArray=new Array("minus2.gif","minus3.gif","minus4.gif","minus.gif","minus5.gif");
107
this.plusArray=new Array("plus2.gif","plus3.gif","plus4.gif","plus.gif","plus5.gif");
108
this.imageArray=new Array("leaf.gif","folderOpen.gif","folderClosed.gif");
109
this.cutImg= new Array(0,0,0);
110
this.cutImage="but_cut.gif";
112
this.dragger= new dhtmlDragAndDropObject();
114
this.htmlNode=new dhtmlXTreeItemObject(this.rootId,"",0,this);
115
this.htmlNode.htmlNode.childNodes[0].childNodes[0].style.display="none";
116
this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[0].className="hiddenRow";
117
//init tree structures
118
this.allTree=this._createSelf();
119
this.allTree.appendChild(this.htmlNode.htmlNode);
121
this.allTree.childNodes[0].width="100%";
122
this.allTree.childNodes[0].style.overflow="hidden";
126
this.allTree.onselectstart=new Function("return false;");
128
this.allTree.oncontextmenu = function(e){ return self._doContClick(e||window.event); };
129
this.allTree.onmousedown = function(e){ return self._doContClick(e||window.event); };
131
this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this,true,this.no_cashe);
132
if (_isIE) this.preventIECashing(true);
137
if (window.addEventListener) window.addEventListener("unload",function(){try{ self.destructor(); } catch(e){}},false);
138
if (window.attachEvent) window.attachEvent("onunload",function(){ try{ self.destructor(); } catch(e){}});
141
this._onEventSet={onMouseIn:function(){this.ehlt=true;},onMouseOut:function(){this.ehlt=true;},onSelect:function(){this._onSSCF=true;}}
143
this.setImagesPath=this.setImagePath;
144
this.setIconsPath=this.setIconPath;
151
* @desc: set default data transfer mode
152
* @param: mode - data mode (json,xml,csv)
156
dhtmlXTreeObject.prototype.setDataMode=function(mode){
162
dhtmlXTreeObject.prototype._doContClick=function(ev){
165
if (this._acMenu.hideContextMenu)
166
this._acMenu.hideContextMenu()
168
this.cMenu._contextEnd();
173
var el=(_isIE?ev.srcElement:ev.target);
174
while ((el)&&(el.tagName!="BODY")) {
175
if (el.parentObject) break;
179
if ((!el)||(!el.parentObject)) return true;
181
var obj=el.parentObject;
182
this._acMenu=(obj.cMenu||this.cMenu);
184
if (!(this.callEvent("onBeforeContextMenu", [
188
ev.srcElement.oncontextmenu = function(){ event.cancelBubble=true; return false; };
190
if (this._acMenu.showContextMenu){
191
this._acMenu.showContextMenu(ev.clientX-1,ev.clientY-1)
192
this.contextID=obj.id;
193
ev.cancelBubble=true;
194
this._acMenu._skip_hide=true;
196
el.contextMenuId=obj.id;
197
el.contextMenu=this._acMenu;
198
el.a=this._acMenu._contextStart;
210
* @desc: replace IMG tag with background images - solve problem with IE image caching , not works for IE6 SP1
211
* @param: mode - true/false - enable/disable fix
215
dhtmlXTreeObject.prototype.enableIEImageFix=function(mode){
218
this._getImg=function(id){ return document.createElement((id==this.rootId)?"div":"img"); }
219
this._setSrc=function(a,b){ a.src=b; }
220
this._getSrc=function(a){ return a.src; }
223
this._getImg=function(){ var z=document.createElement("DIV"); z.innerHTML=" "; z.className="dhx_bg_img_fix"; return z; }
224
this._setSrc=function(a,b){ a.style.backgroundImage="url("+b+")"; }
225
this._getSrc=function(a){ var z=a.style.backgroundImage; return z.substr(4,z.length-5); }
230
* @desc: deletes tree and clears memory
233
dhtmlXTreeObject.prototype.destructor=function(){
234
for (var a in this._idpull){
235
var z=this._idpull[a];
237
z.parentObject=null;z.treeNod=null;z.childNodes=null;z.span=null;z.tr.nodem=null;z.tr=null;z.htmlNode.objBelong=null;z.htmlNode=null;
238
this._idpull[a]=null;
240
this.parentObject.innerHTML="";
241
this.XMLLoader.destructor();
250
cObject.prototype= new Object;
251
cObject.prototype.clone = function () {
253
_dummy.prototype=this;
258
* @desc: tree node constructor
259
* @param: itemId - node id
260
* @param: itemText - node label
261
* @param: parentObject - parent item object
262
* @param: treeObject - tree object
263
* @param: actionHandler - onclick event handler(optional)
264
* @param: mode - do not show images
268
function dhtmlXTreeItemObject(itemId,itemText,parentObject,treeObject,actionHandler,mode){
280
this.childNodes=new Array();
281
this.userData=new cObject();
285
this.treeNod=treeObject;
287
this.parentObject=parentObject;
288
this.actionHandler=actionHandler;
289
this.images=new Array(treeObject.imageArray[0],treeObject.imageArray[1],treeObject.imageArray[2]);
292
this.id=treeObject._globalIdStorageAdd(itemId,this);
293
if (this.treeNod.checkBoxOff ) this.htmlNode=this.treeNod._createItem(1,this,mode);
294
else this.htmlNode=this.treeNod._createItem(0,this,mode);
296
this.htmlNode.objBelong=this;
302
* @desc: register node
304
* @param: itemId - node id
305
* @param: itemObject - node object
308
dhtmlXTreeObject.prototype._globalIdStorageAdd=function(itemId,itemObject){
309
if (this._globalIdStorageFind(itemId,1,1)) { itemId=itemId +"_"+(new Date()).valueOf(); return this._globalIdStorageAdd(itemId,itemObject); }
310
this._idpull[itemId]=itemObject;
316
* @desc: unregister node
318
* @param: itemId - node id
321
dhtmlXTreeObject.prototype._globalIdStorageSub=function(itemId){
322
if (this._idpull[itemId]){
323
this._unselectItem(this._idpull[itemId]);
324
this._idpull[itemId]=null;
327
if ((this._locker)&&(this._locker[itemId])) this._locker[itemId]=false;
331
* @desc: return node object
332
* @param: itemId - node id
336
dhtmlXTreeObject.prototype._globalIdStorageFind=function(itemId,skipXMLSearch,skipParsing,isreparse){
337
var z=this._idpull[itemId]
348
* @desc: escape string
349
* @param: itemId - item ID
353
dhtmlXTreeObject.prototype._escape=function(str){
359
return encodeURI(str);
370
* @desc: create and return new line in tree
372
* @param: htmlObject - parent Node object
373
* @param: node - item object
376
dhtmlXTreeObject.prototype._drawNewTr=function(htmlObject,node)
378
var tr =document.createElement('tr');
379
var td1=document.createElement('td');
380
var td2=document.createElement('td');
381
td1.appendChild(document.createTextNode(" "));
383
td2.appendChild(htmlObject);
384
tr.appendChild(td1); tr.appendChild(td2);
388
* @desc: load tree from xml string
390
* @param: xmlString - XML string
391
* @param: afterCall - function which will be called after xml loading
394
dhtmlXTreeObject.prototype.loadXMLString=function(xmlString,afterCall){
396
if (!this.parsCount) this.callEvent("onXLS",[that,null]);
399
if (afterCall) this.XMLLoader.waitCall=afterCall;
400
this.XMLLoader.loadXMLString(xmlString); };
402
* @desc: load tree from xml file
404
* @param: file - link to XML file
405
* @param: afterCall - function which will be called after xml loading
408
dhtmlXTreeObject.prototype.loadXML=function(file,afterCall){
409
if (this._datamode && this._datamode!="xml") return this["load"+this._datamode.toUpperCase()](file,afterCall);
411
if (!this.parsCount) this.callEvent("onXLS",[that,this._ld_id]);
414
this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this,true,this.no_cashe);
416
if (afterCall) this.XMLLoader.waitCall=afterCall;
417
this.XMLLoader.loadXML(file);
420
* @desc: create new child node
422
* @param: parentObject - parent node object
423
* @param: itemId - new node id
424
* @param: itemText - new node text
425
* @param: itemActionHandler - function fired on node select event
426
* @param: image1 - image for node without children;
427
* @param: image2 - image for closed node;
428
* @param: image3 - image for opened node
429
* @param: optionStr - string of otions
430
* @param: childs - node childs flag (for dynamical trees) (optional)
431
* @param: beforeNode - node, after which new node will be inserted (optional)
434
dhtmlXTreeObject.prototype._attachChildNode=function(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,beforeNode,afterNode){
436
if (beforeNode && beforeNode.parentObject) parentObject=beforeNode.parentObject;
437
if (((parentObject.XMLload==0)&&(this.XMLsource))&&(!this.XMLloadingWarning))
439
parentObject.XMLload=1;
440
this._loadDynXML(parentObject.id);
444
var Count=parentObject.childsCount;
445
var Nodes=parentObject.childNodes;
449
if (afterNode.tr.previousSibling.previousSibling){
450
beforeNode=afterNode.tr.previousSibling.nodem;
453
optionStr=optionStr.replace("TOP","")+",TOP";
459
for (ik=0; ik<Count; ik++)
460
if (Nodes[ik]==beforeNode)
462
for (jk=Count; jk!=ik; jk--)
463
Nodes[1+jk]=Nodes[jk];
472
var tempStr=optionStr.split(",");
473
for (var i=0; i<tempStr.length; i++)
477
case "TOP": if (parentObject.childsCount>0) { beforeNode=new Object; beforeNode.tr=parentObject.childNodes[0].tr.previousSibling; }
478
parentObject._has_top=true;
479
for (ik=Count; ik>0; ik--)
480
Nodes[ik]=Nodes[ik-1];
488
if (!(n=this._idpull[itemId]) || n.span!=-1){
489
n=Nodes[Count]=new dhtmlXTreeItemObject(itemId,itemText,parentObject,this,itemActionHandler,1);
490
itemId = Nodes[Count].id;
491
parentObject.childsCount++;
496
n.htmlNode=this._createItem((this.checkBoxOff?1:0),n);
497
n.htmlNode.objBelong=n;
500
if(image1) n.images[0]=image1;
501
if(image2) n.images[1]=image2;
502
if(image3) n.images[2]=image3;
505
var tr=this._drawNewTr(n.htmlNode);
506
if ((this.XMLloadingWarning)||(this._hAdI))
507
n.htmlNode.parentNode.parentNode.style.display="none";
510
if ((beforeNode)&&(beforeNode.tr.nextSibling))
511
parentObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr.nextSibling);
513
if (this.parsingOn==parentObject.id){
514
this.parsedArray[this.parsedArray.length]=tr;
517
parentObject.htmlNode.childNodes[0].appendChild(tr);
520
if ((beforeNode)&&(!beforeNode.span)) beforeNode=null;
522
if (this.XMLsource) if ((childs)&&(childs!=0)) n.XMLload=0; else n.XMLload=1;
526
if (parentObject.itemId==0)
527
tr.childNodes[0].className="hiddenRow";
529
if ((parentObject._r_logic)||(this._frbtr))
530
this._setSrc(n.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0],this.imPath+this.radioArray[0]);
534
var tempStr=optionStr.split(",");
536
for (var i=0; i<tempStr.length; i++)
540
case "SELECT": this.selectItem(itemId,false); break;
541
case "CALL": this.selectItem(itemId,true); break;
542
case "CHILD": n.XMLload=0; break;
544
if (this.XMLloadingWarning)
545
this.setCheckList+=this.dlmtr+itemId;
547
this.setCheck(itemId,1);
550
this._setCheck(n,"unsure");
552
case "OPEN": n.openMe=1; break;
557
if (!this.XMLloadingWarning)
559
if ((this._getOpenState(parentObject)<0)&&(!this._hAdI)) this.openItem(parentObject.id);
563
this._correctPlus(beforeNode);
564
this._correctLine(beforeNode);
566
this._correctPlus(parentObject);
567
this._correctLine(parentObject);
568
this._correctPlus(n);
569
if (parentObject.childsCount>=2)
571
this._correctPlus(Nodes[parentObject.childsCount-2]);
572
this._correctLine(Nodes[parentObject.childsCount-2]);
574
if (parentObject.childsCount!=2) this._correctPlus(Nodes[0]);
576
if (this.tscheck) this._correctCheckStates(parentObject);
579
if (this.xmlstate==1){
581
this.onXLE=function(id){ this._onradh(itemId); if (old) old(id); }
584
this._onradh(itemId);
595
* @desc: create new node as a child to specified with parentId
597
* @param: parentId - parent node id
598
* @param: itemId - new node id
599
* @param: itemText - new node text
600
* @param: itemActionHandler - function fired on node select event (optional)
601
* @param: image1 - image for node without children; (optional)
602
* @param: image2 - image for closed node; (optional)
603
* @param: image3 - image for opened node (optional)
604
* @param: optionStr - options string (optional)
605
* @param: children - node children flag (for dynamical trees) (optional)
608
dhtmlXTreeObject.prototype.insertNewItem=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){
609
var parentObject=this._globalIdStorageFind(parentId);
610
if (!parentObject) return (-1);
611
var nodez=this._attachChildNode(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children);
616
* @desc: create new node as a child to specified with parentId
618
* @param: parentId - parent node id
619
* @param: itemId - new node id
620
* @param: itemText - new node label
621
* @param: itemActionHandler - function fired on node select event (optional)
622
* @param: image1 - image for node without children; (optional)
623
* @param: image2 - image for closed node; (optional)
624
* @param: image3 - image for opened node (optional)
625
* @param: optionStr - options string (optional)
626
* @param: children - node children flag (for dynamical trees) (optional)
629
dhtmlXTreeObject.prototype.insertNewChild=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){
630
return this.insertNewItem(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children);
635
* @param: dhtmlObject - jsTree object
636
* @param: node - top XML node
637
* @param: parentId - parent node id
638
* @param: level - level of tree
641
dhtmlXTreeObject.prototype._parseXMLTree=function(a,b,c,d,xml){
642
var p=new xmlPointer(xml.getXMLTopNode("tree"));
647
dhtmlXTreeObject.prototype._parseItem=function(c,temp,preNode,befNode){
649
if (this._srnd && (!this._idpull[id=c.get("id")] || !this._idpull[id].span))
651
this._addItemSRND(temp.id,id,c);
657
if ((typeof(this.waitUpdateXML)=="object")&&(!this.waitUpdateXML[a.id])){
658
this._parse(c,a.id,1);
668
if (a.select) zST.push("SELECT");
669
if (a.top) zST.push("TOP");
670
if (a.call) this.nodeAskingCall=a.id;
671
if (a.checked==-1) zST.push("HCHECKED");
672
else if (a.checked) zST.push("CHECKED");
673
if (a.open) zST.push("OPEN");
675
if (this.waitUpdateXML){
676
if (this._globalIdStorageFind(a.id))
677
var newNode=this.updateItem(a.id,a.text,a.im0,a.im1,a.im2,a.checked);
679
if (this.npl==0) zST.push("TOP");
680
else preNode=temp.childNodes[this.npl];
682
var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,0,preNode);
687
var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,(befNode||0),preNode);
689
newNode.span.parentNode.parentNode.title=a.tooltip;
692
if (newNode.span.style.cssText)
693
newNode.span.style.cssText+=(";"+a.style);
695
newNode.span.setAttribute("style",newNode.span.getAttribute("style")+"; "+a.style);
697
if (a.radio) newNode._r_logic=true;
700
newNode.span.parentNode.previousSibling.previousSibling.childNodes[0].style.display='none';
701
newNode.nocheckbox=true;
704
if (a.checked!=null) this._setCheck(newNode,a.checked);
705
this.disableCheckbox(newNode,1);
709
newNode._acc=a.child||0;
711
if (this.parserExtension) this.parserExtension._parseExtension.call(this,c,a,(temp?temp.id:0));
713
this.setItemColor(newNode,a.aCol,a.sCol);
714
if (a.locked=="1") this.lockItem(newNode.id,true,true);
716
if ((a.imwidth)||(a.imheight)) this.setIconSize(a.imwidth,a.imheight,newNode);
717
if ((a.closeable=="0")||(a.closeable=="1")) this.setItemCloseable(newNode,a.closeable);
719
if (a.topoffset) this.setItemTopOffset(newNode,a.topoffset);
720
if ((!this.slowParse)||(typeof(this.waitUpdateXML)=="object")){
721
if (c.sub_exists("item"))
722
zcall=this._parse(c,a.id,1);
725
if (zcall!="") this.nodeAskingCall=zcall;
728
c.each("userdata",function(u){
729
this.setUserData(c.get("id"),u.get("name"),u.content());
734
dhtmlXTreeObject.prototype._parse=function(p,parentId,level,start){
735
if (this._srnd && !this.parentObject.offsetHeight) {
737
return window.setTimeout(function(){
738
self._parse(p,parentId,level,start);
741
if (!p.exists()) return;
743
this.skipLock=true; //disable item locking
746
this.parsCount=this.parsCount?(this.parsCount+1):1;
747
this.XMLloadingWarning=1;
750
if (!parentId) { //top level
751
parentId=p.get("id");
753
this.htmlNode._r_logic=true;
754
this.parsingOn=parentId;
755
this.parsedArray=new Array();
756
this.setCheckList="";
757
this.nodeAskingCall="";
760
var temp=this._globalIdStorageFind(parentId);
761
if (!temp) return dhtmlxError.throwError("DataStructure","XML reffers to not existing parent");
763
if ((temp.childsCount)&&(!start)&&(!this._edsbps)&&(!temp._has_top))
764
var preNode=temp.childNodes[temp.childsCount-1];
770
p.each("item",function(c,i){
773
if ((this._epgps)&&(this._epgpsC==this.npl)){
774
this._setNextPageSign(temp,this.npl+1*(start||0),level,node);
778
this._parseItem(c,temp,preNode);
789
p.each("userdata",function(u){
790
this.setUserData(p.get("id"),u.get("name"),u.content());
794
if (this.waitUpdateXML){
795
this.waitUpdateXML=false;
796
for (var i=temp.childsCount-1; i>=0; i--)
797
if (temp.childNodes[i]._dmark)
798
this.deleteItem(temp.childNodes[i].id);
801
var parsedNodeTop=this._globalIdStorageFind(this.parsingOn);
803
for (var i=0; i<this.parsedArray.length; i++)
804
temp.htmlNode.childNodes[0].appendChild(this.parsedArray[i]);
806
this.lastLoadedXMLId=parentId;
807
this.XMLloadingWarning=0;
809
var chArr=this.setCheckList.split(this.dlmtr);
810
for (var n=0; n<chArr.length; n++)
811
if (chArr[n]) this.setCheck(chArr[n],1);
813
if ((this.XMLsource)&&(this.tscheck)&&(this.smcheck)&&(temp.id!=this.rootId)){
814
if (temp.checkstate===0)
815
this._setSubChecked(0,temp);
816
else if (temp.checkstate===1)
817
this._setSubChecked(1,temp);
820
if (this.onXLE) this.onXLE(this,parentId);
821
this._redrawFrom(this,null,start)
824
if (p.get("order") && p.get("order")!="none")
825
this._reorderBranch(temp,p.get("order"),true);
827
if (this.nodeAskingCall!="") this.selectItem(this.nodeAskingCall,true);
828
if (this._branchUpdate) this._branchUpdateNext(p);
832
if (this.parsCount==1) {
836
if ((!this._edsbps)||(!this._edsbpsA.length)){
838
window.setTimeout( function(){ that.callEvent("onXLE",[that,parentId]); },1);
847
if ((this._epgps)&&(start))
848
this._setPrevPageSign(temp,(start||0),level,node);
850
return this.nodeAskingCall;
854
dhtmlXTreeObject.prototype._branchUpdateNext=function(p){
855
p.each("item",function(c){
857
if (this._idpull[nid] && (!this._idpull[nid].XMLload)) return;
858
this._branchUpdate++;
859
this.smartRefreshItem(c.get("id"),c);
861
this._branchUpdate--;
864
dhtmlXTreeObject.prototype.checkUserData=function(node,parentId){
865
if ((node.nodeType==1)&&(node.tagName == "userdata"))
867
var name=node.getAttribute("name");
868
if ((name)&&(node.childNodes[0]))
869
this.setUserData(parentId,name,node.childNodes[0].data);
877
* @desc: reset tree images from selected level
879
* @param: dhtmlObject - tree
880
* @param: itemObject - current item
883
dhtmlXTreeObject.prototype._redrawFrom=function(dhtmlObject,itemObject,start,visMode){
885
var tempx=dhtmlObject._globalIdStorageFind(dhtmlObject.lastLoadedXMLId);
886
dhtmlObject.lastLoadedXMLId=-1;
887
if (!tempx) return 0;
889
else tempx=itemObject;
892
for (var i=(start?start-1:0); i<tempx.childsCount; i++)
894
if ((!this._branchUpdate)||(this._getOpenState(tempx)==1))
895
if ((!itemObject)||(visMode==1)) tempx.childNodes[i].htmlNode.parentNode.parentNode.style.display="";
896
if (tempx.childNodes[i].openMe==1)
898
this._openItem(tempx.childNodes[i]);
899
tempx.childNodes[i].openMe=0;
902
dhtmlObject._redrawFrom(dhtmlObject,tempx.childNodes[i]);
907
if ((!tempx.unParsed)&&((tempx.XMLload)||(!this.XMLsource)))
909
dhtmlObject._correctLine(tempx);
910
dhtmlObject._correctPlus(tempx);
915
* @desc: create and return main html element of tree
919
dhtmlXTreeObject.prototype._createSelf=function(){
920
var div=document.createElement('div');
921
div.className="containerTableStyle";
922
div.style.width=this.width;
923
div.style.height=this.height;
924
this.parentObject.appendChild(div);
929
* @desc: collapse target node
931
* @param: itemObject - item object
934
dhtmlXTreeObject.prototype._xcloseAll=function(itemObject)
936
if (itemObject.unParsed) return;
937
if (this.rootId!=itemObject.id) {
938
var Nodes=itemObject.htmlNode.childNodes[0].childNodes;
939
var Count=Nodes.length;
941
for (var i=1; i<Count; i++)
942
Nodes[i].style.display="none";
944
this._correctPlus(itemObject);
947
for (var i=0; i<itemObject.childsCount; i++)
948
if (itemObject.childNodes[i].childsCount)
949
this._xcloseAll(itemObject.childNodes[i]);
952
* @desc: expand target node
954
* @param: itemObject - item object
957
dhtmlXTreeObject.prototype._xopenAll=function(itemObject)
959
this._HideShow(itemObject,2);
960
for (var i=0; i<itemObject.childsCount; i++)
961
this._xopenAll(itemObject.childNodes[i]);
964
* @desc: set correct tree-line and node images
966
* @param: itemObject - item object
969
dhtmlXTreeObject.prototype._correctPlus=function(itemObject){
970
if (!itemObject.htmlNode) return;
971
var imsrc=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[0].lastChild;
972
var imsrc2=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[2].childNodes[0];
974
var workArray=this.lineArray;
975
if ((this.XMLsource)&&(!itemObject.XMLload))
977
var workArray=this.plusArray;
978
this._setSrc(imsrc2,this.imPath+itemObject.images[2]);
979
if (this._txtimg) return (imsrc.innerHTML="[+]");
982
if ((itemObject.childsCount)||(itemObject.unParsed))
984
if ((itemObject.htmlNode.childNodes[0].childNodes[1])&&( itemObject.htmlNode.childNodes[0].childNodes[1].style.display!="none" ))
986
if (!itemObject.wsign) var workArray=this.minusArray;
987
this._setSrc(imsrc2,this.iconURL+itemObject.images[1]);
988
if (this._txtimg) return (imsrc.innerHTML="[-]");
992
if (!itemObject.wsign) var workArray=this.plusArray;
993
this._setSrc(imsrc2,this.iconURL+itemObject.images[2]);
994
if (this._txtimg) return (imsrc.innerHTML="[+]");
999
this._setSrc(imsrc2,this.iconURL+itemObject.images[0]);
1004
if (!itemObject.treeNod.treeLinesOn) this._setSrc(imsrc,this.imPath+workArray[3]);
1006
if (itemObject.parentObject) tempNum=this._getCountStatus(itemObject.id,itemObject.parentObject);
1007
this._setSrc(imsrc,this.imPath+workArray[tempNum]);
1012
* @desc: set correct tree-line images
1014
* @param: itemObject - item object
1017
dhtmlXTreeObject.prototype._correctLine=function(itemObject){
1018
if (!itemObject.htmlNode) return;
1019
var sNode=itemObject.parentObject;
1021
if ((this._getLineStatus(itemObject.id,sNode)==0)||(!this.treeLinesOn))
1022
for(var i=1; i<=itemObject.childsCount; i++){
1023
if (!itemObject.htmlNode.childNodes[0].childNodes[i]) break;
1024
itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundImage="";
1025
itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundRepeat="";
1028
for(var i=1; i<=itemObject.childsCount; i++){
1029
if (!itemObject.htmlNode.childNodes[0].childNodes[i]) break;
1030
itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundImage="url("+this.imPath+this.lineArray[5]+")";
1031
itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundRepeat="repeat-y";
1035
* @desc: return type of node
1037
* @param: itemId - item id
1038
* @param: itemObject - parent node object
1041
dhtmlXTreeObject.prototype._getCountStatus=function(itemId,itemObject){
1042
if (itemObject.childsCount<=1) { if (itemObject.id==this.rootId) return 4; else return 0; }
1044
if (itemObject.childNodes[0].id==itemId) if (itemObject.id==this.rootId) return 2; else return 1;
1045
if (itemObject.childNodes[itemObject.childsCount-1].id==itemId) return 0;
1050
* @desc: return type of node
1052
* @param: itemId - node id
1053
* @param: itemObject - parent node object
1056
dhtmlXTreeObject.prototype._getLineStatus =function(itemId,itemObject){
1057
if (itemObject.childNodes[itemObject.childsCount-1].id==itemId) return 0;
1062
* @desc: open/close node
1064
* @param: itemObject - node object
1065
* @param: mode - open/close mode [1-close 2-open](optional)
1068
dhtmlXTreeObject.prototype._HideShow=function(itemObject,mode){
1069
if ((this.XMLsource)&&(!itemObject.XMLload)) {
1070
if (mode==1) return; //close for not loaded node - ignore it
1071
itemObject.XMLload=1;
1072
this._loadDynXML(itemObject.id);
1075
var Nodes=itemObject.htmlNode.childNodes[0].childNodes; var Count=Nodes.length;
1077
if ( ( (Nodes[1].style.display!="none") || (mode==1) ) && (mode!=2) ) {
1078
//nb:solves standard doctype prb in IE
1079
this.allTree.childNodes[0].border = "1";
1080
this.allTree.childNodes[0].border = "0";
1085
for (var i=1; i<Count; i++)
1086
Nodes[i].style.display=nodestyle;
1088
this._correctPlus(itemObject);
1092
* @desc: return node state
1094
* @param: itemObject - node object
1097
dhtmlXTreeObject.prototype._getOpenState=function(itemObject){
1098
var z=itemObject.htmlNode.childNodes[0].childNodes;
1099
if (z.length<=1) return 0;
1100
if (z[1].style.display!="none") return 1;
1107
* @desc: ondblclick item event handler
1111
dhtmlXTreeObject.prototype.onRowClick2=function(){
1112
var that=this.parentObject.treeNod;
1113
if (!that.callEvent("onDblClick",[this.parentObject.id,that])) return 0;
1114
if ((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
1115
that._HideShow(this.parentObject);
1117
that._HideShow(this.parentObject,2);
1119
if (that.checkEvent("onOpenEnd"))
1121
that.callEvent("onOpenEnd",[this.parentObject.id,that._getOpenState(this.parentObject)]);
1123
that._oie_onXLE.push(that.onXLE);
1124
that.onXLE=that._epnFHe;
1128
* @desc: onclick item event handler
1132
dhtmlXTreeObject.prototype.onRowClick=function(){
1133
var that=this.parentObject.treeNod;
1134
if (!that.callEvent("onOpenStart",[this.parentObject.id,that._getOpenState(this.parentObject)])) return 0;
1135
if ((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
1136
that._HideShow(this.parentObject);
1138
that._HideShow(this.parentObject,2);
1141
if (that.checkEvent("onOpenEnd"))
1143
that.callEvent("onOpenEnd",[this.parentObject.id,that._getOpenState(this.parentObject)]);
1145
that._oie_onXLE.push(that.onXLE);
1146
that.onXLE=that._epnFHe;
1151
dhtmlXTreeObject.prototype._epnFHe=function(that,id,flag){
1152
if (id!=this.rootId)
1153
this.callEvent("onOpenEnd",[id,that.getOpenState(id)]);
1154
that.onXLE=that._oie_onXLE.pop();
1156
if (!flag && !that._oie_onXLE.length)
1157
if (that.onXLE) that.onXLE(that,id);
1163
* @desc: onclick item image event handler
1165
* @edition: Professional
1168
dhtmlXTreeObject.prototype.onRowClickDown=function(e){
1170
var that=this.parentObject.treeNod;
1171
that._selectItem(this.parentObject,e);
1180
* @desc: retun selected item id
1182
* @return: id of selected item
1185
dhtmlXTreeObject.prototype.getSelectedItemId=function()
1187
var str=new Array();
1188
for (var i=0; i<this._selected.length; i++) str[i]=this._selected[i].id;
1189
return (str.join(this.dlmtr));
1193
* @desc: visual select item in tree
1195
* @param: node - tree item object
1196
* @edition: Professional
1199
dhtmlXTreeObject.prototype._selectItem=function(node,e){
1200
if (this._onSSCF) this._onSSCFold=this.getSelectedItemId();
1202
this._unselectItems();
1204
this._markItem(node);
1206
var z=this.getSelectedItemId();
1207
if (z!=this._onSSCFold)
1208
this.callEvent("onSelect",[z]);
1211
dhtmlXTreeObject.prototype._markItem=function(node){
1212
if (node.scolor) node.span.style.color=node.scolor;
1213
node.span.className="selectedTreeRow";
1215
this._selected[this._selected.length]=node;
1219
* @desc: retun node index in children collection by Id
1221
* @param: itemId - node id
1222
* @return: node index
1225
dhtmlXTreeObject.prototype.getIndexById=function(itemId){
1226
var z=this._globalIdStorageFind(itemId);
1227
if (!z) return null;
1228
return this._getIndex(z);
1230
dhtmlXTreeObject.prototype._getIndex=function(w){
1231
var z=w.parentObject;
1232
for (var i=0; i<z.childsCount; i++)
1233
if (z.childNodes[i]==w) return i;
1241
* @desc: visual unselect item in tree
1243
* @param: node - tree item object
1244
* @edition: Professional
1247
dhtmlXTreeObject.prototype._unselectItem=function(node){
1248
if ((node)&&(node.i_sel))
1251
node.span.className="standartTreeRow";
1252
if (node.acolor) node.span.style.color=node.acolor;
1254
for (var i=0; i<this._selected.length; i++)
1255
if (!this._selected[i].i_sel) {
1256
this._selected.splice(i,1);
1264
* @desc: visual unselect items in tree
1266
* @param: node - tree item object
1267
* @edition: Professional
1270
dhtmlXTreeObject.prototype._unselectItems=function(){
1271
for (var i=0; i<this._selected.length; i++){
1272
var node=this._selected[i];
1273
node.span.className="standartTreeRow";
1274
if (node.acolor) node.span.style.color=node.acolor;
1277
this._selected=new Array();
1282
* @desc: select node text event handler
1284
* @param: e - event object
1285
* @param: htmlObject - node object
1286
* @param: mode - if false - call onSelect event
1289
dhtmlXTreeObject.prototype.onRowSelect=function(e,htmlObject,mode){
1292
var obj=this.parentObject;
1293
if (htmlObject) obj=htmlObject.parentObject;
1294
var that=obj.treeNod;
1296
var lastId=that.getSelectedItemId();
1297
if ((!e)||(!e.skipUnSel))
1298
that._selectItem(obj,e);
1301
if ((e)&&(e.button==2))
1302
that.callEvent("onRightClick",[obj.id,e]);
1304
if (obj.actionHandler) obj.actionHandler(obj.id,lastId);
1305
else that.callEvent("onClick",[obj.id,lastId]);
1314
* @desc: fix checkbox state
1318
dhtmlXTreeObject.prototype._correctCheckStates=function(dhtmlObject){
1320
if (!this.tscheck) return;
1321
if (!dhtmlObject) return;
1322
if (dhtmlObject.id==this.rootId) return;
1324
var act=dhtmlObject.childNodes;
1325
var flag1=0; var flag2=0;
1326
if (dhtmlObject.childsCount==0) return;
1327
for (var i=0; i<dhtmlObject.childsCount; i++){
1328
if (act[i].dscheck) continue;
1329
if (act[i].checkstate==0) flag1=1;
1330
else if (act[i].checkstate==1) flag2=1;
1331
else { flag1=1; flag2=1; break; }
1334
if ((flag1)&&(flag2)) this._setCheck(dhtmlObject,"unsure");
1335
else if (flag1) this._setCheck(dhtmlObject,false);
1336
else this._setCheck(dhtmlObject,true);
1338
this._correctCheckStates(dhtmlObject.parentObject);
1342
* @desc: checbox select action
1346
dhtmlXTreeObject.prototype.onCheckBoxClick=function(e){
1347
if (!this.treeNod.callEvent("onBeforeCheck",[this.parentObject.id,this.parentObject.checkstate]))
1350
if (this.parentObject.dscheck) return true;
1351
if (this.treeNod.tscheck)
1352
if (this.parentObject.checkstate==1) this.treeNod._setSubChecked(false,this.parentObject);
1353
else this.treeNod._setSubChecked(true,this.parentObject);
1355
if (this.parentObject.checkstate==1) this.treeNod._setCheck(this.parentObject,false);
1356
else this.treeNod._setCheck(this.parentObject,true);
1357
this.treeNod._correctCheckStates(this.parentObject.parentObject);
1359
return this.treeNod.callEvent("onCheck",[this.parentObject.id,this.parentObject.checkstate]);
1362
* @desc: create HTML elements for tree node
1364
* @param: acheck - enable/disable checkbox
1365
* @param: itemObject - item object
1366
* @param: mode - mode
1369
dhtmlXTreeObject.prototype._createItem=function(acheck,itemObject,mode){
1371
var table=document.createElement('table');
1372
table.cellSpacing=0;table.cellPadding=0;
1375
if(this.hfMode)table.style.tableLayout="fixed";
1376
table.style.margin=0;table.style.padding=0;
1378
var tbody=document.createElement('tbody');
1379
var tr=document.createElement('tr');
1381
var td1=document.createElement('td');
1382
td1.className="standartTreeImage";
1385
var img0=document.createElement("div");
1386
td1.appendChild(img0);
1387
img0.className="dhx_tree_textSign";
1391
var img0=this._getImg(itemObject.id);
1393
if (img0.tagName=="IMG") img0.align="absmiddle";
1394
td1.appendChild(img0); img0.style.padding=0; img0.style.margin=0;
1395
img0.style.width=this.def_line_img_x; img0.style.height=this.def_line_img_y;
1398
var td11=document.createElement('td');
1399
// var inp=document.createElement("input"); inp.type="checkbox"; inp.style.width="12px"; inp.style.height="12px";
1400
var inp=this._getImg(this.cBROf?this.rootId:itemObject.id);
1401
inp.checked=0; this._setSrc(inp,this.imPath+this.checkArray[0]); inp.style.width="16px"; inp.style.height="16px";
1402
//can cause problems with hide/show check
1403
if (!acheck) ((!_isIE)?td11:inp).style.display="none";
1405
// td11.className="standartTreeImage";
1407
td11.appendChild(inp);
1408
if ((!this.cBROf)&&(inp.tagName=="IMG")) inp.align="absmiddle";
1409
inp.onclick=this.onCheckBoxClick;
1411
inp.parentObject=itemObject;
1412
if (!window._KHTMLrv) td11.width="20px";
1413
else td11.width="16px";
1415
var td12=document.createElement('td');
1416
td12.className="standartTreeImage";
1417
var img=this._getImg(this.timgen?itemObject.id:this.rootId);
1418
img.onmousedown=this._preventNsDrag; img.ondragstart=this._preventNsDrag;
1421
img.parentObject=itemObject;
1422
if (img.tagName=="IMG") img.align="absmiddle";
1423
img.onclick=this.onRowSelect; }
1424
if (!mode) this._setSrc(img,this.iconURL+this.imageArray[0]);
1425
td12.appendChild(img); img.style.padding=0; img.style.margin=0;
1428
td12.style.width=img.style.width=this.def_img_x; img.style.height=this.def_img_y; }
1431
img.style.width="0px"; img.style.height="0px";
1432
if (_isOpera) td12.style.display="none";
1436
var td2=document.createElement('td');
1437
td2.className="standartTreeRow";
1439
itemObject.span=document.createElement('span');
1440
itemObject.span.className="standartTreeRow";
1442
itemObject.span.style.width=this.mlitems;
1444
itemObject.span.style.display="block";
1446
else td2.noWrap=true;
1447
if (!window._KHTMLrv) td2.style.width="100%";
1449
// itemObject.span.appendChild(document.createTextNode(itemObject.label));
1450
itemObject.span.innerHTML=itemObject.label;
1451
td2.appendChild(itemObject.span);
1452
td2.parentObject=itemObject; td1.parentObject=itemObject;
1453
td2.onclick=this.onRowSelect; td1.onclick=this.onRowClick; td2.ondblclick=this.onRowClick2;
1455
tr.title=itemObject.label;
1457
if (this.dragAndDropOff) {
1458
if (this._aimgs) { this.dragger.addDraggableItem(td12,this); td12.parentObject=itemObject; }
1459
this.dragger.addDraggableItem(td2,this);
1462
itemObject.span.style.paddingLeft="5px"; itemObject.span.style.paddingRight="5px"; td2.style.verticalAlign="";
1463
td2.style.fontSize="10pt"; td2.style.cursor=this.style_pointer;
1464
tr.appendChild(td1); tr.appendChild(td11); tr.appendChild(td12);
1465
tr.appendChild(td2);
1466
tbody.appendChild(tr);
1467
table.appendChild(tbody);
1469
if (this.ehlt){//highlighting
1470
tr.onmousemove=this._itemMouseIn;
1471
tr[(_isIE)?"onmouseleave":"onmouseout"]=this._itemMouseOut;
1473
if(this.checkEvent && this.checkEvent("onRightClick"))
1474
tr.oncontextmenu=Function("e","this.childNodes[0].parentObject.treeNod.callEvent('onRightClick',[this.childNodes[0].parentObject.id,(e||window.event)]); return false;");
1482
* @desc: set path to images directory
1483
* @param: newPath - path to images directory (related to the page with tree or absolute http url)
1487
dhtmlXTreeObject.prototype.setImagePath=function( newPath ){ this.imPath=newPath; if (!this.iconURL) this.iconURL=newPath; };
1489
* @desc: set path to external images used as tree icons
1491
* @param: path - url (or relative path) of images folder with closing "/"
1494
dhtmlXTreeObject.prototype.setIconPath=function(path){
1501
* @desc: set function called when tree node selected
1502
* @param: (function) func - event handling function
1505
* @event: onRightClick
1506
* @depricated: use grid.attachEvent("onRightClick",func); instead
1507
* @eventdesc: Event occurs after right mouse button was clicked.
1508
Assigning this handler can disable default context menu, and incompattible with dhtmlXMenu integration.
1509
* @eventparam: (string) ID of clicked item
1510
* @eventparam: (object) event object
1512
dhtmlXTreeObject.prototype.setOnRightClickHandler=function(func){ this.attachEvent("onRightClick",func); };
1515
* @desc: set function called when tree node clicked, also can be forced to call from API
1516
* @param: func - event handling function
1520
* @depricated: use grid.attachEvent("onClick",func); instead
1521
* @eventdesc: Event raises immideatly after text part of item in tree was clicked, but after default onClick functionality was processed.
1522
Richt mouse button click can be catched by onRightClick event handler.
1523
* @eventparam: ID of clicked item
1524
* @eventparam: ID of previously selected item
1526
dhtmlXTreeObject.prototype.setOnClickHandler=function(func){ this.attachEvent("onClick",func); };
1529
* @desc: set function called when tree node selected or unselected, include any select change caused by any functionality
1530
* @param: func - event handling function
1534
* @depricated: use grid.attachEvent("onSelect",func); instead
1535
* @eventdesc: Event raises immideatly after selection in tree was changed
1536
* @eventparam: selected item ID ( list of IDs in case of multiselection)
1538
dhtmlXTreeObject.prototype.setOnSelectStateChange=function(func){ this.attachEvent("onSelect",func); this._onSSCF=true; };
1542
* @desc: enables dynamic loading from XML
1544
* @param: filePath - name of script returning XML; in case of virtual loading - user defined function
1547
dhtmlXTreeObject.prototype.setXMLAutoLoading=function(filePath){ this.XMLsource=filePath; };
1550
* @desc: set function called before checkbox checked/unchecked
1551
* @param: func - event handling function
1555
* @depricated: use tree.attachEvent("onCheck",func); instead
1556
* @eventdesc: Event raises right before item in tree was checked/unchecked. can be canceled (return false from event handler)
1557
* @eventparam: ID of item which will be checked/unchecked
1558
* @eventparam: Current checkbox state. 1 - item checked, 0 - item unchecked.
1559
* @eventreturn: true - confirm changing checked state; false - deny chaning checked state;
1561
dhtmlXTreeObject.prototype.setOnCheckHandler=function(func){ this.attachEvent("onCheck",func); };
1565
* @desc: set function called before tree node opened/closed
1566
* @param: func - event handling function
1570
* @depricated: use grid.attachEvent("onOpenStart",func); instead
1571
* @eventdesc: Event raises immideatly after item in tree got command to open/close , and before item was opened//closed. Event also raised for unclosable nodes and nodes without open/close functionality - in that case result of function will be ignored.
1572
Event does not occur if node was opened by dhtmlXtree API.
1573
* @eventparam: ID of node which will be opened/closed
1574
* @eventparam: Current open state of tree item. 0 - item has not children, -1 - item closed, 1 - item opened.
1575
* @eventreturn: true - confirm opening/closing; false - deny opening/closing;
1577
dhtmlXTreeObject.prototype.setOnOpenHandler=function(func){ this.attachEvent("onOpenStart",func); };
1579
* @desc: set function called before tree node opened/closed
1580
* @param: func - event handling function
1583
* @event: onOpenStart
1584
* @depricated: use grid.attachEvent("onOpenStart",func); instead
1585
* @eventdesc: Event raises immideatly after item in tree got command to open/close , and before item was opened//closed. Event also raised for unclosable nodes and nodes without open/close functionality - in that case result of function will be ignored.
1586
Event not raised if node opened by dhtmlXtree API.
1587
* @eventparam: ID of node which will be opened/closed
1588
* @eventparam: Current open state of tree item. 0 - item has not children, -1 - item closed, 1 - item opened.
1589
* @eventreturn: true - confirm opening/closing; false - deny opening/closing;
1591
dhtmlXTreeObject.prototype.setOnOpenStartHandler=function(func){ this.attachEvent("onOpenStart",func); };
1594
* @desc: set function called after tree node opened/closed
1595
* @param: func - event handling function
1599
* @depricated: use grid.attachEvent("onOpenEnd",func); instead
1600
* @eventdesc: Event raises immideatly after item in tree was opened//closed. Event also raised for unclosable nodes and nodes without open/close functionality - in that case result of function will be ignored.
1601
Event not raised if node opened by dhtmlXtree API.
1602
* @eventparam: ID of node which will be opened/closed
1603
* @eventparam: Current open state of tree item. 0 - item has not children, -1 - item closed, 1 - item opened.
1605
dhtmlXTreeObject.prototype.setOnOpenEndHandler=function(func){ this.attachEvent("onOpenEnd",func); };
1608
* @desc: set function called when tree node double clicked
1609
* @param: func - event handling function
1612
* @event: onDblClick
1613
* @depricated: use grid.attachEvent("onDblClick",func); instead
1614
* @eventdesc: Event raised immideatly after item in tree was doubleclicked, before default onDblClick functionality was processed.
1615
Beware using both onClick and onDblClick events, because component can generate onClick event before onDblClick event while doubleclicking item in tree.
1616
( that behavior depend on used browser )
1617
* @eventparam: ID of item which was doubleclicked
1618
* @eventreturn: true - confirm opening/closing; false - deny opening/closing;
1620
dhtmlXTreeObject.prototype.setOnDblClickHandler=function(func){ this.attachEvent("onDblClick",func); };
1631
* @desc: expand target node and all sub nodes
1633
* @param: itemId - node id
1636
dhtmlXTreeObject.prototype.openAllItems=function(itemId)
1638
var temp=this._globalIdStorageFind(itemId);
1639
if (!temp) return 0;
1640
this._xopenAll(temp);
1644
* @desc: return open/close state
1646
* @param: itemId - node id
1647
* @return: -1 - close, 1 - opened, 0 - node doesn't have children
1650
dhtmlXTreeObject.prototype.getOpenState=function(itemId){
1651
var temp=this._globalIdStorageFind(itemId);
1652
if (!temp) return "";
1653
return this._getOpenState(temp);
1657
* @desc: collapse target node and all sub nodes
1659
* @param: itemId - node id
1662
dhtmlXTreeObject.prototype.closeAllItems=function(itemId)
1664
if (itemId===window.undefined) itemId=this.rootId;
1666
var temp=this._globalIdStorageFind(itemId);
1667
if (!temp) return 0;
1668
this._xcloseAll(temp);
1670
//nb:solves standard doctype prb in IE
1671
this.allTree.childNodes[0].border = "1";
1672
this.allTree.childNodes[0].border = "0";
1678
* @desc: set user data for target node
1680
* @param: itemId - target node id
1681
* @param: name - key for user data
1682
* @param: value - user data value
1685
dhtmlXTreeObject.prototype.setUserData=function(itemId,name,value){
1686
var sNode=this._globalIdStorageFind(itemId,0,true);
1689
sNode.htmlNode.childNodes[0].childNodes[0].title=value;
1690
if (typeof(sNode.userData["t_"+name])=="undefined"){
1691
if (!sNode._userdatalist) sNode._userdatalist=name;
1692
else sNode._userdatalist+=","+name;
1694
sNode.userData["t_"+name]=value;
1698
* @desc: get user data from target node
1700
* @param: itemId - target node id
1701
* @param: name - key for user data
1702
* @return: value of user data
1705
dhtmlXTreeObject.prototype.getUserData=function(itemId,name){
1706
var sNode=this._globalIdStorageFind(itemId,0,true);
1708
return sNode.userData["t_"+name];
1715
* @desc: get node color (text color)
1716
* @param: itemId - id of node
1718
* @return: color of node (empty string for default color);
1721
dhtmlXTreeObject.prototype.getItemColor=function(itemId)
1723
var temp=this._globalIdStorageFind(itemId);
1724
if (!temp) return 0;
1726
var res= new Object();
1727
if (temp.acolor) res.acolor=temp.acolor;
1728
if (temp.scolor) res.scolor=temp.scolor;
1732
* @desc: set node text color
1733
* @param: itemId - id of node
1734
* @param: defaultColor - node color
1735
* @param: selectedColor - selected node color
1739
dhtmlXTreeObject.prototype.setItemColor=function(itemId,defaultColor,selectedColor)
1741
if ((itemId)&&(itemId.span))
1744
var temp=this._globalIdStorageFind(itemId);
1745
if (!temp) return 0;
1748
{ if (selectedColor) temp.span.style.color=selectedColor; }
1750
{ if (defaultColor) temp.span.style.color=defaultColor; }
1752
if (selectedColor) temp.scolor=selectedColor;
1753
if (defaultColor) temp.acolor=defaultColor;
1758
* @desc: return node text
1759
* @param: itemId - id of node
1761
* @return: text of item (with HTML formatting, if any)
1764
dhtmlXTreeObject.prototype.getItemText=function(itemId)
1766
var temp=this._globalIdStorageFind(itemId);
1767
if (!temp) return 0;
1768
return(temp.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML);
1771
* @desc: return parent item id
1772
* @param: itemId - id of node
1774
* @return: id of parent item
1777
dhtmlXTreeObject.prototype.getParentId=function(itemId)
1779
var temp=this._globalIdStorageFind(itemId);
1780
if ((!temp)||(!temp.parentObject)) return "";
1781
return temp.parentObject.id;
1787
* @desc: change item id
1789
* @param: itemId - old node id
1790
* @param: newItemId - new node id
1793
dhtmlXTreeObject.prototype.changeItemId=function(itemId,newItemId)
1795
if (itemId==newItemId) return;
1796
var temp=this._globalIdStorageFind(itemId);
1797
if (!temp) return 0;
1799
temp.span.contextMenuId=newItemId;
1800
this._idpull[newItemId]=this._idpull[itemId];
1801
delete this._idpull[itemId];
1806
* @desc: mark selected item as cut
1810
dhtmlXTreeObject.prototype.doCut=function(){
1811
if (this.nodeCut) this.clearCut();
1812
this.nodeCut=(new Array()).concat(this._selected);
1813
for (var i=0; i<this.nodeCut.length; i++){
1814
var tempa=this.nodeCut[i];
1815
tempa._cimgs=new Array();
1816
tempa._cimgs[0]=tempa.images[0];
1817
tempa._cimgs[1]=tempa.images[1];
1818
tempa._cimgs[2]=tempa.images[2];
1819
tempa.images[0]=tempa.images[1]=tempa.images[2]=this.cutImage;
1820
this._correctPlus(tempa);
1825
* @desc: insert previously cut branch
1826
* @param: itemId - id of new parent node
1830
dhtmlXTreeObject.prototype.doPaste=function(itemId){
1831
var tobj=this._globalIdStorageFind(itemId);
1832
if (!tobj) return 0;
1833
for (var i=0; i<this.nodeCut.length; i++){
1834
if (this._checkPNodes(tobj,this.nodeCut[i])) continue;
1835
this._moveNode(this.nodeCut[i],tobj);
1845
dhtmlXTreeObject.prototype.clearCut=function(){
1846
for (var i=0; i<this.nodeCut.length; i++)
1848
var tempa=this.nodeCut[i];
1849
tempa.images[0]=tempa._cimgs[0];
1850
tempa.images[1]=tempa._cimgs[1];
1851
tempa.images[2]=tempa._cimgs[2];
1852
this._correctPlus(tempa);
1854
this.nodeCut=new Array();
1860
* @desc: move node with subnodes
1862
* @param: itemObject - moved node object
1863
* @param: targetObject - new parent node
1866
dhtmlXTreeObject.prototype._moveNode=function(itemObject,targetObject){
1868
return this._moveNodeTo(itemObject,targetObject);
1873
* @desc: fix order of nodes in collection
1875
* @param: target - parent item node
1876
* @param: zParent - before node
1877
* @edition: Professional
1881
dhtmlXTreeObject.prototype._fixNodesCollection=function(target,zParent){
1882
var flag=0; var icount=0;
1883
var Nodes=target.childNodes;
1884
var Count=target.childsCount-1;
1886
if (zParent==Nodes[Count]) return;
1887
for (var i=0; i<Count; i++)
1888
if (Nodes[i]==Nodes[Count]) { Nodes[i]=Nodes[i+1]; Nodes[i+1]=Nodes[Count]; }
1890
// Count=target.childsCount;
1891
for (var i=0; i<Count+1; i++)
1899
if (Nodes[i]==zParent) { flag=Nodes[i]; Nodes[i]=Nodes[Count]; }
1904
* @desc: recreate branch
1906
* @param: itemObject - moved node object
1907
* @param: targetObject - new parent node
1908
* @param: level - top level flag
1909
* @param: beforeNode - node for sibling mode
1910
* @mode: mode - DragAndDrop mode (0 - as child, 1 as sibling)
1911
* @edition: Professional
1914
dhtmlXTreeObject.prototype._recreateBranch=function(itemObject,targetObject,beforeNode,level){
1917
for (i=0; i<targetObject.childsCount; i++)
1918
if (targetObject.childNodes[i]==beforeNode) break;
1921
beforeNode=targetObject.childNodes[i-1];
1928
var t2=this._onradh; this._onradh=null;
1929
var newNode=this._attachChildNode(targetObject,itemObject.id,itemObject.label,0,itemObject.images[0],itemObject.images[1],itemObject.images[2],st,0,beforeNode);
1932
newNode._userdatalist=itemObject._userdatalist;
1933
newNode.userData=itemObject.userData.clone();
1934
newNode.XMLload=itemObject.XMLload;
1936
this._onradh=t2; this._onradh(newNode.id); }
1939
for (var i=0; i<itemObject.childsCount; i++)
1940
this._recreateBranch(itemObject.childNodes[i],newNode,0,1);
1947
* @desc: move single node
1949
* @param: itemObject - moved node object
1950
* @param: targetObject - new parent node
1951
* @mode: mode - DragAndDrop mode (0 - as child, 1 as sibling)
1954
dhtmlXTreeObject.prototype._moveNodeTo=function(itemObject,targetObject,beforeNode){
1956
if (itemObject.treeNod._nonTrivialNode)
1957
return itemObject.treeNod._nonTrivialNode(this,targetObject,beforeNode,itemObject);
1959
if (targetObject.mytype)
1960
var framesMove=(itemObject.treeNod.lWin!=targetObject.lWin);
1962
var framesMove=(itemObject.treeNod.lWin!=targetObject.treeNod.lWin);
1964
if (!this.callEvent("onDrag",[itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),itemObject.treeNod,targetObject.treeNod])) return false;
1965
if ((targetObject.XMLload==0)&&(this.XMLsource))
1967
targetObject.XMLload=1;
1968
this._loadDynXML(targetObject.id);
1970
this.openItem(targetObject.id);
1972
var oldTree=itemObject.treeNod;
1973
var c=itemObject.parentObject.childsCount;
1974
var z=itemObject.parentObject;
1977
if ((framesMove)||(oldTree.dpcpy)) {//interframe drag flag
1978
var _otiid=itemObject.id;
1979
itemObject=this._recreateBranch(itemObject,targetObject,beforeNode);
1980
if (!oldTree.dpcpy) oldTree.deleteItem(_otiid);
1985
var Count=targetObject.childsCount; var Nodes=targetObject.childNodes;
1986
if (Count==0) targetObject._open=true;
1987
oldTree._unselectItem(itemObject);
1988
Nodes[Count]=itemObject;
1989
itemObject.treeNod=targetObject.treeNod;
1990
targetObject.childsCount++;
1992
var tr=this._drawNewTr(Nodes[Count].htmlNode);
1996
targetObject.htmlNode.childNodes[0].appendChild(tr);
1997
if (this.dadmode==1) this._fixNodesCollection(targetObject,beforeNode);
2001
targetObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr);
2002
this._fixNodesCollection(targetObject,beforeNode);
2003
Nodes=targetObject.childNodes;
2009
if ((!oldTree.dpcpy)&&(!framesMove)) {
2010
var zir=itemObject.tr;
2012
if ((document.all)&&(navigator.appVersion.search(/MSIE\ 5\.0/gi)!=-1))
2014
window.setTimeout(function() { zir.parentNode.removeChild(zir); } , 250 );
2016
else //if (zir.parentNode) zir.parentNode.removeChild(zir,true);
2018
itemObject.parentObject.htmlNode.childNodes[0].removeChild(itemObject.tr);
2020
//itemObject.tr.removeNode(true);
2021
if ((!beforeNode)||(targetObject!=itemObject.parentObject)){
2022
for (var i=0; i<z.childsCount; i++){
2023
if (z.childNodes[i].id==itemObject.id) {
2026
else z.childNodes[z.childsCount-1]=0;
2028
oldTree._compressChildList(z.childsCount,z.childNodes);
2033
if ((!framesMove)&&(!oldTree.dpcpy)) {
2035
tr.nodem=itemObject;
2036
itemObject.parentObject=targetObject;
2038
if (oldTree!=targetObject.treeNod) { if(itemObject.treeNod._registerBranch(itemObject,oldTree)) return; this._clearStyles(itemObject); this._redrawFrom(this,itemObject.parentObject); };
2040
this._correctPlus(targetObject);
2041
this._correctLine(targetObject);
2043
this._correctLine(itemObject);
2044
this._correctPlus(itemObject);
2046
//fix target siblings
2050
this._correctPlus(beforeNode);
2051
//this._correctLine(beforeNode);
2054
if (targetObject.childsCount>=2)
2057
this._correctPlus(Nodes[targetObject.childsCount-2]);
2058
this._correctLine(Nodes[targetObject.childsCount-2]);
2061
this._correctPlus(Nodes[targetObject.childsCount-1]);
2062
//this._correctLine(Nodes[targetObject.childsCount-1]);
2065
if (this.tscheck) this._correctCheckStates(targetObject);
2066
if (oldTree.tscheck) oldTree._correctCheckStates(z);
2072
if (c>1) { oldTree._correctPlus(z.childNodes[c-2]);
2073
oldTree._correctLine(z.childNodes[c-2]);
2077
// if (z.childsCount==0)
2078
oldTree._correctPlus(z);
2079
oldTree._correctLine(z);
2082
this.callEvent("onDrop",[itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),oldTree,targetObject.treeNod]);
2083
return itemObject.id;
2089
* @desc: recursive set default styles for node
2091
* @param: itemObject - target node object
2094
dhtmlXTreeObject.prototype._clearStyles=function(itemObject){
2095
if (!itemObject.htmlNode) return; //some weird case in SRND mode
2096
var td1=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[1];
2097
var td3=td1.nextSibling.nextSibling;
2099
itemObject.span.innerHTML=itemObject.label;
2100
itemObject.i_sel=false;
2102
if (itemObject._aimgs)
2103
this.dragger.removeDraggableItem(td1.nextSibling);
2105
if (this.checkBoxOff) {
2106
td1.childNodes[0].style.display="";
2107
td1.childNodes[0].onclick=this.onCheckBoxClick;
2108
this._setSrc(td1.childNodes[0],this.imPath+this.checkArray[itemObject.checkstate]);
2110
else td1.childNodes[0].style.display="none";
2111
td1.childNodes[0].treeNod=this;
2113
this.dragger.removeDraggableItem(td3);
2114
if (this.dragAndDropOff) this.dragger.addDraggableItem(td3,this);
2115
if (this._aimgs) this.dragger.addDraggableItem(td1.nextSibling,this);
2117
td3.childNodes[0].className="standartTreeRow";
2118
td3.onclick=this.onRowSelect; td3.ondblclick=this.onRowClick2;
2119
td1.previousSibling.onclick=this.onRowClick;
2121
this._correctLine(itemObject);
2122
this._correctPlus(itemObject);
2123
for (var i=0; i<itemObject.childsCount; i++) this._clearStyles(itemObject.childNodes[i]);
2127
* @desc: register node and all children nodes
2129
* @param: itemObject - node object
2132
dhtmlXTreeObject.prototype._registerBranch=function(itemObject,oldTree){
2133
if (oldTree) oldTree._globalIdStorageSub(itemObject.id);
2134
itemObject.id=this._globalIdStorageAdd(itemObject.id,itemObject);
2135
itemObject.treeNod=this;
2136
for (var i=0; i<itemObject.childsCount; i++)
2137
this._registerBranch(itemObject.childNodes[i],oldTree);
2143
* @desc: enable three state checkboxes
2145
* @param: mode - 1 - on, 0 - off;
2149
dhtmlXTreeObject.prototype.enableThreeStateCheckboxes=function(mode) { this.tscheck=convertStringToBoolean(mode); };
2153
* @desc: set function called when mouse is over tree node
2154
* @param: func - event handling function
2158
* @depricated: use grid.attachEvent("onMouseIn",func); instead
2159
* @eventdesc: Event raised immideatly after mouse started moving over item
2160
* @eventparam: ID of item
2162
dhtmlXTreeObject.prototype.setOnMouseInHandler=function(func){
2164
this.attachEvent("onMouseIn",func);
2168
* @desc: set function called when mouse is out of tree node
2169
* @param: func - event handling function
2172
* @event: onMouseOut
2173
* @depricated: use grid.attachEvent("onMouseOut",func); instead
2174
* @eventdesc: Event raised immideatly after mouse moved out of item
2175
* @eventparam: ID of clicked item
2177
dhtmlXTreeObject.prototype.setOnMouseOutHandler=function(func){
2179
this.attachEvent("onMouseOut",func);
2191
* @desc: enable tree images
2193
* @param: mode - 1 - on, 0 - off;
2197
dhtmlXTreeObject.prototype.enableTreeImages=function(mode) { this.timgen=convertStringToBoolean(mode); };
2202
* @desc: enable mode with fixed tables (looks better, but has no horisontal scrollbar)
2204
* @param: mode - 1 - on, 0 - off;
2208
dhtmlXTreeObject.prototype.enableFixedMode=function(mode) { this.hfMode=convertStringToBoolean(mode); };
2211
* @desc: show/hide checkboxes (all checkboxes in tree)
2213
* @param: mode - true/false
2214
* @param: hidden - if set to true, checkboxes not rendered but can be shown by showItemCheckbox
2217
dhtmlXTreeObject.prototype.enableCheckBoxes=function(mode, hidden){ this.checkBoxOff=convertStringToBoolean(mode); this.cBROf=(!(this.checkBoxOff||convertStringToBoolean(hidden)));
2220
* @desc: set default images for nodes (must be called before XML loading)
2222
* @param: a0 - image for node without children;
2223
* @param: a1 - image for closed node;
2224
* @param: a2 - image for opened node
2227
dhtmlXTreeObject.prototype.setStdImages=function(image1,image2,image3){
2228
this.imageArray[0]=image1; this.imageArray[1]=image2; this.imageArray[2]=image3;};
2231
* @desc: enable/disable tree lines (parent-child threads)
2233
* @param: mode - enable/disable tree lines
2236
dhtmlXTreeObject.prototype.enableTreeLines=function(mode){
2237
this.treeLinesOn=convertStringToBoolean(mode);
2241
* @desc: set images used for parent-child threads drawing (lines, plus, minus)
2243
* @param: arrayName - name of array: plus, minus
2244
* @param: image1 - line crossed image
2245
* @param: image2 - image with top line
2246
* @param: image3 - image with bottom line
2247
* @param: image4 - image without line
2248
* @param: image5 - single root image
2251
dhtmlXTreeObject.prototype.setImageArrays=function(arrayName,image1,image2,image3,image4,image5){
2253
case "plus": this.plusArray[0]=image1; this.plusArray[1]=image2; this.plusArray[2]=image3; this.plusArray[3]=image4; this.plusArray[4]=image5; break;
2254
case "minus": this.minusArray[0]=image1; this.minusArray[1]=image2; this.minusArray[2]=image3; this.minusArray[3]=image4; this.minusArray[4]=image5; break;
2259
* @desc: expand node
2260
* @param: itemId - id of node
2264
dhtmlXTreeObject.prototype.openItem=function(itemId){
2265
var temp=this._globalIdStorageFind(itemId);
2266
if (!temp) return 0;
2267
else return this._openItem(temp);
2271
* @desc: expand node
2272
* @param: item - tree node object
2277
dhtmlXTreeObject.prototype._openItem=function(item){
2278
var state=this._getOpenState(item);
2279
if ((state<0)||(((this.XMLsource)&&(!item.XMLload)))){
2280
if (!this.callEvent("onOpenStart",[item.id,state])) return 0;
2281
this._HideShow(item,2);
2282
if (this.checkEvent("onOpenEnd")){
2283
if (this.onXLE==this._epnFHe) this._epnFHe(this,item.id,true);
2284
if (!this.xmlstate || !this.XMLsource)
2285
this.callEvent("onOpenEnd",[item.id,this._getOpenState(item)]);
2287
this._oie_onXLE.push(this.onXLE);
2288
this.onXLE=this._epnFHe;
2291
} else if (this._srnd) this._HideShow(item,2);
2292
if (item.parentObject) this._openItem(item.parentObject);
2296
* @desc: collapse node
2297
* @param: itemId - id of node
2301
dhtmlXTreeObject.prototype.closeItem=function(itemId){
2302
if (this.rootId==itemId) return 0;
2303
var temp=this._globalIdStorageFind(itemId);
2304
if (!temp) return 0;
2306
this._HideShow(temp,1);
2335
* @desc: get node level (position in hierarchy)
2336
* @param: itemId - id of node
2338
* @return: node level (0 if no such item in hierarchy - probably super root)
2341
dhtmlXTreeObject.prototype.getLevel=function(itemId){
2342
var temp=this._globalIdStorageFind(itemId);
2343
if (!temp) return 0;
2344
return this._getNodeLevel(temp,0);
2350
* @desc: prevent node from closing
2351
* @param: itemId - id of node
2352
* @param: flag - if 0 - node can't be closed, else node can be closed
2356
dhtmlXTreeObject.prototype.setItemCloseable=function(itemId,flag)
2358
flag=convertStringToBoolean(flag);
2359
if ((itemId)&&(itemId.span))
2362
var temp=this._globalIdStorageFind(itemId);
2363
if (!temp) return 0;
2368
* @desc: recursive function used for node level calculation
2369
* @param: itemObject - pointer to node object
2370
* @param: count - counter of levels
2374
dhtmlXTreeObject.prototype._getNodeLevel=function(itemObject,count){
2375
if (itemObject.parentObject) return this._getNodeLevel(itemObject.parentObject,count+1);
2380
* @desc: return number of children
2381
* @param: itemId - id of node
2383
* @return: number of child items for loaded branches; true - for not loaded branches
2386
dhtmlXTreeObject.prototype.hasChildren=function(itemId){
2387
var temp=this._globalIdStorageFind(itemId);
2388
if (!temp) return 0;
2391
if ( (this.XMLsource)&&(!temp.XMLload) ) return true;
2393
return temp.childsCount;
2399
* @desc: get number of leafs (nodes without children)
2400
* @param: itemNode - node object
2402
* @edition: Professional
2405
dhtmlXTreeObject.prototype._getLeafCount=function(itemNode){
2407
for (var b=0; b<itemNode.childsCount; b++)
2408
if (itemNode.childNodes[b].childsCount==0) a++;
2414
* @desc: set new node text (HTML allowed)
2415
* @param: itemId - id of node
2416
* @param: newLabel - node text
2417
* @param: newTooltip - (optional)tooltip for the node
2421
dhtmlXTreeObject.prototype.setItemText=function(itemId,newLabel,newTooltip)
2423
var temp=this._globalIdStorageFind(itemId);
2424
if (!temp) return 0;
2425
temp.label=newLabel;
2426
temp.span.innerHTML=newLabel;
2428
temp.span.parentNode.parentNode.title=newTooltip||"";
2432
* @desc: get item's tooltip
2433
* @param: itemId - id of node
2437
dhtmlXTreeObject.prototype.getItemTooltip=function(itemId){
2438
var temp=this._globalIdStorageFind(itemId);
2439
if (!temp) return "";
2440
return (temp.span.parentNode.parentNode._dhx_title||temp.span.parentNode.parentNode.title||"");
2444
* @desc: refresh tree branch from xml (XML with child nodes rerequested from server)
2445
* @param: itemId - id of node, if not defined tree super root used.
2449
dhtmlXTreeObject.prototype.refreshItem=function(itemId){
2450
if (!itemId) itemId=this.rootId;
2451
var temp=this._globalIdStorageFind(itemId);
2452
this.deleteChildItems(itemId);
2453
this._loadDynXML(itemId);
2457
* @desc: set item images
2458
* @param: itemId - id of node
2459
* @param: image1 - node without children icon
2460
* @param: image2 - closed node icon
2461
* @param: image3 - open node icon
2465
dhtmlXTreeObject.prototype.setItemImage2=function(itemId, image1,image2,image3){
2466
var temp=this._globalIdStorageFind(itemId);
2467
if (!temp) return 0;
2468
temp.images[1]=image2;
2469
temp.images[2]=image3;
2470
temp.images[0]=image1;
2471
this._correctPlus(temp);
2474
* @desc: set item icons (mostly usefull for childless nodes)
2475
* @param: itemId - id of node
2476
* @param: image1 - node without children icon or closed node icon (if image2 specified)
2477
* @param: image2 - open node icon (optional)
2481
dhtmlXTreeObject.prototype.setItemImage=function(itemId,image1,image2)
2483
var temp=this._globalIdStorageFind(itemId);
2484
if (!temp) return 0;
2487
temp.images[1]=image1;
2488
temp.images[2]=image2;
2490
else temp.images[0]=image1;
2491
this._correctPlus(temp);
2496
* @desc: Returns the list of all subitems Ids from the next level of tree, separated by commas.
2497
* @param: itemId - id of node
2499
* @return: list of all subitems from the next level of tree, separated by commas.
2502
dhtmlXTreeObject.prototype.getSubItems =function(itemId)
2504
var temp=this._globalIdStorageFind(itemId,0,1);
2505
if (!temp) return 0;
2508
for (i=0; i<temp.childsCount; i++){
2509
if (!z) z=temp.childNodes[i].id;
2510
else z+=this.dlmtr+temp.childNodes[i].id;
2521
* @desc: Returns the list of all sub items from all next levels of tree, separated by commas.
2522
* @param: itemId - id of node
2523
* @edition: Professional
2527
dhtmlXTreeObject.prototype._getAllScraggyItems =function(node)
2530
for (var i=0; i<node.childsCount; i++)
2532
if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
2534
if (node.childNodes[i].unParsed)
2535
var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);
2537
var zb=this._getAllScraggyItems(node.childNodes[i])
2540
if (z) z+=this.dlmtr+zb;
2544
if (!z) z=node.childNodes[i].id;
2545
else z+=this.dlmtr+node.childNodes[i].id;
2555
* @desc: Returns the list of all children items from all next levels of tree, separated by commas.
2556
* @param: itemId - id of node
2558
* @edition: Professional
2562
dhtmlXTreeObject.prototype._getAllFatItems =function(node)
2565
for (var i=0; i<node.childsCount; i++)
2567
if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
2569
if (!z) z=node.childNodes[i].id;
2570
else z+=this.dlmtr+node.childNodes[i].id;
2572
if (node.childNodes[i].unParsed)
2573
var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);
2575
var zb=this._getAllFatItems(node.childNodes[i])
2577
if (zb) z+=this.dlmtr+zb;
2585
* @desc: Returns the list of all children items from all next levels of tree, separated by commas.
2586
* @param: itemId - id of node
2590
dhtmlXTreeObject.prototype._getAllSubItems =function(itemId,z,node)
2592
if (node) temp=node;
2594
var temp=this._globalIdStorageFind(itemId);
2596
if (!temp) return 0;
2599
for (var i=0; i<temp.childsCount; i++)
2601
if (!z) z=temp.childNodes[i].id;
2602
else z+=this.dlmtr+temp.childNodes[i].id;
2603
var zb=this._getAllSubItems(0,z,temp.childNodes[i])
2605
if (zb) z+=this.dlmtr+zb;
2617
* @desc: select node ( and optionaly fire onselect event)
2619
* @param: itemId - node id
2620
* @param: mode - If true, script function for selected node will be called.
2621
* @param: preserve - preserve earlier selected nodes
2624
dhtmlXTreeObject.prototype.selectItem=function(itemId,mode,preserve){
2625
mode=convertStringToBoolean(mode);
2626
var temp=this._globalIdStorageFind(itemId);
2627
if ((!temp)||(!temp.parentObject)) return 0;
2629
if (this.XMLloadingWarning)
2630
temp.parentObject.openMe=1;
2632
this._openItem(temp.parentObject);
2634
//temp.onRowSelect(0,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],mode);
2637
ze=new Object; ze.ctrlKey=true;
2638
if (temp.i_sel) ze.skipUnSel=true;
2641
this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],false);
2643
this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],true);
2647
* @desc: retun selected node text
2649
* @return: text of selected node (or list of all selected nodes text if more than one selected)
2652
dhtmlXTreeObject.prototype.getSelectedItemText=function()
2654
var str=new Array();
2655
for (var i=0; i<this._selected.length; i++) str[i]=this._selected[i].span.innerHTML;
2656
return (str.join(this.dlmtr));
2663
* @desc: correct childNode list after node deleting
2665
* @param: Count - childNodes collection length
2666
* @param: Nodes - childNodes collection
2669
dhtmlXTreeObject.prototype._compressChildList=function(Count,Nodes)
2672
for (var i=0; i<Count; i++)
2674
if (Nodes[i]==0) { Nodes[i]=Nodes[i+1]; Nodes[i+1]=0;}
2678
* @desc: delete node
2680
* @param: itemId - target node id
2681
* @param: htmlObject - target node object
2682
* @param: skip - node unregistration mode (optional, used by private methods)
2685
dhtmlXTreeObject.prototype._deleteNode=function(itemId,htmlObject,skip){
2686
if ((!htmlObject)||(!htmlObject.parentObject)) return 0;
2687
var tempos=0; var tempos2=0;
2688
if (htmlObject.tr.nextSibling) tempos=htmlObject.tr.nextSibling.nodem;
2689
if (htmlObject.tr.previousSibling) tempos2=htmlObject.tr.previousSibling.nodem;
2691
var sN=htmlObject.parentObject;
2692
var Count=sN.childsCount;
2693
var Nodes=sN.childNodes;
2694
for (var i=0; i<Count; i++)
2696
if (Nodes[i].id==itemId) {
2697
if (!skip) sN.htmlNode.childNodes[0].removeChild(Nodes[i].tr);
2702
this._compressChildList(Count,Nodes);
2708
this._correctPlus(tempos);
2709
this._correctLine(tempos);
2712
this._correctPlus(tempos2);
2713
this._correctLine(tempos2);
2715
if (this.tscheck) this._correctCheckStates(sN);
2718
this._globalIdStorageRecSub(htmlObject);
2722
* @desc: set state of node's checkbox
2724
* @param: itemId - target node id
2725
* @param: state - checkbox state (0/1/"unsure")
2728
dhtmlXTreeObject.prototype.setCheck=function(itemId,state){
2729
var sNode=this._globalIdStorageFind(itemId,0,1);
2732
if (state==="unsure")
2733
this._setCheck(sNode,state);
2736
state=convertStringToBoolean(state);
2737
if ((this.tscheck)&&(this.smcheck)) this._setSubChecked(state,sNode);
2738
else this._setCheck(sNode,state);
2741
this._correctCheckStates(sNode.parentObject);
2744
dhtmlXTreeObject.prototype._setCheck=function(sNode,state){
2746
if (((sNode.parentObject._r_logic)||(this._frbtr))&&(state))
2748
if (this._frbtrL) this.setCheck(this._frbtrL.id,0);
2751
for (var i=0; i<sNode.parentObject.childsCount; i++)
2752
this._setCheck(sNode.parentObject.childNodes[i],0);
2754
var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
2756
if (state=="unsure") sNode.checkstate=2;
2757
else if (state) sNode.checkstate=1; else sNode.checkstate=0;
2758
if (sNode.dscheck) sNode.checkstate=sNode.dscheck;
2759
this._setSrc(z,this.imPath+((sNode.parentObject._r_logic||this._frbtr)?this.radioArray:this.checkArray)[sNode.checkstate]);
2763
* @desc: change state of node's checkbox and all children checkboxes
2765
* @param: itemId - target node id
2766
* @param: state - checkbox state
2769
dhtmlXTreeObject.prototype.setSubChecked=function(itemId,state){
2770
var sNode=this._globalIdStorageFind(itemId);
2771
this._setSubChecked(state,sNode);
2772
this._correctCheckStates(sNode.parentObject);
2778
* @desc: change state of node's checkbox and all childnodes checkboxes
2780
* @param: itemId - target node id
2781
* @param: state - checkbox state
2782
* @param: sNode - target node object (optional, used by private methods)
2785
dhtmlXTreeObject.prototype._setSubChecked=function(state,sNode){
2786
state=convertStringToBoolean(state);
2788
if (((sNode.parentObject._r_logic)||(this._frbtr))&&(state))
2789
for (var i=0; i<sNode.parentObject.childsCount; i++)
2790
this._setSubChecked(0,sNode.parentObject.childNodes[i]);
2793
if (sNode._r_logic||this._frbtr)
2794
this._setSubChecked(state,sNode.childNodes[0]);
2796
for (var i=0; i<sNode.childsCount; i++)
2798
this._setSubChecked(state,sNode.childNodes[i]);
2800
var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
2802
if (state) sNode.checkstate=1;
2803
else sNode.checkstate=0;
2804
if (sNode.dscheck) sNode.checkstate=sNode.dscheck;
2808
this._setSrc(z,this.imPath+((sNode.parentObject._r_logic||this._frbtr)?this.radioArray:this.checkArray)[sNode.checkstate]);
2812
* @desc: get state of nodes's checkbox
2814
* @param: itemId - target node id
2815
* @return: node state (0 - unchecked,1 - checked, 2 - third state)
2818
dhtmlXTreeObject.prototype.isItemChecked=function(itemId){
2819
var sNode=this._globalIdStorageFind(itemId);
2821
return sNode.checkstate;
2831
* @desc: delete all children of node
2833
* @param: itemId - node id
2836
dhtmlXTreeObject.prototype.deleteChildItems=function(itemId)
2838
var sNode=this._globalIdStorageFind(itemId);
2840
var j=sNode.childsCount;
2841
for (var i=0; i<j; i++)
2843
this._deleteNode(sNode.childNodes[0].id,sNode.childNodes[0]);
2848
* @desc: delete node
2850
* @param: itemId - node id
2851
* @param: selectParent - If true parent of deleted item get selection, else no selected items leaving in tree.
2854
dhtmlXTreeObject.prototype.deleteItem=function(itemId,selectParent){
2855
if ((!this._onrdlh)||(this._onrdlh(itemId))){
2856
var z=this._deleteItem(itemId,selectParent);
2860
//nb:solves standard doctype prb in IE
2861
this.allTree.childNodes[0].border = "1";
2862
this.allTree.childNodes[0].border = "0";
2865
* @desc: delete node
2867
* @param: id - node id
2868
* @param: selectParent - If true parent of deleted item get selection, else no selected items leaving in tree.
2869
* @param: skip - unregistering mode (optional, used by private methods)
2872
dhtmlXTreeObject.prototype._deleteItem=function(itemId,selectParent,skip){
2873
selectParent=convertStringToBoolean(selectParent);
2874
var sNode=this._globalIdStorageFind(itemId);
2876
var pid=this.getParentId(itemId);
2878
var zTemp=sNode.parentObject;
2879
this._deleteNode(itemId,sNode,skip);
2880
this._correctPlus(zTemp);
2881
this._correctLine(zTemp);
2883
if ((selectParent)&&(pid!=this.rootId)) this.selectItem(pid,1);
2888
* @desc: uregister all child nodes of target node
2890
* @param: itemObject - node object
2893
dhtmlXTreeObject.prototype._globalIdStorageRecSub=function(itemObject){
2894
for(var i=0; i<itemObject.childsCount; i++)
2896
this._globalIdStorageRecSub(itemObject.childNodes[i]);
2897
this._globalIdStorageSub(itemObject.childNodes[i].id);
2899
this._globalIdStorageSub(itemObject.id);
2901
/*anti memory leaking*/
2903
// var par=z.span.parentNode.parentNode.childNodes;
2904
// par[0].parentObject=null;
2905
// par[1].childNodes[0].parentObject=null;
2906
// par[2].childNodes[0].parentObject=null;
2907
// par[2].childNodes[0].treeNod=null;
2908
// par[2].parentObject=null;
2909
// par[3].parentObject=null;
2917
* @desc: create new node next to specified
2919
* @param: itemId - node id
2920
* @param: newItemId - new node id
2921
* @param: itemText - new node text
2922
* @param: itemActionHandler - function fired on node select event (optional)
2923
* @param: image1 - image for node without children; (optional)
2924
* @param: image2 - image for closed node; (optional)
2925
* @param: image3 - image for opened node (optional)
2926
* @param: optionStr - options string (optional)
2927
* @param: children - node children flag (for dynamical trees) (optional)
2930
dhtmlXTreeObject.prototype.insertNewNext=function(itemId,newItemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){
2931
var sNode=this._globalIdStorageFind(itemId);
2932
if ((!sNode)||(!sNode.parentObject)) return (0);
2934
var nodez=this._attachChildNode(0,newItemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children,sNode);
2942
* @desc: retun node id by index
2944
* @param: itemId - parent node id
2945
* @param: index - index of node, 0 based
2949
dhtmlXTreeObject.prototype.getItemIdByIndex=function(itemId,index){
2950
var z=this._globalIdStorageFind(itemId);
2951
if ((!z)||(index>z.childsCount)) return null;
2952
return z.childNodes[index].id;
2956
* @desc: retun child node id by index
2958
* @param: itemId - parent node id
2959
* @param: index - index of child node
2963
dhtmlXTreeObject.prototype.getChildItemIdByIndex=function(itemId,index){
2964
var z=this._globalIdStorageFind(itemId);
2965
if ((!z)||(index>=z.childsCount)) return null;
2966
return z.childNodes[index].id;
2974
* @desc: set function called when drag-and-drop event occured
2975
* @param: aFunc - event handling function
2979
* @depricated: use grid.attachEvent("onDrag",func); instead
2980
* @eventdesc: Event occured after item was dragged and droped on another item, but before item moving processed.
2981
Event also raised while programmatic moving nodes.
2982
* @eventparam: ID of source item
2983
* @eventparam: ID of target item
2984
* @eventparam: if node droped as sibling then contain id of item before whitch source node will be inserted
2985
* @eventparam: source Tree object
2986
* @eventparam: target Tree object
2987
* @eventreturn: true - confirm drag-and-drop; false - deny drag-and-drop;
2989
dhtmlXTreeObject.prototype.setDragHandler=function(func){ this.attachEvent("onDrag",func); };
2992
* @desc: clear selection from node
2993
* @param: htmlNode - pointer to node object
2997
dhtmlXTreeObject.prototype._clearMove=function(){
2998
if (this._lastMark){
2999
this._lastMark.className=this._lastMark.className.replace(/dragAndDropRow/g,"");
3000
this._lastMark=null;
3003
this.allTree.className=this.allTree.className.replace(" selectionBox","");
3007
* @desc: enable/disable drag-and-drop
3009
* @param: mode - enabled/disabled [ can be true/false/temporary_disabled - last value mean that tree can be D-n-D can be switched to true later ]
3010
* @param: rmode - enabled/disabled drag and drop on super root
3013
dhtmlXTreeObject.prototype.enableDragAndDrop=function(mode,rmode){
3014
if (mode=="temporary_disabled"){
3015
this.dADTempOff=false;
3018
this.dADTempOff=true;
3020
this.dragAndDropOff=convertStringToBoolean(mode);
3021
if (this.dragAndDropOff) this.dragger.addDragLanding(this.allTree,this);
3022
if (arguments.length>1)
3023
this._ddronr=(!convertStringToBoolean(rmode));
3027
* @desc: set selection on node
3028
* @param: node - pointer to node object
3032
dhtmlXTreeObject.prototype._setMove=function(htmlNode,x,y){
3033
if (htmlNode.parentObject.span) {
3035
var a1=getAbsoluteTop(htmlNode);
3036
var a2=getAbsoluteTop(this.allTree);
3038
this.dadmodec=this.dadmode;//this.dadmode;
3042
var zN=htmlNode.parentObject.span;
3043
zN.className+=" dragAndDropRow";
3046
this._autoScroll(null,a1,a2);
3051
dhtmlXTreeObject.prototype._autoScroll=function(node,a1,a2){
3052
if (this.autoScroll)
3055
a1=getAbsoluteTop(node);
3056
a2=getAbsoluteTop(this.allTree);
3059
if ( (a1-a2-parseInt(this.allTree.scrollTop))>(parseInt(this.allTree.offsetHeight)-50) )
3060
this.allTree.scrollTop=parseInt(this.allTree.scrollTop)+20;
3062
if ( (a1-a2)<(parseInt(this.allTree.scrollTop)+30) )
3063
this.allTree.scrollTop=parseInt(this.allTree.scrollTop)-20;
3068
* @desc: create html element for dragging
3070
* @param: htmlObject - html node object
3073
dhtmlXTreeObject.prototype._createDragNode=function(htmlObject,e){
3074
if (!this.dADTempOff) return null;
3076
var obj=htmlObject.parentObject;
3077
if (!this.callEvent("onBeforeDrag",[obj.id])) return null;
3079
this._selectItem(obj,e);
3082
var dragSpan=document.createElement('div');
3084
var text=new Array();
3086
for (var i=0; i<this._selected.length; i++)
3087
text[i]="<table cellspacing='0' cellpadding='0'><tr><td><img width='18px' height='18px' src='"+this._getSrc(this._selected[i].span.parentNode.previousSibling.childNodes[0])+"'></td><td>"+this._selected[i].span.innerHTML+"</td></tr><table>";
3089
text=this.getSelectedItemText().split(this.dlmtr);
3091
dragSpan.innerHTML=text.join("");
3092
dragSpan.style.position="absolute";
3093
dragSpan.className="dragSpanDiv";
3094
this._dragged=(new Array()).concat(this._selected);
3101
* @desc: focus item in tree
3103
* @param: item - node object
3104
* @edition: Professional
3107
dhtmlXTreeObject.prototype._focusNode=function(item){
3108
var z=getAbsoluteTop(item.htmlNode)-getAbsoluteTop(this.allTree);
3109
if ((z>(this.allTree.scrollTop+this.allTree.offsetHeight-30))||(z<this.allTree.scrollTop))
3110
this.allTree.scrollTop=z;
3127
dhtmlXTreeObject.prototype._preventNsDrag=function(e){
3128
if ((e)&&(e.preventDefault)) { e.preventDefault(); return false; }
3132
dhtmlXTreeObject.prototype._drag=function(sourceHtmlObject,dhtmlObject,targetHtmlObject){
3133
if (this._autoOpenTimer) clearTimeout(this._autoOpenTimer);
3135
if (!targetHtmlObject.parentObject){
3136
targetHtmlObject=this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
3141
var z=sourceHtmlObject.parentObject.treeNod;
3142
if ((z)&&(z._clearMove)) z._clearMove("");
3144
if ((!this.dragMove)||(this.dragMove()))
3146
if ((!z)||(!z._clearMove)||(!z._dragged)) var col=new Array(sourceHtmlObject.parentObject);
3147
else var col=z._dragged;
3148
var trg=targetHtmlObject.parentObject;
3150
for (var i=0; i<col.length; i++){
3151
var newID=this._moveNode(col[i],trg);
3152
if ((this.dadmodec)&&(newID!==false)) trg=this._globalIdStorageFind(newID,true,true);
3153
if ((newID)&&(!this._sADnD)) this.selectItem(newID,0,1);
3157
if (z) z._dragged=new Array();
3162
dhtmlXTreeObject.prototype._dragIn=function(htmlObject,shtmlObject,x,y){
3164
if (!this.dADTempOff) return 0;
3165
var fobj=shtmlObject.parentObject;
3166
var tobj=htmlObject.parentObject;
3167
if ((!tobj)&&(this._ddronr)) return;
3168
if (!this.callEvent("onDragIn",[fobj.id,tobj?tobj.id:null,fobj.treeNod,this]))
3172
this.allTree.className+=" selectionBox";
3175
if (fobj.childNodes==null){
3176
this._setMove(htmlObject,x,y);
3180
var stree=fobj.treeNod;
3181
for (var i=0; i<stree._dragged.length; i++)
3182
if (this._checkPNodes(tobj,stree._dragged[i])){
3183
this._autoScroll(htmlObject);
3187
this._setMove(htmlObject,x,y);
3188
if (this._getOpenState(tobj)<=0){
3189
this._autoOpenId=tobj.id;
3190
this._autoOpenTimer=window.setTimeout(new callerFunction(this._autoOpenItem,this),1000);
3197
dhtmlXTreeObject.prototype._autoOpenItem=function(e,treeObject){
3198
treeObject.openItem(treeObject._autoOpenId);
3200
dhtmlXTreeObject.prototype._dragOut=function(htmlObject){
3202
if (this._autoOpenTimer) clearTimeout(this._autoOpenTimer);
3209
//#complex_move:01112006{
3212
* @desc: move item (inside of tree)
3214
* @param: itemId - item Id
3215
* @param: mode - moving mode (left,up,down,item_child,item_sibling,item_sibling_next,up_strict,down_strict)
3216
* @param: targetId - target Node in item_child and item_sibling mode
3217
* @param: targetTree - used for moving between trees (optional)
3221
dhtmlXTreeObject.prototype.moveItem=function(itemId,mode,targetId,targetTree)
3223
var sNode=this._globalIdStorageFind(itemId);
3224
if (!sNode) return (0);
3227
case "right": alert('Not supported yet');
3230
var tNode=(targetTree||this)._globalIdStorageFind(targetId);
3231
if (!tNode) return (0);
3232
(targetTree||this)._moveNodeTo(sNode,tNode,0);
3234
case "item_sibling":
3235
var tNode=(targetTree||this)._globalIdStorageFind(targetId);
3236
if (!tNode) return (0);
3237
(targetTree||this)._moveNodeTo(sNode,tNode.parentObject,tNode);
3239
case "item_sibling_next":
3240
var tNode=(targetTree||this)._globalIdStorageFind(targetId);
3241
if (!tNode) return (0);
3242
if ((tNode.tr)&&(tNode.tr.nextSibling)&&(tNode.tr.nextSibling.nodem))
3243
(targetTree||this)._moveNodeTo(sNode,tNode.parentObject,tNode.tr.nextSibling.nodem);
3245
(targetTree||this)._moveNodeTo(sNode,tNode.parentObject);
3247
case "left": if (sNode.parentObject.parentObject)
3248
this._moveNodeTo(sNode,sNode.parentObject.parentObject,sNode.parentObject);
3250
case "up": var z=this._getPrevNode(sNode);
3251
if ((z==-1)||(!z.parentObject)) return;
3252
this._moveNodeTo(sNode,z.parentObject,z);
3254
case "up_strict": var z=this._getIndex(sNode);
3256
this._moveNodeTo(sNode,sNode.parentObject,sNode.parentObject.childNodes[z-1]);
3258
case "down_strict": var z=this._getIndex(sNode);
3259
var count=sNode.parentObject.childsCount-2;
3261
this._moveNodeTo(sNode,sNode.parentObject);
3263
this._moveNodeTo(sNode,sNode.parentObject,sNode.parentObject.childNodes[z+2]);
3265
case "down": var z=this._getNextNode(this._lastChild(sNode));
3266
if ((z==-1)||(!z.parentObject)) return;
3267
if (z.parentObject==sNode.parentObject)
3268
var z=this._getNextNode(z);
3270
this._moveNodeTo(sNode,sNode.parentObject);
3274
if ((z==-1)||(!z.parentObject)) return;
3275
this._moveNodeTo(sNode,z.parentObject,z);
3291
* @desc: load xml for tree branch
3292
* @param: id - id of parent node
3293
* @param: src - path to xml, optional
3297
dhtmlXTreeObject.prototype._loadDynXML=function(id,src) {
3298
src=src||this.XMLsource;
3299
var sn=(new Date()).valueOf();
3302
this.loadXML(src+getUrlSymbol(src)+"uid="+sn+"&id="+this._escape(id));
3312
* @desc: check possibility of drag-and-drop
3314
* @param: itemId - draged node id
3315
* @param: htmlObject - droped node object
3316
* @param: shtmlObject - sourse node object
3319
dhtmlXTreeObject.prototype._checkPNodes=function(item1,item2){
3320
if (item2==item1) return 1
3321
if (item1.parentObject) return this._checkPNodes(item1.parentObject,item2); else return 0;
3334
* @desc: prevent caching in IE by adding random value to URL string
3335
* @param: mode - enable/disable random value ( disabled by default )
3339
dhtmlXTreeObject.prototype.preventIECaching=function(mode){
3340
this.no_cashe = convertStringToBoolean(mode);
3341
this.XMLLoader.rSeed=this.no_cashe;
3343
dhtmlXTreeObject.prototype.preventIECashing=dhtmlXTreeObject.prototype.preventIECaching;
3350
* @desc: disable checkbox
3351
* @param: itemId - Id of tree item
3352
* @param: mode - 1 - on, 0 - off;
3356
dhtmlXTreeObject.prototype.disableCheckbox=function(itemId,mode) {
3357
if (typeof(itemId)!="object")
3358
var sNode=this._globalIdStorageFind(itemId,0,1);
3362
sNode.dscheck=convertStringToBoolean(mode)?(((sNode.checkstate||0)%3)+3):((sNode.checkstate>2)?(sNode.checkstate-3):sNode.checkstate);
3363
this._setCheck(sNode);
3364
if (sNode.dscheck<3) sNode.dscheck=false;
3371
* @desc: set escaping mode (used for escaping ID in requests)
3372
* @param: mode - escaping mode ("utf8" for UTF escaping)
3376
dhtmlXTreeObject.prototype.setEscapingMode=function(mode){
3382
* @desc: enable item highlighting (item text highlited on mouseover)
3384
* @param: mode - 1 - on, 0 - off;
3388
dhtmlXTreeObject.prototype.enableHighlighting=function(mode) { this.ehlt=true; this.ehlta=convertStringToBoolean(mode); };
3391
* @desc: called on mouse out
3395
dhtmlXTreeObject.prototype._itemMouseOut=function(){
3396
var that=this.childNodes[3].parentObject;
3397
var tree=that.treeNod;
3398
tree.callEvent("onMouseOut",[that.id]);
3399
if (that.id==tree._l_onMSI) tree._l_onMSI=null;
3400
if (!tree.ehlta) return;
3401
that.span.className=that.span.className.replace("_lor","");
3404
* @desc: called on mouse in
3408
dhtmlXTreeObject.prototype._itemMouseIn=function(){
3409
var that=this.childNodes[3].parentObject;
3410
var tree=that.treeNod;
3412
if (tree._l_onMSI!=that.id) tree.callEvent("onMouseIn",[that.id]);
3413
tree._l_onMSI=that.id;
3414
if (!tree.ehlta) return;
3415
that.span.className=that.span.className.replace("_lor","");
3416
that.span.className=that.span.className.replace(/((standart|selected)TreeRow)/,"$1_lor");
3420
* @desc: enable active images (clickable and dragable). By default only text part of the node is active
3422
* @param: mode - 1 - on, 0 - off;
3426
dhtmlXTreeObject.prototype.enableActiveImages=function(mode){this._aimgs=convertStringToBoolean(mode); };
3429
* @desc: focus item in tree (scroll to it if necessary)
3431
* @param: itemId - item Id
3434
dhtmlXTreeObject.prototype.focusItem=function(itemId){
3435
var sNode=this._globalIdStorageFind(itemId);
3436
if (!sNode) return (0);
3437
this._focusNode(sNode);
3442
* @desc: Returns the list of all children from all next levels of tree, separated by default delimiter.
3443
* @param: itemId - id of node
3445
* @return: list of all children items from all next levels of tree, separated by default delimiter
3448
dhtmlXTreeObject.prototype.getAllSubItems =function(itemId){
3449
return this._getAllSubItems(itemId);
3453
* @desc: Returns the list of all items which doesn't have child nodes.
3455
* @return: list of all items which doesn't have child nodes.
3458
dhtmlXTreeObject.prototype.getAllChildless =function(){
3459
return this._getAllScraggyItems(this.htmlNode);
3461
dhtmlXTreeObject.prototype.getAllLeafs=dhtmlXTreeObject.prototype.getAllChildless;
3465
* @desc: Returns the list of all children from all next levels of tree, separated by default delimiter.
3466
* @param: itemId - id of node
3467
* @edition: Professional
3471
dhtmlXTreeObject.prototype._getAllScraggyItems =function(node)
3474
for (var i=0; i<node.childsCount; i++)
3476
if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
3478
if (node.childNodes[i].unParsed)
3479
var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);
3481
var zb=this._getAllScraggyItems(node.childNodes[i])
3484
if (z) z+=this.dlmtr+zb;
3488
if (!z) z=node.childNodes[i].id;
3489
else z+=this.dlmtr+node.childNodes[i].id;
3499
* @desc: Returns the list of all children from all next levels of tree, separated by default delimiter.
3500
* @param: itemId - id of node
3502
* @edition: Professional
3505
dhtmlXTreeObject.prototype._getAllFatItems =function(node)
3508
for (var i=0; i<node.childsCount; i++)
3510
if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
3512
if (!z) z=node.childNodes[i].id;
3513
else z+=this.dlmtr+node.childNodes[i].id;
3515
if (node.childNodes[i].unParsed)
3516
var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);
3518
var zb=this._getAllFatItems(node.childNodes[i])
3520
if (zb) z+=this.dlmtr+zb;
3527
* @desc: Returns the list of all items which have child nodes, separated by default delimiter.
3529
* @return: list of all items which has child nodes, separated by default delimiter.
3532
dhtmlXTreeObject.prototype.getAllItemsWithKids =function(){
3533
return this._getAllFatItems(this.htmlNode);
3535
dhtmlXTreeObject.prototype.getAllFatItems=dhtmlXTreeObject.prototype.getAllItemsWithKids;
3540
* @desc: return list of identificators of nodes with checked checkboxes, separated by default delimiter
3542
* @return: list of ID of items with checked checkboxes, separated by default delimiter
3545
dhtmlXTreeObject.prototype.getAllChecked=function(){
3546
return this._getAllChecked("","",1);
3549
* @desc: return list of identificators of nodes with unchecked checkboxes, separated by default delimiter
3551
* @return: list of ID of items with unchecked checkboxes, separated by default delimiter
3554
dhtmlXTreeObject.prototype.getAllUnchecked=function(itemId){
3556
itemId=this._globalIdStorageFind(itemId);
3557
return this._getAllChecked(itemId,"",0);
3562
* @desc: return list of identificators of nodes with third state checkboxes, separated by default delimiter
3564
* @return: list of ID of items with third state checkboxes, separated by default delimiter
3567
dhtmlXTreeObject.prototype.getAllPartiallyChecked=function(){
3568
return this._getAllChecked("","",2);
3573
* @desc: return list of identificators of nodes with checked and third state checkboxes, separated by default delimiter
3575
* @return: list of ID of items with checked and third state checkboxes, separated by default delimiter
3578
dhtmlXTreeObject.prototype.getAllCheckedBranches=function(){
3579
var temp= this._getAllChecked("","",1);
3580
if (temp!="") temp+=this.dlmtr;
3581
return temp+this._getAllChecked("","",2);
3585
* @desc: return list of identificators of nodes with checked checkboxes
3587
* @param: node - node object (optional, used by private methods)
3588
* @param: list - initial identificators list (optional, used by private methods)
3591
dhtmlXTreeObject.prototype._getAllChecked=function(htmlNode,list,mode){
3592
if (!htmlNode) htmlNode=this.htmlNode;
3594
if (htmlNode.checkstate==mode)
3595
if (!htmlNode.nocheckbox) { if (list) list+=this.dlmtr+htmlNode.id; else list=htmlNode.id; }
3596
var j=htmlNode.childsCount;
3597
for (var i=0; i<j; i++)
3599
list=this._getAllChecked(htmlNode.childNodes[i],list,mode);
3603
if (list) return list; else return "";
3607
* @desc: set individual item style
3609
* @param: itemId - node id
3610
* @param: style_string - valid CSS string
3613
dhtmlXTreeObject.prototype.setItemStyle=function(itemId,style_string){
3614
var temp=this._globalIdStorageFind(itemId);
3615
if (!temp) return 0;
3616
if (!temp.span.style.cssText)
3617
temp.span.setAttribute("style",temp.span.getAttribute("style")+"; "+style_string);
3619
temp.span.style.cssText+=(";"+style_string);
3623
* @desc: enable draging item image with item text
3625
* @param: mode - true/false
3628
dhtmlXTreeObject.prototype.enableImageDrag=function(mode){
3629
this._itim_dg=convertStringToBoolean(mode);
3633
* @desc: set function called when tree item draged over another item
3634
* @param: func - event handling function
3636
* @edition: Professional
3639
* @depricated: use grid.attachEvent("onDragIn",func); instead
3640
* @eventdesc: Event raised when item draged other other dropable target
3641
* @eventparam: ID draged item
3642
* @eventparam: ID potencial drop landing
3643
* @eventparam: source object
3644
* @eventparam: target object
3645
* @eventreturn: true - allow drop; false - deny drop;
3647
dhtmlXTreeObject.prototype.setOnDragIn=function(func){
3648
this.attachEvent("onDragIn",func);
3652
* @desc: enable/disable auto scrolling while drag-and-drop
3654
* @param: mode - enabled/disabled
3657
dhtmlXTreeObject.prototype.enableDragAndDropScrolling=function(mode){ this.autoScroll=convertStringToBoolean(mode); };
3660
dhtmlXTreeObject.prototype.setSkin=function(name){
3661
this.parentObject.className+=" dhxtree_"+name;
3663
dhtmlXTreeObject.prototype.dhx_Event=function()
3665
this.dhx_SeverCatcherPath="";
3667
this.attachEvent = function(original, catcher, CallObj)
3669
if (this._onEventSet && this._onEventSet[original])
3670
this._onEventSet[original].apply(this,[]);
3672
CallObj = CallObj||this;
3673
original = 'ev_'+original;
3674
if ( ( !this[original] ) || ( !this[original].addEvent ) ) {
3675
var z = new this.eventCatcher(CallObj);
3676
z.addEvent( this[original] );
3679
return ( original + ':' + this[original].addEvent(catcher) ); //return ID (event name & event ID)
3681
this.callEvent=function(name,a){
3682
if (this["ev_"+name]) return this["ev_"+name].apply(this,a);
3685
this.checkEvent=function(name){
3686
if (this["ev_"+name]) return true;
3690
this.eventCatcher = function(obj)
3692
var dhx_catch = new Array();
3698
for (var i=0; i<dhx_catch.length; i++) {
3699
if (dhx_catch[i] != null) {
3700
var zr = dhx_catch[i].apply( m_obj, arguments );
3706
z.addEvent = function(ev)
3708
if ( typeof(ev) != "function" )
3711
return dhx_catch.push( ev ) - 1;
3714
z.removeEvent = function(id)
3716
dhx_catch[id] = null;
3721
this.detachEvent = function(id)
3724
var list = id.split(':'); //get EventName and ID
3725
this[ list[0] ].removeEvent( list[1] ); //remove event
3729
//(c)dhtmlx ltd. www.dhtmlx.com
b'\\ No newline at end of file'