background tab also when the user use ctrl or meta
This commit is contained in:
parent
d485946d56
commit
465cc71e9e
1 changed files with 16 additions and 8 deletions
|
@ -48,20 +48,28 @@
|
||||||
|
|
||||||
/* Open cards link */
|
/* Open cards link */
|
||||||
const openLink = (url) => {
|
const openLink = (url) => {
|
||||||
|
const backgroundtab = () =>
|
||||||
|
Object.assign(document.createElement("a"), {
|
||||||
|
href: url,
|
||||||
|
target: "_blank",
|
||||||
|
rel: "noreferrer",
|
||||||
|
}).dispatchEvent(
|
||||||
|
new MouseEvent("click", { ctrlKey: true, metaKey: true })
|
||||||
|
);
|
||||||
|
|
||||||
switch (event.button) {
|
switch (event.button) {
|
||||||
case 0:
|
case 0:
|
||||||
/* Left click */
|
/* Left click */
|
||||||
window.open(url, "_blank", "noreferrer");
|
if (event.ctrlKey || event.metaKey) {
|
||||||
|
backgroundtab();
|
||||||
|
} else {
|
||||||
|
window.open(url, "_blank", "noreferrer");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Middle click */
|
/* Middle click */
|
||||||
Object.assign(document.createElement("a"), {
|
backgroundtab();
|
||||||
href: url,
|
|
||||||
target: "_blank",
|
|
||||||
rel: "noreferrer",
|
|
||||||
}).dispatchEvent(
|
|
||||||
new MouseEvent("click", { ctrlKey: true, metaKey: true })
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue