diff options
author | Kushal Pandya <kushal@gitlab.com> | 2017-01-31 14:44:01 +0530 |
---|---|---|
committer | Kushal Pandya <kushal@gitlab.com> | 2017-02-07 21:12:00 +0530 |
commit | e665ea050a9fcdb69a8d40db4ed120fe35bb0b97 (patch) | |
tree | 6631eef951202a93a120335db13d245cf548b486 | |
parent | ff4950b76c1643120c91ca12ee7187b3131f1010 (diff) | |
download | gitlab-ce-e665ea050a9fcdb69a8d40db4ed120fe35bb0b97.tar.gz |
Add Ctrl+Click support
-rw-r--r-- | app/assets/javascripts/todos.js.es6 | 21 |
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); } |