25 lines
886 B
TypeScript
25 lines
886 B
TypeScript
document.addEventListener('DOMContentLoaded', () => {
|
|
const form = document.getElementById('url-shrink-form');
|
|
if (!form) return;
|
|
|
|
const autogenUrlCheckbox = document.querySelector<HTMLInputElement>('#field-autogen_url');
|
|
const slugField = document.querySelector<HTMLInputElement>('#field-slug');
|
|
|
|
if (slugField && autogenUrlCheckbox) {
|
|
const updateSlugField = () => {
|
|
slugField.disabled = autogenUrlCheckbox.checked;
|
|
|
|
const parent = slugField.parentElement?.parentElement;
|
|
if (parent) {
|
|
if (autogenUrlCheckbox.checked) {
|
|
parent.classList.add('hidden');
|
|
} else {
|
|
parent.classList.remove('hidden');
|
|
}
|
|
}
|
|
};
|
|
autogenUrlCheckbox.addEventListener('change', updateSlugField);
|
|
updateSlugField();
|
|
}
|
|
});
|