From 465cc71e9eab5d09e6da86050ff65694260f2044 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 19 Jan 2024 12:15:44 +0100 Subject: [PATCH] background tab also when the user use ctrl or meta --- templates/portfolio/index.html | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/templates/portfolio/index.html b/templates/portfolio/index.html index 4bbc2fd..847a622 100644 --- a/templates/portfolio/index.html +++ b/templates/portfolio/index.html @@ -48,20 +48,28 @@ /* Open cards link */ 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) { case 0: /* Left click */ - window.open(url, "_blank", "noreferrer"); + if (event.ctrlKey || event.metaKey) { + backgroundtab(); + } else { + window.open(url, "_blank", "noreferrer"); + } break; case 1: /* Middle click */ - Object.assign(document.createElement("a"), { - href: url, - target: "_blank", - rel: "noreferrer", - }).dispatchEvent( - new MouseEvent("click", { ctrlKey: true, metaKey: true }) - ); + backgroundtab(); + break; default: break;