Refactor ZenCompactModeManager and add ZenCompactMode.mjs

This commit is contained in:
mauro-balades
2024-09-21 13:24:06 +02:00
parent 14f4dfc12a
commit aef6c2ac48
5 changed files with 4 additions and 75 deletions

2
l10n

Submodule l10n updated: 6934ff4f19...1d1873c8e4

View File

@@ -191,76 +191,3 @@ var gZenVerticalTabsManager = {
Services.prefs.setBoolPref('zen.view.sidebar-expanded.on-hover', false);
},
};
var gZenCompactModeManager = {
_flashSidebarTimeout: null,
init() {
Services.prefs.addObserver('zen.view.compact', this._updateEvent.bind(this));
Services.prefs.addObserver('zen.view.compact.toolbar-flash-popup.duration', this._updatedSidebarFlashDuration.bind(this));
gZenUIManager.addPopupTrackingAttribute(this.sidebar);
gZenUIManager.addPopupTrackingAttribute(document.getElementById('zen-appcontent-navbar-container'));
},
get prefefence() {
return Services.prefs.getBoolPref('zen.view.compact');
},
set preference(value) {
Services.prefs.setBoolPref('zen.view.compact', value);
},
get sidebar() {
if (!this._sidebar) {
this._sidebar= document.getElementById('navigator-toolbox');
}
return this._sidebar;
},
_updateEvent() {
Services.prefs.setBoolPref('zen.view.sidebar-expanded.on-hover', false);
},
toggle() {
this.preference = !this.prefefence;
},
_updatedSidebarFlashDuration() {
this._flashSidebarDuration = Services.prefs.getIntPref('zen.view.compact.toolbar-flash-popup.duration');
},
toggleSidebar() {
this.sidebar.toggleAttribute('zen-user-show');
},
get flashSidebarDuration() {
if (this._flashSidebarDuration) {
return this._flashSidebarDuration;
}
return Services.prefs.getIntPref('zen.view.compact.toolbar-flash-popup.duration');
},
flashSidebar() {
let tabPanels = document.getElementById('tabbrowser-tabpanels');
if (this.sidebar.matches(':hover') || tabPanels.matches("[zen-split-view='true']")) {
return;
}
if (this._flashSidebarTimeout) {
clearTimeout(this._flashSidebarTimeout);
} else {
window.requestAnimationFrame(() => this.sidebar.setAttribute('flash-popup', ''));
}
this._flashSidebarTimeout = setTimeout(() => {
window.requestAnimationFrame(() => {
this.sidebar.removeAttribute('flash-popup');
this._flashSidebarTimeout = null;
});
}, this.flashSidebarDuration);
},
toggleToolbar() {
let toolbar = document.getElementById('zen-appcontent-navbar-container');
toolbar.toggleAttribute('zen-user-show');
},
};

View File

@@ -33,6 +33,7 @@ window.addEventListener("DOMContentLoaded", async () => {
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenWorkspaces.mjs");
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenViewSplitter.mjs");
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenProfileDialogUI.mjs");
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenCompactMode.mjs");
Services.scriptloader.loadSubScript("chrome://browser/content/zen-components/ZenKeyboardShortcuts.mjs");
}, { once: true });
</script>

View File

@@ -3,6 +3,7 @@
content/browser/zenThemeModifier.js (content/zenThemeModifier.js)
content/browser/ZenStartup.mjs (content/ZenStartup.mjs)
content/browser/ZenUIManager.mjs (content/ZenUIManager.mjs)
content/browser/ZenCompactMode.mjs (content/ZenCompactMode.mjs)
content/browser/zen-components/ZenViewSplitter.mjs (content/zen-components/src/ZenViewSplitter.mjs)
content/browser/zen-components/ZenThemesCommon.mjs (content/zen-components/src/ZenThemesCommon.mjs)
content/browser/zen-components/ZenWorkspaces.mjs (content/zen-components/src/ZenWorkspaces.mjs)