Skip to content
Snippets Groups Projects
Commit e9ced7b2 authored by danielvincent's avatar danielvincent
Browse files

changing photo now updates all user images in page

parent 65ffe2ec
No related branches found
No related tags found
No related merge requests found
......@@ -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);
});
}
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment