mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-08 19:06:38 +00:00
✨ Added new disable all button
This commit is contained in:
2
l10n
2
l10n
Submodule l10n updated: dd93803b84...07f5bf5d9b
Submodule src/browser/base/content/zen-components updated: d853fa8de4...2f2881814e
@@ -4,18 +4,33 @@
|
|||||||
var gZenMarketplaceManager = {
|
var gZenMarketplaceManager = {
|
||||||
async init() {
|
async init() {
|
||||||
const checkForUpdates = document.getElementById('zenThemeMarketplaceCheckForUpdates');
|
const checkForUpdates = document.getElementById('zenThemeMarketplaceCheckForUpdates');
|
||||||
if (!checkForUpdates) return; // We havent entered the settings page yet.
|
const header = document.getElementById('zenMarketplaceHeader');
|
||||||
if (this.__hasInitializedEvents) return;
|
|
||||||
|
if (!checkForUpdates || !header) {
|
||||||
|
return; // We haven't entered the settings page yet.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.__hasInitializedEvents) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
header.appendChild(this._initDisableAll());
|
||||||
|
|
||||||
this.__hasInitializedEvents = true;
|
this.__hasInitializedEvents = true;
|
||||||
|
|
||||||
await this._buildThemesList();
|
await this._buildThemesList();
|
||||||
|
|
||||||
Services.prefs.addObserver(this.updatePref, this);
|
Services.prefs.addObserver(this.updatePref, this);
|
||||||
var checkForUpdateClick = (event) => {
|
|
||||||
|
const checkForUpdateClick = (event) => {
|
||||||
if (event.target === checkForUpdates) {
|
if (event.target === checkForUpdates) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this._checkForThemeUpdates(event);
|
this._checkForThemeUpdates(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
checkForUpdates.addEventListener('click', checkForUpdateClick);
|
checkForUpdates.addEventListener('click', checkForUpdateClick);
|
||||||
|
|
||||||
document.addEventListener('ZenThemeMarketplace:CheckForUpdatesFinished', (event) => {
|
document.addEventListener('ZenThemeMarketplace:CheckForUpdatesFinished', (event) => {
|
||||||
checkForUpdates.disabled = false;
|
checkForUpdates.disabled = false;
|
||||||
const updates = event.detail.updates;
|
const updates = event.detail.updates;
|
||||||
@@ -29,6 +44,7 @@ var gZenMarketplaceManager = {
|
|||||||
error.hidden = false;
|
error.hidden = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('unload', () => {
|
window.addEventListener('unload', () => {
|
||||||
Services.prefs.removeObserver(this.updatePref, this);
|
Services.prefs.removeObserver(this.updatePref, this);
|
||||||
this.__hasInitializedEvents = false;
|
this.__hasInitializedEvents = false;
|
||||||
@@ -40,6 +56,31 @@ var gZenMarketplaceManager = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_initDisableAll() {
|
||||||
|
const areThemesDisabled = Services.prefs.getBoolPref('zen.themes.disable-all', false);
|
||||||
|
const browser = ZenThemesCommon.currentBrowser;
|
||||||
|
const mozToggle = document.createElement('moz-toggle');
|
||||||
|
|
||||||
|
mozToggle.className = 'zenThemeMarketplaceItemPreferenceToggle zenThemeMarketplaceDisableAllToggle';
|
||||||
|
mozToggle.pressed = !areThemesDisabled;
|
||||||
|
|
||||||
|
browser.document.l10n.setAttributes(mozToggle, `zen-theme-disable-all-${!areThemesDisabled ? 'enabled' : 'disabled'}`);
|
||||||
|
|
||||||
|
mozToggle.addEventListener('toggle', async (event) => {
|
||||||
|
const { pressed = false } = event.target || {};
|
||||||
|
|
||||||
|
this.themesList.style.display = pressed ? '' : 'none';
|
||||||
|
Services.prefs.setBoolPref('zen.themes.disable-all', !pressed);
|
||||||
|
browser.document.l10n.setAttributes(mozToggle, `zen-theme-disable-all-${pressed ? 'enabled' : 'disabled'}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (areThemesDisabled) {
|
||||||
|
this.themesList.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
return mozToggle;
|
||||||
|
},
|
||||||
|
|
||||||
async observe() {
|
async observe() {
|
||||||
ZenThemesCommon.resetThemesCache();
|
ZenThemesCommon.resetThemesCache();
|
||||||
await this._buildThemesList();
|
await this._buildThemesList();
|
||||||
@@ -85,6 +126,8 @@ var gZenMarketplaceManager = {
|
|||||||
const themes = await ZenThemesCommon.getThemes();
|
const themes = await ZenThemesCommon.getThemes();
|
||||||
const theme = themes[themeId];
|
const theme = themes[themeId];
|
||||||
|
|
||||||
|
console.log(`[ZenThemeMarketplaceParent:settings]: Disabling theme ${theme.name}`);
|
||||||
|
|
||||||
theme.enabled = false;
|
theme.enabled = false;
|
||||||
|
|
||||||
await IOUtils.writeJSON(ZenThemesCommon.themesDataFile, themes);
|
await IOUtils.writeJSON(ZenThemesCommon.themesDataFile, themes);
|
||||||
@@ -96,6 +139,8 @@ var gZenMarketplaceManager = {
|
|||||||
const themes = await ZenThemesCommon.getThemes();
|
const themes = await ZenThemesCommon.getThemes();
|
||||||
const theme = themes[themeId];
|
const theme = themes[themeId];
|
||||||
|
|
||||||
|
console.log(`[ZenThemeMarketplaceParent:settings]: Enabling theme ${theme.name}`);
|
||||||
|
|
||||||
theme.enabled = true;
|
theme.enabled = true;
|
||||||
|
|
||||||
await IOUtils.writeJSON(ZenThemesCommon.themesDataFile, themes);
|
await IOUtils.writeJSON(ZenThemesCommon.themesDataFile, themes);
|
||||||
@@ -109,7 +154,10 @@ var gZenMarketplaceManager = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async _buildThemesList() {
|
async _buildThemesList() {
|
||||||
if (!this.themesList) return;
|
if (!this.themesList) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this._doNotRebuildThemesList) {
|
if (this._doNotRebuildThemesList) {
|
||||||
this._doNotRebuildThemesList = false;
|
this._doNotRebuildThemesList = false;
|
||||||
return;
|
return;
|
||||||
@@ -617,9 +665,9 @@ var gZenWorkspacesSettings = {
|
|||||||
let buttonIndex = await confirmRestartPrompt(true, 1, true, true);
|
let buttonIndex = await confirmRestartPrompt(true, 1, true, true);
|
||||||
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
|
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
|
||||||
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
Services.prefs.addObserver('zen.workspaces.enabled', this);
|
Services.prefs.addObserver('zen.workspaces.enabled', this);
|
||||||
Services.prefs.addObserver('zen.tab-unloader.enabled', tabsUnloaderPrefListener);
|
Services.prefs.addObserver('zen.tab-unloader.enabled', tabsUnloaderPrefListener);
|
||||||
window.addEventListener('unload', () => {
|
window.addEventListener('unload', () => {
|
||||||
@@ -682,17 +730,17 @@ var zenMissingKeyboardShortcutL10n = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var zenKeycodeFixes = {
|
var zenKeycodeFixes = {
|
||||||
'Digit0': '0',
|
Digit0: '0',
|
||||||
'Digit1': '1',
|
Digit1: '1',
|
||||||
'Digit2': '2',
|
Digit2: '2',
|
||||||
'Digit3': '3',
|
Digit3: '3',
|
||||||
'Digit4': '4',
|
Digit4: '4',
|
||||||
'Digit5': '5',
|
Digit5: '5',
|
||||||
'Digit6': '6',
|
Digit6: '6',
|
||||||
'Digit7': '7',
|
Digit7: '7',
|
||||||
'Digit8': '8',
|
Digit8: '8',
|
||||||
'Digit9': '9',
|
Digit9: '9',
|
||||||
}
|
};
|
||||||
|
|
||||||
var gZenCKSSettings = {
|
var gZenCKSSettings = {
|
||||||
async init() {
|
async init() {
|
||||||
|
@@ -9,7 +9,10 @@
|
|||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<groupbox id="zenMarketplaceGroup" data-category="paneZenMarketplace" hidden="true" class="highlighting-group">
|
<groupbox id="zenMarketplaceGroup" data-category="paneZenMarketplace" hidden="true" class="highlighting-group">
|
||||||
<label><html:h2 data-l10n-id="zen-theme-marketplace-header"/></label>
|
|
||||||
|
<hbox id="zenMarketplaceHeader">
|
||||||
|
<html:h2 data-l10n-id="zen-theme-marketplace-header"/>
|
||||||
|
</hbox>
|
||||||
<description class="description-deemphasized" data-l10n-id="zen-theme-marketplace-description" />
|
<description class="description-deemphasized" data-l10n-id="zen-theme-marketplace-description" />
|
||||||
<hbox class="indent">
|
<hbox class="indent">
|
||||||
<html:a id="zenThemeMarketplaceLink" href="https://zen-browser.app/themes" target="_blank" data-l10n-id="zen-theme-marketplace-link" />
|
<html:a id="zenThemeMarketplaceLink" href="https://zen-browser.app/themes" target="_blank" data-l10n-id="zen-theme-marketplace-link" />
|
||||||
|
@@ -574,8 +574,29 @@ groupbox h2 {
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#zenMarketplaceHeader {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
& h2 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.zenThemeMarketplaceItemPreferenceToggle {
|
.zenThemeMarketplaceItemPreferenceToggle {
|
||||||
align-self: start;
|
align-self: start;
|
||||||
|
|
||||||
|
&::part(button) {
|
||||||
|
background-color: var(--zen-primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
&::part(button)::before {
|
||||||
|
background-color: var(--zen-colors-secondary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.zenThemeMarketplaceDisableAllToggle {
|
||||||
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#zenThemeMarketplaceItemContentHeader {
|
#zenThemeMarketplaceItemContentHeader {
|
||||||
|
Reference in New Issue
Block a user