Skip to content
This repository
Browse code

Fix for issue 2345 - Flip toggle switches *ALWAYS* toggle

- We now track whether or not the user has modified the value of the switch control. If so, we don't toggle it's value on mouseup.
  • Loading branch information...
commit 191b5e04a3811adb00f411c0c6b32dab626b77d4 1 parent fd28644
Kin Blas authored August 29, 2011

Showing 1 changed file with 6 additions and 3 deletions. Show diff stats Hide diff stats

  1. 9  js/jquery.mobile.forms.slider.js
9  js/jquery.mobile.forms.slider.js
@@ -71,7 +71,8 @@ $.widget( "mobile.slider", $.mobile.widget, {
71 71
 			slider: slider,
72 72
 			handle: handle,
73 73
 			dragging: false,
74  
-			beforeStart: null
  74
+			beforeStart: null,
  75
+			userModified: false
75 76
 		});
76 77
 
77 78
 		if ( cType == "select" ) {
@@ -113,12 +114,14 @@ $.widget( "mobile.slider", $.mobile.widget, {
113 114
 		$( document ).bind( "vmousemove", function( event ) {
114 115
 			if ( self.dragging ) {
115 116
 				self.refresh( event );
  117
+				self.userModified = self.userModified || self.beforeStart !== control[0].selectedIndex;
116 118
 				return false;
117 119
 			}
118 120
 		});
119 121
 
120 122
 		slider.bind( "vmousedown", function( event ) {
121 123
 			self.dragging = true;
  124
+			self.userModified = false;
122 125
 
123 126
 			if ( cType === "select" ) {
124 127
 				self.beforeStart = control[0].selectedIndex;
@@ -135,7 +138,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
135 138
 
136 139
 					if ( cType === "select" ) {
137 140
 
138  
-						if ( self.beforeStart === control[ 0 ].selectedIndex ) {
  141
+						if ( !self.userModified ) {
139 142
 							//tap occurred, but value didn't change. flip it!
140 143
 							self.refresh( !self.beforeStart ? 1 : 0 );
141 144
 						}
@@ -323,4 +326,4 @@ $( document ).bind( "pagecreate create", function( e ){
323 326
 
324 327
 });
325 328
 
326  
-})( jQuery );
  329
+})( jQuery );

0 notes on commit 191b5e0

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