/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to includes/dhtmlx/dhtmlxtree.js

  • Committer: Suren A. Chilingaryan
  • Date: 2008-10-29 03:02:24 UTC
  • Revision ID: csa@dside.dyndns.org-20081029030224-yc3wy2dti4htlfxf
New version of dhtmlxmenu and dhtmlxtree is added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//v.2.0 build 81009
 
2
 
 
3
/*
 
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
 
7
*/
 
8
/*_TOPICS_
 
9
@0:Initialization
 
10
@1:Selection control
 
11
@2:Add/delete
 
12
@3:Private
 
13
@4:Node/level control
 
14
@5:Checkboxes/user data manipulation
 
15
@6:Appearence control
 
16
@7: Handlers
 
17
*/
 
18
 
 
19
function xmlPointer(data){
 
20
        this.d=data;
 
21
}
 
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;  } }
 
35
}
 
36
 
 
37
 
 
38
 
 
39
/**
 
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)
 
45
*     @type: public
 
46
*     @topic: 0
 
47
*/
 
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);
 
52
        else
 
53
      this.parentObject=htmlObject;
 
54
 
 
55
        this.parentObject.style.overflow="hidden";
 
56
        this._itim_dg=true;
 
57
    this.dlmtr=",";
 
58
    this.dropLower=false;
 
59
        this.enableIEImageFix();
 
60
 
 
61
   this.xmlstate=0;
 
62
   this.mytype="tree";
 
63
   this.smcheck=true;   //smart checkboxes
 
64
   this.width=width;
 
65
   this.height=height;
 
66
   this.rootId=rootId;
 
67
   this.childCalc=null;
 
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";
 
72
 
 
73
    this._dragged=new Array();
 
74
   this._selected=new Array();
 
75
 
 
76
   this.style_pointer="pointer";
 
77
   if (_isIE)  this.style_pointer="hand";
 
78
 
 
79
   this._aimgs=true;
 
80
   this.htmlcA=" [";
 
81
   this.htmlcB="]";
 
82
   this.lWin=window;
 
83
   this.cMenu=0;
 
84
   this.mlitems=0;
 
85
   this.iconURL="";
 
86
   this.dadmode=0;
 
87
   this.slowParse=false;
 
88
   this.autoScroll=true;
 
89
   this.hfMode=0;
 
90
   this.nodeCut=new Array();
 
91
   this.XMLsource=0;
 
92
   this.XMLloadingWarning=0;
 
93
   this._idpull={};
 
94
   this._pullSize=0;
 
95
   this.treeLinesOn=true;
 
96
   this.tscheck=false;
 
97
   this.timgen=true;
 
98
   this.dpcpy=false;
 
99
    this._ld_id=null;
 
100
        this._oie_onXLE=[];
 
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");
 
104
 
 
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";
 
111
 
 
112
   this.dragger= new dhtmlDragAndDropObject();
 
113
//create root
 
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);
 
120
    if(_isFF){
 
121
         this.allTree.childNodes[0].width="100%";
 
122
         this.allTree.childNodes[0].style.overflow="hidden";
 
123
    }
 
124
 
 
125
   var self=this;
 
126
   this.allTree.onselectstart=new Function("return false;");
 
127
   if (_isMacOS)
 
128
                this.allTree.oncontextmenu = function(e){ return self._doContClick(e||window.event); };   
 
129
   this.allTree.onmousedown = function(e){ return self._doContClick(e||window.event); };  
 
130
   
 
131
   this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this,true,this.no_cashe);
 
132
   if (_isIE) this.preventIECashing(true);
 
133
 
 
134
 
 
135
 
 
136
    
 
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){}});
 
139
 
 
140
        this.dhx_Event();
 
141
        this._onEventSet={onMouseIn:function(){this.ehlt=true;},onMouseOut:function(){this.ehlt=true;},onSelect:function(){this._onSSCF=true;}}
 
142
        
 
143
        this.setImagesPath=this.setImagePath;
 
144
        this.setIconsPath=this.setIconPath;
 
145
 
 
146
   return this;
 
147
};
 
148
 
 
149
 
 
150
/**
 
151
*     @desc: set default data transfer mode 
 
152
*     @param: mode - data mode (json,xml,csv)
 
153
*     @type: public
 
154
*     @topic: 0
 
155
*/
 
156
dhtmlXTreeObject.prototype.setDataMode=function(mode){
 
157
                this._datamode=mode;
 
158
}
 
159
 
 
160
 
 
161
        
 
162
dhtmlXTreeObject.prototype._doContClick=function(ev){
 
163
        if (ev.button!=2) {
 
164
                if(this._acMenu){
 
165
                        if (this._acMenu.hideContextMenu)
 
166
                                this._acMenu.hideContextMenu()
 
167
                        else
 
168
                                this.cMenu._contextEnd();
 
169
                }
 
170
                return true;
 
171
        }
 
172
        
 
173
        var el=(_isIE?ev.srcElement:ev.target);
 
174
        while ((el)&&(el.tagName!="BODY")) {
 
175
                if (el.parentObject) break;
 
176
         el=el.parentNode;
 
177
         }
 
178
        
 
179
    if ((!el)||(!el.parentObject)) return true;
 
180
    
 
181
    var obj=el.parentObject;
 
182
        this._acMenu=(obj.cMenu||this.cMenu);
 
183
        if (this._acMenu){
 
184
                if (!(this.callEvent("onBeforeContextMenu", [
 
185
                                        obj.id
 
186
                                ]))) return true;       
 
187
                if (_isIE)
 
188
                   ev.srcElement.oncontextmenu = function(){ event.cancelBubble=true; return false; };
 
189
                       
 
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;
 
195
                        } else {
 
196
                                el.contextMenuId=obj.id;
 
197
                                el.contextMenu=this._acMenu;
 
198
                                el.a=this._acMenu._contextStart;
 
199
                                el.a(el, ev);
 
200
                                el.a=null;
 
201
                        }
 
202
                        
 
203
                        return false;           
 
204
        }
 
205
    return true;
 
206
}
 
207
 
 
208
 
 
209
/**
 
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
 
212
*     @type: public
 
213
*     @topic: 0
 
214
*/
 
215
dhtmlXTreeObject.prototype.enableIEImageFix=function(mode){
 
216
        if (!mode){
 
217
 
 
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; }
 
221
        }       else    {
 
222
 
 
223
        this._getImg=function(){ var z=document.createElement("DIV"); z.innerHTML="&nbsp;"; 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); }
 
226
        }
 
227
}
 
228
 
 
229
/**
 
230
*       @desc: deletes tree and clears memory
 
231
*       @type: public
 
232
*/
 
233
dhtmlXTreeObject.prototype.destructor=function(){
 
234
    for (var a in this._idpull){
 
235
        var z=this._idpull[a];
 
236
                if (!z) continue;
 
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;
 
239
        }
 
240
    this.parentObject.innerHTML="";
 
241
    this.XMLLoader.destructor();
 
242
    for(var a in this){
 
243
        this[a]=null;
 
244
        }
 
245
}
 
246
 
 
247
function cObject(){
 
248
    return this;
 
249
}
 
250
cObject.prototype= new Object;
 
251
cObject.prototype.clone = function () {
 
252
       function _dummy(){};
 
253
       _dummy.prototype=this;
 
254
       return new _dummy();
 
255
    }
 
256
 
 
257
/**
 
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
 
265
*   @type: private
 
266
*   @topic: 0
 
267
*/
 
268
function dhtmlXTreeItemObject(itemId,itemText,parentObject,treeObject,actionHandler,mode){
 
269
   this.htmlNode="";
 
270
   this.acolor="";
 
271
   this.scolor="";
 
272
   this.tr=0;
 
273
   this.childsCount=0;
 
274
   this.tempDOMM=0;
 
275
   this.tempDOMU=0;
 
276
   this.dragSpan=0;
 
277
   this.dragMove=0;
 
278
   this.span=0;
 
279
   this.closeble=1;
 
280
   this.childNodes=new Array();
 
281
   this.userData=new cObject();
 
282
 
 
283
 
 
284
   this.checkstate=0;
 
285
   this.treeNod=treeObject;
 
286
   this.label=itemText;
 
287
   this.parentObject=parentObject;
 
288
   this.actionHandler=actionHandler;
 
289
   this.images=new Array(treeObject.imageArray[0],treeObject.imageArray[1],treeObject.imageArray[2]);
 
290
 
 
291
 
 
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);
 
295
 
 
296
   this.htmlNode.objBelong=this;
 
297
   return this;
 
298
   };   
 
299
 
 
300
 
 
301
/**
 
302
*     @desc: register node
 
303
*     @type: private
 
304
*     @param: itemId - node id
 
305
*     @param: itemObject - node object
 
306
*     @topic: 3  
 
307
*/
 
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;
 
311
         this._pullSize++;
 
312
      return itemId;
 
313
   };
 
314
 
 
315
/**
 
316
*     @desc: unregister node
 
317
*     @type: private
 
318
*     @param: itemId - node id
 
319
*     @topic: 3
 
320
*/
 
321
   dhtmlXTreeObject.prototype._globalIdStorageSub=function(itemId){
 
322
        if (this._idpull[itemId]){
 
323
                    this._unselectItem(this._idpull[itemId]);
 
324
                        this._idpull[itemId]=null;
 
325
                        this._pullSize--;
 
326
        }
 
327
                if ((this._locker)&&(this._locker[itemId])) this._locker[itemId]=false;
 
328
   };
 
329
   
 
330
/**
 
331
*     @desc: return node object
 
332
*     @param: itemId - node id
 
333
*     @type: private
 
334
*     @topic: 3
 
335
*/
 
336
   dhtmlXTreeObject.prototype._globalIdStorageFind=function(itemId,skipXMLSearch,skipParsing,isreparse){
 
337
                var z=this._idpull[itemId]
 
338
        if (z){
 
339
 
 
340
            return z;
 
341
            }
 
342
 
 
343
                return null;
 
344
   };
 
345
 
 
346
 
 
347
/**
 
348
*     @desc: escape string
 
349
*     @param: itemId - item ID
 
350
*     @type: private
 
351
*     @topic: 3
 
352
*/
 
353
   dhtmlXTreeObject.prototype._escape=function(str){
 
354
        switch(this.utfesc){
 
355
        case "none":
 
356
            return str;
 
357
            break;
 
358
        case "utf8":
 
359
         return encodeURI(str);
 
360
            break;
 
361
        default:
 
362
         return escape(str);
 
363
            break;
 
364
        }
 
365
   }
 
366
 
 
367
 
 
368
 
 
369
/**
 
370
*     @desc: create and return  new line in tree
 
371
*     @type: private
 
372
*     @param: htmlObject - parent Node object
 
373
*     @param: node - item object
 
374
*     @topic: 2  
 
375
*/
 
376
   dhtmlXTreeObject.prototype._drawNewTr=function(htmlObject,node)
 
377
   {
 
378
      var tr =document.createElement('tr');
 
379
      var td1=document.createElement('td');
 
380
      var td2=document.createElement('td');
 
381
      td1.appendChild(document.createTextNode(" "));
 
382
      td2.colSpan=3;
 
383
      td2.appendChild(htmlObject);
 
384
      tr.appendChild(td1);  tr.appendChild(td2);
 
385
      return tr;
 
386
   };
 
387
/**
 
388
*     @desc: load tree from xml string
 
389
*     @type: public
 
390
*     @param: xmlString - XML string
 
391
*     @param: afterCall - function which will be called after xml loading
 
392
*     @topic: 0
 
393
*/
 
394
   dhtmlXTreeObject.prototype.loadXMLString=function(xmlString,afterCall){
 
395
        var that=this;
 
396
      if (!this.parsCount) this.callEvent("onXLS",[that,null]);
 
397
      this.xmlstate=1;
 
398
 
 
399
        if (afterCall) this.XMLLoader.waitCall=afterCall;
 
400
      this.XMLLoader.loadXMLString(xmlString);  };
 
401
/**
 
402
*     @desc: load tree from xml file
 
403
*     @type: public
 
404
*     @param: file - link to XML file
 
405
*     @param: afterCall - function which will be called after xml loading
 
406
*     @topic: 0
 
407
*/
 
408
        dhtmlXTreeObject.prototype.loadXML=function(file,afterCall){ 
 
409
          if (this._datamode && this._datamode!="xml") return this["load"+this._datamode.toUpperCase()](file,afterCall);
 
410
        var that=this;
 
411
      if (!this.parsCount) this.callEvent("onXLS",[that,this._ld_id]);
 
412
      this._ld_id=null;
 
413
      this.xmlstate=1;
 
414
      this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this,true,this.no_cashe);
 
415
 
 
416
      if (afterCall) this.XMLLoader.waitCall=afterCall;
 
417
      this.XMLLoader.loadXML(file);
 
418
   };
 
419
/**
 
420
*     @desc: create new child node
 
421
*     @type: private
 
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)
 
432
*     @topic: 2
 
433
*/
 
434
   dhtmlXTreeObject.prototype._attachChildNode=function(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,beforeNode,afterNode){
 
435
 
 
436
         if (beforeNode && beforeNode.parentObject) parentObject=beforeNode.parentObject;
 
437
         if (((parentObject.XMLload==0)&&(this.XMLsource))&&(!this.XMLloadingWarning))
 
438
         {
 
439
            parentObject.XMLload=1;
 
440
                this._loadDynXML(parentObject.id);
 
441
 
 
442
         }
 
443
 
 
444
         var Count=parentObject.childsCount;
 
445
         var Nodes=parentObject.childNodes;
 
446
 
 
447
 
 
448
            if (afterNode){
 
449
            if (afterNode.tr.previousSibling.previousSibling){
 
450
               beforeNode=afterNode.tr.previousSibling.nodem;
 
451
               }
 
452
            else
 
453
               optionStr=optionStr.replace("TOP","")+",TOP";
 
454
               }
 
455
 
 
456
         if (beforeNode)
 
457
            {
 
458
            var ik,jk;
 
459
            for (ik=0; ik<Count; ik++)
 
460
               if (Nodes[ik]==beforeNode)
 
461
               {
 
462
               for (jk=Count; jk!=ik; jk--)
 
463
                  Nodes[1+jk]=Nodes[jk];
 
464
               break;
 
465
               }
 
466
            ik++;
 
467
            Count=ik;
 
468
            }
 
469
 
 
470
 
 
471
         if (optionStr) {
 
472
             var tempStr=optionStr.split(",");
 
473
            for (var i=0; i<tempStr.length; i++)
 
474
            {
 
475
               switch(tempStr[i])
 
476
               {
 
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];
 
481
                        Count=0;
 
482
                     break;
 
483
               }
 
484
            };
 
485
          };
 
486
 
 
487
                var n;
 
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++;
 
492
        }
 
493
        
 
494
        if(!n.htmlNode) {
 
495
           n.label=itemText;
 
496
                   n.htmlNode=this._createItem((this.checkBoxOff?1:0),n);
 
497
                   n.htmlNode.objBelong=n;
 
498
                  }
 
499
 
 
500
         if(image1) n.images[0]=image1;
 
501
         if(image2) n.images[1]=image2;
 
502
         if(image3) n.images[2]=image3;
 
503
 
 
504
                
 
505
         var tr=this._drawNewTr(n.htmlNode);
 
506
         if ((this.XMLloadingWarning)||(this._hAdI))
 
507
            n.htmlNode.parentNode.parentNode.style.display="none";
 
508
 
 
509
 
 
510
            if ((beforeNode)&&(beforeNode.tr.nextSibling))
 
511
               parentObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr.nextSibling);
 
512
            else
 
