Fix: Remove accidentally added indents

This commit is contained in:
Kristijan Ribarić 2024-11-02 21:16:04 +01:00
parent 49a83678ba
commit 56999c42ba

View file

@ -13,17 +13,17 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} }
this.ownerWindow = window; this.ownerWindow = window;
XPCOMUtils.defineLazyPreferenceGetter( XPCOMUtils.defineLazyPreferenceGetter(
this, this,
'shouldShowIconStrip', 'shouldShowIconStrip',
'zen.workspaces.show-icon-strip', 'zen.workspaces.show-icon-strip',
true, true,
this._expandWorkspacesStrip.bind(this) this._expandWorkspacesStrip.bind(this)
); );
XPCOMUtils.defineLazyPreferenceGetter( XPCOMUtils.defineLazyPreferenceGetter(
this, this,
'shouldForceContainerTabsToWorkspace', 'shouldForceContainerTabsToWorkspace',
'zen.workspaces.force-container-workspace', 'zen.workspaces.force-container-workspace',
true true
); );
XPCOMUtils.defineLazyPreferenceGetter( XPCOMUtils.defineLazyPreferenceGetter(
this, this,
@ -60,9 +60,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
const lastChangeTimestamp = await ZenWorkspacesStorage.getLastChangeTimestamp(); const lastChangeTimestamp = await ZenWorkspacesStorage.getLastChangeTimestamp();
if ( if (
!this._workspaceCache || !this._workspaceCache ||
!this._workspaceCache.lastChangeTimestamp || !this._workspaceCache.lastChangeTimestamp ||
lastChangeTimestamp > this._workspaceCache.lastChangeTimestamp lastChangeTimestamp > this._workspaceCache.lastChangeTimestamp
) { ) {
await this._propagateWorkspaceData(); await this._propagateWorkspaceData();
@ -79,9 +79,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (typeof this._shouldHaveWorkspaces === 'undefined') { if (typeof this._shouldHaveWorkspaces === 'undefined') {
let docElement = document.documentElement; let docElement = document.documentElement;
this._shouldHaveWorkspaces = !( this._shouldHaveWorkspaces = !(
docElement.hasAttribute('privatebrowsingmode') || docElement.hasAttribute('privatebrowsingmode') ||
docElement.getAttribute('chromehidden').includes('toolbar') || docElement.getAttribute('chromehidden').includes('toolbar') ||
docElement.getAttribute('chromehidden').includes('menubar') docElement.getAttribute('chromehidden').includes('menubar')
); );
return this._shouldHaveWorkspaces; return this._shouldHaveWorkspaces;
} }
@ -213,7 +213,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} }
_kIcons = JSON.parse(Services.prefs.getStringPref('zen.workspaces.icons')).map((icon) => _kIcons = JSON.parse(Services.prefs.getStringPref('zen.workspaces.icons')).map((icon) =>
typeof Intl.Segmenter !== 'undefined' ? new Intl.Segmenter().segment(icon).containing().segment : Array.from(icon)[0] typeof Intl.Segmenter !== 'undefined' ? new Intl.Segmenter().segment(icon).containing().segment : Array.from(icon)[0]
); );
_initializeWorkspaceCreationIcons() { _initializeWorkspaceCreationIcons() {
@ -348,7 +348,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
get shouldShowContainers() { get shouldShowContainers() {
return ( return (
Services.prefs.getBoolPref('privacy.userContext.ui.enabled') && ContextualIdentityService.getPublicIdentities().length > 0 Services.prefs.getBoolPref('privacy.userContext.ui.enabled') && ContextualIdentityService.getPublicIdentities().length > 0
); );
} }
@ -367,7 +367,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
element.setAttribute('default', 'true'); element.setAttribute('default', 'true');
} }
const containerGroup = browser.ContextualIdentityService.getPublicIdentities().find( const containerGroup = browser.ContextualIdentityService.getPublicIdentities().find(
(container) => container.userContextId === workspace.containerTabId (container) => container.userContextId === workspace.containerTabId
); );
if (containerGroup) { if (containerGroup) {
element.classList.add('identity-color-' + containerGroup.color); element.classList.add('identity-color-' + containerGroup.color);
@ -378,76 +378,76 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} }
element.addEventListener( element.addEventListener(
'dragstart', 'dragstart',
function (event) { function (event) {
if (this.isReorderModeOn(browser)) { if (this.isReorderModeOn(browser)) {
this.draggedElement = element; this.draggedElement = element;
event.dataTransfer.effectAllowed = 'move'; event.dataTransfer.effectAllowed = 'move';
event.dataTransfer.setData('text/plain', element.getAttribute('zen-workspace-id')); event.dataTransfer.setData('text/plain', element.getAttribute('zen-workspace-id'));
element.classList.add('dragging'); element.classList.add('dragging');
} else { } else {
event.preventDefault();
}
}.bind(browser.ZenWorkspaces)
);
element.addEventListener(
'dragover',
function (event) {
if (this.isReorderModeOn(browser) && this.draggedElement) {
event.preventDefault();
event.dataTransfer.dropEffect = 'move';
}
}.bind(browser.ZenWorkspaces)
);
element.addEventListener(
'dragenter',
function (event) {
if (this.isReorderModeOn(browser) && this.draggedElement) {
element.classList.add('dragover');
}
}.bind(browser.ZenWorkspaces)
);
element.addEventListener(
'dragleave',
function (event) {
element.classList.remove('dragover');
}.bind(browser.ZenWorkspaces)
);
element.addEventListener(
'drop',
async function (event) {
event.preventDefault(); event.preventDefault();
element.classList.remove('dragover'); }
if (this.isReorderModeOn(browser)) { }.bind(browser.ZenWorkspaces)
const draggedWorkspaceId = event.dataTransfer.getData('text/plain');
const targetWorkspaceId = element.getAttribute('zen-workspace-id');
if (draggedWorkspaceId !== targetWorkspaceId) {
await this.moveWorkspace(draggedWorkspaceId, targetWorkspaceId);
}
if (this.draggedElement) {
this.draggedElement.classList.remove('dragging');
this.draggedElement = null;
}
}
}.bind(browser.ZenWorkspaces)
); );
element.addEventListener( element.addEventListener(
'dragend', 'dragover',
function (event) { function (event) {
if (this.isReorderModeOn(browser) && this.draggedElement) {
event.preventDefault();
event.dataTransfer.dropEffect = 'move';
}
}.bind(browser.ZenWorkspaces)
);
element.addEventListener(
'dragenter',
function (event) {
if (this.isReorderModeOn(browser) && this.draggedElement) {
element.classList.add('dragover');
}
}.bind(browser.ZenWorkspaces)
);
element.addEventListener(
'dragleave',
function (event) {
element.classList.remove('dragover');
}.bind(browser.ZenWorkspaces)
);
element.addEventListener(
'drop',
async function (event) {
event.preventDefault();
element.classList.remove('dragover');
if (this.isReorderModeOn(browser)) {
const draggedWorkspaceId = event.dataTransfer.getData('text/plain');
const targetWorkspaceId = element.getAttribute('zen-workspace-id');
if (draggedWorkspaceId !== targetWorkspaceId) {
await this.moveWorkspace(draggedWorkspaceId, targetWorkspaceId);
}
if (this.draggedElement) { if (this.draggedElement) {
this.draggedElement.classList.remove('dragging'); this.draggedElement.classList.remove('dragging');
this.draggedElement = null; this.draggedElement = null;
} }
const workspaceElements = browser.document.querySelectorAll('.zen-workspace-button'); }
for (const elem of workspaceElements) { }.bind(browser.ZenWorkspaces)
elem.classList.remove('dragover'); );
}
}.bind(browser.ZenWorkspaces) element.addEventListener(
'dragend',
function (event) {
if (this.draggedElement) {
this.draggedElement.classList.remove('dragging');
this.draggedElement = null;
}
const workspaceElements = browser.document.querySelectorAll('.zen-workspace-button');
for (const elem of workspaceElements) {
elem.classList.remove('dragover');
}
}.bind(browser.ZenWorkspaces)
); );
let childs = browser.MozXULElement.parseXULToFragment(` let childs = browser.MozXULElement.parseXULToFragment(`
@ -470,18 +470,18 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
childs.querySelector('.zen-workspace-name').textContent = workspace.name; childs.querySelector('.zen-workspace-name').textContent = workspace.name;
if (containerGroup) { if (containerGroup) {
childs.querySelector('.zen-workspace-container').textContent = ContextualIdentityService.getUserContextLabel( childs.querySelector('.zen-workspace-container').textContent = ContextualIdentityService.getUserContextLabel(
containerGroup.userContextId containerGroup.userContextId
); );
} }
childs.querySelector('.zen-workspace-actions').addEventListener( childs.querySelector('.zen-workspace-actions').addEventListener(
'command', 'command',
((event) => { ((event) => {
let button = event.target; let button = event.target;
this._contextMenuId = button.closest('toolbarbutton[zen-workspace-id]').getAttribute('zen-workspace-id'); this._contextMenuId = button.closest('toolbarbutton[zen-workspace-id]').getAttribute('zen-workspace-id');
const popup = button.ownerDocument.getElementById('zenWorkspaceActionsMenu'); const popup = button.ownerDocument.getElementById('zenWorkspaceActionsMenu');
popup.openPopup(button, 'after_end'); popup.openPopup(button, 'after_end');
}).bind(browser.ZenWorkspaces) }).bind(browser.ZenWorkspaces)
); );
element.appendChild(childs); element.appendChild(childs);
element.onclick = (async () => { element.onclick = (async () => {
@ -870,8 +870,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let button = document.getElementById('PanelUI-zen-workspaces-edit-save'); let button = document.getElementById('PanelUI-zen-workspaces-edit-save');
let name = this._workspaceEditInput.value; let name = this._workspaceEditInput.value;
if ( if (
name === this._workspaceEditInput.getAttribute('data-initial-value') && name === this._workspaceEditInput.getAttribute('data-initial-value') &&
icon === this._workspaceEditIconsContainer.getAttribute('data-initial-value') icon === this._workspaceEditIconsContainer.getAttribute('data-initial-value')
) { ) {
button.setAttribute('disabled', 'true'); button.setAttribute('disabled', 'true');
return; return;
@ -903,8 +903,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let firstTab = undefined; let firstTab = undefined;
for (let tab of gBrowser.tabs) { for (let tab of gBrowser.tabs) {
if ( if (
(tab.getAttribute('zen-workspace-id') === window.uuid && !(tab.pinned && !shouldAllowPinnedTabs)) || (tab.getAttribute('zen-workspace-id') === window.uuid && !(tab.pinned && !shouldAllowPinnedTabs)) ||
!tab.hasAttribute('zen-workspace-id') !tab.hasAttribute('zen-workspace-id')
) { ) {
if (!firstTab && (onInit || !tab.pinned)) { if (!firstTab && (onInit || !tab.pinned)) {
firstTab = tab; firstTab = tab;
@ -1037,13 +1037,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
async updateContextMenu(_) { async updateContextMenu(_) {
console.assert(this._contextMenuId, 'No context menu ID set'); console.assert(this._contextMenuId, 'No context menu ID set');
document document
.querySelector(`#PanelUI-zen-workspaces [zen-workspace-id="${this._contextMenuId}"] .zen-workspace-actions`) .querySelector(`#PanelUI-zen-workspaces [zen-workspace-id="${this._contextMenuId}"] .zen-workspace-actions`)
.setAttribute('active', 'true'); .setAttribute('active', 'true');
const workspaces = await this._workspaces(); const workspaces = await this._workspaces();
let deleteMenuItem = document.getElementById('context_zenDeleteWorkspace'); let deleteMenuItem = document.getElementById('context_zenDeleteWorkspace');
if ( if (
workspaces.workspaces.length <= 1 || workspaces.workspaces.length <= 1 ||
workspaces.workspaces.find((workspace) => workspace.uuid === this._contextMenuId).default workspaces.workspaces.find((workspace) => workspace.uuid === this._contextMenuId).default
) { ) {
deleteMenuItem.setAttribute('disabled', 'true'); deleteMenuItem.setAttribute('disabled', 'true');
} else { } else {
@ -1057,7 +1057,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} }
let openMenuItem = document.getElementById('context_zenOpenWorkspace'); let openMenuItem = document.getElementById('context_zenOpenWorkspace');
if ( if (
workspaces.workspaces.find((workspace) => workspace.uuid === this._contextMenuId && this.isWorkspaceActive(workspace)) workspaces.workspaces.find((workspace) => workspace.uuid === this._contextMenuId && this.isWorkspaceActive(workspace))
) { ) {
openMenuItem.setAttribute('disabled', 'true'); openMenuItem.setAttribute('disabled', 'true');
} else { } else {
@ -1081,7 +1081,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
onContextMenuClose() { onContextMenuClose() {
let target = document.querySelector( let target = document.querySelector(
`#PanelUI-zen-workspaces [zen-workspace-id="${this._contextMenuId}"] .zen-workspace-actions` `#PanelUI-zen-workspaces [zen-workspace-id="${this._contextMenuId}"] .zen-workspace-actions`
); );
if (target) { if (target) {
target.removeAttribute('active'); target.removeAttribute('active');
@ -1119,7 +1119,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let workspaceIndex = workspaces.workspaces.indexOf(activeWorkspace); let workspaceIndex = workspaces.workspaces.indexOf(activeWorkspace);
// note: offset can be negative // note: offset can be negative
let nextWorkspace = let nextWorkspace =
workspaces.workspaces[(workspaceIndex + offset + workspaces.workspaces.length) % workspaces.workspaces.length]; workspaces.workspaces[(workspaceIndex + offset + workspaces.workspaces.length) % workspaces.workspaces.length];
await this.changeWorkspace(nextWorkspace); await this.changeWorkspace(nextWorkspace);
} }