Fix image upload progress bar

This commit is contained in:
onli 2016-09-11 17:41:07 +02:00
parent 5108486af3
commit 3aed346370
2 changed files with 12 additions and 3 deletions

View File

@ -1565,6 +1565,7 @@ $(function() {
$('#uploadform').submit(function(event) {
if (! $('#imageurl').val()) {
event.preventDefault();
$('#uploadform .check_inputs').attr('disabled', true);
var sendDataToML = function(data, progressContainer, progress) {
$.ajax({
type: 'post',
@ -1573,12 +1574,14 @@ $(function() {
cache: false,
processData: false,
contentType: false,
xhrFields: {
onprogress: function (e) {
xhr: function() {
var xhr = $.ajaxSettings.xhr();
xhr.upload.onprogress = function(e) {
if (e.lengthComputable) {
progress.value = e.loaded / e.total * 100;
}
}
};
return xhr;
}
}).done(function(data) {
progress.value = 100;
@ -1600,6 +1603,7 @@ $(function() {
$('.form_buttons').prepend(mlLink);
$(mlLink).fadeIn();
}
$('#uploadform .check_inputs').removeAttr('disabled');
});
};
$('.uploadform_userfile').each(function() {

View File

@ -351,6 +351,11 @@ progress div.progress-undefined {
width: 100%;
}
progress {
/* Makes progress bar visible in FF */
background: white;
}
/* HELPER CLASSES */
/* Hide visually, available for screenreaders */
.visuallyhidden {