From 416b666ca873bd4ef84f6703d418c0bae9b3e260 Mon Sep 17 00:00:00 2001 From: John Bender Date: Thu, 15 Sep 2011 10:16:40 -0700 Subject: [PATCH] prevent clicks on anything but the left mouse button, also adds the which value to the events when its undefined in the vmouse plugin --- js/jquery.mobile.navigation.js | 11 ++++++++++- js/jquery.mobile.vmouse.js | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 69068730f1b..590d0bd2794 100755 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -1177,6 +1177,12 @@ //add active state on vclick $( document ).bind( "vclick", function( event ) { + // if this isn't a left click we don't care. Its important to note + // that when the virtual event is generated it will create + if ( event.which > 1 ){ + return; + } + var link = findClosestLink( event.target ); if ( link ) { if ( path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" ) { @@ -1191,7 +1197,10 @@ // click routing - direct to HTTP or Ajax, accordingly $( document ).bind( "click", function( event ) { var link = findClosestLink( event.target ); - if ( !link ) { + + // If there is no link associated with the click or its not a left + // click we want to ignore the click + if ( !link || event.which > 1) { return; } diff --git a/js/jquery.mobile.vmouse.js b/js/jquery.mobile.vmouse.js index 47e9823afef..a4d381282db 100644 --- a/js/jquery.mobile.vmouse.js +++ b/js/jquery.mobile.vmouse.js @@ -74,6 +74,12 @@ function createVirtualEvent( event, eventType ) { } } + // make sure that if the mouse and click virtual events are generated + // without a .which one is defined + if ( t.search(/mouse(down|up)|click/) > -1 && !event.which ){ + event.which = 1; + } + if ( t.search(/^touch/) !== -1 ) { ne = getNativeEvent( oe ); t = ne.touches;