mw.ViewPageTarget: Don't handle edt tab clicks from special mouse buttons

Regular mouse button click is normalised to which=1 by jQuery.

Change-Id: I08a711d8251613144ba6b463d4d240aedd98bb2a
This commit is contained in:
Timo Tijhof 2013-06-26 12:20:19 -07:00
parent a06a81370c
commit 39fdb135f8

View file

@ -555,6 +555,13 @@ ve.init.mw.ViewPageTarget.prototype.onNoChanges = function () {
* @param {jQuery.Event} e Mouse click event
*/
ve.init.mw.ViewPageTarget.prototype.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.metaKey ) {
return;
}
this.logEvent( 'Edit', { action: 'edit-link-click' } );
this.activate();
// Prevent the edit tab's normal behavior
@ -568,6 +575,9 @@ ve.init.mw.ViewPageTarget.prototype.onEditTabClick = function ( e ) {
* @param {jQuery.Event} e Mouse click event
*/
ve.init.mw.ViewPageTarget.prototype.onEditSectionLinkClick = function ( e ) {
if ( ( e.which && e.which !== 1 ) || e.shiftKey || e.altKey || e.metaKey ) {
return;
}
this.logEvent( 'Edit', { action: 'section-edit-link-click' } );
this.saveEditSection( $( e.target ).closest( 'h1, h2, h3, h4, h5, h6' ).get( 0 ) );
this.activate();
@ -582,6 +592,9 @@ ve.init.mw.ViewPageTarget.prototype.onEditSectionLinkClick = function ( e ) {
* @param {jQuery.Event} e Mouse click event
*/
ve.init.mw.ViewPageTarget.prototype.onViewTabClick = function ( e ) {
if ( ( e.which && e.which !== 1 ) || e.shiftKey || e.altKey || e.metaKey ) {
return;
}
if ( this.active ) {
this.deactivate();
// Prevent the edit tab's normal behavior