]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_Spinner.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / form / _Spinner.js.uncompressed.js
1 require({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"}});
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")
9 "dijit/typematic",
10 "./RangeBoundTextBox",
11 "dojo/text!./templates/Spinner.html",
12 "./_TextBoxMixin" // selectInputText
13 ], function(declare, event, keys, lang, has, typematic, RangeBoundTextBox, template, _TextBoxMixin){
14
15 /*=====
16 var RangeBoundTextBox = dijit.form.RangeBoundTextBox;
17 =====*/
18
19 // module:
20 // dijit/form/_Spinner
21 // summary:
22 // Mixin for validation widgets with a spinner.
23
24
25 return declare("dijit.form._Spinner", RangeBoundTextBox, {
26 // summary:
27 // Mixin for validation widgets with a spinner.
28 // description:
29 // This class basically (conceptually) extends `dijit.form.ValidationTextBox`.
30 // It modifies the template to have up/down arrows, and provides related handling code.
31
32 // defaultTimeout: Number
33 // Number of milliseconds before a held arrow key or up/down button becomes typematic
34 defaultTimeout: 500,
35
36 // minimumTimeout: Number
37 // minimum number of milliseconds that typematic event fires when held key or button is held
38 minimumTimeout: 10,
39
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,
45
46 // smallDelta: Number
47 // Adjust the value by this much when spinning using the arrow keys/buttons
48 smallDelta: 1,
49
50 // largeDelta: Number
51 // Adjust the value by this much when spinning using the PgUp/Dn keys
52 largeDelta: 10,
53
54 templateString: template,
55
56 baseClass: "dijitTextBox dijitSpinner",
57
58 // Set classes like dijitUpArrowButtonHover or dijitDownArrowButtonActive depending on
59 // mouse action over specified node
60 cssStateNodes: {
61 "upArrowNode": "dijitUpArrowButton",
62 "downArrowNode": "dijitDownArrowButton"
63 },
64
65 adjust: function(val /*=====, delta =====*/){
66 // summary:
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.
69 // val: Object
70 // delta: Number
71 // tags:
72 // protected extension
73 return val;
74 },
75
76 _arrowPressed: function(/*Node*/ nodePressed, /*Number*/ direction, /*Number*/ increment){
77 // summary:
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);
82 },
83
84 _arrowReleased: function(/*Node*/ /*===== node =====*/){
85 // summary:
86 // Handler for arrow button or arrow key being released
87 this._wheelTimer = null;
88 },
89
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;
96 }
97 if(count == -1){ this._arrowReleased(node); }
98 else{ this._arrowPressed(node, (node == this.upArrowNode) ? 1 : -1, inc); }
99 },
100
101 _wheelTimer: null,
102 _mouseWheeled: function(/*Event*/ evt){
103 // summary:
104 // Mouse wheel listener where supported
105
106 event.stop(evt);
107 // FIXME: Safari bubbles
108
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;
115 }
116 var scrollAmount = evt.detail ? (evt.detail * -1) : wheelDelta;
117 if(scrollAmount !== 0){
118 var node = this[(scrollAmount > 0 ? "upArrowNode" : "downArrowNode" )];
119
120 this._arrowPressed(node, scrollAmount, this.smallDelta);
121
122 if(!this._wheelTimer){
123 clearTimeout(this._wheelTimer);
124 }
125 this._wheelTimer = setTimeout(lang.hitch(this,"_arrowReleased",node), 50);
126 }
127
128 },
129
130 postCreate: function(){
131 this.inherited(arguments);
132
133 // extra listeners
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));
139 }
140 });
141 });