summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemy Suen <remy.suen@gmail.com>2016-11-04 22:31:19 +0900
committerMichael Rennie <Michael_Rennie@ca.ibm.com>2016-11-07 11:39:36 -0400
commite840e56a76eb7839c4754b109c3e60bcdc3f77cb (patch)
treeaf3ffe9b7b63637a6da56f48a76fc73d043363b9
parent2acf2a240367efa69ba5b4f7c9c37e054c10dcee (diff)
downloadorg.eclipse.orion.client-e840e56a76eb7839c4754b109c3e60bcdc3f77cb.zip
org.eclipse.orion.client-e840e56a76eb7839c4754b109c3e60bcdc3f77cb.tar.gz
org.eclipse.orion.client-e840e56a76eb7839c4754b109c3e60bcdc3f77cb.tar.bz2
Bug 507039 - Middle clicking should close tabs
When a user clicks on a tab with the middle mouse button, close it. However, if that is only tab that is currently open, do not close it. Signed-off-by: Remy Suen <remy.suen@gmail.com>
-rw-r--r--modules/orionode/lib/main.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/orionode/lib/main.js b/modules/orionode/lib/main.js
index e39dcdc..0ef87e7 100644
--- a/modules/orionode/lib/main.js
+++ b/modules/orionode/lib/main.js
@@ -99,11 +99,21 @@ function addNewTab(id, iframe) {
}
tab.addEventListener("click", function(evt) {
- setActive();
- evt.preventDefault();
- evt.stopPropagation();
- var menu = document.querySelector("#context-menu");
- menu.classList.remove('context-menu-items-open');
+ if (evt.button === 1 && tabParent.childNodes.length > 1) {
+ // middle button clicked, close the tab if there are two or more
+ // tabs around
+ iframe.parentNode.removeChild(iframe);
+ tab.parentNode.removeChild(tab);
+ update();
+ evt.preventDefault();
+ evt.stopPropagation();
+ } else {
+ setActive();
+ evt.preventDefault();
+ evt.stopPropagation();
+ var menu = document.querySelector("#context-menu");
+ menu.classList.remove('context-menu-items-open');
+ }
});
tab.addEventListener('dragstart', function(evt) {