mirror of
https://github.com/zen-browser/desktop.git
synced 2026-05-27 23:35:09 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e176c1ba41 |
@@ -5,6 +5,7 @@
|
|||||||
import checkForZenUpdates, {
|
import checkForZenUpdates, {
|
||||||
createWindowUpdateAnimation,
|
createWindowUpdateAnimation,
|
||||||
} from 'chrome://browser/content/ZenUpdates.mjs';
|
} from 'chrome://browser/content/ZenUpdates.mjs';
|
||||||
|
import { kDefaultSidebarWidth } from 'resource:///modules/ZenCustomizableUI.sys.mjs';
|
||||||
|
|
||||||
class ZenStartup {
|
class ZenStartup {
|
||||||
#watermarkIgnoreElements = ['zen-toast-container'];
|
#watermarkIgnoreElements = ['zen-toast-container'];
|
||||||
@@ -14,9 +15,11 @@ class ZenStartup {
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.openWatermark();
|
this.openWatermark();
|
||||||
this.#initBrowserBackground();
|
gZenKeyboardShortcutsManager.beforeInit();
|
||||||
this.#changeSidebarLocation();
|
gZenWorkspaces.init().then(() => {
|
||||||
this.#zenInitBrowserLayout();
|
this.#initBrowserBackground();
|
||||||
|
this.#zenInitBrowserLayout();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#initBrowserBackground() {
|
#initBrowserBackground() {
|
||||||
@@ -36,7 +39,7 @@ class ZenStartup {
|
|||||||
#zenInitBrowserLayout() {
|
#zenInitBrowserLayout() {
|
||||||
if (this.#hasInitializedLayout) return;
|
if (this.#hasInitializedLayout) return;
|
||||||
this.#hasInitializedLayout = true;
|
this.#hasInitializedLayout = true;
|
||||||
gZenKeyboardShortcutsManager.beforeInit();
|
this.#changeSidebarLocation();
|
||||||
try {
|
try {
|
||||||
const kNavbarItems = ['nav-bar', 'PersonalToolbar'];
|
const kNavbarItems = ['nav-bar', 'PersonalToolbar'];
|
||||||
const kNewContainerId = 'zen-appcontent-navbar-container';
|
const kNewContainerId = 'zen-appcontent-navbar-container';
|
||||||
@@ -54,16 +57,13 @@ class ZenStartup {
|
|||||||
document.getElementById('zen-appcontent-wrapper').prepend(deckTemplate);
|
document.getElementById('zen-appcontent-wrapper').prepend(deckTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
gZenWorkspaces.init();
|
gZenUIManager.init();
|
||||||
setTimeout(() => {
|
this.#checkForWelcomePage();
|
||||||
gZenUIManager.init();
|
|
||||||
this.#checkForWelcomePage();
|
|
||||||
}, 0);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('ZenThemeModifier: Error initializing browser layout', e);
|
console.error('ZenThemeModifier: Error initializing browser layout', e);
|
||||||
}
|
}
|
||||||
if (gBrowserInit.delayedStartupFinished) {
|
if (gBrowserInit.delayedStartupFinished) {
|
||||||
this.delayedStartupFinished();
|
this.#delayedStartupFinished();
|
||||||
} else {
|
} else {
|
||||||
Services.obs.addObserver(this, 'browser-delayed-startup-finished');
|
Services.obs.addObserver(this, 'browser-delayed-startup-finished');
|
||||||
}
|
}
|
||||||
@@ -74,14 +74,12 @@ class ZenStartup {
|
|||||||
// this window has finished painting and starting up.
|
// this window has finished painting and starting up.
|
||||||
if (aTopic == 'browser-delayed-startup-finished' && aSubject == window) {
|
if (aTopic == 'browser-delayed-startup-finished' && aSubject == window) {
|
||||||
Services.obs.removeObserver(this, 'browser-delayed-startup-finished');
|
Services.obs.removeObserver(this, 'browser-delayed-startup-finished');
|
||||||
this.delayedStartupFinished();
|
this.#delayedStartupFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delayedStartupFinished() {
|
#delayedStartupFinished() {
|
||||||
gZenWorkspaces.promiseInitialized.then(async () => {
|
gZenWorkspaces.promiseInitialized.then(() => {
|
||||||
await delayedStartupPromise;
|
|
||||||
await SessionStore.promiseAllWindowsRestored;
|
|
||||||
delete gZenUIManager.promiseInitialized;
|
delete gZenUIManager.promiseInitialized;
|
||||||
this.#initSearchBar();
|
this.#initSearchBar();
|
||||||
gZenCompactModeManager.init();
|
gZenCompactModeManager.init();
|
||||||
@@ -141,6 +139,20 @@ class ZenStartup {
|
|||||||
const browser = document.getElementById('browser');
|
const browser = document.getElementById('browser');
|
||||||
browser.prepend(gNavToolbox);
|
browser.prepend(gNavToolbox);
|
||||||
|
|
||||||
|
// Set a splitter to navigator-toolbox
|
||||||
|
const splitter = document.createXULElement('splitter');
|
||||||
|
splitter.setAttribute('id', 'zen-sidebar-splitter');
|
||||||
|
splitter.setAttribute('orient', 'horizontal');
|
||||||
|
splitter.setAttribute('resizebefore', 'sibling');
|
||||||
|
splitter.setAttribute('resizeafter', 'none');
|
||||||
|
gNavToolbox.insertAdjacentElement('afterend', splitter);
|
||||||
|
|
||||||
|
splitter.addEventListener('dblclick', (e) => {
|
||||||
|
if (e.button !== 0) return;
|
||||||
|
gNavToolbox.style.width = kDefaultSidebarWidth;
|
||||||
|
gNavToolbox.setAttribute('width', kDefaultSidebarWidth);
|
||||||
|
});
|
||||||
|
|
||||||
const sidebarPanelWrapper = document.getElementById('tabbrowser-tabbox');
|
const sidebarPanelWrapper = document.getElementById('tabbrowser-tabbox');
|
||||||
for (let id of kElementsToAppend) {
|
for (let id of kElementsToAppend) {
|
||||||
const elem = document.getElementById(id);
|
const elem = document.getElementById(id);
|
||||||
@@ -178,7 +190,7 @@ class ZenStartup {
|
|||||||
window.gZenStartup = new ZenStartup();
|
window.gZenStartup = new ZenStartup();
|
||||||
|
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
'MozBeforeInitialXULLayout',
|
'load',
|
||||||
() => {
|
() => {
|
||||||
gZenStartup.init();
|
gZenStartup.init();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
import { AppConstants } from 'resource://gre/modules/AppConstants.sys.mjs';
|
import { AppConstants } from 'resource://gre/modules/AppConstants.sys.mjs';
|
||||||
|
|
||||||
|
export const kDefaultSidebarWidth = AppConstants.platform === 'macosx' ? '230px' : '186px';
|
||||||
|
|
||||||
export const ZenCustomizableUI = new (class {
|
export const ZenCustomizableUI = new (class {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
@@ -39,17 +41,8 @@ export const ZenCustomizableUI = new (class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#addSidebarButtons(window) {
|
#addSidebarButtons(window) {
|
||||||
const kDefaultSidebarWidth = AppConstants.platform === 'macosx' ? '230px' : '186px';
|
|
||||||
const toolbox = window.gNavToolbox;
|
const toolbox = window.gNavToolbox;
|
||||||
|
|
||||||
// Set a splitter to navigator-toolbox
|
|
||||||
const splitter = window.document.createXULElement('splitter');
|
|
||||||
splitter.setAttribute('id', 'zen-sidebar-splitter');
|
|
||||||
splitter.setAttribute('orient', 'horizontal');
|
|
||||||
splitter.setAttribute('resizebefore', 'sibling');
|
|
||||||
splitter.setAttribute('resizeafter', 'none');
|
|
||||||
toolbox.insertAdjacentElement('afterend', splitter);
|
|
||||||
|
|
||||||
const sidebarBox = window.MozXULElement.parseXULToFragment(`
|
const sidebarBox = window.MozXULElement.parseXULToFragment(`
|
||||||
<toolbar id="zen-sidebar-top-buttons"
|
<toolbar id="zen-sidebar-top-buttons"
|
||||||
fullscreentoolbar="true"
|
fullscreentoolbar="true"
|
||||||
@@ -94,12 +87,6 @@ export const ZenCustomizableUI = new (class {
|
|||||||
toolbox.style.width = width;
|
toolbox.style.width = width;
|
||||||
toolbox.setAttribute('width', width);
|
toolbox.setAttribute('width', width);
|
||||||
|
|
||||||
splitter.addEventListener('dblclick', (e) => {
|
|
||||||
if (e.button !== 0) return;
|
|
||||||
toolbox.style.width = kDefaultSidebarWidth;
|
|
||||||
toolbox.setAttribute('width', kDefaultSidebarWidth);
|
|
||||||
});
|
|
||||||
|
|
||||||
const newTab = window.document.getElementById('vertical-tabs-newtab-button');
|
const newTab = window.document.getElementById('vertical-tabs-newtab-button');
|
||||||
newTab.classList.add('zen-sidebar-action-button');
|
newTab.classList.add('zen-sidebar-action-button');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user