1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

66 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-04-20 09:34:12 -07:00
import { initForms } from './forms';
import { initBootstrap } from './bs';
import { initSearch } from './search';
import { initSelect } from './select';
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';
import { initInterfaceTable } from './tables';
2021-06-22 17:20:17 -07:00
import { initSideNav } from './sidenav';
import { initRackElevation } from './racks';
import { initLinks } from './links';
import { initHtmx } from './htmx';
2021-03-13 02:31:57 -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,
initInterfaceTable,
2021-06-22 17:20:17 -07:00
initSideNav,
initRackElevation,
initLinks,
initHtmx,
2021-04-20 09:34:12 -07:00
]) {
init();
2021-03-13 02:31:57 -07:00
}
}
function initWindow(): void {
2022-10-04 15:02:37 +02:00
const documentForms = document.forms;
for (const documentForm of documentForms) {
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())) {
if (value === '') formData.delete(name);
}
});
}
}
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') {
initDocument();
2021-04-20 09:34:12 -07:00
} else {
document.addEventListener('DOMContentLoaded', initDocument);
2021-03-13 02:31:57 -07:00
}