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

add javascript

This commit is contained in:
checktheroads
2021-03-13 02:31:57 -07:00
parent 3b120c0372
commit 912cd220cc
16 changed files with 1069 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import SlimSelect from 'slim-select';
export function initStaticSelect() {
const elements = document.querySelectorAll(
'.netbox-select2-static',
) as NodeListOf<HTMLSelectElement>;
for (const select of elements) {
if (select !== null) {
const label = document.querySelector(`label[for=${select.id}]`) as HTMLLabelElement;
let placeholder;
if (label !== null) {
placeholder = `Select ${label.innerText.trim()}`;
}
new SlimSelect({
select,
allowDeselect: true,
deselectLabel: `<i class="bi bi-x-circle"></i>`,
placeholder,
});
}
}
}