From 529b4be5ce29d14f2fdd680e5b3c78041f598c25 Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Thu, 5 Mar 2015 08:53:15 -0500 Subject: [PATCH] Implements shift close mechanism with mouse, resolves #18 --- popup.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/popup.js b/popup.js index 2108524..296c394 100644 --- a/popup.js +++ b/popup.js @@ -163,13 +163,26 @@ function setupTabs(tabs,callback){ closeButton.addEventListener('click',function(event){ event.preventDefault(); event.stopPropagation(); - chrome.tabs.remove(currentTab.id); - decrementTabCount(li.parentNode); - if (li.parentNode.childNodes.length===1){ //If it's one this means we're removing the window. - li.parentNode.parentNode.parentNode.removeChild(li.parentNode.parentNode); + if (shiftDown){ + var tabList = Array.prototype.slice.call(li.parentNode.childNodes); + tabList.forEach(function(windowTab){ + var tabId = parseInt(windowTab.getAttribute("tabId")); + if (tabId!==currentTab.id){ + chrome.tabs.remove(tabId); + windowTab.parentNode.removeChild(windowTab); + } + }); + setTabCount(li.parentNode, 1); } else{ - li.parentNode.removeChild(li); + chrome.tabs.remove(currentTab.id); + decrementTabCount(li.parentNode); + if (li.parentNode.childNodes.length===1){ //If it's one this means we're removing the window. + li.parentNode.parentNode.parentNode.removeChild(li.parentNode.parentNode); + } + else{ + li.parentNode.removeChild(li); + } } setHeights(); });