]> git.wh0rd.org - tt-rss.git/blame - lib/dijit/form/_Spinner.js.uncompressed.js
modify dojo rebuild script to remove uncompressed files
[tt-rss.git] / lib / dijit / form / _Spinner.js.uncompressed.js
CommitLineData
f0cfe83e
AD
1require({cache:{
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=\"&#9650; \" 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=\"&#9660; \" 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=\"&#935; \" 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"}});
3define("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
10 "../typematic",
11 "./RangeBoundTextBox",
12 "dojo/text!./templates/Spinner.html",
13 "./_TextBoxMixin" // selectInputText
14], function(declare, event, keys, lang, has, mouse, typematic, RangeBoundTextBox, template, _TextBoxMixin){
15
16 // module:
17 // dijit/form/_Spinner
18
19 return declare("dijit.form._Spinner", RangeBoundTextBox, {
20 // summary:
21 // Mixin for validation widgets with a spinner.
22 // description:
23 // This class basically (conceptually) extends `dijit/form/ValidationTextBox`.
24 // It modifies the template to have up/down arrows, and provides related handling code.
25
26 // defaultTimeout: Number
27 // Number of milliseconds before a held arrow key or up/down button becomes typematic
28 defaultTimeout: 500,
29
30 // minimumTimeout: Number
31 // minimum number of milliseconds that typematic event fires when held key or button is held
32 minimumTimeout: 10,
33
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,
39
40 // smallDelta: Number
41 // Adjust the value by this much when spinning using the arrow keys/buttons
42 smallDelta: 1,
43
44 // largeDelta: Number
45 // Adjust the value by this much when spinning using the PgUp/Dn keys
46 largeDelta: 10,
47
48 templateString: template,
49
50 baseClass: "dijitTextBox dijitSpinner",
51
52 // Set classes like dijitUpArrowButtonHover or dijitDownArrowButtonActive depending on
53 // mouse action over specified node
54 cssStateNodes: {
55 "upArrowNode": "dijitUpArrowButton",
56 "downArrowNode": "dijitDownArrowButton"
57 },
58
59 adjust: function(val /*=====, delta =====*/){
60 // summary:
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.
63 // val: Object
64 // delta: Number
65 // tags:
66 // protected extension
67 return val;
68 },
69
70 _arrowPressed: function(/*Node*/ nodePressed, /*Number*/ direction, /*Number*/ increment){
71 // summary:
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);
76 },
77
78 _arrowReleased: function(/*Node*/ /*===== node =====*/){
79 // summary:
80 // Handler for arrow button or arrow key being released
81 this._wheelTimer = null;
82 },
83
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;
90 }
91 if(count == -1){ this._arrowReleased(node); }
92 else{ this._arrowPressed(node, (node == this.upArrowNode) ? 1 : -1, inc); }
93 },
94
95 _wheelTimer: null,
96 _mouseWheeled: function(/*Event*/ evt){
97 // summary:
98 // Mouse wheel listener where supported
99
100 event.stop(evt);
101 // FIXME: Safari bubbles
102
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;
109 }
110 var scrollAmount = evt.detail ? (evt.detail * -1) : wheelDelta;
111 if(scrollAmount !== 0){
112 var node = this[(scrollAmount > 0 ? "upArrowNode" : "downArrowNode" )];
113
114 this._arrowPressed(node, scrollAmount, this.smallDelta);
115
116 if(this._wheelTimer){
117 this._wheelTimer.remove();
118 }
119 this._wheelTimer = this.defer(function(){ this._arrowReleased(node); }, 50);
120 }
121 },
122
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);
128 }else{
129 this.focusNode.removeAttribute("aria-valuemin");
130 }
131 if(this.constraints.max !== undefined){
132 this.focusNode.setAttribute("aria-valuemax", this.constraints.max);
133 }else{
134 this.focusNode.removeAttribute("aria-valuemax");
135 }
136 }
137 },
138
139 _setValueAttr: function(/*Number*/ value, /*Boolean?*/ priorityChange){
140 // summary:
141 // Hook so set('value', ...) works.
142
143 this.focusNode.setAttribute("aria-valuenow", value);
144 this.inherited(arguments);
145 },
146
147 postCreate: function(){
148 this.inherited(arguments);
149
150 // extra listeners
151 this.connect(this.domNode, mouse.wheel, "_mouseWheeled");
152 this.own(
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)
157 );
158 }
159 });
160});