Skip to content

Commit

Permalink
Enable buttons after upload aborted, no images to upload etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismeonmounteverest committed Oct 30, 2023
1 parent 645008b commit c972200
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions templates/gallery/upload.image.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
upload.disabled = true;
abort.disabled = false;
let count = 0;
for (let index = 0; index < files.length; index++) {
const file = files[index];
Expand All @@ -48,13 +49,18 @@
continue;
}
count++;
filename.innerText = file.name;
uploadFile(index, file);
}
progressBars.classList.remove('d-none');
if (count === 0) {
resetForm();
}
return false;
}
Expand All @@ -69,6 +75,7 @@
client.onerror = function(e) {
alert("{{ 'gallery.upload.error'|trans }}");
resetForm();
};
client.onload = function(e) {
Expand All @@ -86,10 +93,7 @@
imageProgress.append(infoDiv);
clients = clients.filter((value)=>value!==client);
if (clients.length === 0) {
let form = document.querySelector('form');
form.reset()
upload.disabled = false;
abort.disabled = true;
resetForm();
}
};
Expand All @@ -101,7 +105,6 @@
const filename = document.getElementById('filename-' + index);
filename.innerText = file.name + " - " + p + "%";
console.log(file.name, percent, filename, " - " + p);
};
client.onabort = function(e) {
Expand All @@ -119,10 +122,7 @@
}
alert("{{ 'upload.canceled'|trans }}");
let form = document.querySelector('form');
form.reset()
upload.disabled = false;
abort.disabled = true;
resetForm();
return false;
}
Expand Down Expand Up @@ -164,6 +164,13 @@
const objectUrl = window.URL.createObjectURL(file);
image.firstChild.src = objectUrl;
}
function resetForm() {
let form = document.querySelector('form');
form.reset()
upload.disabled = false;
abort.disabled = true;
}
</script>
{% endblock javascripts %}

Expand Down

0 comments on commit c972200

Please sign in to comment.