/openshift/adei

To get this branch, use:
bzr branch http://darksoft.org/webbzr/openshift/adei

« back to all changes in this revision

Viewing changes to includes/dhtmlx1/dhtmlxprotobar.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.1.0 build 71114
 
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
 
 
9
                /**
 
10
          *     @desc: protobar object
 
11
          *     @param: func - user defined function
 
12
          *     @type: private
 
13
          *     @topic: 0
 
14
          */
 
15
                function dhtmlXProtobarObject(){
 
16
                        return this;
 
17
                }
 
18
                
 
19
                /**  
 
20
          *     @desc: set action hadler on menu showing
 
21
          *     @param: func - user defined function
 
22
          *     @type: public
 
23
          *     @topic: 2  
 
24
          */            
 
25
                dhtmlXProtobarObject.prototype.setOnShowHandler=function(func){
 
26
                                  if (typeof(func)=="function") this.onShow=func; else this.onShow=eval(func); 
 
27
                };
 
28
 
 
29
                /**  
 
30
          *     @desc: return item index in collection by id
 
31
          *     @type: private
 
32
                  *     @param: id - item id
 
33
                  *     @topic: 3
 
34
          */            
 
35
                dhtmlXProtobarObject.prototype._getItemIndex=function(id){
 
36
                        for (var i=0; i<this.itemsCount; i++)
 
37
                        {
 
38
                                if (this.items[i].id==id) return i;
 
39
                        };              
 
40
                        return -1;
 
41
                };
 
42
                /**  
 
43
          *     @desc: set path to system images
 
44
          *     @param: path - relative path to images
 
45
          *     @type: public
 
46
          *     @topic: 2 
 
47
          */            
 
48
                dhtmlXProtobarObject.prototype.setGfxPath=function(path){
 
49
                                this.sysGfxPath=path;
 
50
                                if (this._adjustGFXPath) this._adjustGFXPath(path);
 
51
                };
 
52
                                
 
53
                /**  
 
54
          *     @desc: set action hadler on menu hiding
 
55
          *     @param: func - user defined function
 
56
          *     @type: public
 
57
          *     @topic: 2 
 
58
          */            
 
59
                dhtmlXProtobarObject.prototype.setOnHideHandler=function(func){
 
60
                          if (typeof(func)=="function") this.onHide=func; else this.onHide=eval(func);          
 
61
                };
 
62
                /**  
 
63
          *     @desc: set item individual action
 
64
          *     @param: id - item identificator
 
65
          *     @param: action  - js function called on item selection
 
66
          *     @type: public
 
67
          *     @topic: 2  
 
68
          */                    
 
69
                dhtmlXProtobarObject.prototype.setItemAction=function(id,action){
 
70
                        var z=this._getItemIndex(id);
 
71
                        if (z>=0){
 
72
                                this.items[z].setSecondAction(action);
 
73
                        };
 
74
                };
 
75
                                /**  
 
76
          *     @desc: return item object by id
 
77
          *     @type: public
 
78
                  *     @param: itemId - item id
 
79
              *     @topic: 4
 
80
          */            
 
81
                dhtmlXProtobarObject.prototype.getItem=function(itemId){
 
82
                        var z=this._getItemIndex(itemId);
 
83
                        if (z>=0)       return this.items[z];
 
84
                };
 
85
                /**  
 
86
          *     @desc: hide menu buttons
 
87
          *     @type: public
 
88
                  *     @param: idList - list of items's ids, separated by comma
 
89
              *     @topic: 4
 
90
          */                    
 
91
                dhtmlXProtobarObject.prototype.hideButtons=function(idList){
 
92
                        if (!idList){
 
93
                        for (var i=0; i<this.itemsCount; i++){
 
94
                                var z=this.items[i].getTopNode();
 
95
                                z.style.display="none";
 
96
                                if (this.extraMode) z.parentNode.style.display="none";
 
97
                                this.items[i].hide=1;
 
98
                                }
 
99
                        return 0;
 
100
                        }
 
101
                        
 
102
                        var temp=idList.split(",");
 
103
                        for (var i=0; i<temp.length;  i++)
 
104
                        {
 
105
                        this.hideItem(temp[i]);
 
106
                        };
 
107
                };
 
