diff --git a/amadeus/static/js/mural.js b/amadeus/static/js/mural.js
index 939fcfc..ac77923 100644
--- a/amadeus/static/js/mural.js
+++ b/amadeus/static/js/mural.js
@@ -255,6 +255,11 @@ function setCommentFormSubmit(post, comment = "") {
var frm = $('#comment-form');
frm.submit(function () {
+ var btn = frm.parent().parent().parent().find("button[form='comment-form']")
+
+ btn.prop('disable', true);
+ btn.prop('disabled', true);
+
var formData = new FormData($(this)[0]);
$.ajax({
diff --git a/mural/templates/mural/_form_comment.html b/mural/templates/mural/_form_comment.html
index 540d31d..755cde1 100644
--- a/mural/templates/mural/_form_comment.html
+++ b/mural/templates/mural/_form_comment.html
@@ -45,19 +45,29 @@
{{ form.image.help_text }}
+
- {% if form.image.errors %}
-
-
-
- {% for error in form.image.errors %}
- - {{ error }}
- {% endfor %}
-
-
- {% endif %}
+ {% if form.image.errors %}
+
+
+
+ {% for error in form.image.errors %}
+ - {{ error }}
+ {% endfor %}
+
+
+ {% endif %}
+
+
+
+
+ - {% trans "The image is too large. It should have less than 5MB." %}
+ - {% trans 'File not supported.' %}
+
@@ -225,10 +235,33 @@
// file selection
function FileSelectHandler(e) {
var files = e.target.files || e.dataTransfer.files,
- parent = $(e.target.offsetParent);
+ parent = $(e.target.offsetParent),
+ max_size = 5*1024*1024;
+
+ $(".client-file-errors").hide();
+ $(".size").hide();
+ $(".format").hide();
+ $("#button").prop('disable', false);
+ $("#button").prop('disabled', false);
// process all File objects
for (var i = 0, f; f = files[i]; i++) {
+ if (f.size > max_size) {
+ $("#button").prop('disable', true);
+ $("#button").prop('disabled', true);
+
+ $(".client-file-errors").show();
+ $(".size").show();
+ }
+
+ if (!f.type.match(/^image\//)) {
+ $("#button").prop('disable', true);
+ $("#button").prop('disabled', true);
+
+ $(".client-file-errors").show();
+ $(".format").show();
+ }
+
parent.find('.filedrag').html(f.name);
}
}
--
libgit2 0.21.2