From d485946d561f0d514bc0ab78023d5787fa929f87 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 19 Jan 2024 12:10:38 +0100 Subject: [PATCH 1/4] fix links in cards --- templates/portfolio/card.html | 2 +- templates/portfolio/index.html | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/templates/portfolio/card.html b/templates/portfolio/card.html index 8a0ad6d..a79ec0a 100644 --- a/templates/portfolio/card.html +++ b/templates/portfolio/card.html @@ -1,5 +1,5 @@ {{#metadata}} {{#info}} {{#portfolio}} {{#link}} -
  • +
  • {{>portfolio/project.html}}
  • {{/link}} {{^link}} diff --git a/templates/portfolio/index.html b/templates/portfolio/index.html index fbf7469..4bbc2fd 100644 --- a/templates/portfolio/index.html +++ b/templates/portfolio/index.html @@ -45,6 +45,28 @@ }); }) ); + + /* Open cards link */ + const openLink = (url) => { + switch (event.button) { + case 0: + /* Left click */ + 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 }) + ); + break; + default: + break; + } + }; From 465cc71e9eab5d09e6da86050ff65694260f2044 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 19 Jan 2024 12:15:44 +0100 Subject: [PATCH 2/4] 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; From cedb2e0e4c92145d4a8ffbc3602a533fd4cc3d19 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 19 Jan 2024 12:20:18 +0100 Subject: [PATCH 3/4] fix the propagation of links --- templates/portfolio/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/portfolio/index.html b/templates/portfolio/index.html index 847a622..9440217 100644 --- a/templates/portfolio/index.html +++ b/templates/portfolio/index.html @@ -40,7 +40,7 @@ document.querySelectorAll("main a").forEach(function (link) { link.setAttribute("target", "_blank"); link.setAttribute("rel", "noreferrer"); - link.addEventListener("click", function (event) { + link.addEventListener("mousedown", function (event) { event.stopPropagation(); }); }) From 07bea92346bc9a139682dfcd666b9575e00c67fa Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 19 Jan 2024 12:21:54 +0100 Subject: [PATCH 4/4] prevent the scroll of the middle click --- templates/portfolio/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/portfolio/index.html b/templates/portfolio/index.html index 9440217..d3aa640 100644 --- a/templates/portfolio/index.html +++ b/templates/portfolio/index.html @@ -68,6 +68,7 @@ break; case 1: /* Middle click */ + event.preventDefault(); backgroundtab(); break;