RS IZ photos now fade in on the album upload page

This commit is contained in:
ilya 2010-07-29 17:26:05 -07:00
parent a534d6424e
commit f6495e2bec
4 changed files with 24 additions and 4 deletions

View file

@ -18,7 +18,11 @@ module SocketsHelper
puts e.message
raise e
end
{:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}.to_json
if object.is_a? Photo
{:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object), :photo_hash => object.thumb_hash }.to_json
else
{:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}.to_json
end
end

View file

@ -51,4 +51,8 @@ class Photo < Post
user.profile.update_attributes!(:image_url => nil)
end
end
def thumb_hash
{:thumb_url => image.url(:thumb_medium), :id => id, :album_id => album_id}
end
end

View file

@ -17,9 +17,10 @@
-unless mine? @album
%h4= "by #{@album.person.real_name}"
- for photo in @album_photos
.image_thumb
= link_to (image_tag photo.image.url(:thumb_medium)), object_path(photo)
#thumbnails
- for photo in @album_photos
.image_thumb
= link_to (image_tag photo.image.url(:thumb_medium)), object_path(photo)
#content_bottom
.back

View file

@ -18,6 +18,8 @@
}else if (obj['class']=="comments"){
processComment(obj['post_id'], obj['html'])
}else if (obj['class']=='photos' && onPageForClass('albums')){
processPhotoInAlbum(obj['photo_hash'])
}else{
processPost(obj['class'], obj['html'])
}
@ -53,6 +55,15 @@
);
}
}
function processPhotoInAlbum(photoHash){
if (location.href.indexOf(photoHash['album_id']) == -1){
return ;
}
html = "<div class=\'image_thumb\'> <a href=\"/photos/"+ photoHash['id'] +"\"><img alt=\"New thumbnail\" src=\""+ photoHash['thumb_url'] +"\" style=\"display:inline;\" /> </a> </div>"
$("#thumbnails").append( $(html).fadeIn("fast") )
}
function onPageForClass(className){
return ((location.href.indexOf(className) != -1 ) || (location.pathname == '/')) && onPageOne();