frontend-dali/source/overlay.ts
2025-10-28 11:38:58 +01:00

101 lines
1.7 KiB
TypeScript

/*
This file is part of »dali«.
Copyright 2025 'kcf' <fenris@folksprak.org>
»dali« is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
»dali« is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with »dali«. If not, see <http://www.gnu.org/licenses/>.
*/
namespace _dali.overlay
{
/**
*/
function get_container_element(
)
: HTMLElement
{
return document.querySelector("#overlay");
}
/**
*/
export function get_content_element(
)
: HTMLElement
{
return document.querySelector("#overlay_content");
}
/**
*/
export function clear(
)
: void
{
get_content_element().innerHTML = "";
}
/**
*/
export function toggle(
{
"mode": mode = null,
}
:
{
mode ?: (null | boolean);
}
=
{
}
)
: void
{
get_container_element().classList.toggle("overlay_active", mode ?? undefined);
}
/**
*/
export function initialize(
)
: Promise<void>
{
clear();
const container_element : HTMLElement = get_container_element();
/*
container_element.addEventListener(
"click",
(event) => {
if (event.target == container_element)
{
toggle({"mode": false});
}
else
{
// do nothing
}
}
);
*/
return Promise.resolve<void>(undefined);
}
}