Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / drawing / ui / dom / Toolbar.js

History | View | Annotate | Download (3.07 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.drawing.ui.dom.Toolbar"]){
9
dojo._hasResource["dojox.drawing.ui.dom.Toolbar"]=true;
10
dojo.provide("dojox.drawing.ui.dom.Toolbar");
11
dojo.deprecated("dojox.drawing.ui.dom.Toolbar","It may not even make it to the 1.4 release.",1.4);
12
(function(){
13
dojo.declare("dojox.drawing.ui.dom.Toolbar",[],{baseClass:"drawingToolbar",buttonClass:"drawingButton",iconClass:"icon",constructor:function(_1,_2){
14
dojo.addOnLoad(this,function(){
15
this.domNode=dojo.byId(_2);
16
dojo.addClass(this.domNode,this.baseClass);
17
this.parse();
18
});
19
},createIcon:function(_3,_4){
20
var _5=_4&&_4.setup?_4.setup:{};
21
if(_5.iconClass){
22
var _6=_5.iconClass?_5.iconClass:"iconNone";
23
var _7=_5.tooltip?_5.tooltip:"Tool";
24
var _8=dojo.create("div",{title:_7},_3);
25
dojo.addClass(_8,this.iconClass);
26
dojo.addClass(_8,_6);
27
dojo.connect(_3,"mouseup",function(_9){
28
dojo.stopEvent(_9);
29
dojo.removeClass(_3,"active");
30
});
31
dojo.connect(_3,"mouseover",function(_a){
32
dojo.stopEvent(_a);
33
dojo.addClass(_3,"hover");
34
});
35
dojo.connect(_3,"mousedown",this,function(_b){
36
dojo.stopEvent(_b);
37
dojo.addClass(_3,"active");
38
});
39
dojo.connect(_3,"mouseout",this,function(_c){
40
dojo.stopEvent(_c);
41
dojo.removeClass(_3,"hover");
42
});
43
}
44
},createTool:function(_d){
45
_d.innerHTML="";
46
var _e=dojo.attr(_d,"tool");
47
this.toolNodes[_e]=_d;
48
dojo.attr(_d,"tabIndex",1);
49
var _f=dojo.getObject(_e);
50
this.createIcon(_d,_f);
51
this.drawing.registerTool(_e,_f);
52
dojo.connect(_d,"mouseup",this,function(evt){
53
dojo.stopEvent(evt);
54
dojo.removeClass(_d,"active");
55
this.onClick(_e);
56
});
57
dojo.connect(_d,"mouseover",function(evt){
58
dojo.stopEvent(evt);
59
dojo.addClass(_d,"hover");
60
});
61
dojo.connect(_d,"mousedown",this,function(evt){
62
dojo.stopEvent(evt);
63
dojo.addClass(_d,"active");
64
});
65
dojo.connect(_d,"mouseout",this,function(evt){
66
dojo.stopEvent(evt);
67
dojo.removeClass(_d,"hover");
68
});
69
},parse:function(){
70
var _10=dojo.attr(this.domNode,"drawingId");
71
this.drawing=dojox.drawing.util.common.byId(_10);
72
!this.drawing&&console.error("Drawing not found based on 'drawingId' in Toolbar. ");
73
this.toolNodes={};
74
var _11;
75
dojo.query(">",this.domNode).forEach(function(_12,i){
76
_12.className=this.buttonClass;
77
var _13=dojo.attr(_12,"tool");
78
var _14=dojo.attr(_12,"action");
79
var _15=dojo.attr(_12,"plugin");
80
if(_13){
81
if(i==0||dojo.attr(_12,"selected")=="true"){
82
_11=_13;
83
}
84
this.createTool(_12);
85
}else{
86
if(_15){
87
var p={name:_15,options:{}},opt=dojo.attr(_12,"options");
88
if(opt){
89
p.options=eval("("+opt+")");
90
}
91
p.options.node=_12;
92
_12.innerHTML="";
93
this.drawing.addPlugin(p);
94
this.createIcon(_12,dojo.getObject(dojo.attr(_12,"plugin")));
95
}
96
}
97
},this);
98
this.drawing.initPlugins();
99
dojo.connect(this.drawing,"setTool",this,"onSetTool");
100
this.drawing.setTool(_11);
101
},onClick:function(_16){
102
this.drawing.setTool(_16);
103
},onSetTool:function(_17){
104
for(var n in this.toolNodes){
105
if(n==_17){
106
dojo.addClass(this.toolNodes[_17],"selected");
107
this.toolNodes[_17].blur();
108
}else{
109
dojo.removeClass(this.toolNodes[n],"selected");
110
}
111
}
112
}});
113
})();
114
}