15 //>>css.structure: ../../themes/base/core.css |
15 //>>css.structure: ../../themes/base/core.css |
16 //>>css.structure: ../../themes/base/spinner.css |
16 //>>css.structure: ../../themes/base/spinner.css |
17 //>>css.theme: ../../themes/base/theme.css |
17 //>>css.theme: ../../themes/base/theme.css |
18 |
18 |
19 ( function( factory ) { |
19 ( function( factory ) { |
|
20 "use strict"; |
|
21 |
20 if ( typeof define === "function" && define.amd ) { |
22 if ( typeof define === "function" && define.amd ) { |
21 |
23 |
22 // AMD. Register as an anonymous module. |
24 // AMD. Register as an anonymous module. |
23 define( [ |
25 define( [ |
24 "jquery", |
26 "jquery", |
42 } |
45 } |
43 }; |
46 }; |
44 } |
47 } |
45 |
48 |
46 $.widget( "ui.spinner", { |
49 $.widget( "ui.spinner", { |
47 version: "1.12.1", |
50 version: "1.13.1", |
48 defaultElement: "<input>", |
51 defaultElement: "<input>", |
49 widgetEventPrefix: "spin", |
52 widgetEventPrefix: "spin", |
50 options: { |
53 options: { |
51 classes: { |
54 classes: { |
52 "ui-spinner": "ui-corner-all", |
55 "ui-spinner": "ui-corner-all", |
135 if ( this.previous !== this.element.val() ) { |
138 if ( this.previous !== this.element.val() ) { |
136 this._trigger( "change", event ); |
139 this._trigger( "change", event ); |
137 } |
140 } |
138 }, |
141 }, |
139 mousewheel: function( event, delta ) { |
142 mousewheel: function( event, delta ) { |
140 if ( !delta ) { |
143 var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ); |
|
144 var isActive = this.element[ 0 ] === activeElement; |
|
145 |
|
146 if ( !isActive || !delta ) { |
141 return; |
147 return; |
142 } |
148 } |
|
149 |
143 if ( !this.spinning && !this._start( event ) ) { |
150 if ( !this.spinning && !this._start( event ) ) { |
144 return false; |
151 return false; |
145 } |
152 } |
146 |
153 |
147 this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event ); |
154 this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event ); |
266 } ); |
273 } ); |
267 |
274 |
268 // IE 6 doesn't understand height: 50% for the buttons |
275 // IE 6 doesn't understand height: 50% for the buttons |
269 // unless the wrapper has an explicit height |
276 // unless the wrapper has an explicit height |
270 if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) && |
277 if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) && |
271 this.uiSpinner.height() > 0 ) { |
278 this.uiSpinner.height() > 0 ) { |
272 this.uiSpinner.height( this.uiSpinner.height() ); |
279 this.uiSpinner.height( this.uiSpinner.height() ); |
273 } |
280 } |
274 }, |
281 }, |
275 |
282 |
276 _keydown: function( event ) { |
283 _keydown: function( event ) { |
277 var options = this.options, |
284 var options = this.options, |
278 keyCode = $.ui.keyCode; |
285 keyCode = $.ui.keyCode; |
279 |
286 |
280 switch ( event.keyCode ) { |
287 switch ( event.keyCode ) { |
281 case keyCode.UP: |
288 case keyCode.UP: |
282 this._repeat( null, 1, event ); |
289 this._repeat( null, 1, event ); |
283 return true; |
290 return true; |
284 case keyCode.DOWN: |
291 case keyCode.DOWN: |
285 this._repeat( null, -1, event ); |
292 this._repeat( null, -1, event ); |
286 return true; |
293 return true; |
287 case keyCode.PAGE_UP: |
294 case keyCode.PAGE_UP: |
288 this._repeat( null, options.page, event ); |
295 this._repeat( null, options.page, event ); |
289 return true; |
296 return true; |
290 case keyCode.PAGE_DOWN: |
297 case keyCode.PAGE_DOWN: |
291 this._repeat( null, -options.page, event ); |
298 this._repeat( null, -options.page, event ); |
292 return true; |
299 return true; |
293 } |
300 } |
294 |
301 |
295 return false; |
302 return false; |
296 }, |
303 }, |
297 |
304 |
433 this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value ); |
440 this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value ); |
434 this.element.prop( "disabled", !!value ); |
441 this.element.prop( "disabled", !!value ); |
435 this.buttons.button( value ? "disable" : "enable" ); |
442 this.buttons.button( value ? "disable" : "enable" ); |
436 }, |
443 }, |
437 |
444 |
438 _setOptions: spinnerModifer( function( options ) { |
445 _setOptions: spinnerModifier( function( options ) { |
439 this._super( options ); |
446 this._super( options ); |
440 } ), |
447 } ), |
441 |
448 |
442 _parse: function( val ) { |
449 _parse: function( val ) { |
443 if ( typeof val === "string" && val !== "" ) { |
450 if ( typeof val === "string" && val !== "" ) { |
500 .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" ); |
507 .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" ); |
501 |
508 |
502 this.uiSpinner.replaceWith( this.element ); |
509 this.uiSpinner.replaceWith( this.element ); |
503 }, |
510 }, |
504 |
511 |
505 stepUp: spinnerModifer( function( steps ) { |
512 stepUp: spinnerModifier( function( steps ) { |
506 this._stepUp( steps ); |
513 this._stepUp( steps ); |
507 } ), |
514 } ), |
508 _stepUp: function( steps ) { |
515 _stepUp: function( steps ) { |
509 if ( this._start() ) { |
516 if ( this._start() ) { |
510 this._spin( ( steps || 1 ) * this.options.step ); |
517 this._spin( ( steps || 1 ) * this.options.step ); |
511 this._stop(); |
518 this._stop(); |
512 } |
519 } |
513 }, |
520 }, |
514 |
521 |
515 stepDown: spinnerModifer( function( steps ) { |
522 stepDown: spinnerModifier( function( steps ) { |
516 this._stepDown( steps ); |
523 this._stepDown( steps ); |
517 } ), |
524 } ), |
518 _stepDown: function( steps ) { |
525 _stepDown: function( steps ) { |
519 if ( this._start() ) { |
526 if ( this._start() ) { |
520 this._spin( ( steps || 1 ) * -this.options.step ); |
527 this._spin( ( steps || 1 ) * -this.options.step ); |
521 this._stop(); |
528 this._stop(); |
522 } |
529 } |
523 }, |
530 }, |
524 |
531 |
525 pageUp: spinnerModifer( function( pages ) { |
532 pageUp: spinnerModifier( function( pages ) { |
526 this._stepUp( ( pages || 1 ) * this.options.page ); |
533 this._stepUp( ( pages || 1 ) * this.options.page ); |
527 } ), |
534 } ), |
528 |
535 |
529 pageDown: spinnerModifer( function( pages ) { |
536 pageDown: spinnerModifier( function( pages ) { |
530 this._stepDown( ( pages || 1 ) * this.options.page ); |
537 this._stepDown( ( pages || 1 ) * this.options.page ); |
531 } ), |
538 } ), |
532 |
539 |
533 value: function( newVal ) { |
540 value: function( newVal ) { |
534 if ( !arguments.length ) { |
541 if ( !arguments.length ) { |
535 return this._parse( this.element.val() ); |
542 return this._parse( this.element.val() ); |
536 } |
543 } |
537 spinnerModifer( this._value ).call( this, newVal ); |
544 spinnerModifier( this._value ).call( this, newVal ); |
538 }, |
545 }, |
539 |
546 |
540 widget: function() { |
547 widget: function() { |
541 return this.uiSpinner; |
548 return this.uiSpinner; |
542 } |
549 } |
552 this.uiSpinner = this.element |
559 this.uiSpinner = this.element |
553 .attr( "autocomplete", "off" ) |
560 .attr( "autocomplete", "off" ) |
554 .wrap( this._uiSpinnerHtml() ) |
561 .wrap( this._uiSpinnerHtml() ) |
555 .parent() |
562 .parent() |
556 |
563 |
557 // Add buttons |
564 // Add buttons |
558 .append( this._buttonHtml() ); |
565 .append( this._buttonHtml() ); |
559 }, |
566 }, |
560 _uiSpinnerHtml: function() { |
567 _uiSpinnerHtml: function() { |
561 return "<span>"; |
568 return "<span>"; |
562 }, |
569 }, |
563 |
570 |