108
                /**  
 
109
          *     @desc: show menu buttons
 
110
          *     @type: public
 
111
                  *     @param: idList - list of items's ids, separated by comma
 
112
              *     @topic: 4
 
113
          */                    
 
114
                dhtmlXProtobarObject.prototype.showButtons=function(idList){
 
115
                        if (!idList){
 
116
                        for (var i=0; i<this.itemsCount; i++){
 
117
                                var w=this.items[i].getTopNode();
 
118
                                w.style.display="";
 
119
                                if (this.extraMode) w.parentNode.style.display="";
 
120
                                this.items[i].hide=0;
 
121
                                }
 
122
                        return 0;
 
123
                        }
 
124
                        
 
125
                        var temp=idList.split(",");
 
126
                        for (var i=0; i<temp.length;  i++)
 
127
                        {
 
128
                        this.showItem(temp[i]);
 
129
                        };
 
130
                };              
 
131
                                /**  
 
132
          *     @desc: disable menu button
 
133
          *     @type: public
 
134
                  *     @param: itemId - item id
 
135
              *     @topic: 4
 
136
          */                    
 
137
                dhtmlXProtobarObject.prototype.disableItem=function(itemId){
 
138
                var z=this.getItem(itemId);
 
139
                        if (z) { if (z.disable) z.disable();  }
 
140
                };
 
141
                /**  
 
142
          *     @desc: enable menu button
 
143
          *     @type: public
 
144
                  *     @param: itemId - item id
 
145
              *     @topic: 4
 
146
          */                    
 
147
                dhtmlXProtobarObject.prototype.enableItem=function(itemId){
 
148
                var z=this.getItem(itemId);
 
149
                        if (z) { if (z.enable) z.enable();  }
 
150
                };              
 
151
                
 
152
                /**  
 
153
          *     @desc: hide menu button
 
154
          *     @type: public
 
155
                  *     @param: itemId - item id
 
156
              *     @topic: 4
 
157
          */                    
 
158
                dhtmlXProtobarObject.prototype.hideItem=function(itemId){
 
159
                        var z=this.getItem(itemId);
 
160
                        if (z) {
 
161
                                var w=z.getTopNode();
 
162
                                w.style.display="none";
 
163
                                if (this.extraMode) w.parentNode.style.display="none";
 
164
                                z.hide=1;
 
165
                if (z.parentPanel){
 
166
                   this._scrollClear(z.parentPanel);
 
167
                   this._scrollCheck(z.parentPanel);
 
168
                   }
 
169
            }
 
170
                }
 
171
/**
 
172
          *     @desc: show menu button
 
173
          *     @type: public
 
174
                  *     @param: id - item id
 
175
              *     @topic: 4
 
176
          */
 
177
                dhtmlXProtobarObject.prototype.showItem=function(id){
 
178
                        var z=this.getItem(id);
 
179
                        if (z) {
 
180
                                var w=z.getTopNode();   
 
181
                                w.style.display="";
 
182
                                if (this.extraMode) w.parentNode.style.display="";
 
183
                z.hide=0;
 
184
                   if (z.parentPanel){
 
185
                   this._scrollClear(z.parentPanel);
 
186
                   this._scrollCheck(z.parentPanel);
 
187
                   }
 
188
               }
 
189
                }
 
190
                /**  
 
191
          *     @desc: set default action
 
192
          *     @type: public
 
193
                  *     @param: action - set default action
 
194
              *     @topic: 2
 
195
          */                            
 
196
                dhtmlXProtobarObject.prototype.setOnClickHandler=function(func){
 
197
                  if (typeof(func)=="function") this.defaultAction=func; else this.defaultAction=eval(func); 
 
198
                };
 
