Skip to content

Commit

Permalink
Fix for issue 2345 - Flip toggle switches *ALWAYS* toggle
Browse files Browse the repository at this point in the history
- 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
jblas committed Aug 29, 2011
1 parent fd28644 commit 191b5e0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/jquery.mobile.forms.slider.js
Expand Up @@ -71,7 +71,8 @@ $.widget( "mobile.slider", $.mobile.widget, {
slider: slider,
handle: handle,
dragging: false,
beforeStart: null
beforeStart: null,
userModified: false
});

if ( cType == "select" ) {
Expand Down Expand Up @@ -113,12 +114,14 @@ $.widget( "mobile.slider", $.mobile.widget, {
$( document ).bind( "vmousemove", function( event ) {
if ( self.dragging ) {
self.refresh( event );
self.userModified = self.userModified || self.beforeStart !== control[0].selectedIndex;
return false;
}
});

slider.bind( "vmousedown", function( event ) {
self.dragging = true;
self.userModified = false;

if ( cType === "select" ) {
self.beforeStart = control[0].selectedIndex;
Expand All @@ -135,7 +138,7 @@ $.widget( "mobile.slider", $.mobile.widget, {

if ( cType === "select" ) {

if ( self.beforeStart === control[ 0 ].selectedIndex ) {
if ( !self.userModified ) {
//tap occurred, but value didn't change. flip it!
self.refresh( !self.beforeStart ? 1 : 0 );
}
Expand Down Expand Up @@ -323,4 +326,4 @@ $( document ).bind( "pagecreate create", function( e ){

});

})( jQuery );
})( jQuery );

0 comments on commit 191b5e0

Please sign in to comment.