From 2c1abe13a183310c0132ccb1783b118012930b99 Mon Sep 17 00:00:00 2001 From: Jennifer Mourek Date: Wed, 20 Mar 2019 14:19:14 +0100 Subject: [PATCH 1/4] Make ctrl-click open new tab refs #3722 --- public/js/icinga/behavior/navigation.js | 5 +++++ public/js/icinga/events.js | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index 69386b2ee..9daae0ee7 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -95,6 +95,11 @@ var _this = event.data.self; var icinga = _this.icinga; + // Check for ctrl or cmd click to open new tab and don't unfold other menus + if (event.ctrlKey || event.metaKey) { + return false; + } + if (href.match(/#/)) { // ...it may be a menu section without a dedicated link. // Switch the active menu item: diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index d45f3d1f8..38e2667c4 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -457,6 +457,12 @@ return true; } + // Check for ctrl or cmd click to open new tab + if (event.ctrlKey || event.metaKey) { + window.open(href, linkTarget); + return false; + } + // Special checks for link clicks in action tables if (! $a.is('tr[href]') && $a.closest('table.action').length > 0) { From 26d696372f1b6b6f93f456c3d05d74c196e84f01 Mon Sep 17 00:00:00 2001 From: Jennifer Mourek Date: Tue, 21 May 2019 14:35:21 +0200 Subject: [PATCH 2/4] Exclude multiselect rows from the open new tab feature --- public/js/icinga/events.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 38e2667c4..ef34e1972 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -457,8 +457,8 @@ return true; } - // Check for ctrl or cmd click to open new tab - if (event.ctrlKey || event.metaKey) { + // Check for ctrl or cmd click to open new tab unless clicking on a multiselect row + if ((event.ctrlKey || event.metaKey) && ! $a.parent().parent('table.multiselect').length > 0) { window.open(href, linkTarget); return false; } From 1c666d88e6f92e830847fda8ade6af60566ab504 Mon Sep 17 00:00:00 2001 From: Jennifer Mourek Date: Thu, 23 May 2019 11:04:11 +0200 Subject: [PATCH 3/4] Prevent new tab opening in tables and href="#" --- public/js/icinga/events.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index ef34e1972..335b3cb9a 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -458,7 +458,7 @@ } // Check for ctrl or cmd click to open new tab unless clicking on a multiselect row - if ((event.ctrlKey || event.metaKey) && ! $a.parent().parent('table.multiselect').length > 0) { + if ((event.ctrlKey || event.metaKey) && ! $a.parent().parent('table').length > 0 && href !== '#') { window.open(href, linkTarget); return false; } @@ -466,7 +466,7 @@ // Special checks for link clicks in action tables if (! $a.is('tr[href]') && $a.closest('table.action').length > 0) { - // ignoray clicks to ANY link with special key pressed + // ignore clicks to ANY link with special key pressed if ($a.closest('table.multiselect').length > 0 && (event.ctrlKey || event.metaKey || event.shiftKey)) { return true; } From b6f8df5ddc9b51f07e1811e377b1a1b24018a2be Mon Sep 17 00:00:00 2001 From: Jennifer Mourek Date: Fri, 24 May 2019 11:09:05 +0200 Subject: [PATCH 4/4] Disallow new tab opening on anything but anchors --- public/js/icinga/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 335b3cb9a..afdcb80d2 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -458,7 +458,7 @@ } // Check for ctrl or cmd click to open new tab unless clicking on a multiselect row - if ((event.ctrlKey || event.metaKey) && ! $a.parent().parent('table').length > 0 && href !== '#') { + if ((event.ctrlKey || event.metaKey) && href !== '#' && $a.is('a')) { window.open(href, linkTarget); return false; }