1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
if(!dojo._hasResource["dijit.form.NumberTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dijit.form.NumberTextBox"] = true;
dojo.provide("dijit.form.NumberTextBox");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dojo.number");
/*=====
dojo.declare(
"dijit.form.NumberTextBox.__Constraints",
[dijit.form.RangeBoundTextBox.__Constraints, dojo.number.__FormatOptions, dojo.number.__ParseOptions]
);
=====*/
dojo.declare(
"dijit.form.NumberTextBoxMixin",
null,
{
// summary:
// A mixin for all number textboxes
regExpGen: dojo.number.regexp,
/*=====
// constraints: dijit.form.NumberTextBox.__Constraints
constraints: {},
======*/
// editOptions: Object
// properties to mix into constraints when the value is being edited
editOptions: { pattern: '#.######' },
_onFocus: function(){
this.setValue(this.getValue(), false);
this.inherited(arguments);
},
_formatter: dojo.number.format,
format: function(/*Number*/ value, /*dojo.number.__FormatOptions*/ constraints){
// summary: formats the value as a Number, according to constraints
if(typeof value == "string") { return value; }
if(isNaN(value)){ return ""; }
if(this.editOptions && this._focused){
constraints = dojo.mixin(dojo.mixin({}, this.editOptions), this.constraints);
}
return this._formatter(value, constraints);
},
parse: dojo.number.parse,
/*=====
parse: function(value, constraints){
// summary: parses the value as a Number, according to constraints
// value: String
//
// constraints: dojo.number.__ParseOptions
},
=====*/
filter: function(/*Number*/ value){
if(typeof value == "string"){ return this.inherited('filter', arguments); }
return isNaN(value) ? '' : value;
},
value: NaN
}
);
dojo.declare(
"dijit.form.NumberTextBox",
[dijit.form.RangeBoundTextBox,dijit.form.NumberTextBoxMixin],
{
// summary:
// A validating, serializable, range-bound text box.
}
);
}
|