Fixed window selection issue.

This commit is contained in:
Maxim Stewart 2018-09-30 17:03:56 -05:00
parent c70553b0e4
commit 9c763c0e7b
4 changed files with 47 additions and 35 deletions

View File

@ -4,10 +4,9 @@ Search Firefox tabs and get a list or automatic direct to the searched tab.
# Download # Download
https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/ https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/
# Version: 1.2.8 # Version: 1.2.9
<ul> <ul>
<li>Fixed search type persistence.</li> <li>Fixed window selection issue.</li>
<li>Fixed missing starting tabs in list.</li>
</ul> </ul>
***Note: ***Note:

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Tab Search and Manage", "name": "Tab Search and Manage",
"version": "1.2.8", "version": "1.2.9",
"description": "This plugin can search, drag-n-drop ordering, and (un)hide all or some tabs.", "description": "This plugin can search, drag-n-drop ordering, and (un)hide all or some tabs.",
"applications": { "applications": {

View File

@ -14,32 +14,34 @@ var windowIndex = 0;
function logTabs(tabs) { function logTabs(tabs) {
windowIndex = 0; windowIndex = 0;
tabsAction.query({currentWindow: true, active: true}).then((tab) => {
focusedWinID = tab[0].windowId;
}, focusedWinID);
for (let tab of tabs) { tabsAction.query({currentWindow: true, active: true}).then((tab) => {
currentWinId = tab.windowId; console.log(tab);
if (currentWinId == newWinId) { focusedWinID = tab[0].windowId;
createContainer(tab); }, focusedWinID).then(() => {
} else { for (let tab of tabs) {
if (windowIndex != 0) { currentWinId = tab.windowId;
var pTag = document.createElement("P"); if (currentWinId == newWinId) {
var msg = (focusedWinID == tab.windowId)
? "[ Current Window ] " : "Window: " + tab.windowId;
var pText = document.createTextNode(msg);
pTag.className = "windowIdHeaders";
pTag.appendChild(pText);
listZone.appendChild(pTag);
windowIndex++;
createContainer(tab); createContainer(tab);
} else { } else {
createContainer(tab); if (windowIndex != 0) {
windowIndex = 1; var pTag = document.createElement("P");
var msg = (focusedWinID == tab.windowId)
? "[ Current Window ] " : "Window: " + tab.windowId;
var pText = document.createTextNode(msg);
pTag.className = "windowIdHeaders";
pTag.appendChild(pText);
listZone.appendChild(pTag);
windowIndex++;
createContainer(tab);
} else {
createContainer(tab);
windowIndex = 1;
}
} }
newWinId = currentWinId;
} }
newWinId = currentWinId; });
}
newWinId = undefined; newWinId = undefined;
// Set poped-out-window position and 100px up from selected elm // Set poped-out-window position and 100px up from selected elm
@ -56,6 +58,19 @@ function createContainer(tab) {
var hidnStImgTag = document.createElement("IMG"); var hidnStImgTag = document.createElement("IMG");
var icoImgTag = document.createElement("IMG"); // Used to properly set bg var icoImgTag = document.createElement("IMG"); // Used to properly set bg
// Set oldElm so eventListeners.js has starting ref
if (tab.active == true) {
browser.windows.getCurrent().then((window) => {
if (tab.windowId == window.id) {
spanTag.className = "block block-focused";
if (oldElm) {
oldElm.setAttribute("class", "block");
}
oldElm = spanTag;
}
}, tab, oldElm, spanTag);
}
spanTag.setAttribute("tabID", tab.id); spanTag.setAttribute("tabID", tab.id);
spanTag.title = tab.title; spanTag.title = tab.title;
spanTag.id = "iconElm"; spanTag.id = "iconElm";
@ -83,15 +98,6 @@ function createContainer(tab) {
pTag.appendChild(iconText); pTag.appendChild(iconText);
spanTag.appendChild(pTag); spanTag.appendChild(pTag);
listZone.appendChild(spanTag); listZone.appendChild(spanTag);
// Set oldElm so eventListeners.js has starting ref
if (tab.active == true) {
spanTag.className = "block block-focused";
if (oldElm) {
oldElm.setAttribute("class", "block");
}
oldElm = spanTag;
}
} }
function createTab() { function createTab() {

View File

@ -16,7 +16,14 @@ function findTabs(tabs) {
searchBar.value = ""; searchBar.value = "";
errHandler.style.display = "none"; errHandler.style.display = "none";
clearNodes(errHandler); clearNodes(errHandler);
loadSelTab(selection[0].id);
if (selection[0].windowId == focusedWinID) {
loadSelTab(selection[0].id);
} else {
browser.windows.update(selection[0].windowId, {focused: true})
.finally(loadSelTab(selection[0].id));
}
getTabs(); getTabs();
} else { } else {
errHandler.style.display = "block"; errHandler.style.display = "block";