Skip to content

Commit

Permalink
Open links on a new tab when Ctrl (Win) / Command (macOS) key is pressed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eduardomozart authored Feb 1, 2024
1 parent d5a8614 commit 96663fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
},

Expand Down

0 comments on commit 96663fa

Please sign in to comment.