513
               if (this.parsingOn==parentObject.id){
 
514
                  this.parsedArray[this.parsedArray.length]=tr;
 
515
                        }
 
516
               else
 
517
                   parentObject.htmlNode.childNodes[0].appendChild(tr);
 
518
 
 
519
 
 
520
               if ((beforeNode)&&(!beforeNode.span)) beforeNode=null;
 
521
 
 
522
            if (this.XMLsource) if ((childs)&&(childs!=0)) n.XMLload=0; else n.XMLload=1;
 
523
            n.tr=tr;
 
524
            tr.nodem=n;
 
525
 
 
526
            if (parentObject.itemId==0)
 
527
                tr.childNodes[0].className="hiddenRow";
 
528
 
 
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]);
 
531
 
 
532
 
 
533
          if (optionStr) {
 
534
             var tempStr=optionStr.split(",");
 
535
 
 
536
            for (var i=0; i<tempStr.length; i++)
 
537
            {
 
538
               switch(tempStr[i])
 
539
               {
 
540
                     case "SELECT": this.selectItem(itemId,false); break;
 
541
                  case "CALL": this.selectItem(itemId,true);   break;
 
542
                  case "CHILD":  n.XMLload=0;  break;
 
543
                  case "CHECKED":
 
544
                     if (this.XMLloadingWarning)
 
545
                        this.setCheckList+=this.dlmtr+itemId;
 
546
                     else
 
547
                        this.setCheck(itemId,1);
 
548
                        break;
 
549
                  case "HCHECKED":
 
550
                        this._setCheck(n,"unsure");
 
551
                        break;                        
 
552
                  case "OPEN": n.openMe=1;  break;
 
553
               }
 
554
            };
 
555
          };
 
556
 
 
557
      if (!this.XMLloadingWarning)
 
558
      {
 
559
             if ((this._getOpenState(parentObject)<0)&&(!this._hAdI)) this.openItem(parentObject.id);
 
560
 
 
561
             if (beforeNode)
 
562
                {
 
563
             this._correctPlus(beforeNode);
 
564
             this._correctLine(beforeNode);
 
565
                }
 
566
             this._correctPlus(parentObject);
 
567
             this._correctLine(parentObject);
 
568
             this._correctPlus(n);
 
569
             if (parentObject.childsCount>=2)
 
570
             {
 
571
                   this._correctPlus(Nodes[parentObject.childsCount-2]);
 
572
                   this._correctLine(Nodes[parentObject.childsCount-2]);
 
573
             }
 
574
             if (parentObject.childsCount!=2) this._correctPlus(Nodes[0]);
 
575
 
 
576
         if (this.tscheck) this._correctCheckStates(parentObject);
 
577
 
 
578
            if (this._onradh) {
 
579
                                if (this.xmlstate==1){
 
580
                                        var old=this.onXLE;
 
581
                                        this.onXLE=function(id){ this._onradh(itemId); if (old) old(id); }
 
582
                                        }
 
583
                                else
 
584
                                        this._onradh(itemId);
 
585
                        }
 
586
 
 
587
      }
 
588
   return n;
 
589
};
 
590
 
 
591
 
 
592
 
 
593
 
 
594
/**
 
595
*     @desc: create new node as a child to specified with parentId
 
596
*     @type: deprecated
 
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)
 
606
*     @topic: 2  
 
607
*/
 
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);
 
612
 
 
613
        return nodez;
 
614
   };
 
615
/**
 
616
*     @desc: create new node as a child to specified with parentId
 
617
*     @type: public
 
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)
 
627
*     @topic: 2  
 
628
*/
 
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);
 
631
   }   
 
632
/**  
 
633
*     @desc: parse xml
 
634
*     @type: private
 
635
*     @param: dhtmlObject - jsTree object
 
636
*     @param: node - top XML node
 
637
*     @param: parentId - parent node id
 
638
*     @param: level - level of tree
 
639
*     @topic: 2
 
640
*/
 
641
        dhtmlXTreeObject.prototype._parseXMLTree=function(a,b,c,d,xml){ 
 
642
                var p=new xmlPointer(xml.getXMLTopNode("tree"));
 
643
                a._parse(p);
 
644
                a._p=p;
 
645
        }
 
646
        
 
647
        dhtmlXTreeObject.prototype._parseItem=function(c,temp,preNode,befNode){ 
 
648
                var id;
 
649
                if (this._srnd && (!this._idpull[id=c.get("id")] || !this._idpull[id].span))
 
650
                {
 
651
                        this._addItemSRND(temp.id,id,c);
 
652
                        return; 
 
653
                }
 
654
                
 
655
  var a=c.get_all();
 
656
        
 
657
        if ((typeof(this.waitUpdateXML)=="object")&&(!this.waitUpdateXML[a.id])){
 
658
                        this._parse(c,a.id,1);
 
659
                        return;
 
660
                }    
 
661
 
 
662
 
 
663
              
 
664
 
 
665
 
 
666
 
 
667
                  var zST=[];
 
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");
 
674
        
 
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);
 
678
                                                else{
 
679
                                                        if (this.npl==0) zST.push("TOP");
 
680
                                                        else preNode=temp.childNodes[this.npl];
 
681
 
 
682
                                    var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,0,preNode);
 
683
                                                        preNode=null;
 
684
                                                }
 
685
                                         }
 
686
                  else
 
687
                     var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,(befNode||0),preNode);
 
688
                  if (a.tooltip)
 
689
                                        newNode.span.parentNode.parentNode.title=a.tooltip;
 
690
 
 
691
                  if (a.style)
 
692
                            if (newNode.span.style.cssText)
 
693
                                newNode.span.style.cssText+=(";"+a.style);
 
694
                            else
 
695
                                newNode.span.setAttribute("style",newNode.span.getAttribute("style")+"; "+a.style);
 
696
 
 
697
                        if (a.radio) newNode._r_logic=true;
 
698
 
 
699
                  if (a.nocheckbox){
 
700
                     newNode.span.parentNode.previousSibling.previousSibling.childNodes[0].style.display='none';
 
701
                     newNode.nocheckbox=true;
 
702
                  }
 
703
                        if (a.disabled){
 
704
                            if (a.checked!=null) this._setCheck(newNode,a.checked);
 
705
                            this.disableCheckbox(newNode,1);
 
706
                            }
 
707
 
 
708
                                
 
709
                  newNode._acc=a.child||0;
 
710
 
 
711
                  if (this.parserExtension) this.parserExtension._parseExtension.call(this,c,a,(temp?temp.id:0));
 
712
 
 
713
                  this.setItemColor(newNode,a.aCol,a.sCol);
 
714
                  if (a.locked=="1")    this.lockItem(newNode.id,true,true);
 
715
 
 
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);
 
718
                  var zcall="";
 
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);
 
723
                  }
 
724
 
 
725
                  if (zcall!="") this.nodeAskingCall=zcall;
 
726
 
 
727
   
 
728
        c.each("userdata",function(u){
 
729
                        this.setUserData(c.get("id"),u.get("name"),u.content());
 
730
                  },this)
 
731
                
 
732
                
 
733
        }
 
734
        dhtmlXTreeObject.prototype._parse=function(p,parentId,level,start){ 
 
735
                if (this._srnd && !this.parentObject.offsetHeight) {
 
736
                        var self=this;
 
737
                        return window.setTimeout(function(){
 
738
                                self._parse(p,parentId,level,start);
 
739
                        },100);
 
740
                }
 
741
                if (!p.exists()) return;
 
742
                
 
743
                this.skipLock=true; //disable item locking
 
744
                //loading flags
 
745
                
 
746
                this.parsCount=this.parsCount?(this.parsCount+1):1;
 
747
                this.XMLloadingWarning=1;
 
748
                
 
749
                
 
750
                if (!parentId) {          //top level  
 
751
                        parentId=p.get("id");
 
752
                        if (p.get("radio"))
 
753
                                this.htmlNode._r_logic=true;
 
754
                        this.parsingOn=parentId;                 
 
755
                        this.parsedArray=new Array();
 
756
                        this.setCheckList="";
 
757
                        this.nodeAskingCall="";
 
758
                }
 
759
                
 
760
                var temp=this._globalIdStorageFind(parentId);
 
761
                if (!temp) return dhtmlxError.throwError("DataStructure","XML reffers to not existing parent");
 
762
         
 
763
                if ((temp.childsCount)&&(!start)&&(!this._edsbps)&&(!temp._has_top))
 
764
            var preNode=temp.childNodes[temp.childsCount-1];
 
765
        else
 
766
            var preNode=0;
 
767
 
 
768
        this.npl=0;
 
769
 
 
770
                p.each("item",function(c,i){
 
771
                                
 
772
                temp.XMLload=1;
 
773
                if ((this._epgps)&&(this._epgpsC==this.npl)){
 
774
                    this._setNextPageSign(temp,this.npl+1*(start||0),level,node);
 
775
                    return -1;
 
776
                }
 
777
                                
 
778
          this._parseItem(c,temp,preNode); 
 
779
                  
 
780
 
 
781
              this.npl++;
 
782
         
 
783
 
 
784
                  
 
785
      },this,start);
 
786
 
 
787
 
 
788
      if (!level) {
 
789
          p.each("userdata",function(u){
 
790
                        this.setUserData(p.get("id"),u.get("name"),u.content());
 
791
                  },this);
 
792
                  
 
793
                 temp.XMLload=1;
 
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);
 
799
                        }
 
800
 
 
801
         var parsedNodeTop=this._globalIdStorageFind(this.parsingOn);
 
802
 
 
803
         for (var i=0; i<this.parsedArray.length; i++)
 
804
               temp.htmlNode.childNodes[0].appendChild(this.parsedArray[i]);
 
805
 
 
806
         this.lastLoadedXMLId=parentId;
 
807
         this.XMLloadingWarning=0;
 
808
 
 
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);
 
812
 
 
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);
 
818
            }
 
819
 
 
820
                 if (this.onXLE) this.onXLE(this,parentId);
 
821
         this._redrawFrom(this,null,start)
 
822
         
 
823
   
 
824
                 if (p.get("order") && p.get("order")!="none")
 
825
                        this._reorderBranch(temp,p.get("order"),true);
 
826
                        
 
827
                                 if (this.nodeAskingCall!="")   this.selectItem(this.nodeAskingCall,true);
 
828
         if (this._branchUpdate) this._branchUpdateNext(p);
 
829
             }
 
830
 
 
831
 
 
832
      if (this.parsCount==1) {
 
833
 
 
834
 
 
835
         
 
836
         if ((!this._edsbps)||(!this._edsbpsA.length)){
 
837
                        var that=this;
 
838
                window.setTimeout( function(){  that.callEvent("onXLE",[that,parentId]); },1);
 
839
                this.xmlstate=0;
 
840
                }
 
841
             this.skipLock=false;
 
842
         }
 
843
      this.parsCount--;
 
844
 
 
845
 
 
846
 
 
847
        if ((this._epgps)&&(start))
 
848
            this._setPrevPageSign(temp,(start||0),level,node);
 
849
 
 
850
      return this.nodeAskingCall;
 
851
  };
 
852
  
 
853
 
 
854
dhtmlXTreeObject.prototype._branchUpdateNext=function(p){
 
855
        p.each("item",function(c){
 
856
                var nid=c.get("id");
 
857
                if (this._idpull[nid] && (!this._idpull[nid].XMLload))  return;
 
858
                this._branchUpdate++;
 
859
                this.smartRefreshItem(c.get("id"),c);
 
860
        },this)
 
861
        this._branchUpdate--;
 
862
 
863
 
 
864
  dhtmlXTreeObject.prototype.checkUserData=function(node,parentId){
 
865
      if ((node.nodeType==1)&&(node.tagName == "userdata"))
 
866
      {
 
867
         var name=node.getAttribute("name");
 
868
            if ((name)&&(node.childNodes[0]))
 
869
               this.setUserData(parentId,name,node.childNodes[0].data);
 
870
      }
 
871
  }
 
872
 
 
873
 
 
874
 
 
875
 
 
876
/**  
 
877
*     @desc: reset tree images from selected level
 
878
*     @type: private
 
879
*     @param: dhtmlObject - tree
 
880
*     @param: itemObject - current item
 
881
*     @topic: 6
 
882
*/
 
883
   dhtmlXTreeObject.prototype._redrawFrom=function(dhtmlObject,itemObject,start,visMode){
 
884
      if (!itemObject) {
 
885
      var tempx=dhtmlObject._globalIdStorageFind(dhtmlObject.lastLoadedXMLId);
 
886
      dhtmlObject.lastLoadedXMLId=-1;
 
887
      if (!tempx) return 0;
 
888
      }
 
889
      else tempx=itemObject;
 
890
      var acc=0;
 
891
 
 
892
      for (var i=(start?start-1:0); i<tempx.childsCount; i++)
 
893
      {
 
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)
 
897
            {
 
898
            this._openItem(tempx.childNodes[i]);
 
899
            tempx.childNodes[i].openMe=0;
 
900
            }
 
901
 
 
902
         dhtmlObject._redrawFrom(dhtmlObject,tempx.childNodes[i]);
 
903
 
 
904
 
 
905
      };
 
906
 
 
907
      if ((!tempx.unParsed)&&((tempx.XMLload)||(!this.XMLsource)))
 
908
      tempx._acc=acc;
 
909
      dhtmlObject._correctLine(tempx);
 
910
      dhtmlObject._correctPlus(tempx);
 
911
 
 
912
   };
 
913
 
 
914
/**
 
915
*     @desc: create and return main html element of tree
 
916
*     @type: private
 
917
*     @topic: 0  
 
918
*/
 
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);
 
925
      return div;
 
926
   };
 
927
 
 
928
/**
 
929
*     @desc: collapse target node
 
930
*     @type: private
 
931
*     @param: itemObject - item object
 
932
*     @topic: 4  
 
933
*/
 
934
   dhtmlXTreeObject.prototype._xcloseAll=function(itemObject)
 
935
   {
 
936
        if (itemObject.unParsed) return;
 
937
      if (this.rootId!=itemObject.id) {
 
938
          var Nodes=itemObject.htmlNode.childNodes[0].childNodes;
 
939
            var Count=Nodes.length;
 
940
 
 
941
          for (var i=1; i<Count; i++)
 
942
             Nodes[i].style.display="none";
 
943
 
 
944
          this._correctPlus(itemObject);
 
945
      }
 
946
 
 
947
       for (var i=0; i<itemObject.childsCount; i++)
 
948
            if (itemObject.childNodes[i].childsCount)
 
949
             this._xcloseAll(itemObject.childNodes[i]);
 
950
   };
 
951
/**
 
952
*     @desc: expand target node
 
953
*     @type: private
 
954
*     @param: itemObject - item object
 
955
*     @topic: 4
 
956
*/      
 
957
   dhtmlXTreeObject.prototype._xopenAll=function(itemObject)
 
958
   {
 
959
      this._HideShow(itemObject,2);
 
960
      for (var i=0; i<itemObject.childsCount; i++)
 
961
         this._xopenAll(itemObject.childNodes[i]);
 
962
   };      
 
963
/**  
 
964
*     @desc: set correct tree-line and node images
 
965
*     @type: private
 
966
*     @param: itemObject - item object
 
967
*     @topic: 6  
 
968
*/
 
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];
 
973
 
 
974
       var workArray=this.lineArray;
 
975
      if ((this.XMLsource)&&(!itemObject.XMLload))
 
976
      {
 
977
            var workArray=this.plusArray;
 
978
                        this._setSrc(imsrc2,this.imPath+itemObject.images[2]);
 
979
                if (this._txtimg) return (imsrc.innerHTML="[+]");
 
980
      }
 
