diff options
author | Thomas Pulzer <t.pulzer@kniel.de> | 2016-08-04 08:28:37 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-08-09 11:58:32 +0200 |
commit | c5033670d5d2b487b621cbc2704b33ec791a13ea (patch) | |
tree | 27aebae08e0d6cee2af0dfa5583b839504939489 | |
parent | 8c9961aa22ee07a121382565e5efa679d46f3d36 (diff) | |
download | nextcloud-server-c5033670d5d2b487b621cbc2704b33ec791a13ea.tar.gz nextcloud-server-c5033670d5d2b487b621cbc2704b33ec791a13ea.zip |
Changed app and user menu delegates to mousedown events.
Added proper handling of primary mouse button click with and without ctrl-/meta-key modifier.
Added handlig of middle mouse button click.
-rw-r--r-- | core/js/js.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/core/js/js.js b/core/js/js.js index 2b0b6e28915..f2301928a31 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1501,17 +1501,21 @@ function initCore() { $navigation.hide(); // show loading feedback - $navigation.delegate('a', 'click', function(event) { + $navigation.delegate('a', 'mousedown', function(event) { var $app = $(event.target); if(!$app.is('a')) { $app = $app.closest('a'); } - if(!event.ctrlKey && !event.metaKey) { + if(event.which === 1 && !event.ctrlKey && !event.metaKey) { $app.addClass('app-loading'); } else { // Close navigation when opening app in // a new tab OC.hideMenus(); + // On middle click or on first button click with ctrl key or meta key hold + if(event.which === 2 || (event.which === 1 && (event.ctrlKey || event.metaKey))) { + window.open($page, '_blank'); + } } }); } @@ -1520,12 +1524,12 @@ function initCore() { var $menu = $('#header #settings'); // show loading feedback - $menu.delegate('a', 'click', function(event) { + $menu.delegate('a', 'mousedown', function(event) { var $page = $(event.target); if (!$page.is('a')) { $page = $page.closest('a'); } - if(!event.ctrlKey && !event.metaKey) { + if(event.which === 1 && !event.ctrlKey && !event.metaKey) { $page.find('img').remove(); $page.find('div').remove(); // prevent odd double-clicks $page.prepend($('<div/>').addClass('icon-loading-small-dark')); @@ -1533,7 +1537,12 @@ function initCore() { // Close navigation when opening menu entry in // a new tab OC.hideMenus(); + // On middle click or on first button click with ctrl key or meta key hold + if(event.which === 2 || (event.which === 1 && (event.ctrlKey || event.metaKey))) { + window.open($page, '_blank'); + } } + $($page).click(); }); } |