Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / grid / cells / dijit.js @ 13

History | View | Annotate | Download (5.26 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.grid.cells.dijit"]){
9
dojo._hasResource["dojox.grid.cells.dijit"]=true;
10
dojo.provide("dojox.grid.cells.dijit");
11
dojo.require("dojox.grid.cells");
12
dojo.require("dijit.form.DateTextBox");
13
dojo.require("dijit.form.TimeTextBox");
14
dojo.require("dijit.form.ComboBox");
15
dojo.require("dojo.data.ItemFileReadStore");
16
dojo.require("dijit.form.CheckBox");
17
dojo.require("dijit.form.TextBox");
18
dojo.require("dijit.form.NumberSpinner");
19
dojo.require("dijit.form.NumberTextBox");
20
dojo.require("dijit.form.CurrencyTextBox");
21
dojo.require("dijit.form.HorizontalSlider");
22
dojo.require("dijit.Editor");
23
(function(){
24
var _1=dojox.grid.cells;
25
dojo.declare("dojox.grid.cells._Widget",_1._Base,{widgetClass:dijit.form.TextBox,constructor:function(_2){
26
this.widget=null;
27
if(typeof this.widgetClass=="string"){
28
dojo.deprecated("Passing a string to widgetClass is deprecated","pass the widget class object instead","2.0");
29
this.widgetClass=dojo.getObject(this.widgetClass);
30
}
31
},formatEditing:function(_3,_4){
32
this.needFormatNode(_3,_4);
33
return "<div></div>";
34
},getValue:function(_5){
35
return this.widget.attr("value");
36
},setValue:function(_6,_7){
37
if(this.widget&&this.widget.attr){
38
if(this.widget.onLoadDeferred){
39
var _8=this;
40
this.widget.onLoadDeferred.addCallback(function(){
41
_8.widget.attr("value",_7===null?"":_7);
42
});
43
}else{
44
this.widget.attr("value",_7);
45
}
46
}else{
47
this.inherited(arguments);
48
}
49
},getWidgetProps:function(_9){
50
return dojo.mixin({dir:this.dir,lang:this.lang},this.widgetProps||{},{constraints:dojo.mixin({},this.constraint)||{},value:_9});
51
},createWidget:function(_a,_b,_c){
52
return new this.widgetClass(this.getWidgetProps(_b),_a);
53
},attachWidget:function(_d,_e,_f){
54
_d.appendChild(this.widget.domNode);
55
this.setValue(_f,_e);
56
},formatNode:function(_10,_11,_12){
57
if(!this.widgetClass){
58
return _11;
59
}
60
if(!this.widget){
61
this.widget=this.createWidget.apply(this,arguments);
62
}else{
63
this.attachWidget.apply(this,arguments);
64
}
65
this.sizeWidget.apply(this,arguments);
66
this.grid.rowHeightChanged(_12);
67
this.focus();
68
return undefined;
69
},sizeWidget:function(_13,_14,_15){
70
var p=this.getNode(_15),box=dojo.contentBox(p);
71
dojo.marginBox(this.widget.domNode,{w:box.w});
72
},focus:function(_16,_17){
73
if(this.widget){
74
setTimeout(dojo.hitch(this.widget,function(){
75
dojox.grid.util.fire(this,"focus");
76
}),0);
77
}
78
},_finish:function(_18){
79
this.inherited(arguments);
80
dojox.grid.util.removeNode(this.widget.domNode);
81
}});
82
_1._Widget.markupFactory=function(_19,_1a){
83
_1._Base.markupFactory(_19,_1a);
84
var d=dojo;
85
var _1b=d.trim(d.attr(_19,"widgetProps")||"");
86
var _1c=d.trim(d.attr(_19,"constraint")||"");
87
var _1d=d.trim(d.attr(_19,"widgetClass")||"");
88
if(_1b){
89
_1a.widgetProps=d.fromJson(_1b);
90
}
91
if(_1c){
92
_1a.constraint=d.fromJson(_1c);
93
}
94
if(_1d){
95
_1a.widgetClass=d.getObject(_1d);
96
}
97
};
98
dojo.declare("dojox.grid.cells.ComboBox",_1._Widget,{widgetClass:dijit.form.ComboBox,getWidgetProps:function(_1e){
99
var _1f=[];
100
dojo.forEach(this.options,function(o){
101
_1f.push({name:o,value:o});
102
});
103
var _20=new dojo.data.ItemFileReadStore({data:{identifier:"name",items:_1f}});
104
return dojo.mixin({},this.widgetProps||{},{value:_1e,store:_20});
105
},getValue:function(){
106
var e=this.widget;
107
e.attr("displayedValue",e.attr("displayedValue"));
108
return e.attr("value");
109
}});
110
_1.ComboBox.markupFactory=function(_21,_22){
111
_1._Widget.markupFactory(_21,_22);
112
var d=dojo;
113
var _23=d.trim(d.attr(_21,"options")||"");
114
if(_23){
115
var o=_23.split(",");
116
if(o[0]!=_23){
117
_22.options=o;
118
}
119
}
120
};
121
dojo.declare("dojox.grid.cells.DateTextBox",_1._Widget,{widgetClass:dijit.form.DateTextBox,setValue:function(_24,_25){
122
if(this.widget){
123
this.widget.attr("value",new Date(_25));
124
}else{
125
this.inherited(arguments);
126
}
127
},getWidgetProps:function(_26){
128
return dojo.mixin(this.inherited(arguments),{value:new Date(_26)});
129
}});
130
_1.DateTextBox.markupFactory=function(_27,_28){
131
_1._Widget.markupFactory(_27,_28);
132
};
133
dojo.declare("dojox.grid.cells.CheckBox",_1._Widget,{widgetClass:dijit.form.CheckBox,getValue:function(){
134
return this.widget.checked;
135
},setValue:function(_29,_2a){
136
if(this.widget&&this.widget.attributeMap.checked){
137
this.widget.attr("checked",_2a);
138
}else{
139
this.inherited(arguments);
140
}
141
},sizeWidget:function(_2b,_2c,_2d){
142
return;
143
}});
144
_1.CheckBox.markupFactory=function(_2e,_2f){
145
_1._Widget.markupFactory(_2e,_2f);
146
};
147
dojo.declare("dojox.grid.cells.Editor",_1._Widget,{widgetClass:dijit.Editor,getWidgetProps:function(_30){
148
return dojo.mixin({},this.widgetProps||{},{height:this.widgetHeight||"100px"});
149
},createWidget:function(_31,_32,_33){
150
var _34=new this.widgetClass(this.getWidgetProps(_32),_31);
151
dojo.connect(_34,"onLoad",dojo.hitch(this,"populateEditor"));
152
return _34;
153
},formatNode:function(_35,_36,_37){
154
this.content=_36;
155
this.inherited(arguments);
156
if(dojo.isMoz){
157
var e=this.widget;
158
e.open();
159
if(this.widgetToolbar){
160
dojo.place(e.toolbar.domNode,e.editingArea,"before");
161
}
162
}
163
},populateEditor:function(){
164
this.widget.attr("value",this.content);
165
this.widget.placeCursorAtEnd();
166
}});
167
_1.Editor.markupFactory=function(_38,_39){
168
_1._Widget.markupFactory(_38,_39);
169
var d=dojo;
170
var h=dojo.trim(dojo.attr(_38,"widgetHeight")||"");
171
if(h){
172
if((h!="auto")&&(h.substr(-2)!="em")){
173
h=parseInt(h,10)+"px";
174
}
175
_39.widgetHeight=h;
176
}
177
};
178
})();
179
}