changing photo now updates all user images in page
This commit is contained in:
parent
65ffe2ecdd
commit
e9ced7b2e6
3 changed files with 8 additions and 3 deletions
|
|
@ -60,7 +60,7 @@ module ApplicationHelper
|
|||
image_location = person.profile.image_url
|
||||
image_location ||= "/images/user/default.png"
|
||||
|
||||
image_tag image_location, :class => "avatar", :alt => person.real_name, :title => person.real_name
|
||||
image_tag image_location, :class => "avatar", :alt => person.real_name, :title => person.real_name, "data-person_id" => person.id
|
||||
end
|
||||
|
||||
def person_image_link(person)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
%div{:id => @photo.id}
|
||||
#show_photo
|
||||
.edit_pane
|
||||
.controls{:data=>{:actor=>"#{@photo.person.owner.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}}
|
||||
.controls{:data=>{:actor=>"#{@photo.person.owner.id}",:actor_person=>"#{@photo.person.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}}
|
||||
= link_to 'make profile photo', '#', :class => "make_profile_photo"
|
||||
= linked_scaled_photo @photo, @album
|
||||
.caption
|
||||
|
|
|
|||
|
|
@ -107,12 +107,17 @@ function openVideo(type, videoid, link) {
|
|||
|
||||
$(".make_profile_photo").live("click", function(){
|
||||
var user_id = $(this).closest(".controls").attr('data-actor');
|
||||
person_id = $(this).closest(".controls").attr('data-actor_person');
|
||||
photo_url = $(this).closest(".controls").attr('data-image_url');
|
||||
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: '/users/'+user_id,
|
||||
data: {"user":{"profile":{ "image_url": photo_url }}},
|
||||
success: window.location.reload()
|
||||
success: function(){
|
||||
$("img[data-person_id='"+ person_id +"']").each( function() {
|
||||
$(this).attr('src', photo_url);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue