add onAllComplete event to fileupload.js; hide mention helper during upload

This commit is contained in:
Michael Nutt 2011-02-27 12:44:56 -05:00
parent b6dc32959c
commit 208a47162c
3 changed files with 337 additions and 313 deletions

View file

@ -30,14 +30,14 @@
onSubmit: function(id, fileName){
$('#file-upload').addClass("loading");
$('#publisher').find("input[type='submit']").attr('disabled','disabled');
$("#publisher .options_and_submit").fadeIn(50);
$("div.mention_helper").fadeTo(100, 0, function() {
$("#publisher .options_and_submit, #fileInfo").fadeIn(50);
});
$("#publisher_spinner").fadeIn(100);
},
onComplete: function(id, fileName, responseJSON) {
$('#fileInfo').text(fileName + ' completed').fadeOut(2000);
$("#publisher_spinner").fadeOut(100);
$('#file-upload').removeClass("loading");
$('#fileInfo').text(fileName + ' completed');
var id = responseJSON.data.photo.id;
var url = responseJSON.data.photo.thumb_small;
@ -70,6 +70,15 @@
}
});
});
},
onAllComplete: function(completed_files){
$('#fileInfo').delay(1800).fadeOut(200, function() {
$("div.mention_helper").fadeTo(100, 100);
});
$("#publisher_spinner").fadeOut(100);
$('#file-upload').removeClass("loading");
}
});

View file

@ -37,7 +37,7 @@
= hidden_field_tag 'aspect_ids[]', aspect_id.to_s
.options_and_submit
%div
%div.mention_helper
%i= t('.mention_helper_text')
.right

View file

@ -266,6 +266,7 @@ qq.FileUploaderBasic = function(o){
onSubmit: function(id, fileName){},
onProgress: function(id, fileName, loaded, total){},
onComplete: function(id, fileName, responseJSON){},
onAllComplete: function(completed_files){},
onCancel: function(id, fileName){},
// messages
messages: {
@ -332,6 +333,9 @@ qq.FileUploaderBasic.prototype = {
self._onComplete(id, fileName, result);
self._options.onComplete(id, fileName, result);
},
onAllComplete: function(completed_files){
self._options.onAllComplete(completed_files);
},
onCancel: function(id, fileName){
self._onCancel(id, fileName);
self._options.onCancel(id, fileName);
@ -859,6 +863,7 @@ qq.UploadHandlerAbstract = function(o){
maxConnections: 999,
onProgress: function(id, fileName, loaded, total){},
onComplete: function(id, fileName, response){},
onAllComplete: function(completed_files){},
onCancel: function(id, fileName){}
};
qq.extend(this._options, o);
@ -866,6 +871,7 @@ qq.UploadHandlerAbstract = function(o){
this._queue = [];
// params for files in queue
this._params = [];
this._completed_files = [];
};
qq.UploadHandlerAbstract.prototype = {
log: function(str){
@ -943,6 +949,13 @@ qq.UploadHandlerAbstract.prototype = {
var nextId = this._queue[max-1];
this._upload(nextId, this._params[nextId]);
}
if (this._queue.length == 0){
this._onAllComplete();
}
},
_onAllComplete: function(){
this._options.onAllComplete(this._completed_files);
}
};
@ -1223,9 +1236,11 @@ qq.extend(qq.UploadHandlerXhr.prototype, {
response = {};
}
this._completed_files.push({file: this._files[id], response: response});
this._options.onComplete(id, name, response);
} else {
this._completed_files.push({file: this._files[id], response: {}});
this._options.onComplete(id, name, {});
}