981
      else
 
982
      if ((itemObject.childsCount)||(itemObject.unParsed))
 
983
      {
 
984
         if ((itemObject.htmlNode.childNodes[0].childNodes[1])&&( itemObject.htmlNode.childNodes[0].childNodes[1].style.display!="none" ))
 
985
            {
 
986
            if (!itemObject.wsign) var workArray=this.minusArray;
 
987
                        this._setSrc(imsrc2,this.iconURL+itemObject.images[1]);
 
988
                if (this._txtimg) return (imsrc.innerHTML="[-]");
 
989
            }
 
990
         else
 
991
            {
 
992
            if (!itemObject.wsign) var workArray=this.plusArray;
 
993
                        this._setSrc(imsrc2,this.iconURL+itemObject.images[2]);
 
994
                if (this._txtimg) return (imsrc.innerHTML="[+]");
 
995
            }
 
996
      }
 
997
      else
 
998
      {
 
999
         this._setSrc(imsrc2,this.iconURL+itemObject.images[0]);
 
1000
       }
 
1001
 
 
1002
 
 
1003
      var tempNum=2;
 
1004
      if (!itemObject.treeNod.treeLinesOn) this._setSrc(imsrc,this.imPath+workArray[3]);
 
1005
      else {
 
1006
          if (itemObject.parentObject) tempNum=this._getCountStatus(itemObject.id,itemObject.parentObject);
 
1007
                  this._setSrc(imsrc,this.imPath+workArray[tempNum]);
 
1008
         }
 
1009
   };
 
1010
 
 
1011
/**
 
1012
*     @desc: set correct tree-line images
 
1013
*     @type: private
 
1014
*     @param: itemObject - item object
 
1015
*     @topic: 6
 
1016
*/
 
1017
   dhtmlXTreeObject.prototype._correctLine=function(itemObject){
 
1018
          if (!itemObject.htmlNode) return;
 
1019
      var sNode=itemObject.parentObject;
 
1020
      if (sNode)
 
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="";
 
1026
                }
 
1027
            else
 
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";
 
1032
             }
 
1033
   };
 
1034
/**
 
1035
*     @desc: return type of node
 
1036
*     @type: private
 
1037
*     @param: itemId - item id
 
1038
*     @param: itemObject - parent node object
 
1039
*     @topic: 6
 
1040
*/
 
1041
   dhtmlXTreeObject.prototype._getCountStatus=function(itemId,itemObject){
 
1042
      if (itemObject.childsCount<=1) { if (itemObject.id==this.rootId) return 4; else  return 0; }
 
1043
 
 
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;
 
1046
 
 
1047
      return 1;
 
1048
   };
 
1049
/**
 
1050
*     @desc: return type of node
 
1051
*     @type: private
 
1052
*     @param: itemId - node id        
 
1053
*     @param: itemObject - parent node object
 
1054
*     @topic: 6
 
1055
*/      
 
1056
   dhtmlXTreeObject.prototype._getLineStatus =function(itemId,itemObject){
 
1057
         if (itemObject.childNodes[itemObject.childsCount-1].id==itemId) return 0;
 
1058
         return 1;
 
1059
      }
 
1060
 
 
1061
/**  
 
1062
*     @desc: open/close node 
 
1063
*     @type: private
 
1064
*     @param: itemObject - node object        
 
1065
*     @param: mode - open/close mode [1-close 2-open](optional)
 
1066
*     @topic: 6
 
1067
*/      
 
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);
 
1073
            return; };
 
1074
 
 
1075
      var Nodes=itemObject.htmlNode.childNodes[0].childNodes; var Count=Nodes.length;
 
1076
      if (Count>1){
 
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";
 
1081
         nodestyle="none";
 
1082
         }
 
1083
         else  nodestyle="";
 
1084
 
 
1085
      for (var i=1; i<Count; i++)
 
1086
         Nodes[i].style.display=nodestyle;
 
1087
      }
 
1088
      this._correctPlus(itemObject);
 
1089
   }
 
1090
 
 
1091
/**
 
1092
*     @desc: return node state
 
1093
*     @type: private
 
1094
*     @param: itemObject - node object        
 
1095
*     @topic: 6
 
1096
*/
 
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;
 
1101
      else return -1;
 
1102
   }
 
1103
 
 
1104
   
 
1105
 
 
1106
/**  
 
1107
*     @desc: ondblclick item  event handler
 
1108
*     @type: private
 
1109
*     @topic: 0  
 
1110
*/      
 
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);
 
1116
      else
 
1117
         that._HideShow(this.parentObject,2);
 
1118
 
 
1119
        if    (that.checkEvent("onOpenEnd"))
 
1120
           if (!that.xmlstate)
 
1121
                                that.callEvent("onOpenEnd",[this.parentObject.id,that._getOpenState(this.parentObject)]);
 
1122
            else{
 
1123
                that._oie_onXLE.push(that.onXLE);
 
1124
                that.onXLE=that._epnFHe;
 
1125
                }         
 
1126
   };
 
1127
/**
 
1128
*     @desc: onclick item event handler
 
1129
*     @type: private
 
1130
*     @topic: 0
 
1131
*/
 
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);
 
1137
      else
 
1138
         that._HideShow(this.parentObject,2);
 
1139
 
 
1140
        
 
1141
   if    (that.checkEvent("onOpenEnd"))
 
1142
           if (!that.xmlstate)
 
1143
                                that.callEvent("onOpenEnd",[this.parentObject.id,that._getOpenState(this.parentObject)]);
 
1144
            else{
 
1145
                that._oie_onXLE.push(that.onXLE);
 
1146
                that.onXLE=that._epnFHe;
 
1147
                }
 
1148
 
 
1149
   };
 
1150
 
 
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();
 
1155
        
 
1156
        if (!flag && !that._oie_onXLE.length)
 
1157
                        if (that.onXLE) that.onXLE(that,id);
 
1158
    }
 
1159
 
 
1160
 
 
1161
 
 
1162
/**
 
1163
*     @desc: onclick item image event handler
 
1164
*     @type: private
 
1165
*     @edition: Professional
 
1166
*     @topic: 0  
 
1167
*/
 
1168
   dhtmlXTreeObject.prototype.onRowClickDown=function(e){
 
1169
            e=e||window.event;
 
1170
         var that=this.parentObject.treeNod;
 
1171
         that._selectItem(this.parentObject,e);
 
1172
      };
 
1173
 
 
1174
 
 
1175
/*****
 
1176
SELECTION
 
1177
*****/
 
1178
 
 
1179
/**
 
1180
*     @desc: retun selected item id
 
1181
*     @type: public
 
1182
*     @return: id of selected item
 
1183
*     @topic: 1
 
1184
*/
 
1185
   dhtmlXTreeObject.prototype.getSelectedItemId=function()
 
1186
   {
 
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));
 
1190
   };
 
1191
 
 
1192
/**
 
1193
*     @desc: visual select item in tree
 
1194
*     @type: private
 
1195
*     @param: node - tree item object
 
1196
*     @edition: Professional
 
1197
*     @topic: 0
 
1198
*/
 
1199
   dhtmlXTreeObject.prototype._selectItem=function(node,e){
 
1200
                if (this._onSSCF) this._onSSCFold=this.getSelectedItemId();
 
1201
 
 
1202
            this._unselectItems();
 
1203
 
 
1204
                                        this._markItem(node);
 
1205
                if (this._onSSCF) {
 
1206
                        var z=this.getSelectedItemId();
 
1207
                        if (z!=this._onSSCFold)
 
1208
                                this.callEvent("onSelect",[z]);
 
1209
                }
 
1210
    }
 
1211
    dhtmlXTreeObject.prototype._markItem=function(node){
 
1212
              if (node.scolor)  node.span.style.color=node.scolor;
 
1213
              node.span.className="selectedTreeRow";
 
1214
             node.i_sel=true;
 
1215
             this._selected[this._selected.length]=node;
 
1216
    }
 
1217
 
 
1218
/**
 
1219
*     @desc: retun node index in children collection by Id
 
1220
*     @type: public
 
1221
*     @param: itemId - node id
 
1222
*     @return: node index
 
1223
*     @topic: 2
 
1224
*/
 
1225
   dhtmlXTreeObject.prototype.getIndexById=function(itemId){
 
1226
         var z=this._globalIdStorageFind(itemId);
 
1227
         if (!z) return null;
 
1228
         return this._getIndex(z);
 
1229
   };
 
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;
 
1234
   };
 
1235
 
 
1236
 
 
1237
 
 
1238
 
 
1239
 
 
1240
/**
 
1241
*     @desc: visual unselect item in tree
 
1242
*     @type: private
 
1243
*     @param: node - tree item object
 
1244
*     @edition: Professional
 
1245
*     @topic: 0
 
1246
*/
 
1247
   dhtmlXTreeObject.prototype._unselectItem=function(node){
 
1248
        if ((node)&&(node.i_sel))
 
1249
            {
 
1250
 
 
1251
          node.span.className="standartTreeRow";
 
1252
          if (node.acolor)  node.span.style.color=node.acolor;
 
1253
            node.i_sel=false;
 
1254
            for (var i=0; i<this._selected.length; i++)
 
1255
                    if (!this._selected[i].i_sel) {
 
1256
                        this._selected.splice(i,1);
 
1257
                        break;
 
1258
                 }
 
1259
 
 
1260
            }
 
1261
       }
 
1262
 
 
1263
/**
 
1264
*     @desc: visual unselect items in tree
 
1265
*     @type: private
 
1266
*     @param: node - tree item object
 
1267
*     @edition: Professional
 
1268
*     @topic: 0
 
1269
*/
 
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;
 
1275
         node.i_sel=false;
 
1276
         }
 
1277
         this._selected=new Array();
 
1278
       }
 
1279
 
 
1280
 
 
1281
/**  
 
1282
*     @desc: select node text event handler
 
1283
*     @type: private
 
1284
*     @param: e - event object
 
1285
*     @param: htmlObject - node object     
 
1286
*     @param: mode - if false - call onSelect event
 
1287
*     @topic: 0  
 
1288
*/
 
1289
   dhtmlXTreeObject.prototype.onRowSelect=function(e,htmlObject,mode){
 
1290
      e=e||window.event;
 
1291
 
 
1292
        var obj=this.parentObject;
 
1293
      if (htmlObject) obj=htmlObject.parentObject;
 
1294
        var that=obj.treeNod;
 
1295
 
 
1296
        var lastId=that.getSelectedItemId();
 
1297
                if ((!e)||(!e.skipUnSel))
 
1298
                that._selectItem(obj,e);
 
1299
 
 
1300
      if (!mode) {
 
1301
         if ((e)&&(e.button==2))
 
1302
                        that.callEvent("onRightClick",[obj.id,e]);
 
1303
                        
 
1304
         if (obj.actionHandler) obj.actionHandler(obj.id,lastId);
 
1305
                 else that.callEvent("onClick",[obj.id,lastId]);
 
1306
         }
 
1307
   };
 
1308
 
 
1309
 
 
1310
 
 
1311
 
 
1312
   
 
1313
/**
 
1314
*     @desc: fix checkbox state
 
1315
*     @type: private
 
1316
*     @topic: 0
 
1317
*/
 
1318
dhtmlXTreeObject.prototype._correctCheckStates=function(dhtmlObject){
 
1319
        
 
1320
   if (!this.tscheck) return;
 
1321
   if (!dhtmlObject) return;
 
1322
   if (dhtmlObject.id==this.rootId) return;
 
1323
   //calculate state
 
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; }
 
1332
                 }
 
1333
 
 
1334
   if ((flag1)&&(flag2)) this._setCheck(dhtmlObject,"unsure");
 
1335
   else if (flag1)  this._setCheck(dhtmlObject,false);
 
1336
      else  this._setCheck(dhtmlObject,true);
 
1337
 
 
1338
      this._correctCheckStates(dhtmlObject.parentObject);
 
1339
}
 
1340
 
 
1341
/**
 
1342
*     @desc: checbox select action
 
1343
*     @type: private
 
1344
*     @topic: 0
 
1345
*/   
 
1346
   dhtmlXTreeObject.prototype.onCheckBoxClick=function(e){
 
1347
                  if (!this.treeNod.callEvent("onBeforeCheck",[this.parentObject.id,this.parentObject.checkstate]))
 
1348
                        return;
 
1349
          
 
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);
 
1354
      else
 
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);
 
1358
 
 
1359
      return this.treeNod.callEvent("onCheck",[this.parentObject.id,this.parentObject.checkstate]);
 
1360
   };
 
1361
/**
 
1362
*     @desc: create HTML elements for tree node
 
1363
*     @type: private
 
1364
*     @param: acheck - enable/disable checkbox
 
1365
*     @param: itemObject - item object
 
1366
*     @param: mode - mode
 
1367
*     @topic: 0
 
1368
*/
 
1369
   dhtmlXTreeObject.prototype._createItem=function(acheck,itemObject,mode){
 
1370
 
 
1371
         var table=document.createElement('table');
 
1372
         table.cellSpacing=0;table.cellPadding=0;
 
1373
         table.border=0;
 
1374
 
 
1375
         if(this.hfMode)table.style.tableLayout="fixed";
 
1376
         table.style.margin=0;table.style.padding=0;
 
1377
 
 
1378
         var tbody=document.createElement('tbody');
 
1379
         var tr=document.createElement('tr');
 
1380
 
 
1381
         var td1=document.createElement('td');
 
1382
         td1.className="standartTreeImage";
 
1383
 
 
1384
         if(this._txtimg){
 
1385
                 var img0=document.createElement("div");
 
1386
                 td1.appendChild(img0);
 
1387
                 img0.className="dhx_tree_textSign";
 
1388
        }
 
1389
            else
 
1390
            {
 
1391
         var img0=this._getImg(itemObject.id);
 
1392
            img0.border="0";
 
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;
 
1396
            }
 
1397
 
 
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";
 
1404
 
 
1405
         // td11.className="standartTreeImage";
 
1406
               //if (acheck)
 
1407
            td11.appendChild(inp);
 
1408
            if ((!this.cBROf)&&(inp.tagName=="IMG")) inp.align="absmiddle";
 
1409
            inp.onclick=this.onCheckBoxClick;
 
1410
            inp.treeNod=this;
 
1411
            inp.parentObject=itemObject;
 
1412
            if (!window._KHTMLrv) td11.width="20px";
 
1413
            else td11.width="16px";
 
1414
 
 
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;
 
1419
            img.border="0";
 
1420
            if (this._aimgs){
 
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;
 
1426
         if (this.timgen)
 
1427
            {  
 
1428
                td12.style.width=img.style.width=this.def_img_x; img.style.height=this.def_img_y; }
 
1429
         else
 
1430
            {
 
1431
                img.style.width="0px"; img.style.height="0px";
 
1432
                if (_isOpera)    td12.style.display="none";
 
1433
                }
 
1434
 
 
1435
 
 
1436
      var td2=document.createElement('td');
 
1437
         td2.className="standartTreeRow";
 
1438
 
 
1439
            itemObject.span=document.createElement('span');
 
1440
            itemObject.span.className="standartTreeRow";
 
1441
            if (this.mlitems) {
 
1442
                                itemObject.span.style.width=this.mlitems;
 
1443
                           //   if (!_isIE)
 
1444
                                        itemObject.span.style.display="block";
 
1445
                                }
 
1446
            else td2.noWrap=true;
 
1447
                if (!window._KHTMLrv) td2.style.width="100%";
 
1448
 
 
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;
 
1454
      if (this.ettip)
 
1455
                        tr.title=itemObject.label;
 
1456
 
 
1457
      if (this.dragAndDropOff) {
 
1458
         if (this._aimgs) { this.dragger.addDraggableItem(td12,this); td12.parentObject=itemObject; }
 
1459
         this.dragger.addDraggableItem(td2,this);
 
1460
         }
 
1461
 
 
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);
 
1468
 
 
1469
          if (this.ehlt){//highlighting
 
1470
                tr.onmousemove=this._itemMouseIn;
 
1471
        tr[(_isIE)?"onmouseleave":"onmouseout"]=this._itemMouseOut;
 
1472
      }
 
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;");
 
1475
 
 
1476
 
 
1477
      return table;
 
1478
   };
 
1479
   
 
1480
 
 
1481
/**  
 
1482
*     @desc: set path to images directory
 
1483
*     @param: newPath - path to images directory (related to the page with tree or absolute http url)
 
1484
*     @type: public
 
1485
*     @topic: 0
 
1486
*/
 
1487
   dhtmlXTreeObject.prototype.setImagePath=function( newPath ){ this.imPath=newPath; if (!this.iconURL) this.iconURL=newPath; };
 
1488
    /**
 
1489
        *   @desc: set path to external images used as tree icons
 
1490
        *   @type: public
 
1491
        *   @param: path - url (or relative path) of images folder with closing "/"
 
1492
        *   @topic: 0,7
 
1493
        */
 
1494
        dhtmlXTreeObject.prototype.setIconPath=function(path){
 
1495
                this.iconURL=path;
 
1496
        }          
 
1497
 
 
1498
 
 
1499
 
 
1500
/**
 
1501
*     @desc: set function called when tree node selected
 
1502
*     @param: (function) func - event handling function
 
1503
*     @type: deprecated
 
1504
*     @topic: 0,7
 
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
 
1511
*/
 
1512
   dhtmlXTreeObject.prototype.setOnRightClickHandler=function(func){  this.attachEvent("onRightClick",func);   };
 
1513
 
 
1514
/**
 
1515
*     @desc: set function called when tree node clicked, also can be forced to call from API
 
1516
*     @param: func - event handling function
 
1517
*     @type: deprecated
 
1518
*     @topic: 0,7
 
1519
*     @event: onClick
 
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
 
1525
*/
 
1526
   dhtmlXTreeObject.prototype.setOnClickHandler=function(func){  this.attachEvent("onClick",func);  };
 
1527
 
 
1528
/**
 
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
 
1531
*     @type: deprecated
 
1532
*     @topic: 0,7
 
1533
*     @event: onSelect
 
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)
 
1537
*/
 
1538
   dhtmlXTreeObject.prototype.setOnSelectStateChange=function(func){  this.attachEvent("onSelect",func); this._onSSCF=true;  };
 
1539
 
 
1540
 
 
1541
/**
 
1542
*     @desc: enables dynamic loading from XML
 
1543
*     @type: public
 
1544
*     @param: filePath - name of script returning XML; in case of virtual loading - user defined function
 
1545
*     @topic: 0  
 
1546
*/
 
1547
   dhtmlXTreeObject.prototype.setXMLAutoLoading=function(filePath){  this.XMLsource=filePath; };
 
1548
 
 
1549
   /**
 
1550
*     @desc: set function called before checkbox checked/unchecked
 
1551
*     @param: func - event handling function
 
1552
*     @type: deprecated
 
1553
*     @topic: 0,7
 
1554
*     @event: onCheck
 
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;
 
1560
*/
 
1561
   dhtmlXTreeObject.prototype.setOnCheckHandler=function(func){ this.attachEvent("onCheck",func);  };
 
1562
 
 
1563
 
 
1564
/**
 
1565
*     @desc: set function called before tree node opened/closed
 
1566
*     @param: func - event handling function
 
1567
*     @type: deprecated
 
1568
*     @topic: 0,7
 
1569
*     @event:  onOpen
 
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;
 
1576
*/
 
1577
   dhtmlXTreeObject.prototype.setOnOpenHandler=function(func){  this.attachEvent("onOpenStart",func);   };
 
1578
/**
 
1579
*     @desc: set function called before tree node opened/closed
 
1580
*     @param: func - event handling function
 
1581
*     @type: deprecated
 
1582
*     @topic: 0,7
 
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;
 
1590
*/
 
1591
   dhtmlXTreeObject.prototype.setOnOpenStartHandler=function(func){  this.attachEvent("onOpenStart",func);    };
 
1592
 
 
1593
/**
 
1594
*     @desc: set function called after tree node opened/closed
 
1595
*     @param: func - event handling function
 
1596
*     @type: deprecated
 
1597
*     @topic: 0,7
 
1598
*     @event:  onOpenEnd
 
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.
 
1604
*/
 
1605
   dhtmlXTreeObject.prototype.setOnOpenEndHandler=function(func){  this.attachEvent("onOpenEnd",func);  };
 
1606
 
 
1607
   /**
 
1608
*     @desc: set function called when tree node double clicked
 
1609
*     @param: func - event handling function
 
1610
*     @type: public
 
1611
*     @topic: 0,7
 
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;
 
1619
*/
 
1620
   dhtmlXTreeObject.prototype.setOnDblClickHandler=function(func){ this.attachEvent("onDblClick",func);   };
 
1621
 
 
1622
 
 
1623
 
 
1624
 
 
1625
 
 
1626
 
 
1627
 
 
1628
 
 
1629
 
 
1630
   /**
 
1631
*     @desc: expand target node and all sub nodes
 
1632
*     @type: public
 
1633
*     @param: itemId - node id
 
1634
*     @topic: 4
 
1635
*/
 
1636
   dhtmlXTreeObject.prototype.openAllItems=function(itemId)
 
1637
   {
 
1638
      var temp=this._globalIdStorageFind(itemId);
 
1639
      if (!temp) return 0;
 
1640
      this._xopenAll(temp);
 
1641
   };
 
1642
   
 
1643
/**
 
1644
*     @desc: return open/close state
 
1645
*     @type: public
 
1646
*     @param: itemId - node id
 
1647
*     @return: -1 - close, 1 - opened, 0 - node doesn't have children
 
1648
*     @topic: 4
 
1649
*/   
 
1650
   dhtmlXTreeObject.prototype.getOpenState=function(itemId){
 
1651
      var temp=this._globalIdStorageFind(itemId);
 
1652
      if (!temp) return "";
 
1653
      return this._getOpenState(temp);
 
1654
   };
 
1655
 
 
1656
/**  
 
1657
*     @desc: collapse target node and all sub nodes
 
1658
*     @type: public
 
1659
*     @param: itemId - node id
 
1660
*     @topic: 4  
 
1661
*/
 
1662
   dhtmlXTreeObject.prototype.closeAllItems=function(itemId)
 
1663
   {
 
1664
        if (itemId===window.undefined) itemId=this.rootId;
 
1665
        
 
1666
      var temp=this._globalIdStorageFind(itemId);
 
1667
      if (!temp) return 0;
 
1668
      this._xcloseAll(temp);
 
1669
 
 
1670
//nb:solves standard doctype prb in IE
 
1671
         this.allTree.childNodes[0].border = "1";
 
1672
       this.allTree.childNodes[0].border = "0";
 
1673
 
 
1674
   };
 
1675
   
 
1676
   
 
1677
/**
 
1678
*     @desc: set user data for target node
 
1679
*     @type: public
 
1680
*     @param: itemId - target node id
 
1681
*     @param: name - key for user data
 
1682
*     @param: value - user data value
 
1683
*     @topic: 5
 
1684
*/
 
1685
   dhtmlXTreeObject.prototype.setUserData=function(itemId,name,value){
 
1686
      var sNode=this._globalIdStorageFind(itemId,0,true);
 
1687
         if (!sNode) return;
 
1688
         if(name=="hint")
 
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;
 
1693
            }
 
1694
            sNode.userData["t_"+name]=value;
 
1695
   };
 
1696
   
 
1697
/**  
 
1698
*     @desc: get user data from target node
 
1699
*     @type: public
 
1700
*     @param: itemId - target node id
 
1701
*     @param: name - key for user data
 
1702
*     @return: value of user data
 
1703
*     @topic: 5
 
1704
*/
 
1705
   dhtmlXTreeObject.prototype.getUserData=function(itemId,name){
 
1706
      var sNode=this._globalIdStorageFind(itemId,0,true);
 
1707
      if (!sNode) return;
 
1708
      return sNode.userData["t_"+name];
 
1709
   };
 
1710
 
 
1711
 
 
1712
 
 
1713
 
 
1714
/**
 
1715
*     @desc: get node color (text color)
 
1716
*     @param: itemId - id of node
 
1717
*     @type: public
 
1718
*     @return: color of node (empty string for default color);
 
1719
*     @topic: 6  
 
1720
*/   
 
1721
   dhtmlXTreeObject.prototype.getItemColor=function(itemId)
 
1722
   {
 
1723
      var temp=this._globalIdStorageFind(itemId);
 
1724
      if (!temp) return 0;
 
1725
 
 
1726
      var res= new Object();
 
1727
      if (temp.acolor) res.acolor=temp.acolor;
 
1728
      if (temp.scolor) res.scolor=temp.scolor;      
 
1729
      return res;
 
1730
   };
 
1731
/**  
 
1732
*     @desc: set node text color
 
1733
*     @param: itemId - id of node
 
1734
*     @param: defaultColor - node color
 
1735
*     @param: selectedColor - selected node color
 
1736
*     @type: public
 
1737
*     @topic: 6
 
1738
*/
 
1739
   dhtmlXTreeObject.prototype.setItemColor=function(itemId,defaultColor,selectedColor)
 
1740
   {
 
1741
      if ((itemId)&&(itemId.span))
 
1742
         var temp=itemId;
 
1743
      else
 
1744
         var temp=this._globalIdStorageFind(itemId);
 
1745
      if (!temp) return 0;
 
1746
         else {
 
1747
         if (temp.i_sel)
 
1748
            {  if (selectedColor) temp.span.style.color=selectedColor; }
 
1749
         else
 
1750
            {  if (defaultColor) temp.span.style.color=defaultColor;  }
 
1751
 
 
1752
         if (selectedColor) temp.scolor=selectedColor;
 
1753
         if (defaultColor) temp.acolor=defaultColor;
 
1754
         }
 
1755
   };
 
1756
 
 
1757
/**
 
1758
*     @desc: return node text
 
1759
*     @param: itemId - id of node
 
1760
*     @type: public
 
1761
*     @return: text of item (with HTML formatting, if any)
 
1762
*     @topic: 6
 
1763
*/
 
1764
   dhtmlXTreeObject.prototype.getItemText=function(itemId)
 
1765
   {
 
1766
      var temp=this._globalIdStorageFind(itemId);
 
1767
      if (!temp) return 0;
 
1768
      return(temp.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML);
 
1769
   };
 
1770
/**  
 
1771
*     @desc: return parent item id
 
1772
*     @param: itemId - id of node
 
1773
*     @type: public
 
1774
*     @return: id of parent item
 
1775
*     @topic: 4
 
1776
*/         
 
1777
   dhtmlXTreeObject.prototype.getParentId=function(itemId)
 
1778
   {
 
1779
      var temp=this._globalIdStorageFind(itemId);
 
1780
      if ((!temp)||(!temp.parentObject)) return "";
 
1781
      return temp.parentObject.id;
 
1782
   };
 
1783
 
 
1784
 
 
1785
 
 
1786
/**  
 
1787
*     @desc: change item id
 
1788
*     @type: public
 
1789
*     @param: itemId - old node id
 
1790
*     @param: newItemId - new node id        
 
1791
*     @topic: 4
 
1792
*/    
 
1793
   dhtmlXTreeObject.prototype.changeItemId=function(itemId,newItemId)
 
1794
   {
 
1795
        if (itemId==newItemId) return;
 
1796
      var temp=this._globalIdStorageFind(itemId);
 
1797
      if (!temp) return 0;
 
1798
        temp.id=newItemId;
 
1799
        temp.span.contextMenuId=newItemId;
 
1800
        this._idpull[newItemId]=this._idpull[itemId];
 
1801
        delete this._idpull[itemId];
 
1802
   };
 
1803
 
 
1804
 
 
1805
/**
 
1806
*     @desc: mark selected item as cut
 
1807
*     @type: public
 
1808
*     @topic: 2  
 
1809
*/    
 
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);
 
1821
        }
 
1822
   };
 
1823
 
 
1824
/**
 
1825
*     @desc: insert previously cut branch
 
1826
*     @param: itemId - id of new parent node
 
1827
*     @type: public
 
1828
*     @topic: 2  
 
1829
*/    
 
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);
 
1836
               }
 
1837
      this.clearCut();
 
1838
   };
 
1839
 
 
1840
/**  
 
1841
*     @desc: clear cut
 
1842
*     @type: public
 
1843
*     @topic: 2  
 
1844
*/
 
1845
   dhtmlXTreeObject.prototype.clearCut=function(){
 
1846
      for (var i=0; i<this.nodeCut.length; i++)
 
1847
         {
 
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);
 
1853
         }
 
1854
          this.nodeCut=new Array();
 
1855
   };
 
1856
   
 
1857
 
 
1858
 
 
1859
   /**  
 
1860
*     @desc: move node with subnodes
 
1861
*     @type: private
 
1862
*     @param: itemObject - moved node object
 
1863
*     @param: targetObject - new parent node
 
1864
*     @topic: 2  
 
1865
*/
 
1866
   dhtmlXTreeObject.prototype._moveNode=function(itemObject,targetObject){
 
1867
 
 
1868
          return this._moveNodeTo(itemObject,targetObject);
 
1869
 
 
1870
   }
 
1871
 
 
1872
   /**
 
1873
*     @desc: fix order of nodes in collection
 
1874
*     @type: private
 
1875
*     @param: target - parent item node
 
1876
*     @param: zParent - before node
 
1877
*     @edition: Professional
 
1878
*     @topic: 2
 
1879
*/
 
1880
 
 
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;
 
1885
 
 
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]; }
 
1889
 
 
1890
//         Count=target.childsCount;
 
1891
      for (var i=0; i<Count+1; i++)      
 
1892
         {
 
1893
         if (flag) { 
 
1894
            var temp=Nodes[i];
 
1895
            Nodes[i]=flag; 
 
1896
            flag=temp; 
 
1897
               }
 
1898
         else 
 
1899
         if (Nodes[i]==zParent) {   flag=Nodes[i]; Nodes[i]=Nodes[Count];  }
 
1900
         }
 
1901
   };
 
1902
   
 
1903
/**  
 
1904
*     @desc: recreate branch
 
1905
*     @type: private
 
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
 
1912
*     @topic: 2
 
1913
*/
 
1914
dhtmlXTreeObject.prototype._recreateBranch=function(itemObject,targetObject,beforeNode,level){
 
1915
    var i; var st="";
 
1916
    if (beforeNode){
 
1917
    for (i=0; i<targetObject.childsCount; i++)
 
1918
        if (targetObject.childNodes[i]==beforeNode) break;
 
1919
 
 
1920
    if (i!=0)
 
1921
        beforeNode=targetObject.childNodes[i-1];
 
1922
    else{
 
1923
        st="TOP";
 
1924
        beforeNode="";
 
1925
        }
 
1926
    }
 
1927
 
 
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);
 
1930
 
 
1931
   //copy user data
 
1932
   newNode._userdatalist=itemObject._userdatalist;
 
1933
   newNode.userData=itemObject.userData.clone();
 
1934
   newNode.XMLload=itemObject.XMLload;
 
1935
   if (t2){
 
1936
        this._onradh=t2; this._onradh(newNode.id); }
 
