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){
|
closeButton.addEventListener('click',function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
chrome.tabs.remove(currentTab.id);
|
if (shiftDown){
|
||||||
decrementTabCount(li.parentNode);
|
var tabList = Array.prototype.slice.call(li.parentNode.childNodes);
|
||||||
if (li.parentNode.childNodes.length===1){ //If it's one this means we're removing the window.
|
tabList.forEach(function(windowTab){
|
||||||
li.parentNode.parentNode.parentNode.removeChild(li.parentNode.parentNode);
|
var tabId = parseInt(windowTab.getAttribute("tabId"));
|
||||||
|
if (tabId!==currentTab.id){
|
||||||
|
chrome.tabs.remove(tabId);
|
||||||
|
windowTab.parentNode.removeChild(windowTab);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setTabCount(li.parentNode, 1);
|
||||||
}
|
}
|
||||||
else{
|
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();
|
setHeights();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue