diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs
index efafb8c..a35ce12 100644
--- a/src/ZenWorkspaces.mjs
+++ b/src/ZenWorkspaces.mjs
@@ -1,18 +1,21 @@
-
var ZenWorkspaces = {
async init() {
let docElement = document.documentElement;
- if (docElement.getAttribute("chromehidden").includes("toolbar")
- || docElement.getAttribute("chromehidden").includes("menubar")
- || docElement.hasAttribute("privatebrowsingmode")) {
- console.warn("ZenWorkspaces: !!! ZenWorkspaces is disabled in hidden windows !!!");
+ if (
+ docElement.getAttribute("chromehidden").includes("toolbar") ||
+ docElement.getAttribute("chromehidden").includes("menubar") ||
+ docElement.hasAttribute("privatebrowsingmode")
+ ) {
+ console.warn(
+ "ZenWorkspaces: !!! ZenWorkspaces is disabled in hidden windows !!!",
+ );
return; // We are in a hidden window, don't initialize ZenWorkspaces
- }
+ }
console.info("ZenWorkspaces: Initializing ZenWorkspaces...");
window.SessionStore.promiseInitialized.then(async () => {
await this.initializeWorkspaces();
console.info("ZenWorkspaces: ZenWorkspaces initialized");
- })
+ });
},
get workspaceEnabled() {
@@ -51,7 +54,10 @@ var ZenWorkspaces = {
},
async initializeWorkspaces() {
- Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this));
+ Services.prefs.addObserver(
+ "zen.workspaces.enabled",
+ this.onWorkspacesEnabledChanged.bind(this),
+ );
this.initializeWorkspacesButton();
let file = new FileUtils.File(this._storeFile);
if (!file.exists()) {
@@ -63,9 +69,13 @@ var ZenWorkspaces = {
if (workspaces.workspaces.length === 0) {
await this.createAndSaveWorkspace("Default Workspace", true);
} else {
- let activeWorkspace = workspaces.workspaces.find(workspace => workspace.used);
+ let activeWorkspace = workspaces.workspaces.find(
+ (workspace) => workspace.used,
+ );
if (!activeWorkspace) {
- activeWorkspace = workspaces.workspaces.find(workspace => workspace.default);
+ activeWorkspace = workspaces.workspaces.find(
+ (workspace) => workspace.default,
+ );
activeWorkspace.used = true;
await this.saveWorkspaces();
}
@@ -90,7 +100,9 @@ var ZenWorkspaces = {
let workspaceID = tab.getAttribute("zen-workspace-id");
// If the tab is the last one in the workspace, create a new tab
if (workspaceID) {
- let tabs = gBrowser.tabs.filter(tab => tab.getAttribute("zen-workspace-id") === workspaceID);
+ let tabs = gBrowser.tabs.filter(
+ (tab) => tab.getAttribute("zen-workspace-id") === workspaceID,
+ );
if (tabs.length === 1) {
this._createNewTabForWorkspace({ uuid: workspaceID });
// We still need to close other tabs in the workspace
@@ -102,7 +114,9 @@ var ZenWorkspaces = {
_kIcons: ["🏠", "📄", "💹", "💼", "📧", "✅", "👥"],
_initializeWorkspaceCreationIcons() {
- let container = document.getElementById("PanelUI-zen-workspaces-create-icons-container");
+ let container = document.getElementById(
+ "PanelUI-zen-workspaces-create-icons-container",
+ );
for (let icon of this._kIcons) {
let button = document.createXULElement("toolbarbutton");
button.className = "toolbarbutton-1";
@@ -129,7 +143,7 @@ var ZenWorkspaces = {
button.onclick = ((event) => {
let wasSelected = button.hasAttribute("selected");
for (let button of container.children) {
- button.removeAttribute("selected");
+ button.removeAttribute("selected");
}
if (!wasSelected) {
button.setAttribute("selected", "true");
@@ -145,7 +159,9 @@ var ZenWorkspaces = {
if (typeof json.workspaces === "undefined") {
json.workspaces = [];
}
- let existing = json.workspaces.findIndex(workspace => workspace.uuid === workspaceData.uuid);
+ let existing = json.workspaces.findIndex(
+ (workspace) => workspace.uuid === workspaceData.uuid,
+ );
if (existing >= 0) {
json.workspaces[existing] = workspaceData;
} else {
@@ -154,16 +170,23 @@ var ZenWorkspaces = {
console.info("ZenWorkspaces: Saving workspace", workspaceData);
await IOUtils.writeJSON(this._storeFile, json);
this._workspaceCache = null;
+
+ await this._updateWorkspacesChangeContextMenu();
},
async removeWorkspace(windowID) {
let json = await this._workspaces();
console.info("ZenWorkspaces: Removing workspace", windowID);
- await this.changeWorkspace(json.workspaces.find(workspace => workspace.uuid !== windowID));
+ await this.changeWorkspace(
+ json.workspaces.find((workspace) => workspace.uuid !== windowID),
+ );
this._deleteAllTabsInWorkspace(windowID);
- json.workspaces = json.workspaces.filter(workspace => workspace.uuid !== windowID);
+ json.workspaces = json.workspaces.filter(
+ (workspace) => workspace.uuid !== windowID,
+ );
await this.unsafeSaveWorkspaces(json);
await this._propagateWorkspaceData();
+ await this._updateWorkspacesChangeContextMenu();
},
async saveWorkspaces() {
@@ -179,34 +202,55 @@ var ZenWorkspaces = {
// Workspaces dialog UI management
openSaveDialog() {
- let parentPanel = document.getElementById("PanelUI-zen-workspaces-multiview");
+ let parentPanel = document.getElementById(
+ "PanelUI-zen-workspaces-multiview",
+ );
PanelUI.showSubView("PanelUI-zen-workspaces-create", parentPanel);
},
async openEditDialog(workspaceUuid) {
- this._workspaceEditDialog.setAttribute("data-workspace-uuid", workspaceUuid);
- document.getElementById("PanelUI-zen-workspaces-edit-save").setAttribute("disabled", "true");
+ this._workspaceEditDialog.setAttribute(
+ "data-workspace-uuid",
+ workspaceUuid,
+ );
+ document
+ .getElementById("PanelUI-zen-workspaces-edit-save")
+ .setAttribute("disabled", "true");
let workspaces = (await this._workspaces()).workspaces;
- let workspaceData = workspaces.find(workspace => workspace.uuid === workspaceUuid);
+ let workspaceData = workspaces.find(
+ (workspace) => workspace.uuid === workspaceUuid,
+ );
this._workspaceEditInput.textContent = workspaceData.name;
this._workspaceEditInput.value = workspaceData.name;
- this._workspaceEditInput.setAttribute("data-initial-value", workspaceData.name);
- this._workspaceEditIconsContainer
- .setAttribute("data-initial-value", workspaceData.icon);
- document.querySelectorAll("#PanelUI-zen-workspaces-edit-icons-container toolbarbutton")
- .forEach(button => {
+ this._workspaceEditInput.setAttribute(
+ "data-initial-value",
+ workspaceData.name,
+ );
+ this._workspaceEditIconsContainer.setAttribute(
+ "data-initial-value",
+ workspaceData.icon,
+ );
+ document
+ .querySelectorAll(
+ "#PanelUI-zen-workspaces-edit-icons-container toolbarbutton",
+ )
+ .forEach((button) => {
if (button.label === workspaceData.icon) {
button.setAttribute("selected", "true");
} else {
button.removeAttribute("selected");
}
});
- let parentPanel = document.getElementById("PanelUI-zen-workspaces-multiview");
+ let parentPanel = document.getElementById(
+ "PanelUI-zen-workspaces-multiview",
+ );
PanelUI.showSubView("PanelUI-zen-workspaces-edit", parentPanel);
},
closeWorkspacesSubView() {
- let parentPanel = document.getElementById("PanelUI-zen-workspaces-multiview");
+ let parentPanel = document.getElementById(
+ "PanelUI-zen-workspaces-multiview",
+ );
parentPanel.goBack();
},
@@ -222,7 +266,9 @@ var ZenWorkspaces = {
},
async _propagateWorkspaceData() {
- let currentContainer = document.getElementById("PanelUI-zen-workspaces-current-info");
+ let currentContainer = document.getElementById(
+ "PanelUI-zen-workspaces-current-info",
+ );
let workspaceList = document.getElementById("PanelUI-zen-workspaces-list");
const createWorkspaceElement = (workspace) => {
let element = document.createXULElement("toolbarbutton");
@@ -239,33 +285,42 @@ var ZenWorkspaces = {