199
                /**  
 
200
          *     @desc: set menu tittle
 
201
          *     @type: public
 
202
                  *     @param: name - new tittle, shown on menu
 
203
              *     @topic: 0
 
204
          */            
 
205
                dhtmlXProtobarObject.prototype.setTitleText=function(newText){
 
206
                        this.tname=newText;
 
207
                        this.nameCell.innerHTML=newText;
 
208
                        this.preNameCell.innerHTML=newText;
 
209
                };
 
210
                                /**  
 
211
          *     @desc: set menu size
 
212
          *     @type: public
 
213
                  *     @param: width - menu width
 
214
                  *     @param: height - menu height
 
215
              *     @topic: 0
 
216
          */
 
217
                  
 
218
                dhtmlXProtobarObject.prototype.setBarSize=function(width,height){ 
 
219
                        if(width) this.topNod.width=width;
 
220
                        if(height) this.topNod.height=height;
 
221
                };
 
222
                                /**
 
223
          *     @desc: hide all items, show only items which ids in list
 
224
          *     @type: public
 
225
                  *     @param: idList - list of id's, separated by comma
 
226
              *     @topic: 4
 
227
          */
 
228
        dhtmlXProtobarObject.prototype.resetBar=function(idList){
 
229
                for (var i=0; i<this.itemsCount;  i++)
 
230
                        this.hideItem(this.items[i].id);
 
231
                var temp=idList.split(",");
 
232
                for (var i=0; i<temp.length;  i++)
 
233
                {
 
234
                        this.showItem(temp[i]);
 
235
                };
 
236
        };
 
237
 
 
238
 
 
239
 
 
240
 
 
241
 
 
242
                /**
 
243
          *     @desc: load XML from file
 
244
          *     @type: public
 
245
                  *     @param: file - file name
 
246
          *         @param: itemId - if of item for which xml requested
 
247
          *         @param: afterCall - function which will be called after loading
 
248
              *     @topic: 0
 
249
          */
 
250
 
 
251
 
 
252
                dhtmlXProtobarObject.prototype.loadXMLFor=function(file,itemId,afterCall){
 
253
                        var z=this._getItemIndex(itemId);
 
254
                        var await=null; var that=this;
 
255
                        if (z>=0)  await=this.gitems[z];
 
256
                        this.xmlLoader=new dtmlXMLLoaderObject(function(){
 
257
                                that._awaitXML=await;
 
258
                                var z=that.xmlLoader;
 
259
                                that.xmlLoader=arguments[4];
 
260
                                that._parseXMLTree.apply(this,arguments);
 
261
                                that.xmlLoader=z;
 
262
                                },this);
 
263
                        this.xmlLoader.waitCall=afterCall||0;
 
264
            this.xmlLoader.loadXML(file);
 
265
        };
 
266
 
 
267
 
 
268
                /**
 
269
          *     @desc: load XML from file
 
270
          *     @type: public
 
271
                  *     @param: file - file name
 
272
          *       @param: afterCall - function which will be called after xml loading
 
273
              *     @topic: 0
 
274
          */
 
275
 
 
276
 
 
277
                dhtmlXProtobarObject.prototype.loadXML=function(file,afterCall){
 
278
                this.xmlLoader.waitCall=afterCall||0;
 
279
        this.xmlLoader.loadXML(file); };
 
280
 
 
281
                /**
 
282
          *     @desc: load XML from string
 
283
          *     @type: public
 
284
                  *     @param: xmlString - string contining XML
 
285
          *       @param: afterCall - function which will be called after xml loading
 
286
              *     @topic: 0
 
287
          */
 
288
                dhtmlXProtobarObject.prototype.loadXMLString=function(xmlString,afterCall){
 
289
        this.waitCall=afterCall||0;
 
290
        this.xmlLoader.loadXMLString(xmlString); };
 
291
 
 
292
                /**
 
293
          *     @desc: show menu
 
294
          *     @type: public
 
295
              *     @topic: 0 
 
296
          */
 
