From 5daa3ffa53ebd4c7edd562767ea8ce35e9a4d291 Mon Sep 17 00:00:00 2001 From: "mr. M" Date: Wed, 30 Oct 2024 13:44:29 +0100 Subject: [PATCH] Refactor ZenGlanceManager.mjs to prevent opening multiple glances when animation is in progress or there is no current browser Refactor ZenWorkspaces.mjs to update the save dialog with a randomly selected icon --- src/ZenGlanceManager.mjs | 2 +- src/ZenWorkspaces.mjs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ZenGlanceManager.mjs b/src/ZenGlanceManager.mjs index 3fb086f..443a27c 100644 --- a/src/ZenGlanceManager.mjs +++ b/src/ZenGlanceManager.mjs @@ -136,7 +136,7 @@ } closeGlance({ noAnimation = false } = {}) { - if (this.#animating) { + if (this.#animating || !this.#currentBrowser) { return; } diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index b6f31c5..7ce030d 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -270,6 +270,22 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { openSaveDialog() { let parentPanel = document.getElementById('PanelUI-zen-workspaces-multiview'); + + // randomly select an icon + let icon = this._kIcons[Math.floor(Math.random() * this._kIcons.length)]; + this._workspaceCreateInput.textContent = ''; + this._workspaceCreateInput.value = ''; + this._workspaceCreateInput.setAttribute('data-initial-value', ''); + this._workspaceCreateIconsContainer.setAttribute('data-initial-value', icon); + document.querySelectorAll('#PanelUI-zen-workspaces-icon-picker-wrapper toolbarbutton').forEach((button) => { + if (button.label === icon) { + button.setAttribute('selected', 'true'); + } else { + button.removeAttribute('selected'); + } + }); + document.querySelector('.PanelUI-zen-workspaces-icons-container.create').textContent = icon; + PanelUI.showSubView('PanelUI-zen-workspaces-create', parentPanel); }