]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_Spinner.js.uncompressed.js
2 'url:dijit/form/templates/Spinner.html':"<div class=\"dijit dijitReset dijitInline dijitLeft\"\n\tid=\"widget_${id}\" role=\"presentation\"\n\t><div class=\"dijitReset dijitButtonNode dijitSpinnerButtonContainer\"\n\t\t><input class=\"dijitReset dijitInputField dijitSpinnerButtonInner\" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t\t/><div class=\"dijitReset dijitLeft dijitButtonNode dijitArrowButton dijitUpArrowButton\"\n\t\t\tdata-dojo-attach-point=\"upArrowNode\"\n\t\t\t><div class=\"dijitArrowButtonInner\"\n\t\t\t\t><input class=\"dijitReset dijitInputField\" value=\"▲\" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t\t\t\t\t${_buttonInputDisabled}\n\t\t\t/></div\n\t\t></div\n\t\t><div class=\"dijitReset dijitLeft dijitButtonNode dijitArrowButton dijitDownArrowButton\"\n\t\t\tdata-dojo-attach-point=\"downArrowNode\"\n\t\t\t><div class=\"dijitArrowButtonInner\"\n\t\t\t\t><input class=\"dijitReset dijitInputField\" value=\"▼\" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t\t\t\t\t${_buttonInputDisabled}\n\t\t\t/></div\n\t\t></div\n\t></div\n\t><div class='dijitReset dijitValidationContainer'\n\t\t><input class=\"dijitReset dijitInputField dijitValidationIcon dijitValidationInner\" value=\"Χ\" type=\"text\" tabIndex=\"-1\" readonly=\"readonly\" role=\"presentation\"\n\t/></div\n\t><div class=\"dijitReset dijitInputField dijitInputContainer\"\n\t\t><input class='dijitReset dijitInputInner' data-dojo-attach-point=\"textbox,focusNode\" type=\"${type}\" data-dojo-attach-event=\"onkeypress:_onKeyPress\"\n\t\t\trole=\"spinbutton\" autocomplete=\"off\" ${!nameAttrSetting}\n\t/></div\n></div>\n"}});
3 define("dijit/form/_Spinner", [
4 "dojo/_base/declare", // declare
5 "dojo/_base/event", // event.stop
6 "dojo/keys", // keys keys.DOWN_ARROW keys.PAGE_DOWN keys.PAGE_UP keys.UP_ARROW
7 "dojo/_base/lang", // lang.hitch
8 "dojo/_base/sniff", // has("mozilla")
10 "./RangeBoundTextBox",
11 "dojo/text!./templates/Spinner.html",
12 "./_TextBoxMixin" // selectInputText
13 ], function(declare
, event
, keys
, lang
, has
, typematic
, RangeBoundTextBox
, template
, _TextBoxMixin
){
16 var RangeBoundTextBox = dijit.form.RangeBoundTextBox;
20 // dijit/form/_Spinner
22 // Mixin for validation widgets with a spinner.
25 return declare("dijit.form._Spinner", RangeBoundTextBox
, {
27 // Mixin for validation widgets with a spinner.
29 // This class basically (conceptually) extends `dijit.form.ValidationTextBox`.
30 // It modifies the template to have up/down arrows, and provides related handling code.
32 // defaultTimeout: Number
33 // Number of milliseconds before a held arrow key or up/down button becomes typematic
36 // minimumTimeout: Number
37 // minimum number of milliseconds that typematic event fires when held key or button is held
40 // timeoutChangeRate: Number
41 // Fraction of time used to change the typematic timer between events.
42 // 1.0 means that each typematic event fires at defaultTimeout intervals.
43 // < 1.0 means that each typematic event fires at an increasing faster rate.
44 timeoutChangeRate
: 0.90,
47 // Adjust the value by this much when spinning using the arrow keys/buttons
51 // Adjust the value by this much when spinning using the PgUp/Dn keys
54 templateString
: template
,
56 baseClass
: "dijitTextBox dijitSpinner",
58 // Set classes like dijitUpArrowButtonHover or dijitDownArrowButtonActive depending on
59 // mouse action over specified node
61 "upArrowNode": "dijitUpArrowButton",
62 "downArrowNode": "dijitDownArrowButton"
65 adjust: function(val
/*=====, delta =====*/){
67 // Overridable function used to adjust a primitive value(Number/Date/...) by the delta amount specified.
68 // The val is adjusted in a way that makes sense to the object type.
72 // protected extension
76 _arrowPressed: function(/*Node*/ nodePressed
, /*Number*/ direction
, /*Number*/ increment
){
78 // Handler for arrow button or arrow key being pressed
79 if(this.disabled
|| this.readOnly
){ return; }
80 this._setValueAttr(this.adjust(this.get('value'), direction
*increment
), false);
81 _TextBoxMixin
.selectInputText(this.textbox
, this.textbox
.value
.length
);
84 _arrowReleased: function(/*Node*/ /*===== node =====*/){
86 // Handler for arrow button or arrow key being released
87 this._wheelTimer
= null;
90 _typematicCallback: function(/*Number*/ count
, /*DOMNode*/ node
, /*Event*/ evt
){
91 var inc
=this.smallDelta
;
92 if(node
== this.textbox
){
93 var key
= evt
.charOrCode
;
94 inc
= (key
== keys
.PAGE_UP
|| key
== keys
.PAGE_DOWN
) ? this.largeDelta
: this.smallDelta
;
95 node
= (key
== keys
.UP_ARROW
|| key
== keys
.PAGE_UP
) ? this.upArrowNode
: this.downArrowNode
;
97 if(count
== -1){ this._arrowReleased(node
); }
98 else{ this._arrowPressed(node
, (node
== this.upArrowNode
) ? 1 : -1, inc
); }
102 _mouseWheeled: function(/*Event*/ evt
){
104 // Mouse wheel listener where supported
107 // FIXME: Safari bubbles
109 // be nice to DOH and scroll as much as the event says to
110 var wheelDelta
= evt
.wheelDelta
/ 120;
111 if(Math
.floor(wheelDelta
) != wheelDelta
){
112 // If not an int multiple of 120, then its touchpad scrolling.
113 // This can change very fast so just assume 1 wheel click to make it more manageable.
114 wheelDelta
= evt
.wheelDelta
> 0 ? 1 : -1;
116 var scrollAmount
= evt
.detail
? (evt
.detail
* -1) : wheelDelta
;
117 if(scrollAmount
!== 0){
118 var node
= this[(scrollAmount
> 0 ? "upArrowNode" : "downArrowNode" )];
120 this._arrowPressed(node
, scrollAmount
, this.smallDelta
);
122 if(!this._wheelTimer
){
123 clearTimeout(this._wheelTimer
);
125 this._wheelTimer
= setTimeout(lang
.hitch(this,"_arrowReleased",node
), 50);
130 postCreate: function(){
131 this.inherited(arguments
);
134 this.connect(this.domNode
, !has("mozilla") ? "onmousewheel" : 'DOMMouseScroll', "_mouseWheeled");
135 this._connects
.push(typematic
.addListener(this.upArrowNode
, this.textbox
, {charOrCode
:keys
.UP_ARROW
,ctrlKey
:false,altKey
:false,shiftKey
:false,metaKey
:false}, this, "_typematicCallback", this.timeoutChangeRate
, this.defaultTimeout
, this.minimumTimeout
));
136 this._connects
.push(typematic
.addListener(this.downArrowNode
, this.textbox
, {charOrCode
:keys
.DOWN_ARROW
,ctrlKey
:false,altKey
:false,shiftKey
:false,metaKey
:false}, this, "_typematicCallback", this.timeoutChangeRate
, this.defaultTimeout
, this.minimumTimeout
));
137 this._connects
.push(typematic
.addListener(this.upArrowNode
, this.textbox
, {charOrCode
:keys
.PAGE_UP
,ctrlKey
:false,altKey
:false,shiftKey
:false,metaKey
:false}, this, "_typematicCallback", this.timeoutChangeRate
, this.defaultTimeout
, this.minimumTimeout
));
138 this._connects
.push(typematic
.addListener(this.downArrowNode
, this.textbox
, {charOrCode
:keys
.PAGE_DOWN
,ctrlKey
:false,altKey
:false,shiftKey
:false,metaKey
:false}, this, "_typematicCallback", this.timeoutChangeRate
, this.defaultTimeout
, this.minimumTimeout
));