297
 dhtmlXProtobarObject.prototype.showBar=function(){
 
298
        this.topNod.style.display="";
 
299
        if ((this.topNod.ieFix)&&(this.topNod.style.position=="absolute")) {
 
300
                this.topNod.ieFix.style.display="";
 
301
                this.topNod.ieFix.style.position="absolute";
 
302
                this.topNod.ieFix.style.top=this.topNod.style.top;
 
303
                this.topNod.ieFix.style.left=this.topNod.style.left;
 
304
                this.topNod.ieFix.style.width=this.topNod.offsetWidth+"px";
 
305
                this.topNod.ieFix.style.height=this.topNod.offsetHeight+"px";
 
306
                }
 
307
        if(this.onShow)this.onShow();
 
308
        };
 
309
        
 
310
        
 
311
                /**  
 
312
          *     @desc: hide menu
 
313
          *     @type: public
 
314
              *     @topic: 0
 
315
          */
 
316
 dhtmlXProtobarObject.prototype.hideBar=function(){
 
317
        this.topNod.style.display="none";
 
318
        if (this.topNod.ieFix) this.topNod.ieFix.style.display="none";
 
319
        if(this.onHide)this.onHide();
 
320
        };
 
321
        
 
322
                                /**  
 
323
          *     @desc: set menu buttons alignment (allowed - 'left','center','right','top','middle','bottom')
 
324
                  *             @param: align - buttons alignment
 
325
          *     @type: public
 
326
              *     @topic: 0
 
327
          */
 
328
                dhtmlXProtobarObject.prototype.setBarAlign=function(align){
 
329
                        if ((align=="left")||(align=="top")) {  this.preNameCell.innerHTML="";
 
330
                                                                                                        this.preNameCell.style.display="none";
 
331
                                                                                                        this.nameCell.style.display="";
 
332
                                                                                                        this.nameCell.width="100%";             
 
333
                                                                                                        this.nameCell.innerHTML=this.tname;
 
334
                                                                                                                                                                                                        
 
335
                                                                                                };
 
336
                        if ((align=="center")||(align=="middle")){ 
 
337
                                                                                                        this.preNameCell.style.display="";
 
338
                                                                                                        this.preNameCell.width="50%";                                                                                                           
 
339
                                                                                                        this.nameCell.style.display="";
 
340
                                                                                                        this.nameCell.width="50%";
 
341
                                                                                                        this.nameCell.innerHTML=this.tname;     
 
342
                                                                                                        this.preNameCell.innerHTML=this.tname;                                                                                          
 
343
                                                                                                };
 
344
                        if ((align=="right")||(align=="bottom"))        { 
 
345
                                                                                                        this.nameCell.innerHTML="";
 
346
                                                                                                        this.nameCell.style.display="none";
 
347
                                                                                                        this.preNameCell.style.display="";      
 
348
                                                                                                        this.preNameCell.width="100%";  
 
349
                                                                                                        this.preNameCell.innerHTML=this.tname;                                                                                                  
 
350
                                                                                                };
 
351
                };
 
352
        
 
353
                dhtmlXProtobarObject.prototype.dummyFunc=function(){ return true; };
 
354
                dhtmlXProtobarObject.prototype.badDummy=function(){return false; };                                             
 
355
 
 
356
                
 
357
 
 
358
                /**  
 
359
          *     @desc: image button prototype 
 
360
          *     @type: private
 
361
          *     @topic: 0  
 
362
          */    
 
363
function dhtmlXButtonPrototypeObject(){ 
 
364
        return this;
 
365
};
 
366
                /**  
 
367
          *     @desc: set default action, action function take one parametr - item id
 
368
          *     @type: public
 
369
                  *     @param: func - js function
 
370
                  *     @topic: 2
 
371
          */    
 
372
        dhtmlXButtonPrototypeObject.prototype.setAction=function(func){
 
373
                 if (typeof(func)=="function") this.action=func; else this.action=eval(func);           
 
374
                }
 
