Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 0d53fbfd0b7651652601b3b8577225ab753aab44 1 parent 1045d3a
Jörn Zaefferer authored December 27, 2012
30  tests/unit/spinner/spinner_events.js
@@ -5,7 +5,7 @@ var simulateKeyDownUp = TestHelpers.spinner.simulateKeyDownUp;
5 5
 module( "spinner: events" );
6 6
 
7 7
 test( "start", function() {
8  
-	expect( 6 );
  8
+	expect( 10 );
9 9
 	var element = $( "#spin" ).spinner();
10 10
 
11 11
 	function shouldStart( expectation, msg ) {
@@ -29,14 +29,14 @@ test( "start", function() {
29 29
 	shouldStart( true, "button down" );
30 30
 	element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
31 31
 
32  
-	shouldStart( false, "stepUp" );
  32
+	shouldStart( true, "stepUp" );
33 33
 	element.spinner( "stepUp" );
34  
-	shouldStart( false, "stepDown" );
  34
+	shouldStart( true, "stepDown" );
35 35
 	element.spinner( "stepDown" );
36 36
 
37  
-	shouldStart( false, "pageUp" );
  37
+	shouldStart( true, "pageUp" );
38 38
 	element.spinner( "pageUp" );
39  
-	shouldStart( false, "pageDown" );
  39
+	shouldStart( true, "pageDown" );
40 40
 	element.spinner( "pageDown" );
41 41
 
42 42
 	shouldStart( false, "value" );
@@ -44,7 +44,7 @@ test( "start", function() {
44 44
 });
45 45
 
46 46
 test( "spin", function() {
47  
-	expect( 6 );
  47
+	expect( 10 );
48 48
 	var element = $( "#spin" ).spinner();
49 49
 
50 50
 	function shouldSpin( expectation, msg ) {
@@ -68,14 +68,14 @@ test( "spin", function() {
68 68
 	shouldSpin( true, "button down" );
69 69
 	element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
70 70
 
71  
-	shouldSpin( false, "stepUp" );
  71
+	shouldSpin( true, "stepUp" );
72 72
 	element.spinner( "stepUp" );
73  
-	shouldSpin( false, "stepDown" );
  73
+	shouldSpin( true, "stepDown" );
74 74
 	element.spinner( "stepDown" );
75 75
 
76  
-	shouldSpin( false, "pageUp" );
  76
+	shouldSpin( true, "pageUp" );
77 77
 	element.spinner( "pageUp" );
78  
-	shouldSpin( false, "pageDown" );
  78
+	shouldSpin( true, "pageDown" );
79 79
 	element.spinner( "pageDown" );
80 80
 
81 81
 	shouldSpin( false, "value" );
@@ -83,7 +83,7 @@ test( "spin", function() {
83 83
 });
84 84
 
85 85
 test( "stop", function() {
86  
-	expect( 6 );
  86
+	expect( 10 );
87 87
 	var element = $( "#spin" ).spinner();
88 88
 
89 89
 	function shouldStop( expectation, msg ) {
@@ -107,14 +107,14 @@ test( "stop", function() {
107 107
 	shouldStop( true, "button down" );
108 108
 	element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
109 109
 
110  
-	shouldStop( false, "stepUp" );
  110
+	shouldStop( true, "stepUp" );
111 111
 	element.spinner( "stepUp" );
112  
-	shouldStop( false, "stepDown" );
  112
+	shouldStop( true, "stepDown" );
113 113
 	element.spinner( "stepDown" );
114 114
 
115  
-	shouldStop( false, "pageUp" );
  115
+	shouldStop( true, "pageUp" );
116 116
 	element.spinner( "pageUp" );
117  
-	shouldStop( false, "pageDown" );
  117
+	shouldStop( true, "pageDown" );
118 118
 	element.spinner( "pageDown" );
119 119
 
120 120
 	shouldStop( false, "value" );
10  ui/jquery.ui.spinner.js
@@ -453,14 +453,20 @@ $.widget( "ui.spinner", {
453 453
 		this._stepUp( steps );
454 454
 	}),
455 455
 	_stepUp: function( steps ) {
456  
-		this._spin( (steps || 1) * this.options.step );
  456
+		if ( this._start() ) {
  457
+			this._spin( (steps || 1) * this.options.step );
  458
+			this._stop();
  459
+		}
457 460
 	},
458 461
 
459 462
 	stepDown: modifier(function( steps ) {
460 463
 		this._stepDown( steps );
461 464
 	}),
462 465
 	_stepDown: function( steps ) {
463  
-		this._spin( (steps || 1) * -this.options.step );
  466
+		if ( this._start() ) {
  467
+			this._spin( (steps || 1) * -this.options.step );
  468
+			this._stop();
  469
+		}
464 470
 	},
465 471
 
466 472
 	pageUp: modifier(function( pages ) {

0 notes on commit 0d53fbf

Please sign in to comment.
Something went wrong with that request. Please try again.