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