Some fixes for darkmode:

- Fix darkmode not switched in popups
- Fix a quick white page shown before switching to darkmode when it's set to 'auto'
This commit is contained in:
Hadi Nategh 2021-01-27 12:26:37 +01:00
parent e980f3a851
commit b9570b9b60
5 changed files with 28 additions and 9 deletions

View File

@ -177,12 +177,15 @@ var AppJS = (function(){ "use strict"; return Class.extend(
} }
this.et2 = et2.widgetContainer; this.et2 = et2.widgetContainer;
this._fix_iFrameScrolling(); this._fix_iFrameScrolling();
if (this.egw && this.egw.is_popup()) this._set_Window_title(); if (this.egw && this.egw.is_popup())
{
this._set_Window_title();
// apply theme mode
jQuery('html').attr('data-darkmode', egw.getSessionItem('api', 'darkmode') == '0'?'0':'1');
}
// Highlights the favorite based on initial list state // Highlights the favorite based on initial list state
this.highlight_favorite(); this.highlight_favorite();
}, },
/** /**

View File

@ -113,12 +113,13 @@ var EgwApp = /** @class */ (function () {
} }
this.et2 = et2.widgetContainer; this.et2 = et2.widgetContainer;
this._fix_iFrameScrolling(); this._fix_iFrameScrolling();
if (this.egw && this.egw.is_popup()) if (this.egw && this.egw.is_popup()) {
this._set_Window_title(); this._set_Window_title();
// apply theme mode
jQuery('html').attr('data-darkmode', egw.getSessionItem('api', 'darkmode') == '0' ? '0' : '1');
}
// Highlights the favorite based on initial list state // Highlights the favorite based on initial list state
this.highlight_favorite(); this.highlight_favorite();
// apply theme mode
window.framework._setDarkMode(egw.getSessionItem('api', 'darkmode'));
}; };
/** /**
* Observer method receives update notifications from all applications * Observer method receives update notifications from all applications

View File

@ -203,12 +203,15 @@ export abstract class EgwApp
} }
this.et2 = et2.widgetContainer; this.et2 = et2.widgetContainer;
this._fix_iFrameScrolling(); this._fix_iFrameScrolling();
if (this.egw && this.egw.is_popup()) this._set_Window_title(); if (this.egw && this.egw.is_popup())
{
this._set_Window_title();
// apply theme mode
jQuery('html').attr('data-darkmode', egw.getSessionItem('api', 'darkmode') == '0'?'0':'1');
}
// Highlights the favorite based on initial list state // Highlights the favorite based on initial list state
this.highlight_favorite(); this.highlight_favorite();
// apply theme mode
window.framework._setDarkMode(egw.getSessionItem('api', 'darkmode'));
} }
/** /**

View File

@ -46,6 +46,12 @@
* @package pixelegg * @package pixelegg
* @version $Id$ * @version $Id$
*/ */
@media (prefers-color-scheme: dark) {
html[data-darkmode='2'] {
background: #000;
filter: invert(1) hue-rotate(180deg);
}
}
/** /**
* DARK THEME * DARK THEME
*/ */

View File

@ -10,6 +10,12 @@
* @version $Id$ * @version $Id$
*/ */
@media (prefers-color-scheme: dark) {
html[data-darkmode='2'] {
background: #000;
filter: invert(1) hue-rotate(180deg);
}
}
/** /**
* DARK THEME * DARK THEME
*/ */