From 9f50d55dcd9c7ea77db36ab60fec4ad16043a37a Mon Sep 17 00:00:00 2001 From: Thomas Brouard Date: Mon, 31 Oct 2016 17:59:13 +0100 Subject: [PATCH] Middle click on a tab closes it --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 44e80ac..36e5f1e 100644 --- a/index.js +++ b/index.js @@ -108,9 +108,8 @@ class Tab { this.setIcon(this.iconURL); this.setButtons(); - tab.addEventListener("click", this.activate.bind(this), false); + tab.addEventListener("click", this.tabClickHandler.bind(this), false); this.tabGroup.tabContainer.appendChild(this.tab); - // TODO: handle middle click } initWebview () { @@ -158,6 +157,14 @@ class Tab { } } + tabClickHandler (e) { + if (e.which === 1) { + this.activate(); + } else if (e.which === 2) { + this.close(); + } + } + activate () { let activeTab = this.tabGroup.getActiveTab(); if (activeTab) {