mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-05 09:26: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 data = this.sidebarData;
|
||||||
let panel = data.data[this.contextTab];
|
let panel = data.data[this.contextTab];
|
||||||
let url = (browser == null) ? panel.url : browser.currentURI.spec;
|
let url = (browser == null) ? panel.url : browser.currentURI.spec;
|
||||||
let tab = gBrowser.addTrustedTab(url);
|
gZenUIManager.openAndChangeToTab(url);
|
||||||
gBrowser.selectedTab = tab;
|
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -1,4 +1,12 @@
|
|||||||
|
|
||||||
var gZenUIManager = {
|
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,
|
this,
|
||||||
'ExtensionSettingsStore',
|
'ExtensionSettingsStore',
|
||||||
'resource://gre/modules/ExtensionSettingsStore.jsm'
|
'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
|
// Util stuff copied from browser/components/preferences/search.js
|
||||||
@@ -305,6 +308,7 @@ class Pages {
|
|||||||
* @param {Page[]} pages The pages
|
* @param {Page[]} pages The pages
|
||||||
*/
|
*/
|
||||||
constructor(pages) {
|
constructor(pages) {
|
||||||
|
console.log("Initializing welcome pages...");
|
||||||
this.pages = pages
|
this.pages = pages
|
||||||
this.currentPage = 0;
|
this.currentPage = 0;
|
||||||
|
|
||||||
@@ -324,6 +328,7 @@ class Pages {
|
|||||||
dots.appendChild(dot);
|
dots.appendChild(dot);
|
||||||
}
|
}
|
||||||
this._displayCurrentPage();
|
this._displayCurrentPage();
|
||||||
|
console.log("Welcome pages initialized.")
|
||||||
}
|
}
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
@@ -333,15 +338,20 @@ class Pages {
|
|||||||
// We can use internal js apis to close the window. We also want to set
|
// 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
|
// 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this._displayCurrentPage()
|
this._displayCurrentPage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_openWelcomePage() {
|
||||||
|
gZenUIManager.openAndChangeToTab(kWelcomeURL);
|
||||||
|
}
|
||||||
|
|
||||||
_displayCurrentPage() {
|
_displayCurrentPage() {
|
||||||
let dots = document.getElementsByClassName("dot");
|
let dots = document.getElementsByClassName("dot");
|
||||||
for (let i = 0; i < dots.length; i++) {
|
for (let i = 0; i < dots.length; i++) {
|
||||||
|
@@ -503,7 +503,7 @@ panelmultiview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#navigator-toolbox:hover #titlebar,
|
#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;
|
background: var(--zen-themed-toolbar-bg) !important;
|
||||||
border-right: var(--zen-appcontent-border) !important;
|
border-right: var(--zen-appcontent-border) !important;
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
|
Reference in New Issue
Block a user