]>
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/sniff", // has("mozilla")
9 "dojo/mouse", // mouse.wheel
11 "./RangeBoundTextBox",
12 "dojo/text!./templates/Spinner.html",
13 "./_TextBoxMixin" // selectInputText
14 ], function(declare
, event
, keys
, lang
, has
, mouse
, typematic
, RangeBoundTextBox
, template
, _TextBoxMixin
){
17 // dijit/form/_Spinner
19 return declare("dijit.form._Spinner", RangeBoundTextBox
, {
21 // Mixin for validation widgets with a spinner.
23 // This class basically (conceptually) extends `dijit/form/ValidationTextBox`.
24 // It modifies the template to have up/down arrows, and provides related handling code.
26 // defaultTimeout: Number
27 // Number of milliseconds before a held arrow key or up/down button becomes typematic
30 // minimumTimeout: Number
31 // minimum number of milliseconds that typematic event fires when held key or button is held
34 // timeoutChangeRate: Number
35 // Fraction of time used to change the typematic timer between events.
36 // 1.0 means that each typematic event fires at defaultTimeout intervals.
37 // Less than 1.0 means that each typematic event fires at an increasing faster rate.
38 timeoutChangeRate
: 0.90,
41 // Adjust the value by this much when spinning using the arrow keys/buttons
45 // Adjust the value by this much when spinning using the PgUp/Dn keys
48 templateString
: template
,
50 baseClass
: "dijitTextBox dijitSpinner",
52 // Set classes like dijitUpArrowButtonHover or dijitDownArrowButtonActive depending on
53 // mouse action over specified node
55 "upArrowNode": "dijitUpArrowButton",
56 "downArrowNode": "dijitDownArrowButton"
59 adjust: function(val
/*=====, delta =====*/){
61 // Overridable function used to adjust a primitive value(Number/Date/...) by the delta amount specified.
62 // The val is adjusted in a way that makes sense to the object type.
66 // protected extension
70 _arrowPressed: function(/*Node*/ nodePressed
, /*Number*/ direction
, /*Number*/ increment
){
72 // Handler for arrow button or arrow key being pressed
73 if(this.disabled
|| this.readOnly
){ return; }
74 this._setValueAttr(this.adjust(this.get('value'), direction
*increment
), false);
75 _TextBoxMixin
.selectInputText(this.textbox
, this.textbox
.value
.length
);
78 _arrowReleased: function(/*Node*/ /*===== node =====*/){
80 // Handler for arrow button or arrow key being released
81 this._wheelTimer
= null;
84 _typematicCallback: function(/*Number*/ count
, /*DOMNode*/ node
, /*Event*/ evt
){
85 var inc
=this.smallDelta
;
86 if(node
== this.textbox
){
87 var key
= evt
.charOrCode
;
88 inc
= (key
== keys
.PAGE_UP
|| key
== keys
.PAGE_DOWN
) ? this.largeDelta
: this.smallDelta
;
89 node
= (key
== keys
.UP_ARROW
|| key
== keys
.PAGE_UP
) ? this.upArrowNode
: this.downArrowNode
;
91 if(count
== -1){ this._arrowReleased(node
); }
92 else{ this._arrowPressed(node
, (node
== this.upArrowNode
) ? 1 : -1, inc
); }
96 _mouseWheeled: function(/*Event*/ evt
){
98 // Mouse wheel listener where supported
101 // FIXME: Safari bubbles
103 // be nice to DOH and scroll as much as the event says to
104 var wheelDelta
= evt
.wheelDelta
/ 120;
105 if(Math
.floor(wheelDelta
) != wheelDelta
){
106 // If not an int multiple of 120, then its touchpad scrolling.
107 // This can change very fast so just assume 1 wheel click to make it more manageable.
108 wheelDelta
= evt
.wheelDelta
> 0 ? 1 : -1;
110 var scrollAmount
= evt
.detail
? (evt
.detail
* -1) : wheelDelta
;
111 if(scrollAmount
!== 0){
112 var node
= this[(scrollAmount
> 0 ? "upArrowNode" : "downArrowNode" )];
114 this._arrowPressed(node
, scrollAmount
, this.smallDelta
);
116 if(this._wheelTimer
){
117 this._wheelTimer
.remove();
119 this._wheelTimer
= this.defer(function(){ this._arrowReleased(node
); }, 50);
123 _setConstraintsAttr: function(/*Object*/ constraints
){
124 this.inherited(arguments
);
125 if(this.focusNode
){ // not set when called from postMixInProperties
126 if(this.constraints
.min
!== undefined){
127 this.focusNode
.setAttribute("aria-valuemin", this.constraints
.min
);
129 this.focusNode
.removeAttribute("aria-valuemin");
131 if(this.constraints
.max
!== undefined){
132 this.focusNode
.setAttribute("aria-valuemax", this.constraints
.max
);
134 this.focusNode
.removeAttribute("aria-valuemax");
139 _setValueAttr: function(/*Number*/ value
, /*Boolean?*/ priorityChange
){
141 // Hook so set('value', ...) works.
143 this.focusNode
.setAttribute("aria-valuenow", value
);
144 this.inherited(arguments
);
147 postCreate: function(){
148 this.inherited(arguments
);
151 this.connect(this.domNode
, mouse
.wheel
, "_mouseWheeled");
153 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
),
154 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
),
155 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
),
156 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
)