Remove unused CSS files related to Zen theme

This commit is contained in:
Mauro Balades
2024-08-14 13:37:40 +02:00
parent 194056007a
commit 36e7fdad8b
9 changed files with 122 additions and 125 deletions

View File

@@ -33,12 +33,13 @@ var ZenThemeModifier = {
init() {
this._inMainBrowserWindow = window.location.href == "chrome://browser/content/browser.xhtml";
this.listenForEvents();
this.updateExtraBrowserStyles();
this.updateAllThemeBasics();
this._zenInitBrowserLayout();
this._onPrefersColorSchemeChange();
},
listenForEvents() {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', this._onPrefersColorSchemeChange.bind(this));
Services.prefs.addObserver(kZenThemeAccentColorPref, this.handleEvent.bind(this));
Services.prefs.addObserver(kZenThemeBorderRadiusPref, this.handleEvent.bind(this));
},
@@ -74,96 +75,8 @@ var ZenThemeModifier = {
}
},
updateExtraBrowserStyles() {
// If we are in the main browser window, we can add some extra styles.
if (!this._inMainBrowserWindow) return;
this._changeSidebarLocation();
},
_changeSidebarLocation() {
const kElementsToAppend = [
"sidebar-splitter",
"sidebar-box",
"navigator-toolbox",
];
const wrapper = document.getElementById("zen-tabbox-wrapper");
const appWrapepr = document.getElementById("zen-sidebar-box-container");
for (let id of kElementsToAppend) {
const elem = document.getElementById(id);
if (elem) {
wrapper.prepend(elem);
}
}
appWrapepr.setAttribute("hidden", "true");
// 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");
const titlebar = document.getElementById("navigator-toolbox");
titlebar.insertAdjacentElement("afterend", splitter);
},
_zenInitBrowserLayout() {
if (!this._inMainBrowserWindow) return;
if (this.__hasInitBrowserLayout) return;
this.__hasInitBrowserLayout = true;
this.openWatermark();
console.info("ZenThemeModifier: init browser layout");
const kNavbarItems = [
"nav-bar",
"PersonalToolbar"
];
const kNewContainerId = "zen-appcontent-navbar-container";
let newContainer = document.getElementById(kNewContainerId);
for (let id of kNavbarItems) {
const node = document.getElementById(id);
console.assert(node, "Could not find node with id: " + id);
if (!node) continue;
newContainer.appendChild(node);
}
// Fix notification deck
document.getElementById("zen-appcontent-navbar-container")
.appendChild(document.getElementById("tab-notification-deck-template"));
gZenVerticalTabsManager.init();
gZenCompactModeManager.init();
gZenKeyboardShortcuts.init();
_onPrefersColorSchemeChange() {
this._updateZenAvatar();
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', this._onPrefersColorSchemeChange.bind(this));
function throttle(f, delay) {
let timer = 0;
return function(...args) {
clearTimeout(timer);
timer = setTimeout(() => f.apply(this, args), delay);
}
}
new ResizeObserver(throttle(
this._updateTabsToolbar.bind(this), 1000
)).observe(document.getElementById("tabbrowser-tabs"));
this.closeWatermark();
},
_onPrefersColorSchemeChange(event) {
this._updateZenAvatar();
},
_updateTabsToolbar() {
// Set tabs max-height to the "toolbar-items" height
const toolbarItems = document.getElementById("tabbrowser-tabs");
const tabs = document.getElementById("tabbrowser-arrowscrollbox");
tabs.style.maxHeight = '0px'; // reset to 0
const toolbarRect = toolbarItems.getBoundingClientRect();
// -5 for the controls padding
tabs.style.maxHeight = toolbarRect.height - 5 + "px";
console.info("ZenThemeModifier: set tabs max-height to", toolbarRect.height + "px");
},
_updateZenAvatar() {
@@ -192,23 +105,6 @@ var ZenThemeModifier = {
let scheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? "dark" : "light";
return `${withoutExtension}-${scheme}.svg`;
},
openWatermark() {
if (!Services.prefs.getBoolPref("zen.watermark.enabled", false)) {
return;
}
const watermark = document.getElementById("zen-watermark");
if (watermark) {
watermark.removeAttribute("hidden");
}
},
closeWatermark() {
const watermark = document.getElementById("zen-watermark");
if (watermark) {
watermark.setAttribute("hidden", "true");
}
},
};
if (typeof Services !== "undefined")