Initial
This commit is contained in:
25
public/js/admin.js
Normal file
25
public/js/admin.js
Normal file
@@ -0,0 +1,25 @@
|
||||
document.querySelectorAll("form").forEach((form) => {
|
||||
form.addEventListener("submit", (event) => {
|
||||
const danger = event.submitter?.classList.contains("danger");
|
||||
if (danger && !confirm("Please confirm this permanent action.")) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
const button = event.submitter;
|
||||
if (button && button.tagName === "BUTTON") {
|
||||
button.dataset.originalText = button.textContent;
|
||||
button.textContent = "Saving...";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll("input[type='file']").forEach((input) => {
|
||||
input.addEventListener("change", () => {
|
||||
const existing = input.parentElement.querySelector(".file-hint");
|
||||
existing?.remove();
|
||||
const hint = document.createElement("small");
|
||||
hint.className = "file-hint";
|
||||
hint.textContent = `${input.files.length} selected`;
|
||||
input.parentElement.appendChild(hint);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user