mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-05 17:36:34 +00:00
chore: Refactor ZenSidebarManager and ZenUIManager to improve tab handling
This commit is contained in:
@@ -438,8 +438,7 @@ var gZenBrowserManagerSidebar = {
|
||||
let data = this.sidebarData;
|
||||
let panel = data.data[this.contextTab];
|
||||
let url = (browser == null) ? panel.url : browser.currentURI.spec;
|
||||
let tab = gBrowser.addTrustedTab(url);
|
||||
gBrowser.selectedTab = tab;
|
||||
gZenUIManager.openAndChangeToTab(url);
|
||||
this.close();
|
||||
},
|
||||
|
||||
|
@@ -1,4 +1,12 @@
|
||||
|
||||
var gZenUIManager = {
|
||||
|
||||
openAndChangeToTab(url, options) {
|
||||
if (window.ownerGlobal.parent) {
|
||||
let tab = window.ownerGlobal.parent.gBrowser.addTrustedTab(url, options);
|
||||
window.ownerGlobal.parent.gBrowser.selectedTab = tab;
|
||||
return;
|
||||
}
|
||||
let tab = window.gBrowser.addTrustedTab(url, options);
|
||||
window.gBrowser.selectedTab = tab;
|
||||
}
|
||||
};
|
||||
|
@@ -14,9 +14,12 @@ ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
'ExtensionSettingsStore',
|
||||
'resource://gre/modules/ExtensionSettingsStore.jsm'
|
||||
)
|
||||
);
|
||||
|
||||
const welcomeSeenPref = 'zen.welcomeScreen.seen'
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/ZenUIManager.mjs");
|
||||
|
||||
const kWelcomeURL = 'https://get-zen.vercel.app/welcome';
|
||||
const kWelcomeSeenPref = 'zen.welcomeScreen.seen'
|
||||
|
||||
// =============================================================================
|
||||
// Util stuff copied from browser/components/preferences/search.js
|
||||
@@ -305,6 +308,7 @@ class Pages {
|
||||
* @param {Page[]} pages The pages
|
||||
*/
|
||||
constructor(pages) {
|
||||
console.log("Initializing welcome pages...");
|
||||
this.pages = pages
|
||||
this.currentPage = 0;
|
||||
|
||||
@@ -324,6 +328,7 @@ class Pages {
|
||||
dots.appendChild(dot);
|
||||
}
|
||||
this._displayCurrentPage();
|
||||
console.log("Welcome pages initialized.")
|
||||
}
|
||||
|
||||
next() {
|
||||
@@ -333,15 +338,20 @@ class Pages {
|
||||
// We can use internal js apis to close the window. We also want to set
|
||||
// the settings api for welcome seen to false to stop it showing again
|
||||
|
||||
Services.prefs.setBoolPref(welcomeSeenPref, true)
|
||||
Services.prefs.setBoolPref(kWelcomeSeenPref, true)
|
||||
|
||||
close()
|
||||
close();
|
||||
this._openWelcomePage();
|
||||
return
|
||||
}
|
||||
|
||||
this._displayCurrentPage()
|
||||
}
|
||||
|
||||
_openWelcomePage() {
|
||||
gZenUIManager.openAndChangeToTab(kWelcomeURL);
|
||||
}
|
||||
|
||||
_displayCurrentPage() {
|
||||
let dots = document.getElementsByClassName("dot");
|
||||
for (let i = 0; i < dots.length; i++) {
|
||||
|
@@ -503,7 +503,7 @@ panelmultiview {
|
||||
}
|
||||
|
||||
#navigator-toolbox:hover #titlebar,
|
||||
#navigator-toolbox:has([open="true"]) #titlebar {
|
||||
#navigator-toolbox:has([open="true"]:not(tab)) #titlebar {
|
||||
background: var(--zen-themed-toolbar-bg) !important;
|
||||
border-right: var(--zen-appcontent-border) !important;
|
||||
padding: 0 5px;
|
||||
|
Reference in New Issue
Block a user