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
This commit is contained in:
Niklas Laxström
2020-11-05 10:35:03 +01:00
committed by jenkins-bot
parent 78884e87b2
commit 4387bb9d61

View File

@@ -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;