Merge pull request #3740 from movilla/progress_upload

Add progress percentage to upload images. Close #3633
This commit is contained in:
Florian Staudacher 2012-12-22 02:57:03 -08:00
commit 4587a926ad
6 changed files with 15 additions and 3 deletions

View file

@ -17,6 +17,7 @@
* Add possibility to contact the administrator. [#3792](https://github.com/diaspora/diaspora/pull/3792) * Add possibility to contact the administrator. [#3792](https://github.com/diaspora/diaspora/pull/3792)
* Add simple background for unread messages/conversations mobile. [#3724](https://github.com/diaspora/diaspora/pull/3724) * Add simple background for unread messages/conversations mobile. [#3724](https://github.com/diaspora/diaspora/pull/3724)
* Add flash warning to conversation mobile, unification of flash warning with login and register mobile, and add support for flash warning to Opera browser. [#3686](https://github.com/diaspora/diaspora/pull/3686) * Add flash warning to conversation mobile, unification of flash warning with login and register mobile, and add support for flash warning to Opera browser. [#3686](https://github.com/diaspora/diaspora/pull/3686)
* Add progress percentage to upload images. [#3740](https://github.com/diaspora/diaspora/pull/3740)
## Bug Fixes ## Bug Fixes

View file

@ -99,6 +99,9 @@ app.views.Publisher = Backbone.View.extend(_.extend(
this.$("input[name='photos[]']").remove(); this.$("input[name='photos[]']").remove();
this.el_wrapper.removeClass("with_attachments"); this.el_wrapper.removeClass("with_attachments");
// empty upload-photo
this.$('#fileInfo').empty();
// close publishing area (CSS) // close publishing area (CSS)
this.close(); this.close();

View file

@ -2839,3 +2839,7 @@ a.toggle_selector
:color #666 :color #666
:color #666 :color #666
#fileInfo
:font-size small
:text-align right
:margin 5px 2px

View file

@ -17,6 +17,8 @@
sizeLimit: 4194304, sizeLimit: 4194304,
onProgress: function(id, fileName, loaded, total){ onProgress: function(id, fileName, loaded, total){
var progress = Math.round(loaded / total * 100 );
$('#fileInfo').text(fileName + ' ' + progress + '%').fadeTo(200, 1);
}, },
messages: { messages: {
@ -38,7 +40,7 @@
}, },
onComplete: function(id, fileName, responseJSON) { onComplete: function(id, fileName, responseJSON) {
$('#fileInfo').text(fileName + ' completed'); $('#fileInfo').text(Diaspora.I18n.t("photo_uploader.completed", file=fileName)).fadeTo(2000, 0);
var id = responseJSON.data.photo.id, var id = responseJSON.data.photo.id,
url = responseJSON.data.photo.unprocessed_image.url, url = responseJSON.data.photo.unprocessed_image.url,
currentPlaceholder = $('li.loading').first(); currentPlaceholder = $('li.loading').first();
@ -69,7 +71,7 @@
success: function() { success: function() {
photo.fadeOut(400, function(){ photo.fadeOut(400, function(){
photo.remove(); photo.remove();
if ( $('.publisher_photo').length == 0){ if ( $('.publisher_photo').length == 0){
app.publisher.el_wrapper.removeClass("with_attachments"); app.publisher.el_wrapper.removeClass("with_attachments");
} }
}); });
@ -84,4 +86,4 @@
}); });
} }
createUploader(); createUploader();

View file

@ -14,6 +14,7 @@
= status.error_messages = status.error_messages
%div %div
%params %params
#fileInfo
#publisher_textarea_wrapper #publisher_textarea_wrapper
= link_to( image_tag('deletelabel.png'), "#", :id => "hide_publisher", :title => t('.discard_post')) = link_to( image_tag('deletelabel.png'), "#", :id => "hide_publisher", :title => t('.discard_post'))
%ul#photodropzone %ul#photodropzone

View file

@ -71,6 +71,7 @@ en:
preparing_your_stream: "Preparing your personalized stream..." preparing_your_stream: "Preparing your personalized stream..."
photo_uploader: photo_uploader:
looking_good: "OMG, you look awesome!" looking_good: "OMG, you look awesome!"
completed: "<%= file %> completed"
tags: tags:
wasnt_that_interesting: "OK, I suppose #<%= tagName %> wasn't all that interesting..." wasnt_that_interesting: "OK, I suppose #<%= tagName %> wasn't all that interesting..."
people: people: