From 9b47343e2afca0f8e295d95ba713085a96419bde Mon Sep 17 00:00:00 2001 From: Dave Cranwell Date: Wed, 8 Oct 2014 14:13:07 +0100 Subject: [PATCH] updates to how error message and accepted file type/size are mentioned by jquery upload plugin --- .../static/wagtailimages/js/add-multiple.js | 28 +++++++------------ .../wagtailimages/scss/add-multiple.scss | 4 +++ .../templates/wagtailimages/multiple/add.html | 5 +++- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js b/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js index f472c32aa8..dd9525007d 100644 --- a/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js +++ b/wagtail/wagtailimages/static/wagtailimages/js/add-multiple.js @@ -14,35 +14,25 @@ $(function(){ dataType: 'html', sequentialUploads: true, dropZone: $('.drop-zone'), - acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, + acceptFileTypes: window.accepted_file_types, maxFileSize: window.max_file_size, previewMinWidth:150, previewMaxWidth:150, previewMinHeight:150, - previewMaxHeight:150, - + previewMaxHeight:150, + messages: { + acceptFileTypes: window.message_accepted_file_types, + maxFileSize: window.messages_max_filesize + }, add: function (e, data) { var $this = $(this); var that = $this.data('blueimp-fileupload') || $this.data('fileupload') var li = $($('#upload-list-item').html()).addClass('upload-uploading') var options = that.options; - console.log(data); - $('#upload-list').append(li); data.context = li; - // check if initial File API validation failed. - if (data.files.error) { - console.log('here'); - data.context.each(function (index) { - var error = data.files[index].error; - if (error) { - $(this).find('.error_messages').text(error); - } - }); - } - data.process(function () { return $this.fileupload('process', data); }).always(function () { @@ -71,7 +61,11 @@ $(function(){ }); } }); + }, + processfail: function(e, data){ + var itemElement = $(data.context); + itemElement.removeClass('upload-uploading').addClass('upload-failure'); }, progress: function (e, data) { @@ -134,8 +128,6 @@ $(function(){ var form = $(this); var itemElement = form.closest('#upload-list > li'); - console.log(form); - e.preventDefault(); $.post(this.action, form.serialize(), function(data) { diff --git a/wagtail/wagtailimages/static/wagtailimages/scss/add-multiple.scss b/wagtail/wagtailimages/static/wagtailimages/scss/add-multiple.scss index 161b9e5ef6..9893f23774 100644 --- a/wagtail/wagtailimages/static/wagtailimages/scss/add-multiple.scss +++ b/wagtail/wagtailimages/static/wagtailimages/scss/add-multiple.scss @@ -112,6 +112,10 @@ } .upload-failure{ border-color:$color-red; + + .preview{ + display:none; + } .status-msg.failure{ display:block; diff --git a/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html b/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html index fbf63563ca..354325366a 100644 --- a/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html +++ b/wagtail/wagtailimages/templates/wagtailimages/multiple/add.html @@ -70,7 +70,10 @@ {% url 'wagtailadmin_tag_autocomplete' as autocomplete_url %}