.
This commit is contained in:
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="IU-261.25134.95">
|
||||
<component name="dataSourceStorageLocal" created-in="IU-253.32098.101">
|
||||
<data-source name="articles" uuid="315cb5c9-2b0f-435b-b602-59823b160908">
|
||||
<database-info product="SQLite" version="3.51.1" jdbc-version="4.2" driver-name="SQLite JDBC" driver-version="3.51.1.0" dbms="SQLITE" exact-version="3.51.1" exact-driver-version="3.51">
|
||||
<identifier-quote-string>"</identifier-quote-string>
|
||||
|
||||
@@ -457,6 +457,18 @@ if ($replyAuthor === null) {
|
||||
<button type="submit" class="button">
|
||||
Kommentar senden
|
||||
</button>
|
||||
|
||||
<p
|
||||
id="comment-loading"
|
||||
class="comment-loading"
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
hidden
|
||||
>
|
||||
<span class="comment-spinner" aria-hidden="true"></span>
|
||||
Kommentar wird gesendet …
|
||||
</p>
|
||||
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<div class="comment-login-hint">
|
||||
|
||||
@@ -226,3 +226,33 @@ h1 {
|
||||
text-decoration: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.comment-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.comment-loading[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.comment-spinner {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 2px solid #cbd5e1;
|
||||
border-top-color: #1f2937;
|
||||
border-radius: 50%;
|
||||
animation: comment-spinner-rotation 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes comment-spinner-rotation {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
#comment-form button[type="submit"]:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.65;
|
||||
}
|
||||
+38
-1
@@ -11,7 +11,19 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
const parentCommentInput = document.getElementById("parent-comment-id");
|
||||
const replyInfo = document.getElementById("reply-info");
|
||||
|
||||
if (!form || !commentsList || !commentContent || !parentCommentInput) {
|
||||
const submitButton = form
|
||||
? form.querySelector('button[type="submit"]')
|
||||
: null;
|
||||
|
||||
const loadingMessage = document.getElementById("comment-loading");
|
||||
|
||||
if (
|
||||
!form
|
||||
|| !commentsList
|
||||
|| !commentContent
|
||||
|| !parentCommentInput
|
||||
|| !submitButton
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,6 +65,23 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
form.addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
/*
|
||||
* Verhindert einen erneuten Submit, während der vorherige
|
||||
* Kommentar noch gespeichert wird.
|
||||
*/
|
||||
if (submitButton.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const originalButtonText = submitButton.textContent;
|
||||
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = "Wird gesendet …";
|
||||
|
||||
if (loadingMessage) {
|
||||
loadingMessage.hidden = false;
|
||||
}
|
||||
|
||||
const formData = new FormData(form);
|
||||
const parentCommentId = parentCommentInput.value;
|
||||
|
||||
@@ -269,6 +298,14 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
.catch(function (error) {
|
||||
console.error(error);
|
||||
alert("Kommentar konnte nicht gesendet werden.");
|
||||
})
|
||||
.finally(function () {
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = originalButtonText;
|
||||
|
||||
if (loadingMessage) {
|
||||
loadingMessage.hidden = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user