From 96663fa1548301dc62cc7c402ebdb9ba75dae145 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:32:11 -0300 Subject: [PATCH] Open links on a new tab when Ctrl (Win) / Command (macOS) key is pressed When you're editing a page (&do=edit) and attempt to open another page through the sidebar pressing Ctrl (Windows) or Command (macOS) key, the plug-in attempts to load the clicked page on the current tab, triggering the alert "Changes not saved". This commit adds support for Ctrl (Win)/Command (macOS) key, so if those keys are pressed, instead of opening the link on the current tab, it opens the clicked link on a new tab. --- script.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index c66d194..3fca77a 100644 --- a/script.js +++ b/script.js @@ -211,7 +211,13 @@ jQuery(function(){ // on page load } if(node.data.url){ - window.location.href = node.data.url; + if (e.ctrlKey || e.metaKey) { + e.stopPropagation(); + e.preventDefault(); + window.open(node.data.url); + } else { + window.location.href = node.data.url; + } } },