diff --git a/files/assets/js/core.js b/files/assets/js/core.js index ef2db5155..2756439d0 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -312,7 +312,7 @@ function reload() { location.reload(); } -function sendFormXHR(form, extraActionsOnSuccess) { +function setupFormXhr(form, extraActionsOnSuccess) { if (typeof close_inline_emoji_modal === "function") { close_inline_emoji_modal(); } @@ -354,6 +354,11 @@ function sendFormXHR(form, extraActionsOnSuccess) { form.classList.remove('is-submitting'); }; + return xhr +} + +function sendFormXHR(form, extraActionsOnSuccess) { + const xhr = setupFormXhr(form, extraActionsOnSuccess); xhr.send(formData); } diff --git a/files/assets/js/post.js b/files/assets/js/post.js index 389534cd7..e7afa14ed 100644 --- a/files/assets/js/post.js +++ b/files/assets/js/post.js @@ -47,3 +47,10 @@ if (fake_textarea) { location.href = fake_textarea.dataset.href; }); } + +function edit_post(form) { + const xhr = setupFormXhr(form, reload); + const upload_prog = document.getElementById('upload-prog-edit-post'); + xhr.upload.onprogress = (e) => {handleUploadProgress(e, upload_prog)}; + xhr.send(formData); +} \ No newline at end of file diff --git a/files/templates/post.html b/files/templates/post.html index ec37330c9..3ba91a05d 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -215,7 +215,7 @@ {% if v and v.can_edit(p) %}