diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 73ee0ec79bd8a65c82c210df1eb69a702d59ae41..4e9f94c2465373888a8c77c1172423c895d42ff7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 12b6a1af178b821e42c083d123f469e792a0b960..58f6a97bd69ea8d275af70b40738a4495e276806 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -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 diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 575007819da6a2573a303bad87234b49c49df554..74687f668f0e75e96b9eda7aa50db2c26d2a8398 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -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); + }); + } }); });