diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index c518ceec5..faf29ed63 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -4,11 +4,11 @@ module PhotosHelper link_to (image_tag photo.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch" end - def link_to_prev(photo, album) - link_to "<< prev", photo_path(album.prev_photo(photo)), :rel => "prefetch" + def url_to_prev(photo, album) + photo_path(album.prev_photo(photo)) end - def link_to_next(photo, album) - link_to "next >>", photo_path(album.next_photo(photo)), :rel => "prefetch" + def url_to_next(photo, album) + photo_path(album.next_photo(photo)) end end diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 8636998b3..27afac74c 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -1,3 +1,16 @@ +:javascript + $(document).keydown(function(e){ + switch(e.keyCode) { + case 37: + window.location.replace( "#{url_to_prev(@photo,@album)}" ); + break; + case 39: + window.location.replace( "#{url_to_next(@photo,@album)}" ); + break; + } + }); + + .back= link_to "⇧ #{@album.name}", album_path(@album) %h1.big_text = @photo.image @@ -6,11 +19,11 @@ = link_to 'Edit Photo', edit_photo_path(@photo), :class => "button" .sub_header - = link_to_prev @photo, @album + = link_to "<< prev", url_to_prev(@photo, @album) | = link_to "full size", @photo.url | - = link_to_next @photo, @album + = link_to "next >>", url_to_next(@photo, @album) %div{:id => @photo.id} #show_photo