Simplify shift close mechanism on the keybaord

This commit is contained in:
Nick Krichevsky 2015-03-05 08:56:13 -05:00
parent 529b4be5ce
commit 591011bc1b

View file

@ -627,45 +627,32 @@ document.addEventListener('DOMContentLoaded', function() {
//Close when c is pressed
else if (event.keyCode===67){
if (tabKeyIndex>=0){
//If shift is down, close all except the selected window
tabList[tabKeyIndex].querySelector('i.close').click();
tabList.splice(tabKeyIndex, 1);
//Move the selection after pressing c.
//Check to make sure we're not leaving the bounds of the list
if (shiftDown){
//Get all tabs in the current window
var closeTabList = createTabList(mainList, windowKeyIndex, true, windowList);
var selectedTab = tabList[tabKeyIndex];
closeTabList.forEach(function(tab){
if (tab!==selectedTab){
tab.querySelector('i.close').click();
}
});
//Set the tab count to 1 to prevent negative numbers
setTabCount(selectedTab.parentNode, 1);
tabKeyIndex = 0;
}
else{
tabList[tabKeyIndex].querySelector('i.close').click();
tabList.splice(tabKeyIndex, 1);
//Move the selection after pressing c.
//Check to make sure we're not leaving the bounds of the list
if (tabKeyIndex-1>0){
tabKeyIndex-=1;
}
//If we're closing a window with only one tab left, move to the previous list.
if (tabList.length===0){
//Remove the list from the popup
//If we're at the front of the list, we move to the window below it.
if (windowKeyIndex===0){
tabList = createTabList(mainList, windowKeyIndex);
tabKeyIndex=0;
}
//Otherwise, we move up one.
else{
windowKeyIndex-=1;
tabList = createTabList(mainList, windowKeyIndex);
tabKeyIndex=tabList.length-1;
}
}
tabList[tabKeyIndex].classList.add('keyHover');
else if (tabKeyIndex-1>0){
tabKeyIndex-=1;
}
//If we're closing a window with only one tab left, move to the previous list.
if (tabList.length===0){
//Remove the list from the popup
//If we're at the front of the list, we move to the window below it.
if (windowKeyIndex===0){
tabList = createTabList(mainList, windowKeyIndex);
tabKeyIndex=0;
}
//Otherwise, we move up one.
else{
windowKeyIndex-=1;
tabList = createTabList(mainList, windowKeyIndex);
tabKeyIndex=tabList.length-1;
}
}
tabList[tabKeyIndex].classList.add('keyHover');
}
}
//Pin when p is pressed