summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKushal Pandya <kushal@gitlab.com>2017-01-31 14:44:01 +0530
committerKushal Pandya <kushal@gitlab.com>2017-02-07 21:12:00 +0530
commite665ea050a9fcdb69a8d40db4ed120fe35bb0b97 (patch)
tree6631eef951202a93a120335db13d245cf548b486
parentff4950b76c1643120c91ca12ee7187b3131f1010 (diff)
downloadgitlab-ce-e665ea050a9fcdb69a8d40db4ed120fe35bb0b97.tar.gz
Add Ctrl+Click support
-rw-r--r--app/assets/javascripts/todos.js.es621
1 files changed, 18 insertions, 3 deletions
diff --git a/app/assets/javascripts/todos.js.es6 b/app/assets/javascripts/todos.js.es6
index 96c7d927509..bf84d82af97 100644
--- a/app/assets/javascripts/todos.js.es6
+++ b/app/assets/javascripts/todos.js.es6
@@ -147,13 +147,28 @@
goToTodoUrl(e) {
const todoLink = $(this).data('url');
+ let targetLink = $(e.target).attr('href');
+
+ if ($(e.target).is('img')) { // See if clicked target was Avatar
+ targetLink = $(e.target).parent().attr('href'); // Parent of Avatar is link
+ }
+
if (!todoLink) {
return;
}
- // Allow Meta-Click or Mouse3-click to open in a new tab
- if (e.metaKey || e.which === 2) {
+
+ // Allow Meta-Click (Cmd+Click or Ctrl+Click)
+ // or Mouse3-click (middle-click)
+ // to open in a new tab
+ if (e.metaKey || e.ctrlKey || e.which === 2) {
e.preventDefault();
- return window.open(todoLink, '_blank');
+ // Meta-Click on username leads to different URL than todoLink.
+ // Turbolinks can resolve that URL, but window.open requires URL manually.
+ if (targetLink !== todoLink) {
+ return window.open(targetLink, '_blank');
+ } else {
+ return window.open(todoLink, '_blank');
+ }
} else {
return gl.utils.visitUrl(todoLink);
}