]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Trigger start/spin/stop events when calling step/page methods. Fixes #8901...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 27 Dec 2012 16:05:25 +0000 (17:05 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Thu, 27 Dec 2012 16:06:01 +0000 (17:06 +0100)
tests/unit/spinner/spinner_events.js
ui/jquery.ui.spinner.js

index 1ee0d17a59d3233752fff280b9a38681ff275e3d..610f7a2ecddfd4a8ae31689761cbca20bb0b06e4 100644 (file)
@@ -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,14 +29,14 @@ 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" );
@@ -44,7 +44,7 @@ test( "start", function() {
 });
 
 test( "spin", function() {
-       expect( 6 );
+       expect( 10 );
        var element = $( "#spin" ).spinner();
 
        function shouldSpin( expectation, msg ) {
@@ -68,14 +68,14 @@ 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" );
@@ -83,7 +83,7 @@ test( "spin", function() {
 });
 
 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" );
index aeffe0a3e340339d45bf6fec5f9fbf51475899d7..1881c99ed001526115c9465d0c410ef15494d360 100644 (file)
@@ -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 ) {