2021-04-20 09:34:12 -07:00
|
|
|
import { initForms } from './forms';
|
|
|
|
import { initBootstrap } from './bs';
|
|
|
|
import { initSearch } from './search';
|
|
|
|
import { initSelect } from './select';
|
2021-04-19 20:48:03 -07:00
|
|
|
import { initButtons } from './buttons';
|
2021-04-25 20:11:46 -07:00
|
|
|
import { initColorMode } from './colorMode';
|
2021-04-20 09:34:12 -07:00
|
|
|
import { initMessages } from './messages';
|
2021-04-13 21:51:12 -07:00
|
|
|
import { initClipboard } from './clipboard';
|
2021-04-20 09:34:12 -07:00
|
|
|
import { initDateSelector } from './dateSelector';
|
|
|
|
import { initTableConfig } from './tableConfig';
|
2021-05-26 16:32:09 -07:00
|
|
|
import { initInterfaceTable } from './tables';
|
2021-06-22 17:20:17 -07:00
|
|
|
import { initSideNav } from './sidenav';
|
2021-07-06 17:56:49 -07:00
|
|
|
import { initRackElevation } from './racks';
|
2021-07-13 09:14:57 -07:00
|
|
|
import { initLinks } from './links';
|
2021-12-21 11:11:33 -07:00
|
|
|
import { initHtmx } from './htmx';
|
2021-03-13 02:31:57 -07:00
|
|
|
|
2021-08-23 22:31:36 -07:00
|
|
|
function initDocument(): void {
|
2021-04-20 09:34:12 -07:00
|
|
|
for (const init of [
|
|
|
|
initBootstrap,
|
2021-04-25 20:11:46 -07:00
|
|
|
initColorMode,
|
2021-04-20 09:34:12 -07:00
|
|
|
initMessages,
|
|
|
|
initForms,
|
|
|
|
initSearch,
|
|
|
|
initSelect,
|
|
|
|
initDateSelector,
|
|
|
|
initButtons,
|
|
|
|
initClipboard,
|
|
|
|
initTableConfig,
|
2021-05-26 16:32:09 -07:00
|
|
|
initInterfaceTable,
|
2021-06-22 17:20:17 -07:00
|
|
|
initSideNav,
|
2021-07-06 17:56:49 -07:00
|
|
|
initRackElevation,
|
2021-07-13 09:14:57 -07:00
|
|
|
initLinks,
|
2021-12-21 11:11:33 -07:00
|
|
|
initHtmx,
|
2021-04-20 09:34:12 -07:00
|
|
|
]) {
|
|
|
|
init();
|
2021-03-13 02:31:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-23 22:31:36 -07:00
|
|
|
function initWindow(): void {
|
2022-10-04 15:02:37 +02:00
|
|
|
const documentForms = document.forms;
|
|
|
|
for (const documentForm of documentForms) {
|
2022-10-03 20:32:01 +02:00
|
|
|
if (documentForm.method.toUpperCase() == 'GET') {
|
2022-10-04 15:02:37 +02:00
|
|
|
documentForm.addEventListener('formdata', function (event: FormDataEvent) {
|
|
|
|
const formData: FormData = event.formData;
|
|
|
|
for (const [name, value] of Array.from(formData.entries())) {
|
2022-10-03 20:32:01 +02:00
|
|
|
if (value === '') formData.delete(name);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:13:54 -07:00
|
|
|
const contentContainer = document.querySelector<HTMLElement>('.content-container');
|
|
|
|
if (contentContainer !== null) {
|
|
|
|
// Focus the content container for accessible navigation.
|
|
|
|
contentContainer.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener('load', initWindow);
|
|
|
|
|
2021-03-13 02:31:57 -07:00
|
|
|
if (document.readyState !== 'loading') {
|
2021-08-19 14:13:54 -07:00
|
|
|
initDocument();
|
2021-04-20 09:34:12 -07:00
|
|
|
} else {
|
2021-08-19 14:13:54 -07:00
|
|
|
document.addEventListener('DOMContentLoaded', initDocument);
|
2021-03-13 02:31:57 -07:00
|
|
|
}
|