375
                /**  
 
376
          *     @desc: set personal onClick action (action must return false for preventing calling default action after personal), action function take one parametr - item id
 
377
                  *             @param: func - js function
 
378
          *     @type: public
 
379
          *     @topic: 2  
 
380
          */
 
381
        dhtmlXButtonPrototypeObject.prototype.setSecondAction=function(func){
 
382
                 if (typeof(func)=="function") this.persAction=func; else this.persAction=eval(func);           
 
383
                };              
 
384
                /**
 
385
          *     @desc: enable object
 
386
          *     @type: public
 
387
          *     @topic: 4  
 
388
          */            
 
389
                dhtmlXButtonPrototypeObject.prototype.enable=function(){
 
390
                        if (this.disableImage) this.imageTag.src=this.src;
 
391
                        else            
 
392
                                if (!this.className)
 
393
                                        this.topNod.className=this.objectNode.className;
 
394
                                else 
 
395
                                        this.topNod.className=this.className;   
 
396
 
 
397
                                if (this.textTag)
 
398
                                        this.textTag.className=this.textClassName;
 
399
 
 
400
                this.topNod.onclick=this._onclickX;
 
401
                this.topNod.onmouseover=this._onmouseoverX;
 
402
                this.topNod.onmouseout=this._onmouseoutX;
 
403
                this.topNod.onmousedown=this._onmousedownX;                     
 
404
                this.topNod.onmouseup=this._onmouseupX;
 
405
                this._dstate=false;
 
406
                };                      
 
407
                /**  
 
408
          *     @desc: disable object
 
409
          *     @type: public
 
410
          *     @topic: 4  
 
411
          */
 
412
                dhtmlXButtonPrototypeObject.prototype.disable=function(){
 
413
                        if (this.disableImage)
 
414
                                {
 
415
                                this.imageTag.src=this.disableImage;
 
416
                                }
 
417
                        else this.topNod.className="iconGray";
 
418
 
 
419
                        if (this.textTag)
 
420
                                        this.textTag.className="buttonTextDisabled";
 
421
 
 
422
 
 
423
                this.topNod.onclick=this.dummy;
 
424
                this.topNod.onmouseover=this.dummy;
 
425
                this.topNod.onmouseout=this.dummy;
 
426
                this.topNod.onmousedown=this.dummy;
 
427
                this.topNod.onmouseup=this.dummy;
 
428
                this._dstate=true;
 
429
                };
 
430
 
 
431
                /**  
 
432
          *     @desc: inner onclick handler
 
433
          *     @type: private
 
434
          *     @topic: 2 
 
435
          */                    
 
436
                dhtmlXButtonPrototypeObject.prototype._onclickX=function(e,that){
 
437
                        if (!that) that=this.objectNode;
 
438
                        if (that.topNod.dstatus) return;
 
439
                        if ((!that.persAction)||(that.persAction()))
 
440
                                if (that.action) { that.action(that.id); }
 
441
                };
 
442
                /**  
 
443
          *     @desc: set innerHTML of button
 
444
                  *             @param: htmlText - new text
 
445
          *     @type: public
 
446
          *     @topic: 4  
 
447
          */                    
 
448
                dhtmlXButtonPrototypeObject.prototype.setHTML=function(htmlText){
 
449
                        this.topNod.innerHTML=htmlText;
 
450
                };
 
451
                /**  
 
452
          *     @desc: set alt text of button image
 
453
          *     @type: public
 
454
                  *     @param: imageText - new alt image text
 
455
                  *     @topic: 4
 
456
          */                                    
 
457
                dhtmlXButtonPrototypeObject.prototype.setAltText=function(imageText){
 
458
                        this.imageTag.alt=imageText;            
 
459
                };              
 
460
                /**  
 
461
          *     @desc: set image href
 
462
          *     @type: public
 
463
                  *     @param: imageSrc - new image href                 
 
464
                  *     @param: disabledImageSrc - new image href                                 
 
465
                  *     @topic: 4
 
466
          */
 
