Implements shift close mechanism with mouse, resolves #18
This commit is contained in:
parent
43024a116f
commit
529b4be5ce
23
popup.js
23
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();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue