Centralize some checks for unmodified left clicks

Change-Id: I59cee4da9bbca4c8a29eaf9d52cb00ab6e70b670
Depends-On: I4f164f7cf1d755c3662571b2a1a8371d9fe756f9
This commit is contained in:
David Lynch 2016-08-11 11:22:45 -07:00
parent 3e370fa286
commit 87ea771ae6
2 changed files with 4 additions and 8 deletions

View file

@ -538,11 +538,7 @@
},
onEditTabClick: function ( e ) {
// Default mouse button is normalised by jQuery to key code 1.
// Only do our handling if no keys are pressed, mouse button is 1
// (e.g. not middle click or right click) and no modifier keys
// (e.g. cmd-click to open in new tab).
if ( ( e.which && e.which !== 1 ) || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) {
if ( !ve.isUnmodifiedLeftClick( e ) ) {
return;
}
e.preventDefault();
@ -598,7 +594,7 @@
onEditSectionLinkClick: function ( e ) {
var targetPromise;
if ( ( e.which && e.which !== 1 ) || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) {
if ( !ve.isUnmodifiedLeftClick( e ) ) {
return;
}

View file

@ -851,7 +851,7 @@ ve.init.mw.DesktopArticleTarget.prototype.onDocumentKeyDown = function ( e ) {
* @param {jQuery.Event} e Mouse click event
*/
ve.init.mw.DesktopArticleTarget.prototype.onViewTabClick = function ( e ) {
if ( ( e.which && e.which !== 1 ) || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) {
if ( !ve.isUnmodifiedLeftClick( e ) ) {
return;
}
this.deactivate( false, 'navigate-read' );
@ -1068,7 +1068,7 @@ ve.init.mw.DesktopArticleTarget.prototype.setupSkinTabs = function () {
}
$( '#ca-viewsource, #ca-edit' ).on( 'click', function ( e ) {
if ( !target.active || e.which !== 1 || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) {
if ( !target.active || !ve.isUnmodifiedLeftClick( e ) ) {
return;
}