root / trunk / web / dojo / dijit / form / NumberSpinner.js @ 9
History | View | Annotate | Download (1.11 KB)
1 |
/*
|
---|---|
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["dijit.form.NumberSpinner"]){ |
9 |
dojo._hasResource["dijit.form.NumberSpinner"]=true; |
10 |
dojo.provide("dijit.form.NumberSpinner");
|
11 |
dojo.require("dijit.form._Spinner");
|
12 |
dojo.require("dijit.form.NumberTextBox");
|
13 |
dojo.declare("dijit.form.NumberSpinner",[dijit.form._Spinner,dijit.form.NumberTextBoxMixin],{adjust:function(_1,_2){ |
14 |
var tc=this.constraints,v=isNaN(_1),_3=!isNaN(tc.max),_4=!isNaN(tc.min); |
15 |
if(v&&_2!=0){ |
16 |
_1=(_2>0)?_4?tc.min:_3?tc.max:0:_3?this.constraints.max:_4?tc.min:0; |
17 |
} |
18 |
var _5=_1+_2;
|
19 |
if(v||isNaN(_5)){
|
20 |
return _1;
|
21 |
} |
22 |
if(_3&&(_5>tc.max)){
|
23 |
_5=tc.max; |
24 |
} |
25 |
if(_4&&(_5<tc.min)){
|
26 |
_5=tc.min; |
27 |
} |
28 |
return _5;
|
29 |
},_onKeyPress:function(e){ |
30 |
if((e.charOrCode==dojo.keys.HOME||e.charOrCode==dojo.keys.END)&&!(e.ctrlKey||e.altKey||e.metaKey)&&typeof this.get("value")!="undefined"){ |
31 |
var _6=this.constraints[(e.charOrCode==dojo.keys.HOME?"min":"max")]; |
32 |
if(typeof _6=="number"){ |
33 |
this._setValueAttr(_6,false); |
34 |
} |
35 |
dojo.stopEvent(e); |
36 |
} |
37 |
}}); |
38 |
} |