Skip to content

Commit

Permalink
prevent clicks on anything but the left mouse button, also adds the w…
Browse files Browse the repository at this point in the history
…hich value to the events when its undefined in the vmouse plugin
  • Loading branch information
johnbender committed Sep 15, 2011
1 parent 7dc20cd commit 416b666
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/jquery.mobile.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== "#" ) {
Expand All @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions js/jquery.mobile.vmouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 416b666

Please sign in to comment.