mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-28 06:34:14 +01:00
66 lines
1.0 KiB
JavaScript
66 lines
1.0 KiB
JavaScript
/**
|
|
* Application handling.
|
|
*
|
|
* @returns {{init: init, handleTooltips: handleTooltips}}
|
|
* @constructor
|
|
*/
|
|
const App = function(){
|
|
|
|
// dom selectors
|
|
const aSelectors = {
|
|
darkModeButton: '#dark_mode'
|
|
};
|
|
|
|
/**
|
|
* initialization.
|
|
*
|
|
*/
|
|
function init(){
|
|
|
|
// dark theme button
|
|
$(aSelectors.darkModeButton).on('click', function(){
|
|
$('body').attr('data-bs-theme', this.ariaPressed === 'true' ? 'dark' : 'light');
|
|
});
|
|
|
|
// dark theme button state
|
|
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);
|
|
}
|
|
|
|
// handle tooltips
|
|
handleTooltips(document);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap tooltip initialization.
|
|
*
|
|
* @param oElement
|
|
*/
|
|
function handleTooltips(oElement){
|
|
const tooltips = oElement.querySelectorAll("[data-bs-toggle='tooltip']");
|
|
tooltips.forEach((el) => {
|
|
new bootstrap.Tooltip(el);
|
|
});
|
|
}
|
|
|
|
return {
|
|
init,
|
|
handleTooltips
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|