[TASK] add input group element with interaction
All checks were successful
CI/CD Pipeline / test (push) Successful in 14m49s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
Marie Birner
2025-05-02 17:24:40 +02:00
parent a73bbf059f
commit c47b1988b2
6 changed files with 109 additions and 68 deletions

View File

@ -24,6 +24,7 @@ document.addEventListener("DOMContentLoaded", function () {
reloadPage();
setCurrentdate(<HTMLInputElement>document.querySelector("#departure"));
initDropdown();
editReadOnlyField();
});
function changeTheme() {
@ -40,6 +41,25 @@ function changeTheme() {
}
}
function editReadOnlyField() {
const editBtns = document.querySelectorAll(
'.edit-js'
);
if (editBtns) {
Array.prototype.forEach.call(editBtns, (btn: HTMLButtonElement) => {
btn.addEventListener("click", function () {
let wrapper = btn.parentElement;
let input = wrapper?.querySelector('input');
wrapper?.classList.toggle('editable')
input?.toggleAttribute('readonly');
if(!input?.hasAttribute('readonly')) input?.focus();
});
});
}
}
/***
* init javascript
* 1) detect native color scheme or use set theme in local storage