467
                dhtmlXButtonPrototypeObject.prototype.setImage=function(imageSrc,disabledImageSrc){
 
468
                        this.src=imageSrc;              
 
469
                        if (disabledImageSrc) this.disableImage=disabledImageSrc;
 
470
                        
 
471
                        if (this._dstate)
 
472
                                { if (disabledImageSrc) this.imageTag.src=disabledImageSrc;      }
 
473
                        else
 
474
                                this.imageTag.src=imageSrc;             
 
475
                };
 
476
                
 
477
                dhtmlXButtonPrototypeObject.prototype.dummy=function(){};       
 
478
                /**  
 
479
          *     @desc: return HTML top node
 
480
          *     @type: private
 
481
                  *     @topic: 4
 
482
          */                    
 
483
                dhtmlXButtonPrototypeObject.prototype.getTopNode=function(){ return this.topNod;  }             
 
484
                /**  
 
485
          *     @desc: onmouseover handler
 
486
          *     @type: private
 
487
                  *     @topic: 2
 
488
          */                            
 
489
                dhtmlXButtonPrototypeObject.prototype._onmouseoverY=function() {
 
490
                if (this._mvImage)
 
491
                this.imageTag.src=this._mvImage;  
 
492
                        else
 
493
                                this.topNod.className=this.className+'Over';
 
494
                };
 
495
                /**  
 
496
          *     @desc: onmouseout handler
 
497
          *     @type: private
 
498
                  *     @topic: 2
 
499
          */                            
 
500
                dhtmlXButtonPrototypeObject.prototype._onmouseoutY=function()    {
 
501
                if (this._mnImage)
 
502
                this.imageTag.src=this._mnImage;
 
503
                        else
 
504
                                this.topNod.className=this.className;
 
505
                };
 
506
                /**  
 
507
          *     @desc: onmousedown handler
 
508
          *     @type: private
 
509
                  *     @topic: 2
 
510
          */                            
 
511
                dhtmlXButtonPrototypeObject.prototype._onmousedownX=function() { this.className=this.objectNode.className+'Down'; return true; };
 
512
                /**  
 
513
          *     @desc: onmouseup handler
 
514
          *     @type: private
 
515
                  *     @topic: 2
 
516
          */                            
 
517
                dhtmlXButtonPrototypeObject.prototype._onmouseupX=function() { this.className=this.objectNode.className; return true; };                
 
518
 
 
519
 
 
520
                
 
521
                dhtmlXButtonPrototypeObject.prototype._onmouseoutX=function(e){
 
522
                        if (!e) e=event;
 
523
                        //e.cancelBubble=true;
 
524
                        if (this.timeoutop) clearTimeout(this.timeoutop);
 
525
                        this.timeoutop=setTimeout( this.objectNode._delayedTimerCall(this.objectNode,"_onmouseoutY"),100);
 
526
                };
 
527
                
 
528
                dhtmlXButtonPrototypeObject.prototype._onmouseoverX=function(e){
 
529
                        if (!e) e=event; 
 
530
                        //e.cancelBubble=true;          
 
531
                        if (this.timeoutop) clearTimeout(this.timeoutop);
 
532
                        this.timeoutop=setTimeout( this.objectNode._delayedTimerCall(this.objectNode,"_onmouseoverY"),50);
 
533
                };
 
534
                        
 
535
                dhtmlXButtonPrototypeObject.prototype._delayedTimerCall=function(object,functionName,time){
 
536
                        this.callFunc=function(){
 
537
                                eval("object."+functionName+"();");
 
538
                        }
 
539
                        return this.callFunc;
 
540
                }
 
541
    dhtmlXButtonPrototypeObject.prototype._arg2obj=function(n,list){
 
542
                var nAtr=new Object();
 
543
                for (var i=0; i<n.length; i++)
 
544
                nAtr[list[i]]=n[i];
 
545
                return nAtr;
 
546
        }
 
547
//(c)dhtmlx ltd. www.dhtmlx.com
 
 
b'\\ No newline at end of file'