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
This commit is contained in:
mr. M 2024-10-30 13:44:29 +01:00
parent 5eb4fb0d0d
commit 5daa3ffa53
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB
2 changed files with 17 additions and 1 deletions

View file

@ -136,7 +136,7 @@
} }
closeGlance({ noAnimation = false } = {}) { closeGlance({ noAnimation = false } = {}) {
if (this.#animating) { if (this.#animating || !this.#currentBrowser) {
return; return;
} }

View file

@ -270,6 +270,22 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
openSaveDialog() { openSaveDialog() {
let parentPanel = document.getElementById('PanelUI-zen-workspaces-multiview'); 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); PanelUI.showSubView('PanelUI-zen-workspaces-create', parentPanel);
} }