diff options
author | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:10 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:18 +0400 |
commit | 1354d17270961fff662d40f90521223f8fd0d73b (patch) | |
tree | e9266be71587e47c800303446e968a6d3565e2cf /lib/dijit/form/NumberSpinner.js.uncompressed.js | |
parent | d04f8c826f5283765f52cf6b98b42a1ed8f2d6bc (diff) |
update dojo to 1.7.3
Diffstat (limited to 'lib/dijit/form/NumberSpinner.js.uncompressed.js')
-rw-r--r-- | lib/dijit/form/NumberSpinner.js.uncompressed.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/dijit/form/NumberSpinner.js.uncompressed.js b/lib/dijit/form/NumberSpinner.js.uncompressed.js new file mode 100644 index 000000000..e96848eeb --- /dev/null +++ b/lib/dijit/form/NumberSpinner.js.uncompressed.js @@ -0,0 +1,74 @@ +define("dijit/form/NumberSpinner", [ + "dojo/_base/declare", // declare + "dojo/_base/event", // event.stop + "dojo/keys", // keys.END keys.HOME + "./_Spinner", + "./NumberTextBox" +], function(declare, event, keys, _Spinner, NumberTextBox){ + +/*===== + var _Spinner = dijit.form._Spinner; + var NumberTextBox = dijit.form.NumberTextBox; +=====*/ + +// module: +// dijit/form/NumberSpinner +// summary: +// Extends NumberTextBox to add up/down arrows and pageup/pagedown for incremental change to the value + + +return declare("dijit.form.NumberSpinner", [_Spinner, NumberTextBox.Mixin], { + // summary: + // Extends NumberTextBox to add up/down arrows and pageup/pagedown for incremental change to the value + // + // description: + // A `dijit.form.NumberTextBox` extension to provide keyboard accessible value selection + // as well as icons for spinning direction. When using the keyboard, the typematic rules + // apply, meaning holding the key will gradually increase or decrease the value and + // accelerate. + // + // example: + // | new dijit.form.NumberSpinner({ constraints:{ max:300, min:100 }}, "someInput"); + + adjust: function(/*Object*/ val, /*Number*/ delta){ + // summary: + // Change Number val by the given amount + // tags: + // protected + + var tc = this.constraints, + v = isNaN(val), + gotMax = !isNaN(tc.max), + gotMin = !isNaN(tc.min) + ; + if(v && delta != 0){ // blank or invalid value and they want to spin, so create defaults + val = (delta > 0) ? + gotMin ? tc.min : gotMax ? tc.max : 0 : + gotMax ? this.constraints.max : gotMin ? tc.min : 0 + ; + } + var newval = val + delta; + if(v || isNaN(newval)){ return val; } + if(gotMax && (newval > tc.max)){ + newval = tc.max; + } + if(gotMin && (newval < tc.min)){ + newval = tc.min; + } + return newval; + }, + + _onKeyPress: function(e){ + if((e.charOrCode == keys.HOME || e.charOrCode == keys.END) && !(e.ctrlKey || e.altKey || e.metaKey) + && typeof this.get('value') != 'undefined' /* gibberish, so HOME and END are default editing keys*/){ + var value = this.constraints[(e.charOrCode == keys.HOME ? "min" : "max")]; + if(typeof value == "number"){ + this._setValueAttr(value, false); + } + // eat home or end key whether we change the value or not + event.stop(e); + } + } +}); + +}); |