]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/NumberTextBox.js
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
8 if(!dojo
._hasResource
["dijit.form.NumberTextBox"]){
9 dojo
._hasResource
["dijit.form.NumberTextBox"]=true;
10 dojo
.provide("dijit.form.NumberTextBox");
11 dojo
.require("dijit.form.ValidationTextBox");
12 dojo
.require("dojo.number");
13 dojo
.declare("dijit.form.NumberTextBoxMixin",null,{regExpGen
:dojo
.number
.regexp
,value
:NaN
,editOptions
:{pattern
:"#.######"},_formatter
:dojo
.number
.format
,_setConstraintsAttr:function(_1
){
14 var _2
=typeof _1
.places
=="number"?_1
.places
:0;
18 if(typeof _1
.max
!="number"){
19 _1
.max
=9*Math
.pow(10,15-_2
);
21 if(typeof _1
.min
!="number"){
22 _1
.min
=-9*Math
.pow(10,15-_2
);
24 this.inherited(arguments
,[_1
]);
25 if(this.focusNode
&&this.focusNode
.value
&&!isNaN(this.value
)){
26 this.set("value",this.value
);
28 },_onFocus:function(){
32 var _3
=this.get("value");
33 if(typeof _3
=="number"&&!isNaN(_3
)){
34 var _4
=this.format(_3
,this.constraints
);
36 this.textbox
.value
=_4
;
39 this.inherited(arguments
);
40 },format:function(_5
,_6
){
42 if(typeof _5
!="number"){
48 if(!("rangeCheck" in this&&this.rangeCheck(_5
,_6
))&&_6
.exponent
!==false&&/\de[-+]?\d/i.test(_7
)){
51 if(this.editOptions
&&this._focused
){
52 _6
=dojo
.mixin({},_6
,this.editOptions
);
54 return this._formatter(_5
,_6
);
55 },parse
:dojo
.number
.parse
,_getDisplayedValueAttr:function(){
56 var v
=this.inherited(arguments
);
57 return isNaN(v
)?this.textbox
.value
:v
;
58 },filter:function(_8
){
59 return (_8
===null||_8
===""||_8
===undefined)?NaN
:this.inherited(arguments
);
60 },serialize:function(_9
,_a
){
61 return (typeof _9
!="number"||isNaN(_9
))?"":this.inherited(arguments
);
62 },_setValueAttr:function(_b
,_c
,_d
){
63 if(_b
!==undefined&&_d
===undefined){
65 if(typeof _b
=="number"){
69 if(("rangeCheck" in this&&this.rangeCheck(_b
,this.constraints
))||this.constraints
.exponent
===false||!/\de[-+]?\d/i.test(_d
)){
82 this.inherited(arguments
,[_b
,_c
,_d
]);
83 },_getValueAttr:function(){
84 var v
=this.inherited(arguments
);
85 if(isNaN(v
)&&this.textbox
.value
!==""){
86 if(this.constraints
.exponent
!==false&&/\de[-+]?\d/i.test(this.textbox
.value
)&&(new RegExp("^"+dojo
.number
._realNumberRegexp(dojo
.mixin({},this.constraints
))+"$").test(this.textbox
.value
))){
87 var n
=Number(this.textbox
.value
);
88 return isNaN(n
)?undefined:n
;
95 },isValid:function(_e
){
96 if(!this._focused
||this._isEmpty(this.textbox
.value
)){
97 return this.inherited(arguments
);
99 var v
=this.get("value");
100 if(!isNaN(v
)&&this.rangeCheck(v
,this.constraints
)){
101 if(this.constraints
.exponent
!==false&&/\de[-+]?\d/i.test(this.textbox
.value
)){
104 return this.inherited(arguments
);
111 dojo
.declare("dijit.form.NumberTextBox",[dijit
.form
.RangeBoundTextBox
,dijit
.form
.NumberTextBoxMixin
],{});