jquery-ui-rails 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jquery-ui-rails might be problematic. Click here for more details.
- data/History.md +15 -0
- data/License.txt +2 -3
- data/README.md +17 -19
- data/Rakefile +79 -28
- data/lib/jquery/ui/rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.ui.accordion.js +537 -417
- data/vendor/assets/javascripts/jquery.ui.all.js +17 -14
- data/vendor/assets/javascripts/jquery.ui.autocomplete.js +311 -339
- data/vendor/assets/javascripts/jquery.ui.button.js +63 -59
- data/vendor/assets/javascripts/jquery.ui.core.js +134 -112
- data/vendor/assets/javascripts/jquery.ui.datepicker-ar-DZ.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-ar.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-az.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-bg.js +16 -16
- data/vendor/assets/javascripts/jquery.ui.datepicker-bs.js +5 -5
- data/vendor/assets/javascripts/jquery.ui.datepicker-ca.js +13 -13
- data/vendor/assets/javascripts/jquery.ui.datepicker-cs.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-cy-GB.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-da.js +9 -9
- data/vendor/assets/javascripts/jquery.ui.datepicker-de.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-el.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-eo.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-es.js +6 -6
- data/vendor/assets/javascripts/jquery.ui.datepicker-et.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-eu.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-fa.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-fi.js +5 -5
- data/vendor/assets/javascripts/jquery.ui.datepicker-fo.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-fr-CH.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-fr.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-gl.js +6 -6
- data/vendor/assets/javascripts/jquery.ui.datepicker-he.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-hr.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-hy.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-id.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-is.js +11 -11
- data/vendor/assets/javascripts/jquery.ui.datepicker-it.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-ja.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-kk.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-ko.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-lt.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-lv.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-ml.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-ms.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-nl.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-no.js +18 -18
- data/vendor/assets/javascripts/jquery.ui.datepicker-pl.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-pt-BR.js +7 -7
- data/vendor/assets/javascripts/jquery.ui.datepicker-pt.js +6 -6
- data/vendor/assets/javascripts/jquery.ui.datepicker-rm.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-ro.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-ru.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-sk.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-sl.js +6 -6
- data/vendor/assets/javascripts/jquery.ui.datepicker-sq.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-sr-SR.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-sr.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-sv.js +9 -9
- data/vendor/assets/javascripts/jquery.ui.datepicker-th.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-tj.js +1 -1
- data/vendor/assets/javascripts/jquery.ui.datepicker-tr.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-uk.js +3 -3
- data/vendor/assets/javascripts/jquery.ui.datepicker-vi.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-zh-CN.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-zh-HK.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker-zh-TW.js +2 -2
- data/vendor/assets/javascripts/jquery.ui.datepicker.js +51 -59
- data/vendor/assets/javascripts/jquery.ui.dialog.js +402 -409
- data/vendor/assets/javascripts/jquery.ui.draggable.js +79 -75
- data/vendor/assets/javascripts/jquery.ui.droppable.js +10 -17
- data/vendor/assets/javascripts/jquery.ui.effect-blind.js +84 -0
- data/vendor/assets/javascripts/jquery.ui.effect-bounce.js +115 -0
- data/vendor/assets/javascripts/jquery.ui.effect-clip.js +69 -0
- data/vendor/assets/javascripts/jquery.ui.effect-drop.js +67 -0
- data/vendor/assets/javascripts/jquery.ui.effect-explode.js +99 -0
- data/vendor/assets/javascripts/jquery.ui.effect-fade.js +32 -0
- data/vendor/assets/javascripts/jquery.ui.effect-fold.js +78 -0
- data/vendor/assets/javascripts/jquery.ui.effect-highlight.js +52 -0
- data/vendor/assets/javascripts/jquery.ui.effect-pulsate.js +65 -0
- data/vendor/assets/javascripts/jquery.ui.effect-scale.js +320 -0
- data/vendor/assets/javascripts/jquery.ui.effect-shake.js +76 -0
- data/vendor/assets/javascripts/jquery.ui.effect-slide.js +66 -0
- data/vendor/assets/javascripts/jquery.ui.effect-transfer.js +49 -0
- data/vendor/assets/javascripts/jquery.ui.effect.all.js +14 -0
- data/vendor/assets/javascripts/jquery.ui.effect.js +1276 -0
- data/vendor/assets/javascripts/jquery.ui.menu.js +614 -0
- data/vendor/assets/javascripts/jquery.ui.mouse.js +22 -20
- data/vendor/assets/javascripts/jquery.ui.position.js +367 -158
- data/vendor/assets/javascripts/jquery.ui.progressbar.js +10 -14
- data/vendor/assets/javascripts/jquery.ui.resizable.js +143 -149
- data/vendor/assets/javascripts/jquery.ui.selectable.js +22 -28
- data/vendor/assets/javascripts/jquery.ui.slider.js +88 -106
- data/vendor/assets/javascripts/jquery.ui.sortable.js +97 -95
- data/vendor/assets/javascripts/jquery.ui.spinner.js +482 -0
- data/vendor/assets/javascripts/jquery.ui.tabs.js +1189 -580
- data/vendor/assets/javascripts/jquery.ui.tooltip.js +402 -0
- data/vendor/assets/javascripts/jquery.ui.widget.js +373 -117
- data/vendor/assets/stylesheets/jquery.ui.accordion.css.erb +10 -13
- data/vendor/assets/stylesheets/jquery.ui.all.css.erb +4 -3
- data/vendor/assets/stylesheets/jquery.ui.autocomplete.css.erb +10 -44
- data/vendor/assets/stylesheets/jquery.ui.base.css.erb +7 -3
- data/vendor/assets/stylesheets/jquery.ui.button.css.erb +6 -4
- data/vendor/assets/stylesheets/jquery.ui.core.css.erb +5 -4
- data/vendor/assets/stylesheets/jquery.ui.datepicker.css.erb +4 -3
- data/vendor/assets/stylesheets/jquery.ui.dialog.css.erb +6 -5
- data/vendor/assets/stylesheets/jquery.ui.menu.css.erb +34 -0
- data/vendor/assets/stylesheets/jquery.ui.progressbar.css.erb +4 -3
- data/vendor/assets/stylesheets/jquery.ui.resizable.css.erb +4 -3
- data/vendor/assets/stylesheets/jquery.ui.selectable.css.erb +4 -3
- data/vendor/assets/stylesheets/jquery.ui.slider.css.erb +4 -3
- data/vendor/assets/stylesheets/jquery.ui.spinner.css.erb +27 -0
- data/vendor/assets/stylesheets/jquery.ui.tabs.css.erb +8 -8
- data/vendor/assets/stylesheets/jquery.ui.theme.css.erb +8 -7
- data/vendor/assets/stylesheets/jquery.ui.tooltip.css.erb +25 -0
- metadata +24 -19
- data/dependencies.js +0 -31
- data/vendor/assets/javascripts/jquery.effects.all.js +0 -14
- data/vendor/assets/javascripts/jquery.effects.blind.js +0 -51
- data/vendor/assets/javascripts/jquery.effects.bounce.js +0 -80
- data/vendor/assets/javascripts/jquery.effects.clip.js +0 -56
- data/vendor/assets/javascripts/jquery.effects.core.js +0 -612
- data/vendor/assets/javascripts/jquery.effects.drop.js +0 -52
- data/vendor/assets/javascripts/jquery.effects.explode.js +0 -81
- data/vendor/assets/javascripts/jquery.effects.fade.js +0 -34
- data/vendor/assets/javascripts/jquery.effects.fold.js +0 -58
- data/vendor/assets/javascripts/jquery.effects.highlight.js +0 -52
- data/vendor/assets/javascripts/jquery.effects.pulsate.js +0 -53
- data/vendor/assets/javascripts/jquery.effects.scale.js +0 -180
- data/vendor/assets/javascripts/jquery.effects.shake.js +0 -59
- data/vendor/assets/javascripts/jquery.effects.slide.js +0 -52
- data/vendor/assets/javascripts/jquery.effects.transfer.js +0 -47
@@ -0,0 +1,482 @@
|
|
1
|
+
//= require jquery.ui.core
|
2
|
+
//= require jquery.ui.widget
|
3
|
+
//= require jquery.ui.button
|
4
|
+
|
5
|
+
/*!
|
6
|
+
* jQuery UI Spinner 1.9.2
|
7
|
+
* http://jqueryui.com
|
8
|
+
*
|
9
|
+
* Copyright 2012 jQuery Foundation and other contributors
|
10
|
+
* Released under the MIT license.
|
11
|
+
* http://jquery.org/license
|
12
|
+
*
|
13
|
+
* http://api.jqueryui.com/spinner/
|
14
|
+
*
|
15
|
+
* Depends:
|
16
|
+
* jquery.ui.core.js
|
17
|
+
* jquery.ui.widget.js
|
18
|
+
* jquery.ui.button.js
|
19
|
+
*/
|
20
|
+
(function( $ ) {
|
21
|
+
|
22
|
+
function modifier( fn ) {
|
23
|
+
return function() {
|
24
|
+
var previous = this.element.val();
|
25
|
+
fn.apply( this, arguments );
|
26
|
+
this._refresh();
|
27
|
+
if ( previous !== this.element.val() ) {
|
28
|
+
this._trigger( "change" );
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
$.widget( "ui.spinner", {
|
34
|
+
version: "1.9.2",
|
35
|
+
defaultElement: "<input>",
|
36
|
+
widgetEventPrefix: "spin",
|
37
|
+
options: {
|
38
|
+
culture: null,
|
39
|
+
icons: {
|
40
|
+
down: "ui-icon-triangle-1-s",
|
41
|
+
up: "ui-icon-triangle-1-n"
|
42
|
+
},
|
43
|
+
incremental: true,
|
44
|
+
max: null,
|
45
|
+
min: null,
|
46
|
+
numberFormat: null,
|
47
|
+
page: 10,
|
48
|
+
step: 1,
|
49
|
+
|
50
|
+
change: null,
|
51
|
+
spin: null,
|
52
|
+
start: null,
|
53
|
+
stop: null
|
54
|
+
},
|
55
|
+
|
56
|
+
_create: function() {
|
57
|
+
// handle string values that need to be parsed
|
58
|
+
this._setOption( "max", this.options.max );
|
59
|
+
this._setOption( "min", this.options.min );
|
60
|
+
this._setOption( "step", this.options.step );
|
61
|
+
|
62
|
+
// format the value, but don't constrain
|
63
|
+
this._value( this.element.val(), true );
|
64
|
+
|
65
|
+
this._draw();
|
66
|
+
this._on( this._events );
|
67
|
+
this._refresh();
|
68
|
+
|
69
|
+
// turning off autocomplete prevents the browser from remembering the
|
70
|
+
// value when navigating through history, so we re-enable autocomplete
|
71
|
+
// if the page is unloaded before the widget is destroyed. #7790
|
72
|
+
this._on( this.window, {
|
73
|
+
beforeunload: function() {
|
74
|
+
this.element.removeAttr( "autocomplete" );
|
75
|
+
}
|
76
|
+
});
|
77
|
+
},
|
78
|
+
|
79
|
+
_getCreateOptions: function() {
|
80
|
+
var options = {},
|
81
|
+
element = this.element;
|
82
|
+
|
83
|
+
$.each( [ "min", "max", "step" ], function( i, option ) {
|
84
|
+
var value = element.attr( option );
|
85
|
+
if ( value !== undefined && value.length ) {
|
86
|
+
options[ option ] = value;
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
return options;
|
91
|
+
},
|
92
|
+
|
93
|
+
_events: {
|
94
|
+
keydown: function( event ) {
|
95
|
+
if ( this._start( event ) && this._keydown( event ) ) {
|
96
|
+
event.preventDefault();
|
97
|
+
}
|
98
|
+
},
|
99
|
+
keyup: "_stop",
|
100
|
+
focus: function() {
|
101
|
+
this.previous = this.element.val();
|
102
|
+
},
|
103
|
+
blur: function( event ) {
|
104
|
+
if ( this.cancelBlur ) {
|
105
|
+
delete this.cancelBlur;
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
|
109
|
+
this._refresh();
|
110
|
+
if ( this.previous !== this.element.val() ) {
|
111
|
+
this._trigger( "change", event );
|
112
|
+
}
|
113
|
+
},
|
114
|
+
mousewheel: function( event, delta ) {
|
115
|
+
if ( !delta ) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
if ( !this.spinning && !this._start( event ) ) {
|
119
|
+
return false;
|
120
|
+
}
|
121
|
+
|
122
|
+
this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
|
123
|
+
clearTimeout( this.mousewheelTimer );
|
124
|
+
this.mousewheelTimer = this._delay(function() {
|
125
|
+
if ( this.spinning ) {
|
126
|
+
this._stop( event );
|
127
|
+
}
|
128
|
+
}, 100 );
|
129
|
+
event.preventDefault();
|
130
|
+
},
|
131
|
+
"mousedown .ui-spinner-button": function( event ) {
|
132
|
+
var previous;
|
133
|
+
|
134
|
+
// We never want the buttons to have focus; whenever the user is
|
135
|
+
// interacting with the spinner, the focus should be on the input.
|
136
|
+
// If the input is focused then this.previous is properly set from
|
137
|
+
// when the input first received focus. If the input is not focused
|
138
|
+
// then we need to set this.previous based on the value before spinning.
|
139
|
+
previous = this.element[0] === this.document[0].activeElement ?
|
140
|
+
this.previous : this.element.val();
|
141
|
+
function checkFocus() {
|
142
|
+
var isActive = this.element[0] === this.document[0].activeElement;
|
143
|
+
if ( !isActive ) {
|
144
|
+
this.element.focus();
|
145
|
+
this.previous = previous;
|
146
|
+
// support: IE
|
147
|
+
// IE sets focus asynchronously, so we need to check if focus
|
148
|
+
// moved off of the input because the user clicked on the button.
|
149
|
+
this._delay(function() {
|
150
|
+
this.previous = previous;
|
151
|
+
});
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
// ensure focus is on (or stays on) the text field
|
156
|
+
event.preventDefault();
|
157
|
+
checkFocus.call( this );
|
158
|
+
|
159
|
+
// support: IE
|
160
|
+
// IE doesn't prevent moving focus even with event.preventDefault()
|
161
|
+
// so we set a flag to know when we should ignore the blur event
|
162
|
+
// and check (again) if focus moved off of the input.
|
163
|
+
this.cancelBlur = true;
|
164
|
+
this._delay(function() {
|
165
|
+
delete this.cancelBlur;
|
166
|
+
checkFocus.call( this );
|
167
|
+
});
|
168
|
+
|
169
|
+
if ( this._start( event ) === false ) {
|
170
|
+
return;
|
171
|
+
}
|
172
|
+
|
173
|
+
this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
|
174
|
+
},
|
175
|
+
"mouseup .ui-spinner-button": "_stop",
|
176
|
+
"mouseenter .ui-spinner-button": function( event ) {
|
177
|
+
// button will add ui-state-active if mouse was down while mouseleave and kept down
|
178
|
+
if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
|
182
|
+
if ( this._start( event ) === false ) {
|
183
|
+
return false;
|
184
|
+
}
|
185
|
+
this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
|
186
|
+
},
|
187
|
+
// TODO: do we really want to consider this a stop?
|
188
|
+
// shouldn't we just stop the repeater and wait until mouseup before
|
189
|
+
// we trigger the stop event?
|
190
|
+
"mouseleave .ui-spinner-button": "_stop"
|
191
|
+
},
|
192
|
+
|
193
|
+
_draw: function() {
|
194
|
+
var uiSpinner = this.uiSpinner = this.element
|
195
|
+
.addClass( "ui-spinner-input" )
|
196
|
+
.attr( "autocomplete", "off" )
|
197
|
+
.wrap( this._uiSpinnerHtml() )
|
198
|
+
.parent()
|
199
|
+
// add buttons
|
200
|
+
.append( this._buttonHtml() );
|
201
|
+
|
202
|
+
this.element.attr( "role", "spinbutton" );
|
203
|
+
|
204
|
+
// button bindings
|
205
|
+
this.buttons = uiSpinner.find( ".ui-spinner-button" )
|
206
|
+
.attr( "tabIndex", -1 )
|
207
|
+
.button()
|
208
|
+
.removeClass( "ui-corner-all" );
|
209
|
+
|
210
|
+
// IE 6 doesn't understand height: 50% for the buttons
|
211
|
+
// unless the wrapper has an explicit height
|
212
|
+
if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
|
213
|
+
uiSpinner.height() > 0 ) {
|
214
|
+
uiSpinner.height( uiSpinner.height() );
|
215
|
+
}
|
216
|
+
|
217
|
+
// disable spinner if element was already disabled
|
218
|
+
if ( this.options.disabled ) {
|
219
|
+
this.disable();
|
220
|
+
}
|
221
|
+
},
|
222
|
+
|
223
|
+
_keydown: function( event ) {
|
224
|
+
var options = this.options,
|
225
|
+
keyCode = $.ui.keyCode;
|
226
|
+
|
227
|
+
switch ( event.keyCode ) {
|
228
|
+
case keyCode.UP:
|
229
|
+
this._repeat( null, 1, event );
|
230
|
+
return true;
|
231
|
+
case keyCode.DOWN:
|
232
|
+
this._repeat( null, -1, event );
|
233
|
+
return true;
|
234
|
+
case keyCode.PAGE_UP:
|
235
|
+
this._repeat( null, options.page, event );
|
236
|
+
return true;
|
237
|
+
case keyCode.PAGE_DOWN:
|
238
|
+
this._repeat( null, -options.page, event );
|
239
|
+
return true;
|
240
|
+
}
|
241
|
+
|
242
|
+
return false;
|
243
|
+
},
|
244
|
+
|
245
|
+
_uiSpinnerHtml: function() {
|
246
|
+
return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
|
247
|
+
},
|
248
|
+
|
249
|
+
_buttonHtml: function() {
|
250
|
+
return "" +
|
251
|
+
"<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
|
252
|
+
"<span class='ui-icon " + this.options.icons.up + "'>▲</span>" +
|
253
|
+
"</a>" +
|
254
|
+
"<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
|
255
|
+
"<span class='ui-icon " + this.options.icons.down + "'>▼</span>" +
|
256
|
+
"</a>";
|
257
|
+
},
|
258
|
+
|
259
|
+
_start: function( event ) {
|
260
|
+
if ( !this.spinning && this._trigger( "start", event ) === false ) {
|
261
|
+
return false;
|
262
|
+
}
|
263
|
+
|
264
|
+
if ( !this.counter ) {
|
265
|
+
this.counter = 1;
|
266
|
+
}
|
267
|
+
this.spinning = true;
|
268
|
+
return true;
|
269
|
+
},
|
270
|
+
|
271
|
+
_repeat: function( i, steps, event ) {
|
272
|
+
i = i || 500;
|
273
|
+
|
274
|
+
clearTimeout( this.timer );
|
275
|
+
this.timer = this._delay(function() {
|
276
|
+
this._repeat( 40, steps, event );
|
277
|
+
}, i );
|
278
|
+
|
279
|
+
this._spin( steps * this.options.step, event );
|
280
|
+
},
|
281
|
+
|
282
|
+
_spin: function( step, event ) {
|
283
|
+
var value = this.value() || 0;
|
284
|
+
|
285
|
+
if ( !this.counter ) {
|
286
|
+
this.counter = 1;
|
287
|
+
}
|
288
|
+
|
289
|
+
value = this._adjustValue( value + step * this._increment( this.counter ) );
|
290
|
+
|
291
|
+
if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
|
292
|
+
this._value( value );
|
293
|
+
this.counter++;
|
294
|
+
}
|
295
|
+
},
|
296
|
+
|
297
|
+
_increment: function( i ) {
|
298
|
+
var incremental = this.options.incremental;
|
299
|
+
|
300
|
+
if ( incremental ) {
|
301
|
+
return $.isFunction( incremental ) ?
|
302
|
+
incremental( i ) :
|
303
|
+
Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
|
304
|
+
}
|
305
|
+
|
306
|
+
return 1;
|
307
|
+
},
|
308
|
+
|
309
|
+
_precision: function() {
|
310
|
+
var precision = this._precisionOf( this.options.step );
|
311
|
+
if ( this.options.min !== null ) {
|
312
|
+
precision = Math.max( precision, this._precisionOf( this.options.min ) );
|
313
|
+
}
|
314
|
+
return precision;
|
315
|
+
},
|
316
|
+
|
317
|
+
_precisionOf: function( num ) {
|
318
|
+
var str = num.toString(),
|
319
|
+
decimal = str.indexOf( "." );
|
320
|
+
return decimal === -1 ? 0 : str.length - decimal - 1;
|
321
|
+
},
|
322
|
+
|
323
|
+
_adjustValue: function( value ) {
|
324
|
+
var base, aboveMin,
|
325
|
+
options = this.options;
|
326
|
+
|
327
|
+
// make sure we're at a valid step
|
328
|
+
// - find out where we are relative to the base (min or 0)
|
329
|
+
base = options.min !== null ? options.min : 0;
|
330
|
+
aboveMin = value - base;
|
331
|
+
// - round to the nearest step
|
332
|
+
aboveMin = Math.round(aboveMin / options.step) * options.step;
|
333
|
+
// - rounding is based on 0, so adjust back to our base
|
334
|
+
value = base + aboveMin;
|
335
|
+
|
336
|
+
// fix precision from bad JS floating point math
|
337
|
+
value = parseFloat( value.toFixed( this._precision() ) );
|
338
|
+
|
339
|
+
// clamp the value
|
340
|
+
if ( options.max !== null && value > options.max) {
|
341
|
+
return options.max;
|
342
|
+
}
|
343
|
+
if ( options.min !== null && value < options.min ) {
|
344
|
+
return options.min;
|
345
|
+
}
|
346
|
+
|
347
|
+
return value;
|
348
|
+
},
|
349
|
+
|
350
|
+
_stop: function( event ) {
|
351
|
+
if ( !this.spinning ) {
|
352
|
+
return;
|
353
|
+
}
|
354
|
+
|
355
|
+
clearTimeout( this.timer );
|
356
|
+
clearTimeout( this.mousewheelTimer );
|
357
|
+
this.counter = 0;
|
358
|
+
this.spinning = false;
|
359
|
+
this._trigger( "stop", event );
|
360
|
+
},
|
361
|
+
|
362
|
+
_setOption: function( key, value ) {
|
363
|
+
if ( key === "culture" || key === "numberFormat" ) {
|
364
|
+
var prevValue = this._parse( this.element.val() );
|
365
|
+
this.options[ key ] = value;
|
366
|
+
this.element.val( this._format( prevValue ) );
|
367
|
+
return;
|
368
|
+
}
|
369
|
+
|
370
|
+
if ( key === "max" || key === "min" || key === "step" ) {
|
371
|
+
if ( typeof value === "string" ) {
|
372
|
+
value = this._parse( value );
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
this._super( key, value );
|
377
|
+
|
378
|
+
if ( key === "disabled" ) {
|
379
|
+
if ( value ) {
|
380
|
+
this.element.prop( "disabled", true );
|
381
|
+
this.buttons.button( "disable" );
|
382
|
+
} else {
|
383
|
+
this.element.prop( "disabled", false );
|
384
|
+
this.buttons.button( "enable" );
|
385
|
+
}
|
386
|
+
}
|
387
|
+
},
|
388
|
+
|
389
|
+
_setOptions: modifier(function( options ) {
|
390
|
+
this._super( options );
|
391
|
+
this._value( this.element.val() );
|
392
|
+
}),
|
393
|
+
|
394
|
+
_parse: function( val ) {
|
395
|
+
if ( typeof val === "string" && val !== "" ) {
|
396
|
+
val = window.Globalize && this.options.numberFormat ?
|
397
|
+
Globalize.parseFloat( val, 10, this.options.culture ) : +val;
|
398
|
+
}
|
399
|
+
return val === "" || isNaN( val ) ? null : val;
|
400
|
+
},
|
401
|
+
|
402
|
+
_format: function( value ) {
|
403
|
+
if ( value === "" ) {
|
404
|
+
return "";
|
405
|
+
}
|
406
|
+
return window.Globalize && this.options.numberFormat ?
|
407
|
+
Globalize.format( value, this.options.numberFormat, this.options.culture ) :
|
408
|
+
value;
|
409
|
+
},
|
410
|
+
|
411
|
+
_refresh: function() {
|
412
|
+
this.element.attr({
|
413
|
+
"aria-valuemin": this.options.min,
|
414
|
+
"aria-valuemax": this.options.max,
|
415
|
+
// TODO: what should we do with values that can't be parsed?
|
416
|
+
"aria-valuenow": this._parse( this.element.val() )
|
417
|
+
});
|
418
|
+
},
|
419
|
+
|
420
|
+
// update the value without triggering change
|
421
|
+
_value: function( value, allowAny ) {
|
422
|
+
var parsed;
|
423
|
+
if ( value !== "" ) {
|
424
|
+
parsed = this._parse( value );
|
425
|
+
if ( parsed !== null ) {
|
426
|
+
if ( !allowAny ) {
|
427
|
+
parsed = this._adjustValue( parsed );
|
428
|
+
}
|
429
|
+
value = this._format( parsed );
|
430
|
+
}
|
431
|
+
}
|
432
|
+
this.element.val( value );
|
433
|
+
this._refresh();
|
434
|
+
},
|
435
|
+
|
436
|
+
_destroy: function() {
|
437
|
+
this.element
|
438
|
+
.removeClass( "ui-spinner-input" )
|
439
|
+
.prop( "disabled", false )
|
440
|
+
.removeAttr( "autocomplete" )
|
441
|
+
.removeAttr( "role" )
|
442
|
+
.removeAttr( "aria-valuemin" )
|
443
|
+
.removeAttr( "aria-valuemax" )
|
444
|
+
.removeAttr( "aria-valuenow" );
|
445
|
+
this.uiSpinner.replaceWith( this.element );
|
446
|
+
},
|
447
|
+
|
448
|
+
stepUp: modifier(function( steps ) {
|
449
|
+
this._stepUp( steps );
|
450
|
+
}),
|
451
|
+
_stepUp: function( steps ) {
|
452
|
+
this._spin( (steps || 1) * this.options.step );
|
453
|
+
},
|
454
|
+
|
455
|
+
stepDown: modifier(function( steps ) {
|
456
|
+
this._stepDown( steps );
|
457
|
+
}),
|
458
|
+
_stepDown: function( steps ) {
|
459
|
+
this._spin( (steps || 1) * -this.options.step );
|
460
|
+
},
|
461
|
+
|
462
|
+
pageUp: modifier(function( pages ) {
|
463
|
+
this._stepUp( (pages || 1) * this.options.page );
|
464
|
+
}),
|
465
|
+
|
466
|
+
pageDown: modifier(function( pages ) {
|
467
|
+
this._stepDown( (pages || 1) * this.options.page );
|
468
|
+
}),
|
469
|
+
|
470
|
+
value: function( newVal ) {
|
471
|
+
if ( !arguments.length ) {
|
472
|
+
return this._parse( this.element.val() );
|
473
|
+
}
|
474
|
+
modifier( this._value ).call( this, newVal );
|
475
|
+
},
|
476
|
+
|
477
|
+
widget: function() {
|
478
|
+
return this.uiSpinner;
|
479
|
+
}
|
480
|
+
});
|
481
|
+
|
482
|
+
}( jQuery ) );
|