Skip to content
Extraits de code Groupes Projets
Valider 37a67b29 rédigé par danielvincent's avatar danielvincent
Parcourir les fichiers

left/right arrow keys on photo show page go to prev/next

parent 2355947d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -4,11 +4,11 @@ module PhotosHelper ...@@ -4,11 +4,11 @@ module PhotosHelper
link_to (image_tag photo.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch" link_to (image_tag photo.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch"
end end
def link_to_prev(photo, album) def url_to_prev(photo, album)
link_to "<< prev", photo_path(album.prev_photo(photo)), :rel => "prefetch" photo_path(album.prev_photo(photo))
end end
def link_to_next(photo, album) def url_to_next(photo, album)
link_to "next >>", photo_path(album.next_photo(photo)), :rel => "prefetch" photo_path(album.next_photo(photo))
end end
end end
: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) .back= link_to "⇧ #{@album.name}", album_path(@album)
%h1.big_text %h1.big_text
= @photo.image = @photo.image
...@@ -6,11 +19,11 @@ ...@@ -6,11 +19,11 @@
= link_to 'Edit Photo', edit_photo_path(@photo), :class => "button" = link_to 'Edit Photo', edit_photo_path(@photo), :class => "button"
.sub_header .sub_header
= link_to_prev @photo, @album = link_to "<< prev", url_to_prev(@photo, @album)
| |
= link_to "full size", @photo.url = link_to "full size", @photo.url
| |
= link_to_next @photo, @album = link_to "next >>", url_to_next(@photo, @album)
%div{:id => @photo.id} %div{:id => @photo.id}
#show_photo #show_photo
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter