mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 16:19:58 +02:00
Merge branch 'zen-browser:main' into main
This commit is contained in:
commit
1dcfec3d5a
1 changed files with 22 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
var ZenWorkspaces = {
|
var ZenWorkspaces = {
|
||||||
async init() {
|
async init() {
|
||||||
let docElement = document.documentElement;
|
let docElement = document.documentElement;
|
||||||
|
@ -95,7 +96,7 @@ var ZenWorkspaces = {
|
||||||
if (tabs.length === 1) {
|
if (tabs.length === 1) {
|
||||||
this._createNewTabForWorkspace({ uuid: workspaceID });
|
this._createNewTabForWorkspace({ uuid: workspaceID });
|
||||||
// We still need to close other tabs in the workspace
|
// We still need to close other tabs in the workspace
|
||||||
this.changeWorkspace({ uuid: workspaceID });
|
this.changeWorkspace({ uuid: workspaceID }, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -469,10 +470,15 @@ var ZenWorkspaces = {
|
||||||
button.removeAttribute('disabled');
|
button.removeAttribute('disabled');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get _shouldAllowPinTab() {
|
||||||
|
return Services.prefs.getBoolPref('zen.workspaces.individual-pinned-tabs');
|
||||||
|
},
|
||||||
|
|
||||||
async changeWorkspace(window, onInit = false) {
|
async changeWorkspace(window, onInit = false) {
|
||||||
if (!this.workspaceEnabled) {
|
if (!this.workspaceEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const shouldAllowPinnedTabs = this._shouldAllowPinTab;
|
||||||
let firstTab = undefined;
|
let firstTab = undefined;
|
||||||
let workspaces = await this._workspaces();
|
let workspaces = await this._workspaces();
|
||||||
for (let workspace of workspaces.workspaces) {
|
for (let workspace of workspaces.workspaces) {
|
||||||
|
@ -481,7 +487,7 @@ var ZenWorkspaces = {
|
||||||
this.unsafeSaveWorkspaces(workspaces);
|
this.unsafeSaveWorkspaces(workspaces);
|
||||||
console.info('ZenWorkspaces: Changing workspace to', window.uuid);
|
console.info('ZenWorkspaces: Changing workspace to', window.uuid);
|
||||||
for (let tab of gBrowser.tabs) {
|
for (let tab of gBrowser.tabs) {
|
||||||
if ((tab.getAttribute('zen-workspace-id') === window.uuid && !tab.pinned) || !tab.hasAttribute('zen-workspace-id')) {
|
if ((tab.getAttribute('zen-workspace-id') === window.uuid && !(tab.pinned && !shouldAllowPinnedTabs)) || !tab.hasAttribute('zen-workspace-id')) {
|
||||||
if (!firstTab) {
|
if (!firstTab) {
|
||||||
firstTab = tab;
|
firstTab = tab;
|
||||||
} else if (gBrowser.selectedTab === tab) {
|
} else if (gBrowser.selectedTab === tab) {
|
||||||
|
@ -504,7 +510,7 @@ var ZenWorkspaces = {
|
||||||
}
|
}
|
||||||
for (let tab of gBrowser.tabs) {
|
for (let tab of gBrowser.tabs) {
|
||||||
if (tab.getAttribute('zen-workspace-id') !== window.uuid) {
|
if (tab.getAttribute('zen-workspace-id') !== window.uuid) {
|
||||||
gBrowser.hideTab(tab);
|
gBrowser.hideTab(tab, undefined, shouldAllowPinnedTabs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.documentElement.setAttribute('zen-workspace-id', window.uuid);
|
document.documentElement.setAttribute('zen-workspace-id', window.uuid);
|
||||||
|
@ -512,6 +518,8 @@ var ZenWorkspaces = {
|
||||||
await this._updateWorkspacesButton();
|
await this._updateWorkspacesButton();
|
||||||
await this._propagateWorkspaceData();
|
await this._propagateWorkspaceData();
|
||||||
await this._updateWorkspacesChangeContextMenu();
|
await this._updateWorkspacesChangeContextMenu();
|
||||||
|
|
||||||
|
document.getElementById('tabbrowser-tabs')._positionPinnedTabs();
|
||||||
},
|
},
|
||||||
|
|
||||||
async _updateWorkspacesChangeContextMenu() {
|
async _updateWorkspacesChangeContextMenu() {
|
||||||
|
@ -683,6 +691,17 @@ var ZenWorkspaces = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Tab browser utilities
|
// Tab browser utilities
|
||||||
|
createContainerTabMenu(event) {
|
||||||
|
let window = event.target.ownerGlobal;
|
||||||
|
const workspace = this._workspaceCache.workspaces.find((workspace) => this._contextMenuId === workspace.uuid);
|
||||||
|
let containerTabId = workspace.containerTabId;
|
||||||
|
return window.createUserContextMenu(event, {
|
||||||
|
isContextMenu: true,
|
||||||
|
excludeUserContextId: containerTabId,
|
||||||
|
showDefaultTab: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
getContextIdIfNeeded(userContextId) {
|
getContextIdIfNeeded(userContextId) {
|
||||||
if (typeof userContextId !== "undefined" || !this.workspaceEnabled) {
|
if (typeof userContextId !== "undefined" || !this.workspaceEnabled) {
|
||||||
return [userContextId, false];
|
return [userContextId, false];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue