mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-19 04:46:42 +02:00
Introduce dark/light mode theme switch into framework
This commit is contained in:
@@ -63,6 +63,9 @@ var fw_base = (function(){ "use strict"; return Class.extend(
|
||||
|
||||
// keep track of opened popups
|
||||
this.popups = [];
|
||||
|
||||
// initiate dark mode
|
||||
this._setDarkMode(egw.preference('darkmode', 'common'));
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1299,5 +1302,10 @@ var fw_base = (function(){ "use strict"; return Class.extend(
|
||||
isAnInternalApp: function(_app)
|
||||
{
|
||||
return _app && _app.appName != _app.internalName;
|
||||
},
|
||||
|
||||
_setDarkMode: function(_state)
|
||||
{
|
||||
jQuery('html').attr('data-darkmode', _state);
|
||||
}
|
||||
});}).call(this);
|
||||
|
@@ -535,6 +535,27 @@
|
||||
execPushBroadcastAppStatus: function(_data)
|
||||
{
|
||||
if (app.status) app.status.mergeContent(_data, true);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
toggle_darkmode: function(node)
|
||||
{
|
||||
let state = node.firstElementChild.classList.contains('darkmode_on');
|
||||
egw.set_preference('common', 'darkmode',state?'0':'1');
|
||||
this._setDarkMode(state?'0':'1');
|
||||
if (state == 1)
|
||||
{
|
||||
node.firstElementChild.classList.remove('darkmode_on');
|
||||
node.firstElementChild.title = egw.lang('light mode');
|
||||
}
|
||||
else
|
||||
{
|
||||
node.firstElementChild.classList.add('darkmode_on');
|
||||
node.firstElementChild.title = egw.lang('dark mode');
|
||||
}
|
||||
}
|
||||
});
|
||||
})(window);
|
||||
|
Reference in New Issue
Block a user