Tab duplicate behavior change
This commit is contained in:
parent
73af98379e
commit
55b807ee07
|
@ -4,9 +4,8 @@ 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.3.9
|
# Version: 1.3.10
|
||||||
* Added tab duplicate button
|
* Improved tab duplicate behavior
|
||||||
* Added secondary control menu
|
|
||||||
|
|
||||||
|
|
||||||
***Note:
|
***Note:
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 420 B |
Binary file not shown.
Before Width: | Height: | Size: 446 B |
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Tab Search and Manage",
|
"name": "Tab Search and Manage",
|
||||||
"version": "1.3.9",
|
"version": "1.3.10",
|
||||||
"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": {
|
||||||
|
|
|
@ -88,21 +88,26 @@ function setNewTabAction(target, targetID, parentElm, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function popoutSelectedTabAction(target, targetID) {
|
function popoutSelectedTabAction(target, targetID) {
|
||||||
parentElm = target.parentElement;
|
let parentElm = target.parentElement;
|
||||||
id = parseInt(target.getAttribute("tabID"));
|
let id = parseInt(target.getAttribute("tabID"));
|
||||||
popoutSelectedTab(id);
|
popoutSelectedTab(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function duplicateTabAction(target, targetID) {
|
function duplicateTabAction(target, targetID) {
|
||||||
parentElm = target.parentElement;
|
let parentElm = target.parentElement;
|
||||||
id = parseInt(target.getAttribute("tabID"));
|
let id = parseInt(target.getAttribute("tabID"));
|
||||||
duplicateTab(id);
|
let kids = parentElm.children;
|
||||||
|
let toIndex = 0;
|
||||||
|
|
||||||
|
while (kids[toIndex] !== target) { toIndex++; }
|
||||||
|
|
||||||
|
duplicateTab(id, (toIndex += 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideSelectedTabAction(target, targetID) {
|
function hideSelectedTabAction(target, targetID) {
|
||||||
parentElm = target.parentElement;
|
let parentElm = target.parentElement;
|
||||||
id = parseInt(target.getAttribute("tabID"));
|
let id = parseInt(target.getAttribute("tabID"));
|
||||||
control = document.getElementById("tabControls").querySelector("#hideTgglBttn");
|
let control = document.getElementById("tabControls").querySelector("#hideTgglBttn");
|
||||||
|
|
||||||
if (id != oldElm.getAttribute("tabID")) {
|
if (id != oldElm.getAttribute("tabID")) {
|
||||||
if (control.src.includes("eyeClosed.png")) {
|
if (control.src.includes("eyeClosed.png")) {
|
||||||
|
|
|
@ -21,36 +21,24 @@ function popoutSelectedTab(id) {
|
||||||
windowsAction.create({tabId: id});
|
windowsAction.create({tabId: id});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function duplicateTab(id, pos) {
|
||||||
async function duplicateTab(id) {
|
tab = await tabsAction.duplicate(id, {index: pos, active: true});
|
||||||
tab = await tabsAction.duplicate(id);
|
createContainer(tab, pos);
|
||||||
createContainer(tab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function unhideSelectedTab(id) {
|
function unhideSelectedTab(id) { tabsAction.show(id).then(successMsg, errMsg); }
|
||||||
tabsAction.show(id).then(successMsg, errMsg);
|
function hideSelectedTab(id) { tabsAction.hide(id).then(successMsg, errMsg); }
|
||||||
|
function muteSelectedTab(id) { tabsAction.update(id, {muted: true}) }
|
||||||
|
function unmuteSelectedTab(id) { tabsAction.update(id, {muted: false}) }
|
||||||
|
|
||||||
|
function resetWinIndex() { windowIndex = 0; }
|
||||||
|
function createWin() { windowsAction.create({}); }
|
||||||
|
function onError(error) { console.log(`Error: ${error}`); }
|
||||||
|
|
||||||
|
function createTab() {
|
||||||
|
tabsAction.create({}).then(function (tab) { createContainer(tab); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideSelectedTab(id) {
|
|
||||||
tabsAction.hide(id).then(successMsg, errMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
function muteSelectedTab(id) {
|
|
||||||
tabsAction.update(
|
|
||||||
id,
|
|
||||||
{muted: true}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function unmuteSelectedTab(id) {
|
|
||||||
tabsAction.update(
|
|
||||||
id,
|
|
||||||
{muted: false}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function logTabs(tabs) {
|
function logTabs(tabs) {
|
||||||
windowIndex = 0;
|
windowIndex = 0;
|
||||||
|
@ -60,13 +48,14 @@ function logTabs(tabs) {
|
||||||
}, focusedWinID).then(() => {
|
}, focusedWinID).then(() => {
|
||||||
for (let tab of tabs) {
|
for (let tab of tabs) {
|
||||||
currentWinId = tab.windowId;
|
currentWinId = tab.windowId;
|
||||||
|
|
||||||
if (currentWinId == newWinId) {
|
if (currentWinId == newWinId) {
|
||||||
createContainer(tab);
|
createContainer(tab);
|
||||||
} else {
|
} else {
|
||||||
if (windowIndex != 0) {
|
if (windowIndex != 0) {
|
||||||
var pTag = document.createElement("P");
|
var pTag = document.createElement("P");
|
||||||
var msg = (focusedWinID == tab.windowId)
|
var msg = (focusedWinID == tab.windowId)
|
||||||
? "[ Current Window ] " : "Window: " + tab.windowId;
|
? "[ Current Window ] " : "Window: " + tab.windowId;
|
||||||
var pText = document.createTextNode(msg);
|
var pText = document.createTextNode(msg);
|
||||||
pTag.className = "windowIdHeaders";
|
pTag.className = "windowIdHeaders";
|
||||||
pTag.appendChild(pText);
|
pTag.appendChild(pText);
|
||||||
|
@ -86,7 +75,7 @@ function logTabs(tabs) {
|
||||||
scrollToView();
|
scrollToView();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createContainer(tab) {
|
function createContainer(tab, pos = null) {
|
||||||
var template = document.querySelector('#tabContainerTemplate');
|
var template = document.querySelector('#tabContainerTemplate');
|
||||||
var clone = document.importNode(template.content, true);
|
var clone = document.importNode(template.content, true);
|
||||||
var spanTag = clone.querySelector("#iconElm");
|
var spanTag = clone.querySelector("#iconElm");
|
||||||
|
@ -111,71 +100,59 @@ function createContainer(tab) {
|
||||||
}
|
}
|
||||||
|
|
||||||
spanTag.setAttribute("tabID", tab.id);
|
spanTag.setAttribute("tabID", tab.id);
|
||||||
spanTag.title = tab.title;
|
spanTag.title = tab.title;
|
||||||
|
|
||||||
if (!tab.hidden)
|
if (!tab.hidden) {
|
||||||
spanTag.className = "block";
|
spanTag.className = "block";
|
||||||
else
|
} else {
|
||||||
spanTag.className = "block hiddenBGColor";
|
spanTag.className = "block hiddenBGColor";
|
||||||
|
}
|
||||||
|
|
||||||
|
spanTag.style.backgroundImage = "url(" + tab.favIconUrl + ")";
|
||||||
spanTag.style.backgroundImage = "url(" + tab.favIconUrl + ")";
|
icoImgTag.src = tab.favIconUrl;
|
||||||
icoImgTag.src = tab.favIconUrl;
|
icoImgTag.onerror = function() { spanTag.style.backgroundImage = "url(" + tabImg + ")"; }
|
||||||
icoImgTag.onerror = function() { spanTag.style.backgroundImage = "url(" + tabImg + ")"; }
|
|
||||||
|
|
||||||
spanTag.addEventListener("mouseenter", function (eve) {
|
spanTag.addEventListener("mouseenter", function (eve) {
|
||||||
moveTabControlTo(eve.target);
|
moveTabControlTo(eve.target);
|
||||||
});
|
});
|
||||||
|
|
||||||
pTag.appendChild(iconText);
|
pTag.appendChild(iconText);
|
||||||
listZone.appendChild(clone);
|
if (pos == null) {
|
||||||
}
|
listZone.appendChild(clone);
|
||||||
|
} else {
|
||||||
function createTab() {
|
listZone.insertBefore(clone, listZone.children[pos]);
|
||||||
tabsAction.create({})
|
}
|
||||||
.then(function (tab) {
|
|
||||||
createContainer(tab);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createWin() {
|
|
||||||
windowsAction.create({});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function moveTabControlTo(elm) {
|
async function moveTabControlTo(elm) {
|
||||||
let tabControls = document.getElementById("tabControls");
|
let tabControls = document.getElementById("tabControls");
|
||||||
let tabControls2 = document.getElementById("tabControls2");
|
let tabControls2 = document.getElementById("tabControls2");
|
||||||
let hideTgglBttn = tabControls.querySelector("#hideTgglBttn")
|
let hideTgglBttn = tabControls.querySelector("#hideTgglBttn")
|
||||||
let muteTgglBttn = tabControls.querySelector("#muteTgglBttn")
|
let muteTgglBttn = tabControls.querySelector("#muteTgglBttn")
|
||||||
|
let rect = elm.getBoundingClientRect();
|
||||||
let rect = elm.getBoundingClientRect();
|
tabControls.style.left = (rect.left) + "px";
|
||||||
|
tabControls.style.top = (rect.top) + "px";
|
||||||
tabControls.style.left = (rect.left) + "px";
|
|
||||||
tabControls.style.top = (rect.top) + "px";
|
|
||||||
|
|
||||||
tabControls2.style.left = (rect.left - 46) + "px";
|
tabControls2.style.left = (rect.left - 46) + "px";
|
||||||
tabControls2.style.top = rect.top + "px";
|
tabControls2.style.top = rect.top + "px";
|
||||||
hoverTarget = elm;
|
hoverTarget = elm;
|
||||||
|
|
||||||
if (elm.className == "block hiddenBGColor")
|
if (elm.className == "block hiddenBGColor") {
|
||||||
hideTgglBttn.src = "../icons/eyeClosed.png";
|
hideTgglBttn.src = "../icons/eyeClosed.png";
|
||||||
else
|
} else {
|
||||||
hideTgglBttn.src = "../icons/eyeOpen.png";
|
hideTgglBttn.src = "../icons/eyeOpen.png";
|
||||||
|
}
|
||||||
|
|
||||||
id = parseInt(hoverTarget.getAttribute("tabID"));
|
id = parseInt(hoverTarget.getAttribute("tabID"));
|
||||||
tab = await tabsAction.get(id);
|
tab = await tabsAction.get(id);
|
||||||
if (tab.mutedInfo.muted == false)
|
if (tab.mutedInfo.muted == false) {
|
||||||
muteTgglBttn.src = "../icons/isNotMuted.png";
|
muteTgglBttn.src = "../icons/isNotMuted.png";
|
||||||
else
|
} else {
|
||||||
muteTgglBttn.src = "../icons/isMuted.png";
|
muteTgglBttn.src = "../icons/isMuted.png";
|
||||||
|
}
|
||||||
|
|
||||||
tabControls.style.display = "";
|
tabControls.style.display = "";
|
||||||
tabControls2.style.display = "";
|
tabControls2.style.display = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(error) { console.log(`Error: ${error}`); }
|
|
||||||
|
|
||||||
function getTabs() {
|
function getTabs() {
|
||||||
clearNodes(listZone);
|
clearNodes(listZone);
|
||||||
|
|
||||||
|
@ -209,8 +186,8 @@ function getTabs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setSearchMode(target, text, img, state) {
|
async function setSearchMode(target, text, img, state) {
|
||||||
target.title = "Searching " + text + "...";
|
target.title = "Searching " + text + "...";
|
||||||
target.src = "../icons/" + img + ".png";
|
target.src = "../icons/" + img + ".png";
|
||||||
target.setAttribute("searchwindowsmode", state);
|
target.setAttribute("searchwindowsmode", state);
|
||||||
|
|
||||||
await storageArea.set({"searchMode": state });
|
await storageArea.set({"searchMode": state });
|
||||||
|
@ -222,7 +199,3 @@ function clearNodes(targetNode) {
|
||||||
targetNode.removeChild(targetNode.firstChild);
|
targetNode.removeChild(targetNode.firstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetWinIndex() {
|
|
||||||
windowIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue