From e9ced7b2e6d748920cd9a6a91b088ec1d134f358 Mon Sep 17 00:00:00 2001 From: danielvincent <danielgrippi@gmail.com> Date: Wed, 20 Oct 2010 12:35:16 -0700 Subject: [PATCH] changing photo now updates all user images in page --- app/helpers/application_helper.rb | 2 +- app/views/photos/show.html.haml | 2 +- public/javascripts/view.js | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 73ee0ec79b..4e9f94c246 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 12b6a1af17..58f6a97bd6 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 575007819d..74687f668f 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); + }); + } }); }); -- GitLab