mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-13 01:33:16 +00:00
started adding pre-upload validation to images
This commit is contained in:
parent
4a6a09ec13
commit
c0c6a1bd7c
2 changed files with 16 additions and 2 deletions
|
|
@ -27,9 +27,22 @@ $(function(){
|
|||
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 () {
|
||||
|
|
@ -46,14 +59,14 @@ $(function(){
|
|||
if ((that._trigger('added', e, data) !== false) &&
|
||||
(options.autoUpload || data.autoUpload) &&
|
||||
data.autoUpload !== false) {
|
||||
data.submit();
|
||||
data.submit()
|
||||
}
|
||||
}).fail(function () {
|
||||
if (data.files.error) {
|
||||
data.context.each(function (index) {
|
||||
var error = data.files[index].error;
|
||||
if (error) {
|
||||
$(this).find('.error').text(error);
|
||||
$(this).find('.error_messages').text(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
<script src="{{ STATIC_URL }}wagtailimages/js/vendor/jquery.fileupload.js"></script>
|
||||
<script src="{{ STATIC_URL }}wagtailimages/js/vendor/jquery.fileupload-process.js"></script>
|
||||
<script src="{{ STATIC_URL }}wagtailimages/js/vendor/jquery.fileupload-image.js"></script>
|
||||
<script src="{{ STATIC_URL }}wagtailimages/js/vendor/jquery.fileupload-validate.js"></script>
|
||||
<script src="{{ STATIC_URL }}wagtailadmin/js/vendor/tag-it.js"></script>
|
||||
|
||||
<!-- Main script -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue