DG MS; added more feedback to photo uploader
This commit is contained in:
parent
882c0c2170
commit
2ef56224be
3 changed files with 58 additions and 51 deletions
|
|
@ -3,24 +3,7 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
#profile_photo_upload
|
- content_for :head do
|
||||||
= owner_image_tag(:thumb_medium)
|
|
||||||
|
|
||||||
#file-upload.button
|
|
||||||
=t('.upload')
|
|
||||||
%br
|
|
||||||
%br
|
|
||||||
%p
|
|
||||||
#fileInfo
|
|
||||||
|
|
||||||
-if !aspect.nil? && aspect != :getting_started && current_user.person.has_photos?
|
|
||||||
%br
|
|
||||||
%br
|
|
||||||
%p
|
|
||||||
\...#{t('.or_select_one')}
|
|
||||||
= link_to t('_photos'), person_photos_path(person)
|
|
||||||
|
|
||||||
#publisher_photo_upload
|
|
||||||
:javascript
|
:javascript
|
||||||
function createUploader(){
|
function createUploader(){
|
||||||
var uploader = new qq.FileUploaderBasic({
|
var uploader = new qq.FileUploaderBasic({
|
||||||
|
|
@ -28,11 +11,9 @@
|
||||||
params: {'photo' : {'pending' : true, 'aspect_ids' : "all", 'set_profile_photo': true}},
|
params: {'photo' : {'pending' : true, 'aspect_ids' : "all", 'set_profile_photo': true}},
|
||||||
allowedExtensions: ['jpg', 'jpeg', 'png'],
|
allowedExtensions: ['jpg', 'jpeg', 'png'],
|
||||||
action: "#{photos_path}",
|
action: "#{photos_path}",
|
||||||
debug: true,
|
|
||||||
button: document.getElementById('file-upload'),
|
button: document.getElementById('file-upload'),
|
||||||
sizeLimit: 4194304,
|
sizeLimit: 4194304,
|
||||||
|
|
||||||
|
|
||||||
onProgress: function(id, fileName, loaded, total){
|
onProgress: function(id, fileName, loaded, total){
|
||||||
var progress = Math.round(loaded / total * 100 );
|
var progress = Math.round(loaded / total * 100 );
|
||||||
$('#fileInfo').text(fileName + ' ' + progress + '%');
|
$('#fileInfo').text(fileName + ' ' + progress + '%');
|
||||||
|
|
@ -46,10 +27,12 @@
|
||||||
|
|
||||||
onSubmit: function(id, fileName){
|
onSubmit: function(id, fileName){
|
||||||
$('#file-upload').addClass("loading");
|
$('#file-upload').addClass("loading");
|
||||||
$("#profile_photo_upload").find(".avatar").fadeTo(200,0.5);
|
$("#profile_photo_upload").find(".avatar").addClass('loading');
|
||||||
|
$("#file-upload-spinner").removeClass("hidden");
|
||||||
},
|
},
|
||||||
|
|
||||||
onComplete: function(id, fileName, responseJSON){
|
onComplete: function(id, fileName, responseJSON){
|
||||||
|
$("#file-upload-spinner").addClass("hidden");
|
||||||
$('#fileInfo').text(fileName + ' completed').fadeOut(2000);
|
$('#fileInfo').text(fileName + ' completed').fadeOut(2000);
|
||||||
$('#file-upload').removeClass("loading");
|
$('#file-upload').removeClass("loading");
|
||||||
var id = responseJSON.data.photo.id;
|
var id = responseJSON.data.photo.id;
|
||||||
|
|
@ -62,10 +45,32 @@
|
||||||
oldPhoto.val(id);
|
oldPhoto.val(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#profile_photo_upload").find(".avatar").fadeTo(200,1);
|
$("#profile_photo_upload").find(".avatar").removeClass('loading');
|
||||||
$("#profile_photo_upload").find(".avatar").attr("src",url);
|
$("#profile_photo_upload").find(".avatar").attr("src",url);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
window.onload = createUploader;
|
window.onload = createUploader;
|
||||||
|
|
||||||
|
#profile_photo_upload
|
||||||
|
= owner_image_tag(:thumb_medium)
|
||||||
|
|
||||||
|
#file-upload.button
|
||||||
|
=t('.upload')
|
||||||
|
|
||||||
|
= image_tag('mobile-spinner.gif', :class => 'hidden', :style => "z-index:-1", :id => 'file-upload-spinner')
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%p
|
||||||
|
#fileInfo
|
||||||
|
|
||||||
|
-if !aspect.nil? && aspect != :getting_started && current_user.person.has_photos?
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%p
|
||||||
|
\...#{t('.or_select_one')}
|
||||||
|
= link_to t('_photos'), person_photos_path(person)
|
||||||
|
|
||||||
|
#publisher_photo_upload
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
var data = $.parseJSON( '#{@tags_array.to_json.gsub("'", "\\\\'")}' ),
|
var data = $.parseJSON( '#{@tags_array.to_json.gsub("'", "\\\\'")}' ),
|
||||||
autocompleteInput = $("#profile_tag_string");
|
autocompleteInput = $("#profile_tag_string");
|
||||||
|
|
||||||
|
|
||||||
autocompleteInput.autoSuggest("#{tags_path}", {
|
autocompleteInput.autoSuggest("#{tags_path}", {
|
||||||
selectedItemProp: "name",
|
selectedItemProp: "name",
|
||||||
searchObjProps: "name",
|
searchObjProps: "name",
|
||||||
|
|
|
||||||
|
|
@ -1011,7 +1011,6 @@ label
|
||||||
@include opacity(0.5)
|
@include opacity(0.5)
|
||||||
|
|
||||||
#publisher_textarea_wrapper
|
#publisher_textarea_wrapper
|
||||||
|
|
||||||
#hide_publisher
|
#hide_publisher
|
||||||
@include opacity(0.3)
|
@include opacity(0.3)
|
||||||
:padding 3px
|
:padding 3px
|
||||||
|
|
@ -1547,6 +1546,11 @@ ul.aspects
|
||||||
:height 100px
|
:height 100px
|
||||||
:width 100px
|
:width 100px
|
||||||
|
|
||||||
|
&.avatar
|
||||||
|
@include transition(opacity, 0.5s)
|
||||||
|
&.loading
|
||||||
|
@include opacity(0.3)
|
||||||
|
|
||||||
:padding
|
:padding
|
||||||
:left 120px
|
:left 120px
|
||||||
|
|
||||||
|
|
@ -2628,7 +2632,6 @@ h1.tag
|
||||||
:border
|
:border
|
||||||
:bottom 2px dotted $blue
|
:bottom 2px dotted $blue
|
||||||
|
|
||||||
|
|
||||||
.info
|
.info
|
||||||
.tag
|
.tag
|
||||||
:background
|
:background
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue