Permalink
Browse files

Spinner: Trigger start/spin/stop events when calling step/page method…

…s. Fixes #8901 - Spinner does not fire start/spin/stop events when calling stepUp()/Down(), pageUp()/Down() methods
  • Loading branch information...
jzaefferer committed Dec 27, 2012
1 parent 1045d3a commit 0d53fbfd0b7651652601b3b8577225ab753aab44
Showing with 23 additions and 17 deletions.
  1. +15 −15 tests/unit/spinner/spinner_events.js
  2. +8 −2 ui/jquery.ui.spinner.js
@@ -5,7 +5,7 @@ var simulateKeyDownUp = TestHelpers.spinner.simulateKeyDownUp;
module( "spinner: events" );
test( "start", function() {
- expect( 6 );
+ expect( 10 );
var element = $( "#spin" ).spinner();
function shouldStart( expectation, msg ) {
@@ -29,22 +29,22 @@ test( "start", function() {
shouldStart( true, "button down" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
- shouldStart( false, "stepUp" );
+ shouldStart( true, "stepUp" );
element.spinner( "stepUp" );
- shouldStart( false, "stepDown" );
+ shouldStart( true, "stepDown" );
element.spinner( "stepDown" );
- shouldStart( false, "pageUp" );
+ shouldStart( true, "pageUp" );
element.spinner( "pageUp" );
- shouldStart( false, "pageDown" );
+ shouldStart( true, "pageDown" );
element.spinner( "pageDown" );
shouldStart( false, "value" );
element.spinner( "value", 999 );
});
test( "spin", function() {
- expect( 6 );
+ expect( 10 );
var element = $( "#spin" ).spinner();
function shouldSpin( expectation, msg ) {
@@ -68,22 +68,22 @@ test( "spin", function() {
shouldSpin( true, "button down" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
- shouldSpin( false, "stepUp" );
+ shouldSpin( true, "stepUp" );
element.spinner( "stepUp" );
- shouldSpin( false, "stepDown" );
+ shouldSpin( true, "stepDown" );
element.spinner( "stepDown" );
- shouldSpin( false, "pageUp" );
+ shouldSpin( true, "pageUp" );
element.spinner( "pageUp" );
- shouldSpin( false, "pageDown" );
+ shouldSpin( true, "pageDown" );
element.spinner( "pageDown" );
shouldSpin( false, "value" );
element.spinner( "value", 999 );
});
test( "stop", function() {
- expect( 6 );
+ expect( 10 );
var element = $( "#spin" ).spinner();
function shouldStop( expectation, msg ) {
@@ -107,14 +107,14 @@ test( "stop", function() {
shouldStop( true, "button down" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
- shouldStop( false, "stepUp" );
+ shouldStop( true, "stepUp" );
element.spinner( "stepUp" );
- shouldStop( false, "stepDown" );
+ shouldStop( true, "stepDown" );
element.spinner( "stepDown" );
- shouldStop( false, "pageUp" );
+ shouldStop( true, "pageUp" );
element.spinner( "pageUp" );
- shouldStop( false, "pageDown" );
+ shouldStop( true, "pageDown" );
element.spinner( "pageDown" );
shouldStop( false, "value" );
View
@@ -453,14 +453,20 @@ $.widget( "ui.spinner", {
this._stepUp( steps );
}),
_stepUp: function( steps ) {
- this._spin( (steps || 1) * this.options.step );
+ if ( this._start() ) {
+ this._spin( (steps || 1) * this.options.step );
+ this._stop();
+ }
},
stepDown: modifier(function( steps ) {
this._stepDown( steps );
}),
_stepDown: function( steps ) {
- this._spin( (steps || 1) * -this.options.step );
+ if ( this._start() ) {
+ this._spin( (steps || 1) * -this.options.step );
+ this._stop();
+ }
},
pageUp: modifier(function( pages ) {

0 comments on commit 0d53fbf

Please sign in to comment.