aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display.js14
-rw-r--r--ext/js/display/query-parser.js3
2 files changed, 15 insertions, 2 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index e9fdfd9f..386f456b 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -304,7 +304,6 @@ export class Display extends EventDispatcher {
/** */
async prepare() {
// Theme
- this._themeController.siteTheme = 'light';
this._themeController.prepare();
// State setup
@@ -488,6 +487,10 @@ export class Display extends EventDispatcher {
this._history.pushState(state, content, url);
break;
}
+
+ if (this._options) {
+ this._setTheme(this._options);
+ }
}
/**
@@ -1149,8 +1152,16 @@ export class Display extends EventDispatcher {
_setTheme(options) {
const {general} = options;
const {popupTheme} = general;
+ try {
+ // eslint-disable-next-line no-underscore-dangle
+ const pageTheme = this._history._current.state?.pageTheme;
+ this._themeController.siteTheme = pageTheme ?? null;
+ } catch (e) {
+ log.error(e);
+ }
this._themeController.theme = popupTheme;
this._themeController.outerTheme = general.popupOuterTheme;
+ this._themeController.siteOverride = this._pageType === 'search';
this._themeController.updateTheme();
this.setCustomCss(general.customPopupCss);
}
@@ -1933,6 +1944,7 @@ export class Display extends EventDispatcher {
url,
sentence: sentence !== null ? sentence : void 0,
documentTitle,
+ pageTheme: 'light',
},
content: {
dictionaryEntries: dictionaryEntries !== null ? dictionaryEntries : void 0,
diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js
index c53208ca..344383fb 100644
--- a/ext/js/display/query-parser.js
+++ b/ext/js/display/query-parser.js
@@ -155,7 +155,7 @@ export class QueryParser extends EventDispatcher {
/**
* @param {import('text-scanner').EventArgument<'searchSuccess'>} details
*/
- _onSearchSuccess({type, dictionaryEntries, sentence, inputInfo, textSource, optionsContext}) {
+ _onSearchSuccess({type, dictionaryEntries, sentence, inputInfo, textSource, optionsContext, pageTheme}) {
this.trigger('searched', {
textScanner: this._textScanner,
type,
@@ -165,6 +165,7 @@ export class QueryParser extends EventDispatcher {
textSource,
optionsContext,
sentenceOffset: this._getSentenceOffset(textSource),
+ pageTheme: pageTheme,
});
}