]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/NumberSpinner.js.uncompressed.js
1 define("dijit/form/NumberSpinner", [
2 "dojo/_base/declare", // declare
3 "dojo/_base/event", // event.stop
4 "dojo/keys", // keys.END keys.HOME
7 ], function(declare
, event
, keys
, _Spinner
, NumberTextBox
){
10 var _Spinner = dijit.form._Spinner;
11 var NumberTextBox = dijit.form.NumberTextBox;
15 // dijit/form/NumberSpinner
17 // Extends NumberTextBox to add up/down arrows and pageup/pagedown for incremental change to the value
20 return declare("dijit.form.NumberSpinner", [_Spinner
, NumberTextBox
.Mixin
], {
22 // Extends NumberTextBox to add up/down arrows and pageup/pagedown for incremental change to the value
25 // A `dijit.form.NumberTextBox` extension to provide keyboard accessible value selection
26 // as well as icons for spinning direction. When using the keyboard, the typematic rules
27 // apply, meaning holding the key will gradually increase or decrease the value and
31 // | new dijit.form.NumberSpinner({ constraints:{ max:300, min:100 }}, "someInput");
33 adjust: function(/*Object*/ val
, /*Number*/ delta
){
35 // Change Number val by the given amount
39 var tc
= this.constraints
,
41 gotMax
= !isNaN(tc
.max
),
42 gotMin
= !isNaN(tc
.min
)
44 if(v
&& delta
!= 0){ // blank or invalid value and they want to spin, so create defaults
46 gotMin
? tc
.min
: gotMax
? tc
.max
: 0 :
47 gotMax
? this.constraints
.max
: gotMin
? tc
.min
: 0
50 var newval
= val
+ delta
;
51 if(v
|| isNaN(newval
)){ return val
; }
52 if(gotMax
&& (newval
> tc
.max
)){
55 if(gotMin
&& (newval
< tc
.min
)){
61 _onKeyPress: function(e
){
62 if((e
.charOrCode
== keys
.HOME
|| e
.charOrCode
== keys
.END
) && !(e
.ctrlKey
|| e
.altKey
|| e
.metaKey
)
63 && typeof this.get('value') != 'undefined' /* gibberish, so HOME and END are default editing keys*/){
64 var value
= this.constraints
[(e
.charOrCode
== keys
.HOME
? "min" : "max")];
65 if(typeof value
== "number"){
66 this._setValueAttr(value
, false);
68 // eat home or end key whether we change the value or not