mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-12 13:58:28 -04:00
Reserve darkReader for non-Wikimedia ZIMs in auto
Fixes #333 Former-commit-id: c825383a1d5de50d453a22463f738d6b02009af2
This commit is contained in:
parent
eb1e57bcad
commit
c90484ecfa
@ -1547,6 +1547,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
|||||||
if (checkAuto && typeof Windows !== 'undefined' && Windows.UI && Windows.UI.ViewManagement) {
|
if (checkAuto && typeof Windows !== 'undefined' && Windows.UI && Windows.UI.ViewManagement) {
|
||||||
uiSettings = new Windows.UI.ViewManagement.UISettings();
|
uiSettings = new Windows.UI.ViewManagement.UISettings();
|
||||||
uiSettings.oncolorvalueschanged = function () {
|
uiSettings.oncolorvalueschanged = function () {
|
||||||
|
params.cssTheme = settingsStore.getItem('cssTheme');
|
||||||
if (params.cssUITheme == 'auto') cssUIThemeGetOrSet('auto');
|
if (params.cssUITheme == 'auto') cssUIThemeGetOrSet('auto');
|
||||||
if (params.cssTheme == 'auto') switchCSSTheme();
|
if (params.cssTheme == 'auto') switchCSSTheme();
|
||||||
};
|
};
|
||||||
@ -1555,6 +1556,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
|||||||
if (checkAuto && window.matchMedia('(prefers-color-scheme)').media !== 'not all') {
|
if (checkAuto && window.matchMedia('(prefers-color-scheme)').media !== 'not all') {
|
||||||
uiSettings = window.matchMedia('(prefers-color-scheme:dark)');
|
uiSettings = window.matchMedia('(prefers-color-scheme:dark)');
|
||||||
uiSettings.onchange = function () {
|
uiSettings.onchange = function () {
|
||||||
|
params.cssTheme = settingsStore.getItem('cssTheme');
|
||||||
if (params.cssUITheme == 'auto') cssUIThemeGetOrSet('auto');
|
if (params.cssUITheme == 'auto') cssUIThemeGetOrSet('auto');
|
||||||
if (params.cssTheme == 'auto') switchCSSTheme();
|
if (params.cssTheme == 'auto') switchCSSTheme();
|
||||||
};
|
};
|
||||||
@ -1566,11 +1568,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
|||||||
if (params.cssTheme == 'auto') document.getElementById('darkDarkReader').style.display = params.contentInjectionMode === 'serviceworker' ? cssUIThemeGetOrSet('auto', true) == 'light' ? 'none' : 'block' : 'none';
|
if (params.cssTheme == 'auto') document.getElementById('darkDarkReader').style.display = params.contentInjectionMode === 'serviceworker' ? cssUIThemeGetOrSet('auto', true) == 'light' ? 'none' : 'block' : 'none';
|
||||||
document.getElementById('cssUIDarkThemeCheck').addEventListener('click', function () {
|
document.getElementById('cssUIDarkThemeCheck').addEventListener('click', function () {
|
||||||
//This code implements a tri-state checkbox
|
//This code implements a tri-state checkbox
|
||||||
if (this.readOnly) this.checked = this.readOnly = false;
|
// if (this.readOnly) this.checked = this.readOnly = false;
|
||||||
else if (!this.checked) this.readOnly = this.indeterminate = true;
|
// else if (!this.checked) this.readOnly = this.indeterminate = true;
|
||||||
//Code below shows how to invert the order
|
//Code below shows how to invert the order
|
||||||
//if (this.readOnly) { this.checked = true; this.readOnly = false; }
|
if (this.readOnly) { this.checked = true; this.readOnly = false; }
|
||||||
//else if (this.checked) this.readOnly = this.indeterminate = true;
|
else if (this.checked) this.readOnly = this.indeterminate = true;
|
||||||
params.cssUITheme = this.indeterminate ? "auto" : this.checked ? 'dark' : 'light';
|
params.cssUITheme = this.indeterminate ? "auto" : this.checked ? 'dark' : 'light';
|
||||||
if (!uiSettings) initializeUISettings();
|
if (!uiSettings) initializeUISettings();
|
||||||
settingsStore.setItem('cssUITheme', params.cssUITheme, Infinity);
|
settingsStore.setItem('cssUITheme', params.cssUITheme, Infinity);
|
||||||
@ -1581,8 +1583,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
|||||||
params.cssThemeOriginal = null;
|
params.cssThemeOriginal = null;
|
||||||
});
|
});
|
||||||
document.getElementById('cssWikiDarkThemeCheck').addEventListener('click', function () {
|
document.getElementById('cssWikiDarkThemeCheck').addEventListener('click', function () {
|
||||||
if (this.readOnly) this.checked = this.readOnly = false;
|
// if (this.readOnly) this.checked = this.readOnly = false;
|
||||||
else if (!this.checked) this.readOnly = this.indeterminate = true;
|
// else if (!this.checked) this.readOnly = this.indeterminate = true;
|
||||||
|
// Invert order:
|
||||||
|
if (this.readOnly) { this.checked = true; this.readOnly = false; }
|
||||||
|
else if (this.checked) this.readOnly = this.indeterminate = true;
|
||||||
params.cssTheme = this.indeterminate ? "auto" : this.checked ? 'dark' : 'light';
|
params.cssTheme = this.indeterminate ? "auto" : this.checked ? 'dark' : 'light';
|
||||||
if (!uiSettings) initializeUISettings();
|
if (!uiSettings) initializeUISettings();
|
||||||
var determinedValue = params.cssTheme;
|
var determinedValue = params.cssTheme;
|
||||||
@ -2812,20 +2817,22 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
|||||||
if (params.allowHTMLExtraction) document.getElementById('allowHTMLExtractionCheck').click();
|
if (params.allowHTMLExtraction) document.getElementById('allowHTMLExtractionCheck').click();
|
||||||
// Set defaults that allow for greatest compabitibility with Zimit ZIM types
|
// Set defaults that allow for greatest compabitibility with Zimit ZIM types
|
||||||
if (params.zimType === 'zimit') {
|
if (params.zimType === 'zimit') {
|
||||||
if (params.cssTheme !== 'light' && params.cssTheme !== 'darkReader' && !/UWP/.test(params.appType)) {
|
var determinedTheme = params.cssTheme == 'auto' ? cssUIThemeGetOrSet('auto', true) : params.cssTheme;
|
||||||
document.getElementById('cssWikiDarkThemeDarkReaderCheck').click();
|
if (params.cssTheme === 'auto' && determinedTheme !== 'light' && !/UWP/.test(params.appType)) {
|
||||||
|
params.cssTheme = 'darkReader';
|
||||||
|
document.getElementById('cssWikiDarkThemeDarkReaderCheck').checked = true;
|
||||||
}
|
}
|
||||||
if (!params.windowOpener) {
|
if (!params.windowOpener) {
|
||||||
document.getElementById('tabOpenerCheck').click();
|
document.getElementById('tabOpenerCheck').click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (wikimediaZimLoaded) {
|
|
||||||
params.noWarning = true;
|
params.noWarning = true;
|
||||||
if (!params.manipulateImages) document.getElementById('manipulateImagesCheck').click();
|
if (!params.manipulateImages) document.getElementById('manipulateImagesCheck').click();
|
||||||
params.noWarning = false;
|
params.noWarning = false;
|
||||||
if (params.cssTheme === 'darkReader' && /UWP/.test(params.appType)) {
|
params.cssTheme = settingsStore.getItem('cssTheme');
|
||||||
document.getElementById('cssWikiDarkThemeDarkReaderCheck').click();
|
if (params.cssTheme === 'auto') {
|
||||||
|
document.getElementById('cssWikiDarkThemeDarkReaderCheck').checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3190,20 +3197,22 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
|
|||||||
if (params.allowHTMLExtraction) document.getElementById('allowHTMLExtractionCheck').click();
|
if (params.allowHTMLExtraction) document.getElementById('allowHTMLExtractionCheck').click();
|
||||||
// Set defaults that allow for greatest compabitibility with Zimit ZIM types
|
// Set defaults that allow for greatest compabitibility with Zimit ZIM types
|
||||||
if (params.zimType === 'zimit') {
|
if (params.zimType === 'zimit') {
|
||||||
if (params.cssTheme !== 'light' && params.cssTheme !== 'darkReader' && !/UWP/.test(params.appType)) {
|
var determinedTheme = params.cssTheme == 'auto' ? cssUIThemeGetOrSet('auto', true) : params.cssTheme;
|
||||||
document.getElementById('cssWikiDarkThemeDarkReaderCheck').click();
|
if (params.cssTheme === 'auto' && determinedTheme !== 'light' && !/UWP/.test(params.appType)) {
|
||||||
|
params.cssTheme = 'darkReader';
|
||||||
|
document.getElementById('cssWikiDarkThemeDarkReaderCheck').checked = true;
|
||||||
}
|
}
|
||||||
if (!params.windowOpener) {
|
if (!params.windowOpener) {
|
||||||
document.getElementById('tabOpenerCheck').click();
|
document.getElementById('tabOpenerCheck').click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (wikimediaZimLoaded) {
|
|
||||||
params.noWarning = true;
|
params.noWarning = true;
|
||||||
if (!params.manipulateImages) document.getElementById('manipulateImagesCheck').click();
|
if (!params.manipulateImages) document.getElementById('manipulateImagesCheck').click();
|
||||||
params.noWarning = false;
|
params.noWarning = false;
|
||||||
if (params.cssTheme === 'darkReader' && /UWP/.test(params.appType)) {
|
params.cssTheme = settingsStore.getItem('cssTheme');
|
||||||
document.getElementById('cssWikiDarkThemeDarkReaderCheck').click();
|
if (params.cssTheme === 'auto') {
|
||||||
|
document.getElementById('cssWikiDarkThemeDarkReaderCheck').checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user