mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-29 13:38:44 +02:00
49 lines
648 B
JavaScript
49 lines
648 B
JavaScript
/**
|
|
* Application handling.
|
|
*
|
|
* @returns {{init: init}}
|
|
* @constructor
|
|
*/
|
|
const App = function(){
|
|
|
|
// dom selectors
|
|
const aSelectors = {
|
|
darkModeButton: '#dark_mode'
|
|
};
|
|
|
|
/**
|
|
* init.
|
|
*
|
|
*/
|
|
function init(){
|
|
|
|
$(aSelectors.darkModeButton).on('click', function(){
|
|
$('body').attr('data-bs-theme', this.ariaPressed === 'true' ? 'dark' : 'light');
|
|
});
|
|
|
|
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
$('body').attr('data-bs-theme', 'dark');
|
|
$(aSelectors.darkModeButton).attr('aria-pressed', 'true');
|
|
$(aSelectors.darkModeButton).toggleClass('active', true);
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
init
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|