1937
 
 
1938
 
 
1939
   for (var i=0; i<itemObject.childsCount; i++)
 
1940
      this._recreateBranch(itemObject.childNodes[i],newNode,0,1);
 
1941
 
 
1942
 
 
1943
   return newNode;
 
1944
}
 
1945
 
 
1946
/**
 
1947
*     @desc: move single node
 
1948
*     @type: private
 
1949
*     @param: itemObject - moved node object
 
1950
*     @param: targetObject - new parent node
 
1951
*     @mode: mode - DragAndDrop mode (0 - as child, 1 as sibling)
 
1952
*     @topic: 2
 
1953
*/
 
1954
   dhtmlXTreeObject.prototype._moveNodeTo=function(itemObject,targetObject,beforeNode){
 
1955
    //return;
 
1956
    if   (itemObject.treeNod._nonTrivialNode)
 
1957
        return itemObject.treeNod._nonTrivialNode(this,targetObject,beforeNode,itemObject);
 
1958
 
 
1959
    if    (targetObject.mytype)
 
1960
       var framesMove=(itemObject.treeNod.lWin!=targetObject.lWin);
 
1961
    else
 
1962
          var framesMove=(itemObject.treeNod.lWin!=targetObject.treeNod.lWin);
 
1963
 
 
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))
 
1966
         {
 
1967
         targetObject.XMLload=1;
 
1968
            this._loadDynXML(targetObject.id);
 
1969
         }
 
1970
        this.openItem(targetObject.id);
 
1971
 
 
1972
   var oldTree=itemObject.treeNod;
 
1973
   var c=itemObject.parentObject.childsCount;
 
1974
   var z=itemObject.parentObject;
 
1975
   
 
1976
 
 
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);
 
1981
        }
 
1982
   else
 
1983
      {
 
1984
        
 
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++;         
 
1991
                        
 
1992
            var tr=this._drawNewTr(Nodes[Count].htmlNode);
 
1993
 
 
1994
            if (!beforeNode)
 
1995
               {
 
1996
                  targetObject.htmlNode.childNodes[0].appendChild(tr);
 
1997
               if (this.dadmode==1) this._fixNodesCollection(targetObject,beforeNode);
 
1998
               }
 
1999
            else
 
2000
               {
 
2001
               targetObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr);
 
2002
               this._fixNodesCollection(targetObject,beforeNode);
 
2003
               Nodes=targetObject.childNodes;
 
2004
               }
 
2005
 
 
2006
 
 
2007
         }
 
2008
 
 
2009
            if ((!oldTree.dpcpy)&&(!framesMove))   {
 
2010
                var zir=itemObject.tr;
 
2011
 
 
2012
                if ((document.all)&&(navigator.appVersion.search(/MSIE\ 5\.0/gi)!=-1))
 
2013
                    {
 
2014
                    window.setTimeout(function() { zir.parentNode.removeChild(zir); } , 250 );
 
2015
                    }
 
2016
                else   //if (zir.parentNode) zir.parentNode.removeChild(zir,true);
 
2017
 
 
2018
                itemObject.parentObject.htmlNode.childNodes[0].removeChild(itemObject.tr);
 
2019
 
 
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) {
 
2024
                  z.childNodes[i]=0;
 
2025
                  break;            }}}
 
2026
               else z.childNodes[z.childsCount-1]=0;
 
2027
 
 
2028
            oldTree._compressChildList(z.childsCount,z.childNodes);
 
2029
            z.childsCount--;
 
2030
            }
 
2031
 
 
2032
 
 
2033
      if ((!framesMove)&&(!oldTree.dpcpy)) {
 
2034
       itemObject.tr=tr;
 
2035
      tr.nodem=itemObject;
 
2036
      itemObject.parentObject=targetObject;
 
2037
 
 
2038
      if (oldTree!=targetObject.treeNod) {  if(itemObject.treeNod._registerBranch(itemObject,oldTree)) return;      this._clearStyles(itemObject);  this._redrawFrom(this,itemObject.parentObject);   };
 
2039
 
 
2040
      this._correctPlus(targetObject);
 
2041
      this._correctLine(targetObject);
 
2042
 
 
2043
      this._correctLine(itemObject);
 
2044
      this._correctPlus(itemObject);
 
2045
 
 
2046
         //fix target siblings
 
2047
      if (beforeNode)
 
2048
      {
 
2049
 
 
2050
         this._correctPlus(beforeNode);
 
2051
         //this._correctLine(beforeNode);
 
2052
      }
 
2053
      else 
 
2054
      if (targetObject.childsCount>=2)
 
2055
      {
 
2056
 
 
2057
         this._correctPlus(Nodes[targetObject.childsCount-2]);
 
2058
         this._correctLine(Nodes[targetObject.childsCount-2]);
 
2059
      }
 
2060
      
 
2061
      this._correctPlus(Nodes[targetObject.childsCount-1]);
 
2062
      //this._correctLine(Nodes[targetObject.childsCount-1]);
 
2063
 
 
2064
 
 
2065
      if (this.tscheck) this._correctCheckStates(targetObject);
 
2066
      if (oldTree.tscheck) oldTree._correctCheckStates(z);
 
2067
 
 
2068
      }
 
2069
 
 
2070
      //fix source parent
 
2071
 
 
2072
      if (c>1) { oldTree._correctPlus(z.childNodes[c-2]);
 
2073
               oldTree._correctLine(z.childNodes[c-2]);
 
2074
               }
 
2075
 
 
2076
 
 
2077
//      if (z.childsCount==0)
 
2078
          oldTree._correctPlus(z);
 
2079
            oldTree._correctLine(z);
 
2080
 
 
2081
 
 
2082
      this.callEvent("onDrop",[itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),oldTree,targetObject.treeNod]);
 
2083
      return itemObject.id;
 
2084
   };
 
2085
 
 
2086
   
 
2087
 
 
2088
/**
 
2089
*     @desc: recursive set default styles for node
 
2090
*     @type: private
 
2091
*     @param: itemObject - target node object
 
2092
*     @topic: 6  
 
2093
*/   
 
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;
 
2098
 
 
2099
         itemObject.span.innerHTML=itemObject.label;
 
2100
                 itemObject.i_sel=false;
 
2101
 
 
2102
                 if (itemObject._aimgs)
 
2103
                 this.dragger.removeDraggableItem(td1.nextSibling);
 
2104
 
 
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]);
 
2109
                        }
 
2110
         else td1.childNodes[0].style.display="none";
 
2111
         td1.childNodes[0].treeNod=this;
 
2112
 
 
2113
         this.dragger.removeDraggableItem(td3);
 
2114
         if (this.dragAndDropOff) this.dragger.addDraggableItem(td3,this);
 
2115
                 if (this._aimgs) this.dragger.addDraggableItem(td1.nextSibling,this);
 
2116
                                 
 
2117
         td3.childNodes[0].className="standartTreeRow";
 
2118
         td3.onclick=this.onRowSelect; td3.ondblclick=this.onRowClick2;
 
2119
         td1.previousSibling.onclick=this.onRowClick;
 
2120
 
 
2121
         this._correctLine(itemObject);
 
2122
         this._correctPlus(itemObject);
 
2123
         for (var i=0; i<itemObject.childsCount; i++) this._clearStyles(itemObject.childNodes[i]); 
 
2124
 
 
2125
   };
 
2126
/**
 
2127
*     @desc: register node and all children nodes
 
2128
*     @type: private
 
2129
*     @param: itemObject - node object
 
2130
*     @topic: 2  
 
2131
*/
 
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);
 
2138
      return 0;
 
2139
   };
 
2140
 
 
2141
   
 
2142
/**  
 
2143
*     @desc: enable three state checkboxes
 
2144
*     @beforeInit: 1
 
2145
*     @param: mode - 1 - on, 0 - off;
 
2146
*     @type: public
 
2147
*     @topic: 0  
 
2148
*/
 
2149
   dhtmlXTreeObject.prototype.enableThreeStateCheckboxes=function(mode) { this.tscheck=convertStringToBoolean(mode); };
 
2150
 
 
2151
 
 
2152
/**
 
2153
*     @desc: set function called when mouse is over tree node
 
2154
*     @param: func - event handling function
 
2155
*     @type: deprecated
 
2156
*     @topic: 0,7
 
2157
*     @event: onMouseIn
 
2158
*     @depricated: use grid.attachEvent("onMouseIn",func); instead
 
2159
*     @eventdesc: Event raised immideatly after mouse started moving over item
 
2160
*     @eventparam:  ID of item
 
2161
*/
 
2162
   dhtmlXTreeObject.prototype.setOnMouseInHandler=function(func){
 
2163
        this.ehlt=true;
 
2164
                this.attachEvent("onMouseIn",func);
 
2165
        };
 
2166
 
 
2167
/**
 
2168
*     @desc: set function called when mouse is out of tree node
 
2169
*     @param: func - event handling function
 
2170
*     @type: deprecated
 
2171
*     @topic: 0,7
 
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
 
2176
*/
 
2177
   dhtmlXTreeObject.prototype.setOnMouseOutHandler=function(func){
 
2178
                this.ehlt=true;
 
2179
                this.attachEvent("onMouseOut",func);
 
2180
        };
 
2181
 
 
2182
 
 
2183
 
 
2184
 
 
2185
 
 
2186
 
 
2187
 
 
2188
 
 
2189
 
 
2190
/**
 
2191
*     @desc: enable tree images
 
2192
*     @beforeInit: 1
 
2193
*     @param: mode - 1 - on, 0 - off;
 
2194
*     @type: public
 
2195
*     @topic: 0  
 
2196
*/         
 
2197
   dhtmlXTreeObject.prototype.enableTreeImages=function(mode) { this.timgen=convertStringToBoolean(mode); };
 
2198
   
 
2199
 
 
2200
   
 
2201
/**
 
2202
*     @desc: enable mode with fixed tables (looks better, but has no horisontal scrollbar)
 
2203
*     @beforeInit: 1
 
2204
*     @param: mode - 1 - on, 0 - off;
 
2205
*     @type: private
 
2206
*     @topic: 0  
 
2207
*/
 
2208
   dhtmlXTreeObject.prototype.enableFixedMode=function(mode) { this.hfMode=convertStringToBoolean(mode); };
 
2209
   
 
2210
/**  
 
2211
*     @desc: show/hide checkboxes (all checkboxes in tree)
 
2212
*     @type: public
 
2213
*     @param: mode - true/false
 
2214
*     @param: hidden - if set to true, checkboxes not rendered but can be shown by showItemCheckbox
 
2215
*     @topic: 0  
 
2216
*/
 
2217
   dhtmlXTreeObject.prototype.enableCheckBoxes=function(mode, hidden){ this.checkBoxOff=convertStringToBoolean(mode); this.cBROf=(!(this.checkBoxOff||convertStringToBoolean(hidden))); 
 
2218
        };
 
2219
/**
 
2220
*     @desc: set default images for nodes (must be called before XML loading)
 
2221
*     @type: public
 
2222
*     @param: a0 - image for node without children;
 
2223
*     @param: a1 - image for closed node;
 
2224
*     @param: a2 - image for opened node                  
 
2225
*     @topic: 6  
 
2226
*/
 
2227
   dhtmlXTreeObject.prototype.setStdImages=function(image1,image2,image3){
 
2228
                  this.imageArray[0]=image1; this.imageArray[1]=image2; this.imageArray[2]=image3;};
 
2229
 
 
2230
/**
 
2231
*     @desc: enable/disable tree lines (parent-child threads)
 
2232
*     @type: public
 
2233
*     @param: mode - enable/disable tree lines
 
2234
*     @topic: 6
 
2235
*/                  
 
2236
   dhtmlXTreeObject.prototype.enableTreeLines=function(mode){
 
2237
      this.treeLinesOn=convertStringToBoolean(mode);
 
2238
   }
 
2239
 
 
2240
/**
 
2241
*     @desc: set images used for parent-child threads drawing (lines, plus, minus)
 
2242
*     @type: public
 
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
 
2249
*     @topic: 6
 
2250
*/      
 
2251
   dhtmlXTreeObject.prototype.setImageArrays=function(arrayName,image1,image2,image3,image4,image5){
 
2252
      switch(arrayName){
 
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;
 
2255
      }
 
2256
   };
 
2257
 
 
2258
/**  
 
2259
*     @desc: expand node
 
2260
*     @param: itemId - id of node
 
2261
*     @type: public
 
2262
*     @topic: 4
 
2263
*/ 
 
2264
   dhtmlXTreeObject.prototype.openItem=function(itemId){
 
2265
      var temp=this._globalIdStorageFind(itemId);
 
2266
      if (!temp) return 0;
 
2267
      else return this._openItem(temp);
 
2268
   };
 
2269
 
 
2270
/**  
 
2271
*     @desc: expand node
 
2272
*     @param: item - tree node object
 
2273
*     @type: private
 
2274
*     @editing: pro
 
2275
*     @topic: 4  
 
2276
*/ 
 
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)]);
 
2286
                                else{
 
2287
                                    this._oie_onXLE.push(this.onXLE);
 
2288
                                    this.onXLE=this._epnFHe;
 
2289
                                    }
 
2290
                                                        }
 
2291
                           } else if (this._srnd) this._HideShow(item,2);
 
2292
           if (item.parentObject) this._openItem(item.parentObject);
 
2293
   };
 
2294
   
 
2295
/**  
 
2296
*     @desc: collapse node
 
2297
*     @param: itemId - id of node
 
2298
*     @type: public
 
2299
*     @topic: 4  
 
2300
*/
 
2301
   dhtmlXTreeObject.prototype.closeItem=function(itemId){
 
2302
      if (this.rootId==itemId) return 0;
 
2303
      var temp=this._globalIdStorageFind(itemId);
 
2304
      if (!temp) return 0;
 
2305
         if (temp.closeble)
 
2306
            this._HideShow(temp,1);
 
2307
   };
 
2308
   
 
2309
   
 
2310
 
 
2311
   
 
2312
   
 
2313
   
 
2314
   
 
2315
   
 
2316
 
 
2317
   
 
2318
   
 
2319
   
 
2320
   
 
2321
   
 
2322
   
 
2323
   
 
2324
   
 
2325
   
 
2326
   
 
2327
   
 
2328
   
 
2329
   
 
2330
   
 
2331
   
 
2332
   
 
2333
      
 
2334
/**
 
2335
*     @desc: get node level (position in hierarchy)
 
2336
*     @param: itemId - id of node
 
2337
*     @type: public
 
2338
*     @return: node level (0 if no such item in hierarchy - probably super root)
 
2339
*     @topic: 4
 
2340
*/
 
2341
   dhtmlXTreeObject.prototype.getLevel=function(itemId){
 
2342
      var temp=this._globalIdStorageFind(itemId);
 
2343
      if (!temp) return 0;
 
2344
      return this._getNodeLevel(temp,0);
 
2345
   };
 
2346
   
 
2347
      
 
2348
 
 
2349
/**  
 
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
 
2353
*     @type: public
 
2354
*     @topic: 4  
 
2355
*/ 
 
2356
   dhtmlXTreeObject.prototype.setItemCloseable=function(itemId,flag)
 
2357
   {
 
2358
      flag=convertStringToBoolean(flag);
 
2359
      if ((itemId)&&(itemId.span)) 
 
2360
         var temp=itemId;
 
2361
      else      
 
2362
         var temp=this._globalIdStorageFind(itemId);
 
2363
      if (!temp) return 0;
 
2364
         temp.closeble=flag;
 
2365
   };
 
