mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-10 23:53:10 +00:00
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.
This commit is contained in:
parent
fd286444f4
commit
191b5e04a3
1 changed files with 6 additions and 3 deletions
|
|
@ -71,7 +71,8 @@ $.widget( "mobile.slider", $.mobile.widget, {
|
|||
slider: slider,
|
||||
handle: handle,
|
||||
dragging: false,
|
||||
beforeStart: null
|
||||
beforeStart: null,
|
||||
userModified: false
|
||||
});
|
||||
|
||||
if ( cType == "select" ) {
|
||||
|
|
@ -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;
|
||||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -323,4 +326,4 @@ $( document ).bind( "pagecreate create", function( e ){
|
|||
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
})( jQuery );
|
||||
|
|
|
|||
Loading…
Reference in a new issue