js hack to see bigger version of photo thumbnails in the stream without being abnoxious

This commit is contained in:
maxwell 2011-03-11 17:16:36 -08:00
parent 59820d1994
commit ab997e2d21
2 changed files with 21 additions and 4 deletions

View file

@ -5,14 +5,17 @@
- if photos.size > 0 - if photos.size > 0
.photo_attachments .photo_attachments
= link_to (image_tag photos.first.url(:scaled_full)), photo_path(photos.first) .key_photo
= link_to (image_tag photos.first.url(:scaled_full)), photo_path(photos.first)
%br
- if photos.size > 1 - if photos.size > 1
- if photos.size >= 8 - if photos.size >= 8
- for photo in photos[1..8] - for photo in photos[1..8]
= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) = link_to (image_tag photo.url(:thumb_small)), photo_path(photo)
- else - else
- for photo in photos[1..photos.size] .thumbs
= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) - for photo in photos
= link_to (image_tag photo.url(:thumb_small)), photo_path(photo)
= markdownify(post.message, :youtube_maps => post[:youtube_titles]) = markdownify(post.message, :youtube_maps => post[:youtube_titles])
- else - else

View file

@ -16,7 +16,9 @@ var Stream = {
$(this).parent().html("<audio src='" + this.href + "' controls='controls'>mom</audio>");} $(this).parent().html("<audio src='" + this.href + "' controls='controls'>mom</audio>");}
}); });
$('.thumbs img').live('hover', function(){
Stream.replaceKeyPhoto($(this));
});
// comment link form focus // comment link form focus
$stream.delegate(".focus_comment_textarea", "click", function(e){ $stream.delegate(".focus_comment_textarea", "click", function(e){
Stream.focusNewComment($(this), e); Stream.focusNewComment($(this), e);
@ -127,7 +129,19 @@ var Stream = {
commentBlock.find('textarea').focus(); commentBlock.find('textarea').focus();
} }
} }
},
replaceKeyPhoto: function(photo){
var show_url = photo.parent().first()[0].href
var img_url = photo.first()[0].src;
var large_url = img_url.replace("thumb_small", "scaled_full");
var key_photo = photo.parent().parent().siblings('.key_photo')
var key_photo_img = key_photo.find('img');
key_photo_img.attr('height', key_photo_img.height());
key_photo_img.attr('src', large_url);
key_photo.find('a').attr('href', show_url);
} }
}; };
$(document).ready(Stream.initialize); $(document).ready(Stream.initialize);