2366
 
 
2367
   /**  
 
2368
*     @desc: recursive function used for node level calculation
 
2369
*     @param: itemObject - pointer to node object
 
2370
*     @param: count - counter of levels        
 
2371
*     @type: private
 
2372
*     @topic: 4  
 
2373
*/   
 
2374
   dhtmlXTreeObject.prototype._getNodeLevel=function(itemObject,count){
 
2375
      if (itemObject.parentObject) return this._getNodeLevel(itemObject.parentObject,count+1);
 
2376
      return(count);
 
2377
   };
 
2378
   
 
2379
   /**  
 
2380
*     @desc: return number of children
 
2381
*     @param: itemId - id of node
 
2382
*     @type: public
 
2383
*     @return: number of child items for loaded branches; true - for not loaded branches
 
2384
*     @topic: 4
 
2385
*/
 
2386
   dhtmlXTreeObject.prototype.hasChildren=function(itemId){
 
2387
      var temp=this._globalIdStorageFind(itemId);
 
2388
      if (!temp) return 0;
 
2389
      else 
 
2390
         {
 
2391
            if ( (this.XMLsource)&&(!temp.XMLload) ) return true;
 
2392
            else 
 
2393
               return temp.childsCount;
 
2394
         };
 
2395
   };
 
2396
   
 
2397
 
 
2398
   /**
 
2399
*     @desc: get number of leafs (nodes without children)
 
2400
*     @param: itemNode -  node object
 
2401
*     @type: private
 
2402
*     @edition: Professional
 
2403
*     @topic: 4
 
2404
*/
 
2405
   dhtmlXTreeObject.prototype._getLeafCount=function(itemNode){
 
2406
      var a=0;
 
2407
      for (var b=0; b<itemNode.childsCount; b++)
 
2408
         if (itemNode.childNodes[b].childsCount==0) a++;
 
2409
      return a;
 
2410
   }
 
2411
 
 
2412
   
 
2413
/**
 
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
 
2418
*     @type: public
 
2419
*     @topic: 6
 
2420
*/
 
2421
   dhtmlXTreeObject.prototype.setItemText=function(itemId,newLabel,newTooltip)
 
2422
   {
 
2423
      var temp=this._globalIdStorageFind(itemId);
 
2424
      if (!temp) return 0;
 
2425
      temp.label=newLabel;
 
2426
      temp.span.innerHTML=newLabel;
 
2427
 
 
2428
              temp.span.parentNode.parentNode.title=newTooltip||"";
 
2429
   };
 
2430
 
 
2431
/**
 
2432
*     @desc: get item's tooltip
 
2433
*     @param: itemId - id of node
 
2434
*     @type: public
 
2435
*     @topic: 6
 
2436
*/
 
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||"");
 
2441
   };
 
2442
 
 
2443
/**  
 
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.
 
2446
*     @type: public
 
2447
*     @topic: 6  
 
2448
*/
 
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);
 
2454
   };
 
2455
 
 
2456
   /**  
 
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         
 
2462
*     @type: public
 
2463
*     @topic: 6
 
2464
*/
 
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);
 
2472
   };
 
2473
/**
 
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)        
 
2478
*     @type: public
 
2479
*     @topic: 6  
 
2480
*/   
 
2481
   dhtmlXTreeObject.prototype.setItemImage=function(itemId,image1,image2)
 
2482
   {
 
2483
      var temp=this._globalIdStorageFind(itemId);
 
2484
      if (!temp) return 0;
 
2485
         if (image2)
 
2486
         {
 
2487
            temp.images[1]=image1;
 
2488
            temp.images[2]=image2;
 
2489
         }
 
2490
         else temp.images[0]=image1;
 
2491
      this._correctPlus(temp);
 
2492
   };
 
2493
 
 
2494
 
 
2495
/**
 
2496
*     @desc: Returns the list of all subitems Ids from the next level of tree, separated by commas.
 
2497
*     @param: itemId - id of node
 
2498
*     @type: public
 
2499
*     @return: list of all subitems from the next level of tree, separated by commas.
 
2500
*     @topic: 6
 
2501
*/
 
2502
   dhtmlXTreeObject.prototype.getSubItems =function(itemId)
 
2503
   {
 
2504
      var temp=this._globalIdStorageFind(itemId,0,1);
 
2505
      if (!temp) return 0;
 
2506
 
 
2507
      var z="";
 
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;
 
2511
 
 
2512
                                                         }
 
2513
 
 
2514
      return z;
 
2515
   };
 
2516
 
 
2517
 
 
2518
 
 
2519
 
 
2520
/**
 
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
 
2524
*     @type: private
 
2525
*     @topic: 6
 
2526
*/
 
2527
   dhtmlXTreeObject.prototype._getAllScraggyItems =function(node)
 
2528
   {
 
2529
      var z="";
 
2530
      for (var i=0; i<node.childsCount; i++)
 
2531
        {
 
2532
            if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
 
2533
            {
 
2534
                    if (node.childNodes[i].unParsed)
 
2535
                        var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);
 
2536
                    else
 
2537
                       var zb=this._getAllScraggyItems(node.childNodes[i])
 
2538
 
 
2539
                 if (zb)
 
2540
                        if (z) z+=this.dlmtr+zb;
 
2541
                        else z=zb;
 
2542
         }
 
2543
            else
 
2544
               if (!z) z=node.childNodes[i].id;
 
2545
             else z+=this.dlmtr+node.childNodes[i].id;
 
2546
         }
 
2547
          return z;
 
2548
   };
 
2549
 
 
2550
 
 
2551
 
 
2552
 
 
2553
 
 
2554
/**
 
2555
*     @desc: Returns the list of all children items from all next levels of tree, separated by commas.
 
2556
*     @param: itemId - id of node
 
2557
*     @type: private
 
2558
*     @edition: Professional
 
2559
*     @topic: 6
 
2560
*/
 
2561
 
 
2562
   dhtmlXTreeObject.prototype._getAllFatItems =function(node)
 
2563
   {
 
2564
      var z="";
 
2565
      for (var i=0; i<node.childsCount; i++)
 
2566
        {
 
2567
            if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
 
2568
            {
 
2569
             if (!z) z=node.childNodes[i].id;
 
2570
                else z+=this.dlmtr+node.childNodes[i].id;
 
2571
 
 
2572
                    if (node.childNodes[i].unParsed)
 
2573
                        var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);
 
2574
                    else
 
2575
                       var zb=this._getAllFatItems(node.childNodes[i])
 
2576
 
 
2577
                 if (zb) z+=this.dlmtr+zb;
 
2578
         }
 
2579
         }
 
2580
          return z;
 
2581
   };
 
2582
 
 
2583
 
 
2584
/**
 
2585
*     @desc: Returns the list of all children items from all next levels of tree, separated by commas.
 
2586
*     @param: itemId - id of node
 
2587
*     @type: private
 
2588
*     @topic: 6
 
2589
*/
 
2590
   dhtmlXTreeObject.prototype._getAllSubItems =function(itemId,z,node)
 
2591
   {
 
2592
      if (node) temp=node;
 
2593
      else {
 
2594
      var temp=this._globalIdStorageFind(itemId);
 
2595
         };
 
2596
      if (!temp) return 0;
 
2597
 
 
2598
      z="";
 
2599
      for (var i=0; i<temp.childsCount; i++)
 
2600
         {
 
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])
 
2604
 
 
2605
         if (zb) z+=this.dlmtr+zb;
 
2606
         }
 
2607
 
 
2608
 
 
2609
          return z;
 
2610
   };
 
2611
 
 
2612
 
 
2613
 
 
2614
 
 
2615
   
 
2616
/**  
 
2617
*     @desc: select node ( and optionaly fire onselect event)
 
2618
*     @type: public
 
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
 
2622
*     @topic: 1
 
2623
*/
 
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;
 
2628
 
 
2629
            if (this.XMLloadingWarning)
 
2630
                temp.parentObject.openMe=1;
 
2631
            else
 
2632
                this._openItem(temp.parentObject);
 
2633
 
 
2634
      //temp.onRowSelect(0,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],mode);
 
2635
        var ze=null;
 
2636
        if (preserve)  {
 
2637
                        ze=new Object; ze.ctrlKey=true;
 
2638
                        if (temp.i_sel) ze.skipUnSel=true;
 
2639
                }
 
2640
      if (mode)
 
2641
         this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],false);
 
2642
      else
 
2643
         this.onRowSelect(ze,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],true);
 
2644
   };
 
2645
   
 
2646
/**
 
2647
*     @desc: retun selected node text
 
2648
*     @type: public
 
2649
*     @return: text of selected node (or list of all selected nodes text if more than one selected)
 
2650
*     @topic: 1
 
2651
*/
 
2652
   dhtmlXTreeObject.prototype.getSelectedItemText=function()
 
2653
   {
 
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));
 
2657
   };
 
2658
 
 
2659
 
 
2660
 
 
2661
 
 
2662
/**  
 
2663
*     @desc: correct childNode list after node deleting
 
2664
*     @type: private
 
2665
*     @param: Count - childNodes collection length        
 
2666
*     @param: Nodes - childNodes collection
 
2667
*     @topic: 4  
 
2668
*/   
 
2669
   dhtmlXTreeObject.prototype._compressChildList=function(Count,Nodes)
 
2670
   {
 
2671
      Count--;
 
2672
      for (var i=0; i<Count; i++)
 
2673
      {
 
2674
         if (Nodes[i]==0) { Nodes[i]=Nodes[i+1]; Nodes[i+1]=0;}
 
2675
      };
 
2676
   };
 
2677
/**  
 
2678
*     @desc: delete node
 
2679
*     @type: private
 
2680
*     @param: itemId - target node id
 
2681
*     @param: htmlObject - target node object        
 
2682
*     @param: skip - node unregistration mode (optional, used by private methods)
 
2683
*     @topic: 2
 
2684
*/      
 
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;
 
2690
   
 
2691
      var sN=htmlObject.parentObject;
 
2692
      var Count=sN.childsCount;
 
2693
      var Nodes=sN.childNodes;
 
2694
            for (var i=0; i<Count; i++)
 
2695
            {
 
2696
               if (Nodes[i].id==itemId) { 
 
2697
               if (!skip) sN.htmlNode.childNodes[0].removeChild(Nodes[i].tr);
 
2698
               Nodes[i]=0;
 
2699
               break;
 
2700
               }
 
2701
            }
 
2702
      this._compressChildList(Count,Nodes);
 
2703
      if (!skip) {
 
2704
        sN.childsCount--;
 
2705
                 }
 
2706
 
 
2707
      if (tempos) {
 
2708
      this._correctPlus(tempos);
 
2709
      this._correctLine(tempos);
 
2710
               }
 
2711
      if (tempos2) {
 
2712
      this._correctPlus(tempos2);
 
2713
      this._correctLine(tempos2);
 
2714
               }
 
2715
      if (this.tscheck) this._correctCheckStates(sN);
 
2716
 
 
2717
      if (!skip) {
 
2718
        this._globalIdStorageRecSub(htmlObject);
 
2719
                 }
 
2720
   };
 
2721
/**
 
2722
*     @desc: set state of node's checkbox
 
2723
*     @type: public
 
2724
*     @param: itemId - target node id
 
2725
*     @param: state - checkbox state (0/1/"unsure")
 
2726
*     @topic: 5
 
2727
*/
 
2728
   dhtmlXTreeObject.prototype.setCheck=function(itemId,state){
 
2729
      var sNode=this._globalIdStorageFind(itemId,0,1);
 
2730
      if (!sNode) return;
 
2731
 
 
2732
        if (state==="unsure")
 
2733
            this._setCheck(sNode,state);
 
2734
        else
 
2735
        {
 
2736
      state=convertStringToBoolean(state);
 
2737
        if ((this.tscheck)&&(this.smcheck)) this._setSubChecked(state,sNode);
 
2738
      else this._setCheck(sNode,state);
 
2739
        }
 
2740
      if (this.smcheck)
 
2741
         this._correctCheckStates(sNode.parentObject);
 
2742
   };
 
2743
 
 
2744
   dhtmlXTreeObject.prototype._setCheck=function(sNode,state){
 
2745
                if (!sNode) return;
 
2746
        if (((sNode.parentObject._r_logic)||(this._frbtr))&&(state))
 
2747
                        if (this._frbtrs){
 
2748
                                if (this._frbtrL)   this.setCheck(this._frbtrL.id,0);
 
2749
                                this._frbtrL=sNode;
 
2750
                        } else
 
2751
                for (var i=0; i<sNode.parentObject.childsCount; i++)
 
2752
                        this._setCheck(sNode.parentObject.childNodes[i],0);
 
2753
 
 
2754
      var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
 
2755
 
 
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]);
 
2760
   };
 
2761
 
 
2762
/**
 
2763
*     @desc: change state of node's checkbox and all children checkboxes
 
2764
*     @type: public
 
2765
*     @param: itemId - target node id
 
2766
*     @param: state - checkbox state
 
2767
*     @topic: 5
 
2768
*/
 
2769
dhtmlXTreeObject.prototype.setSubChecked=function(itemId,state){
 
2770
   var sNode=this._globalIdStorageFind(itemId);
 
2771
   this._setSubChecked(state,sNode);
 
2772
   this._correctCheckStates(sNode.parentObject);
 
2773
}
 
2774
 
 
2775
 
 
2776
 
 
2777
/**  
 
2778
*     @desc: change state of node's checkbox and all childnodes checkboxes
 
2779
*     @type: private
 
2780
*     @param: itemId - target node id
 
2781
*     @param: state - checkbox state
 
2782
*     @param: sNode - target node object (optional, used by private methods)
 
2783
*     @topic: 5  
 
2784
*/
 
2785
   dhtmlXTreeObject.prototype._setSubChecked=function(state,sNode){
 
2786
      state=convertStringToBoolean(state);
 
2787
      if (!sNode) return;
 
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]);
 
2791
 
 
2792
 
 
2793
        if (sNode._r_logic||this._frbtr)
 
2794
           this._setSubChecked(state,sNode.childNodes[0]);
 
2795
        else
 
2796
      for (var i=0; i<sNode.childsCount; i++)
 
2797
         {
 
2798
             this._setSubChecked(state,sNode.childNodes[i]);
 
2799
         };
 
2800
      var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
 
2801
 
 
2802
      if (state) sNode.checkstate=1;
 
2803
      else    sNode.checkstate=0;
 
2804
      if (sNode.dscheck)  sNode.checkstate=sNode.dscheck;
 
2805
 
 
2806
 
 
2807
 
 
2808
      this._setSrc(z,this.imPath+((sNode.parentObject._r_logic||this._frbtr)?this.radioArray:this.checkArray)[sNode.checkstate]);
 
2809
   };
 
2810
 
 
2811
/**
 
2812
*     @desc: get state of nodes's checkbox
 
2813
*     @type: public
 
2814
*     @param: itemId - target node id
 
2815
*     @return: node state (0 - unchecked,1 - checked, 2 - third state)
 
2816
*     @topic: 5  
 
2817
*/      
 
2818
   dhtmlXTreeObject.prototype.isItemChecked=function(itemId){
 
2819
      var sNode=this._globalIdStorageFind(itemId);
 
2820
      if (!sNode) return;      
 
2821
      return   sNode.checkstate;
 
2822
   };
 
2823
 
 
2824
 
 
2825
 
 
2826
 
 
2827
 
 
2828
 
 
2829
 
 
2830
/**
 
2831
*     @desc: delete all children of node
 
2832
*     @type: public
 
2833
*     @param: itemId - node id
 
2834
*     @topic: 2
 
2835
*/
 
2836
    dhtmlXTreeObject.prototype.deleteChildItems=function(itemId)
 
