From 4387bb9d61153077cfd6928aa4282814d599e213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Laxstr=C3=B6m?= Date: Thu, 5 Nov 2020 10:35:03 +0100 Subject: [PATCH] CompactLinks: Better handling of opening links to new tab/window * Check for any of Shift, Ctrl or Meta * Only do it for links * Support both mouse and keyboard Change-Id: I0b331b802e1d96ae0e0511746d6b42663db924b1 --- resources/js/ext.uls.launch.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/resources/js/ext.uls.launch.js b/resources/js/ext.uls.launch.js index eab55ec0..117076a1 100644 --- a/resources/js/ext.uls.launch.js +++ b/resources/js/ext.uls.launch.js @@ -52,11 +52,15 @@ function launchULS( $trigger, languagesObject ) { $trigger.removeClass( 'selector-open' ); mw.uls.addPreviousLanguage( language ); - // Switch the current tab to the new language, - // unless it was Ctrl-click or Command-click - if ( !event.metaKey && !event.shiftKey ) { - location.href = languagesObject[ language ].href; + // Switch the current tab to the new language, unless it was + // {Ctrl,Shift,Command} activation on a link + if ( + event.target instanceof HTMLAnchorElement && + ( event.metaKey || event.shiftKey || event.ctrlKey ) + ) { + return; } + location.href = languagesObject[ language ].href; }, onVisible: function () { var offset, height, width, triangleWidth;