2837
   {
 
2838
      var sNode=this._globalIdStorageFind(itemId);
 
2839
      if (!sNode) return;
 
2840
      var j=sNode.childsCount;
 
2841
      for (var i=0; i<j; i++)
 
2842
      {
 
2843
         this._deleteNode(sNode.childNodes[0].id,sNode.childNodes[0]);
 
2844
      };
 
2845
   };
 
2846
 
 
2847
/**
 
2848
*     @desc: delete node
 
2849
*     @type: public
 
2850
*     @param: itemId - node id
 
2851
*     @param: selectParent - If true parent of deleted item get selection, else no selected items leaving in tree.
 
2852
*     @topic: 2  
 
2853
*/      
 
2854
dhtmlXTreeObject.prototype.deleteItem=function(itemId,selectParent){
 
2855
    if ((!this._onrdlh)||(this._onrdlh(itemId))){
 
2856
                var z=this._deleteItem(itemId,selectParent);
 
2857
 
 
2858
        }
 
2859
 
 
2860
    //nb:solves standard doctype prb in IE
 
2861
      this.allTree.childNodes[0].border = "1";
 
2862
      this.allTree.childNodes[0].border = "0";
 
2863
}
 
2864
/**
 
2865
*     @desc: delete node
 
2866
*     @type: private
 
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)        
 
2870
*     @topic: 2  
 
2871
*/
 
2872
dhtmlXTreeObject.prototype._deleteItem=function(itemId,selectParent,skip){
 
2873
      selectParent=convertStringToBoolean(selectParent);
 
2874
      var sNode=this._globalIdStorageFind(itemId);
 
2875
      if (!sNode) return;
 
2876
        var pid=this.getParentId(itemId);
 
2877
 
 
2878
      var zTemp=sNode.parentObject;
 
2879
      this._deleteNode(itemId,sNode,skip);
 
2880
      this._correctPlus(zTemp);
 
2881
      this._correctLine(zTemp);
 
2882
 
 
2883
      if  ((selectParent)&&(pid!=this.rootId)) this.selectItem(pid,1);
 
2884
      return    zTemp;
 
2885
   };
 
2886
 
 
2887
/**
 
2888
*     @desc: uregister all child nodes of target node
 
2889
*     @type: private
 
2890
*     @param: itemObject - node object
 
2891
*     @topic: 3  
 
2892
*/      
 
2893
   dhtmlXTreeObject.prototype._globalIdStorageRecSub=function(itemObject){
 
2894
      for(var i=0; i<itemObject.childsCount; i++)
 
2895
      {
 
2896
         this._globalIdStorageRecSub(itemObject.childNodes[i]);
 
2897
         this._globalIdStorageSub(itemObject.childNodes[i].id);
 
2898
      };
 
2899
      this._globalIdStorageSub(itemObject.id);
 
2900
 
 
2901
          /*anti memory leaking*/
 
2902
                var z=itemObject;
 
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;
 
2910
                z.span=null;
 
2911
                z.tr.nodem=null;
 
2912
                z.tr=null;
 
2913
                z.htmlNode=null;
 
2914
   };
 
2915
 
 
2916
/**  
 
2917
*     @desc: create new node next to specified
 
2918
*     @type: public
 
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)
 
2928
*     @topic: 2  
 
2929
*/
 
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);
 
2933
 
 
2934
      var nodez=this._attachChildNode(0,newItemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children,sNode);
 
2935
 
 
2936
        return nodez;
 
2937
   };
 
2938
 
 
2939
 
 
2940
   
 
2941
/**
 
2942
*     @desc: retun node id by index
 
2943
*     @type: public
 
2944
*     @param: itemId - parent node id
 
2945
*     @param: index - index of node, 0 based
 
2946
*     @return: node id
 
2947
*     @topic: 1
 
2948
*/
 
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;
 
2953
   };
 
2954
 
 
2955
/**
 
2956
*     @desc: retun child node id by index
 
2957
*     @type: public
 
2958
*     @param: itemId - parent node id        
 
2959
*     @param: index - index of child node
 
2960
*     @return: node id
 
2961
*     @topic: 1
 
2962
*/      
 
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;
 
2967
   };
 
2968
 
 
2969
 
 
2970
 
 
2971
   
 
2972
 
 
2973
/**
 
2974
*     @desc: set function called when drag-and-drop event occured
 
2975
*     @param: aFunc - event handling function
 
2976
*     @type: deprecated
 
2977
*     @topic: 0,7
 
2978
*     @event:    onDrag
 
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;
 
2988
*/
 
2989
   dhtmlXTreeObject.prototype.setDragHandler=function(func){ this.attachEvent("onDrag",func); };
 
2990
   
 
2991
   /**
 
2992
*     @desc: clear selection from node
 
2993
*     @param: htmlNode - pointer to node object
 
2994
*     @type: private
 
2995
*     @topic: 1
 
2996
*/
 
2997
    dhtmlXTreeObject.prototype._clearMove=function(){
 
2998
                if (this._lastMark){
 
2999
                        this._lastMark.className=this._lastMark.className.replace(/dragAndDropRow/g,"");
 
3000
                        this._lastMark=null;
 
3001
                }
 
3002
 
 
3003
                this.allTree.className=this.allTree.className.replace(" selectionBox","");
 
3004
   };
 
3005
 
 
3006
   /**  
 
3007
*     @desc: enable/disable drag-and-drop
 
3008
*     @type: public
 
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
 
3011
*     @topic: 0
 
3012
*/
 
3013
   dhtmlXTreeObject.prototype.enableDragAndDrop=function(mode,rmode){
 
3014
        if  (mode=="temporary_disabled"){
 
3015
            this.dADTempOff=false;
 
3016
            mode=true;                  }
 
3017
        else
 
3018
            this.dADTempOff=true;
 
3019
 
 
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));
 
3024
       };   
 
3025
 
 
3026
/**
 
3027
*     @desc: set selection on node
 
3028
*     @param: node - pointer to node object
 
3029
*     @type: private
 
3030
*     @topic: 1
 
3031
*/    
 
3032
   dhtmlXTreeObject.prototype._setMove=function(htmlNode,x,y){
 
3033
      if (htmlNode.parentObject.span) {
 
3034
      //window.status=x;
 
3035
      var a1=getAbsoluteTop(htmlNode);
 
3036
      var a2=getAbsoluteTop(this.allTree);
 
3037
 
 
3038
      this.dadmodec=this.dadmode;//this.dadmode;
 
3039
      this.dadmodefix=0;
 
3040
 
 
3041
 
 
3042
                        var zN=htmlNode.parentObject.span;
 
3043
                        zN.className+=" dragAndDropRow";
 
3044
                        this._lastMark=zN;
 
3045
 
 
3046
         this._autoScroll(null,a1,a2);
 
3047
 
 
3048
      }
 
3049
   };
 
3050
 
 
3051
dhtmlXTreeObject.prototype._autoScroll=function(node,a1,a2){
 
3052
         if (this.autoScroll)
 
3053
         {
 
3054
                        if (node){
 
3055
                                a1=getAbsoluteTop(node);
 
3056
                        a2=getAbsoluteTop(this.allTree);
 
3057
                        }
 
3058
            //scroll down
 
3059
            if ( (a1-a2-parseInt(this.allTree.scrollTop))>(parseInt(this.allTree.offsetHeight)-50) )
 
3060
               this.allTree.scrollTop=parseInt(this.allTree.scrollTop)+20;
 
3061
            //scroll top
 
3062
            if ( (a1-a2)<(parseInt(this.allTree.scrollTop)+30) )
 
3063
               this.allTree.scrollTop=parseInt(this.allTree.scrollTop)-20;
 
3064
         }
 
3065
}
 
3066
 
 
3067
/**
 
3068
*     @desc: create html element for dragging
 
3069
*     @type: private
 
3070
*     @param: htmlObject - html node object
 
3071
*     @topic: 1
 
3072
*/
 
3073
dhtmlXTreeObject.prototype._createDragNode=function(htmlObject,e){
 
3074
      if (!this.dADTempOff) return null;
 
3075
 
 
3076
     var obj=htmlObject.parentObject;
 
3077
     if (!this.callEvent("onBeforeDrag",[obj.id])) return null;
 
3078
    if (!obj.i_sel)
 
3079
         this._selectItem(obj,e);
 
3080
 
 
3081
 
 
3082
      var dragSpan=document.createElement('div');
 
3083
 
 
3084
            var text=new Array();
 
3085
            if (this._itim_dg)
 
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>";
 
3088
            else
 
3089
                text=this.getSelectedItemText().split(this.dlmtr);
 
3090
 
 
3091
            dragSpan.innerHTML=text.join("");
 
3092
         dragSpan.style.position="absolute";
 
3093
         dragSpan.className="dragSpanDiv";
 
3094
      this._dragged=(new Array()).concat(this._selected);
 
3095
     return dragSpan;
 
3096
}
 
3097
 
 
3098
 
 
3099
 
 
3100
/**  
 
3101
*     @desc: focus item in tree
 
3102
*     @type: private
 
3103
*     @param: item - node object
 
3104
*     @edition: Professional
 
3105
*     @topic: 0  
 
3106
*/
 
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;
 
3111
   };
 
3112
 
 
3113
 
 
3114
 
 
3115
 
 
3116
              
 
3117
 
 
3118
 
 
3119
 
 
3120
 
 
3121
 
 
3122
 
 
3123
 
 
3124
 
 
3125
///DragAndDrop
 
3126
 
 
3127
dhtmlXTreeObject.prototype._preventNsDrag=function(e){
 
3128
   if ((e)&&(e.preventDefault)) { e.preventDefault(); return false; }
 
3129
   return false;
 
3130
}
 
3131
 
 
3132
dhtmlXTreeObject.prototype._drag=function(sourceHtmlObject,dhtmlObject,targetHtmlObject){
 
3133
      if (this._autoOpenTimer) clearTimeout(this._autoOpenTimer);
 
3134
 
 
3135
      if (!targetHtmlObject.parentObject){
 
3136
            targetHtmlObject=this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
 
3137
            this.dadmodec=0;
 
3138
            }
 
3139
 
 
3140
      this._clearMove();
 
3141
      var z=sourceHtmlObject.parentObject.treeNod;
 
3142
        if ((z)&&(z._clearMove))   z._clearMove("");
 
3143
 
 
3144
       if ((!this.dragMove)||(this.dragMove()))
 
3145
          {
 
3146
              if ((!z)||(!z._clearMove)||(!z._dragged)) var col=new Array(sourceHtmlObject.parentObject);
 
3147
              else var col=z._dragged;
 
3148
                                var trg=targetHtmlObject.parentObject;
 
3149
 
 
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);
 
3154
                }
 
3155
 
 
3156
         }
 
3157
        if (z) z._dragged=new Array();
 
3158
 
 
3159
 
 
3160
}
 
3161
 
 
3162
dhtmlXTreeObject.prototype._dragIn=function(htmlObject,shtmlObject,x,y){
 
3163
 
 
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]))
 
3169
                                                return 0;
 
3170
 
 
3171
                                        if (!tobj) 
 
3172
                                this.allTree.className+=" selectionBox";
 
3173
                                        else
 
3174
                                        {
 
3175
                            if (fobj.childNodes==null){
 
3176
                                        this._setMove(htmlObject,x,y);
 
3177
                                return htmlObject;
 
3178
                        }
 
3179
 
 
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);
 
3184
                                        return 0;
 
3185
                                                        }
 
3186
 
 
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);
 
3191
                                    }
 
3192
                                        }
 
3193
                                        
 
3194
                                return htmlObject;
 
3195
 
 
3196
}
 
3197
dhtmlXTreeObject.prototype._autoOpenItem=function(e,treeObject){
 
3198
   treeObject.openItem(treeObject._autoOpenId);
 
3199
};
 
3200
dhtmlXTreeObject.prototype._dragOut=function(htmlObject){
 
3201
this._clearMove();
 
3202
if (this._autoOpenTimer) clearTimeout(this._autoOpenTimer);
 
3203
 }
 
3204
 
 
3205
 
 
3206
 
 
3207
 
 
3208
 
 
3209
//#complex_move:01112006{
 
3210
 
 
3211
/**
 
3212
*     @desc: move item (inside of tree)
 
3213
*     @type:  public
 
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)
 
3218
*     @return: node id
 
3219
*     @topic: 2
 
3220
*/
 
3221
dhtmlXTreeObject.prototype.moveItem=function(itemId,mode,targetId,targetTree)
 
3222
{
 
3223
      var sNode=this._globalIdStorageFind(itemId);
 
3224
      if (!sNode) return (0);
 
3225
 
 
3226
      switch(mode){
 
3227
      case "right": alert('Not supported yet');
 
3228
         break;
 
3229
      case "item_child":
 
3230
              var tNode=(targetTree||this)._globalIdStorageFind(targetId);
 
3231
              if (!tNode) return (0);
 
3232
            (targetTree||this)._moveNodeTo(sNode,tNode,0);
 
3233
         break;
 
3234
      case "item_sibling":
 
3235
              var tNode=(targetTree||this)._globalIdStorageFind(targetId);
 
3236
              if (!tNode) return (0);
 
3237
            (targetTree||this)._moveNodeTo(sNode,tNode.parentObject,tNode);
 
3238
         break;
 
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);
 
3244
                else
 
3245
                    (targetTree||this)._moveNodeTo(sNode,tNode.parentObject);
 
3246
         break;
 
3247
      case "left": if (sNode.parentObject.parentObject)
 
3248
            this._moveNodeTo(sNode,sNode.parentObject.parentObject,sNode.parentObject);
 
3249
         break;
 
3250
      case "up": var z=this._getPrevNode(sNode);
 
3251
               if ((z==-1)||(!z.parentObject)) return;
 
3252
               this._moveNodeTo(sNode,z.parentObject,z);
 
3253
         break;
 
3254
      case "up_strict": var z=this._getIndex(sNode);
 
3255
                          if (z!=0)
 
3256
                         this._moveNodeTo(sNode,sNode.parentObject,sNode.parentObject.childNodes[z-1]);
 
3257
         break;
 
3258
      case "down_strict": var z=this._getIndex(sNode);
 
3259
                            var count=sNode.parentObject.childsCount-2;
 
3260
                            if (z==count)
 
3261
                             this._moveNodeTo(sNode,sNode.parentObject);
 
3262
                            else if (z<count)
 
3263
                             this._moveNodeTo(sNode,sNode.parentObject,sNode.parentObject.childNodes[z+2]);
 
3264
         break;
 
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);
 
3269
                        if (z==-1){
 
3270
                        this._moveNodeTo(sNode,sNode.parentObject);
 
3271
                        }
 
3272
                        else
 
3273
                        {
 
3274
                       if ((z==-1)||(!z.parentObject)) return;
 
3275
                       this._moveNodeTo(sNode,z.parentObject,z);
 
3276
                        }
 
3277
         break;
 
3278
      }
 
3279
}
 
3280
 
 
3281
 
 
3282
//#}
 
3283
 
 
3284
 
 
3285
 
 
3286
 
 
3287
 
 
3288
 
 
3289
 
 
3290
/**
 
3291
*     @desc: load xml for tree branch
 
3292
*     @param: id - id of parent node
 
3293
*     @param: src - path to xml, optional
 
3294
*     @type: private
 
3295
*     @topic: 1
 
3296
*/
 
3297
   dhtmlXTreeObject.prototype._loadDynXML=function(id,src) {
 
3298
                src=src||this.XMLsource;
 
3299
        var sn=(new Date()).valueOf();
 
3300
        this._ld_id=id;
 
3301
 
 
3302
            this.loadXML(src+getUrlSymbol(src)+"uid="+sn+"&id="+this._escape(id));
 
3303
        };
 
3304
 
 
3305
 
 
3306
 
 
3307
 
 
3308
 
 
3309
 
 
3310
 
 
3311
/**
 
3312
*     @desc: check possibility of drag-and-drop
 
3313
*     @type: private
 
3314
*     @param: itemId - draged node id
 
3315
*     @param: htmlObject - droped node object
 
3316
*     @param: shtmlObject - sourse node object
 
3317
*     @topic: 6
 
3318
*/
 
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;
 
3322
   };
 
3323
 
 
3324
 
 
3325
 
 
3326
 
 
3327
 
 
3328
 
 
3329
 
 
3330
 
 
3331
 
 
3332
 
 
3333
/**
 
3334
*   @desc:  prevent caching in IE  by adding random value to URL string
 
3335
*   @param: mode - enable/disable random value ( disabled by default )
 
3336
*   @type: public
 
3337
*   @topic: 0
 
3338
*/
 
3339
dhtmlXTreeObject.prototype.preventIECaching=function(mode){
 
3340
      this.no_cashe = convertStringToBoolean(mode);
 
3341
      this.XMLLoader.rSeed=this.no_cashe;
 
3342
}
 
3343
dhtmlXTreeObject.prototype.preventIECashing=dhtmlXTreeObject.prototype.preventIECaching;
 
3344
 
 
3345
 
 
3346
 
 
3347
 
 
3348
 
 
3349
/**
 
3350
*     @desc: disable checkbox
 
3351
*     @param: itemId - Id of tree item
 
3352
*     @param: mode - 1 - on, 0 - off;
 
3353
*     @type: public
 
3354
*     @topic: 5
 
3355
*/
 
3356
   dhtmlXTreeObject.prototype.disableCheckbox=function(itemId,mode) {
 
3357
            if (typeof(itemId)!="object")
 
3358
             var sNode=this._globalIdStorageFind(itemId,0,1);
 
3359
            else
 
3360
                var sNode=itemId;
 
3361
         if (!sNode) return;
 
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;
 
3365
         };
 
3366
 
 
3367
 
 
3368
 
 
3369
 
 
3370
/**
 
3371
*     @desc: set escaping mode (used for escaping ID in requests)
 
3372
*     @param: mode - escaping mode ("utf8" for UTF escaping)
 
3373
*     @type: public
 
3374
*     @topic: 0
 
3375
*/
 
3376
   dhtmlXTreeObject.prototype.setEscapingMode=function(mode){
 
3377
        this.utfesc=mode;
 
3378
        }
 
3379
 
 
3380
 
 
3381
/**
 
3382
*     @desc: enable item highlighting (item text highlited on mouseover)
 
3383
*     @beforeInit: 1
 
3384
*     @param: mode - 1 - on, 0 - off;
 
3385
*     @type: public
 
3386
*     @topic: 0
 
3387
*/
 
3388
   dhtmlXTreeObject.prototype.enableHighlighting=function(mode) { this.ehlt=true; this.ehlta=convertStringToBoolean(mode); };
 
3389
 
 
3390
/**
 
3391
*     @desc: called on mouse out
 
3392
*     @type: private
 
3393
*     @topic: 0
 
3394
*/
 
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","");
 
3402
   }
 
3403
/**
 
3404
*     @desc: called on mouse in
 
3405
*     @type: private
 
3406
*     @topic: 0
 
3407
*/
 
3408
   dhtmlXTreeObject.prototype._itemMouseIn=function(){
 
3409
                var that=this.childNodes[3].parentObject;
 
3410
                var tree=that.treeNod;
 
3411
 
 
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");
 
3417
   }
 
3418
 
 
3419
/**
 
3420
*     @desc: enable active images (clickable and dragable). By default only text part of the node is active
 
3421
*     @beforeInit: 1
 
3422
*     @param: mode - 1 - on, 0 - off;
 
3423
*     @type: public
 
3424
*     @topic: 0
 
3425
*/
 
3426
   dhtmlXTreeObject.prototype.enableActiveImages=function(mode){this._aimgs=convertStringToBoolean(mode); };
 
3427
 
 
3428
/**
 
3429
*     @desc: focus item in tree (scroll to it if necessary)
 
3430
*     @type: public
 
3431
*     @param: itemId - item Id
 
3432
*     @topic: 0
 
3433
*/
 
3434
dhtmlXTreeObject.prototype.focusItem=function(itemId){
 
3435
      var sNode=this._globalIdStorageFind(itemId);
 
3436
      if (!sNode) return (0);
 
3437
      this._focusNode(sNode);
 
3438
   };
 
3439
 
 
3440
 
 
3441
/**
 
3442
*     @desc: Returns the list of all children from all next levels of tree, separated by default delimiter.
 
3443
*     @param: itemId - id of node
 
3444
*     @type: public
 
3445
*     @return: list of all children items from all next levels of tree, separated by default delimiter
 
3446
*     @topic: 6
 
3447
*/
 
3448
   dhtmlXTreeObject.prototype.getAllSubItems =function(itemId){
 
3449
      return this._getAllSubItems(itemId);
 
3450
   }
 
3451
 
 
3452
/**
 
3453
*     @desc: Returns the list of all items which doesn't have child nodes.
 
3454
*     @type: public
 
3455
*     @return: list of all items which doesn't have child nodes.
 
3456
*     @topic: 6
 
3457
*/
 
3458
        dhtmlXTreeObject.prototype.getAllChildless =function(){
 
3459
                return this._getAllScraggyItems(this.htmlNode);
 
3460
        }
 
3461
        dhtmlXTreeObject.prototype.getAllLeafs=dhtmlXTreeObject.prototype.getAllChildless;
 
3462
 
 
3463
 
 
3464
/**
 
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
 
3468
*     @type: private
 
3469
*     @topic: 6
 
3470
*/
 
3471
   dhtmlXTreeObject.prototype._getAllScraggyItems =function(node)
 
3472
   {
 
3473
      var z="";
 
3474
      for (var i=0; i<node.childsCount; i++)
 
3475
        {
 
3476
            if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
 
3477
            {
 
3478
                    if (node.childNodes[i].unParsed)
 
3479
                        var zb=this._getAllScraggyItemsXML(node.childNodes[i].unParsed,1);
 
3480
                    else
 
3481
                       var zb=this._getAllScraggyItems(node.childNodes[i])
 
3482
 
 
3483
                 if (zb)
 
3484
                        if (z) z+=this.dlmtr+zb;
 
3485
                        else z=zb;
 
3486
         }
 
3487
            else
 
3488
               if (!z) z=node.childNodes[i].id;
 
3489
             else z+=this.dlmtr+node.childNodes[i].id;
 
3490
         }
 
3491
          return z;
 
3492
   };
 
3493
 
 
3494
 
 
3495
 
 
3496
 
 
3497
 
 
3498
/**
 
3499
*     @desc: Returns the list of all children from all next levels of tree, separated by default delimiter.
 
3500
*     @param: itemId - id of node
 
3501
*     @type: private
 
3502
*     @edition: Professional
 
3503
*     @topic: 6
 
3504
*/
 
3505
   dhtmlXTreeObject.prototype._getAllFatItems =function(node)
 
3506
   {
 
3507
      var z="";
 
3508
      for (var i=0; i<node.childsCount; i++)
 
3509
        {
 
3510
            if ((node.childNodes[i].unParsed)||(node.childNodes[i].childsCount>0))
 
3511
            {
 
3512
             if (!z) z=node.childNodes[i].id;
 
3513
                else z+=this.dlmtr+node.childNodes[i].id;
 
3514
 
 
3515
                    if (node.childNodes[i].unParsed)
 
3516
                        var zb=this._getAllFatItemsXML(node.childNodes[i].unParsed,1);
 
3517
                    else
 
3518
                       var zb=this._getAllFatItems(node.childNodes[i])
 
3519
 
 
3520
                 if (zb) z+=this.dlmtr+zb;
 
3521
         }
 
3522
         }
 
3523
          return z;
 
3524
   };
 
3525
 
 
3526
/**
 
3527
*     @desc: Returns the list of all items which have child nodes, separated by default delimiter.
 
3528
*     @type: public
 
3529
*     @return: list of all items which has child nodes, separated by default delimiter.
 
3530
*     @topic: 6
 
3531
*/
 
3532
        dhtmlXTreeObject.prototype.getAllItemsWithKids =function(){
 
3533
                return this._getAllFatItems(this.htmlNode);
 
3534
        }
 
3535
        dhtmlXTreeObject.prototype.getAllFatItems=dhtmlXTreeObject.prototype.getAllItemsWithKids;
 
3536
 
 
3537
 
 
3538
 
 
3539
/**
 
3540
*     @desc: return list of identificators of nodes with checked checkboxes, separated by default delimiter
 
3541
*     @type: public
 
3542
*     @return: list of ID of items with checked checkboxes, separated by default delimiter
 
3543
*     @topic: 5
 
3544
*/
 
3545
   dhtmlXTreeObject.prototype.getAllChecked=function(){
 
3546
      return this._getAllChecked("","",1);
 
3547
   }
 
3548
/**
 
3549
*     @desc: return list of identificators of nodes with unchecked checkboxes, separated by default delimiter
 
3550
*     @type: public
 
3551
*     @return: list of ID of items with unchecked checkboxes, separated by default delimiter
 
3552
*     @topic: 5
 
3553
*/
 
3554
   dhtmlXTreeObject.prototype.getAllUnchecked=function(itemId){
 
3555
        if (itemId)
 
3556
            itemId=this._globalIdStorageFind(itemId);
 
3557
      return this._getAllChecked(itemId,"",0);
 
3558
    }
 
3559
 
 
3560
 
 
3561
/**
 
3562
*     @desc: return list of identificators of nodes with third state checkboxes, separated by default delimiter
 
3563
*     @type: public
 
3564
*     @return: list of ID of items with third state checkboxes, separated by default delimiter
 
3565
*     @topic: 5
 
3566
*/
 
3567
   dhtmlXTreeObject.prototype.getAllPartiallyChecked=function(){
 
3568
      return this._getAllChecked("","",2);
 
3569
   }
 
3570
 
 
3571
 
 
3572
/**
 
3573
*     @desc: return list of identificators of nodes with checked and third state checkboxes, separated by default delimiter
 
3574
*     @type: public
 
3575
*     @return: list of ID of items with checked and third state checkboxes, separated by default delimiter
 
3576
*     @topic: 5
 
3577
*/
 
3578
   dhtmlXTreeObject.prototype.getAllCheckedBranches=function(){
 
3579
        var temp= this._getAllChecked("","",1);
 
3580
        if (temp!="") temp+=this.dlmtr;
 
3581
         return temp+this._getAllChecked("","",2);
 
3582
   }
 
3583
 
 
3584
/**
 
3585
*     @desc: return list of identificators of nodes with checked checkboxes
 
3586
*     @type: private
 
3587
*     @param: node - node object (optional, used by private methods)
 
3588
*     @param: list - initial identificators list (optional, used by private methods)
 
3589
*     @topic: 5
 
3590
*/
 
3591
   dhtmlXTreeObject.prototype._getAllChecked=function(htmlNode,list,mode){
 
3592
      if (!htmlNode) htmlNode=this.htmlNode;
 
3593
 
 
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++)
 
3598
      {
 
3599
         list=this._getAllChecked(htmlNode.childNodes[i],list,mode);
 
3600
      };
 
3601
 
 
3602
 
 
3603
      if (list) return list; else return "";
 
3604
   };
 
3605
 
 
3606
/**
 
3607
*     @desc: set individual item style
 
3608
*     @type: public
 
3609
*     @param: itemId - node id
 
3610
*     @param: style_string - valid CSS string
 
3611
*     @topic: 2
 
3612
*/
 
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);
 
3618
        else
 
3619
          temp.span.style.cssText+=(";"+style_string);
 
3620
}
 
3621
 
 
3622
/**
 
3623
*     @desc: enable draging item image with item text
 
3624
*     @type: public
 
3625
*     @param: mode - true/false
 
3626
*     @topic: 1
 
3627
*/
 
3628
dhtmlXTreeObject.prototype.enableImageDrag=function(mode){
 
3629
    this._itim_dg=convertStringToBoolean(mode);
 
3630
}
 
3631
 
 
3632
/**
 
3633
*     @desc: set function called when tree item draged over another item
 
3634
*     @param: func - event handling function
 
3635
*     @type: depricated
 
3636
*     @edition: Professional
 
3637
*     @topic: 4
 
3638
*     @event: onDragIn
 
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;
 
3646
*/
 
3647
        dhtmlXTreeObject.prototype.setOnDragIn=function(func){
 
3648
                this.attachEvent("onDragIn",func);
 
3649
        };
 
3650
 
 
3651
/**
 
3652
*     @desc: enable/disable auto scrolling while drag-and-drop
 
3653
*     @type: public
 
3654
*     @param: mode - enabled/disabled
 
3655
*     @topic: 0
 
3656
*/
 
3657
   dhtmlXTreeObject.prototype.enableDragAndDropScrolling=function(mode){ this.autoScroll=convertStringToBoolean(mode); };
 
3658
 
 
3659
 
 
3660
dhtmlXTreeObject.prototype.setSkin=function(name){
 
3661
        this.parentObject.className+=" dhxtree_"+name;
 
3662
}
 
3663
dhtmlXTreeObject.prototype.dhx_Event=function()
 
3664
{
 
3665
   this.dhx_SeverCatcherPath="";
 
3666
 
 
3667
   this.attachEvent = function(original, catcher, CallObj)
 
3668
   {
 
3669
      if (this._onEventSet && this._onEventSet[original])
 
3670
                this._onEventSet[original].apply(this,[]);
 
3671
 
 
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] );
 
3677
           this[original] = z;
 
3678
       }
 
3679
       return ( original + ':' + this[original].addEvent(catcher) );   //return ID (event name & event ID)
 
3680
   }
 
3681
   this.callEvent=function(name,a){
 
3682
         if (this["ev_"+name]) return this["ev_"+name].apply(this,a);
 
3683
                 return true;
 
3684
   }
 
3685
   this.checkEvent=function(name){
 
3686
         if (this["ev_"+name]) return true;
 
3687
                 return false;
 
3688
   }
 
3689
 
 
3690
   this.eventCatcher = function(obj)
 
3691
   {
 
3692
       var dhx_catch = new Array();
 
3693
       var m_obj = obj;
 
3694
       var z = function()
 
3695
             {
 
3696
                   if (dhx_catch)
 
3697
                      var res=true;
 
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 );
 
3701
                           res = res && zr;
 
3702
                      }
 
3703
                   }
 
3704
                   return res;
 
3705
                }
 
3706
       z.addEvent = function(ev)
 
3707
                {
 
3708
                       if ( typeof(ev) != "function" )
 
3709
                               ev = eval(ev);
 
3710
                       if (ev)
 
3711
                           return dhx_catch.push( ev ) - 1;
 
3712
                       return false;
 
3713
                }
 
3714
       z.removeEvent = function(id)
 
3715
                   {
 
3716
                     dhx_catch[id] = null;
 
3717
                   }
 
3718
       return z;
 
3719
   }
 
3720
 
 
3721
   this.detachEvent = function(id)
 
3722
   {
 
3723
      if (id != false) {
 
3724
         var list = id.split(':');            //get EventName and ID
 
3725
         this[ list[0] ].removeEvent( list[1] );   //remove event
 
3726
      }
 
3727
   }
 
3728
}
 
3729
//(c)dhtmlx ltd. www.dhtmlx.com
 
 
b'\\ No newline at end of file'