1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Now reliably logging photo views with an onComplete function on the

fancybox plugin.
This commit is contained in:
Dan Barber 2010-12-18 11:17:05 -05:00
parent 54ea0d9c33
commit 67e7f0eb12
7 changed files with 19 additions and 5 deletions

View File

@ -19,5 +19,6 @@ class PhotosController < ApplicationController
def log_view
@photo = Photo.find(params[:id])
@photo.log_view
render :nothing => true
end
end

View File

@ -1,2 +1,5 @@
module PhotosHelper
def link_to_photo(photo)
link_to '', photo.photo.url, :rel => 'photos', :class => 'fancy', :id => photo.id
end
end

View File

@ -17,7 +17,7 @@
<% @photos.each do |photo| %>
<div class="sg-11 photo" style="background: url('<%= photo.photo.url(:size11) %>')">
<%= link_to '', photo.photo.url, :class => 'fancy' %>
<%= link_to_photo photo %>
</div>
<% end %>

View File

@ -8,7 +8,7 @@
<% if @photo %>
<div class="sg-17 photo" style="background: url('<%= @photo.photo.url(:size17) %>')">
<%= link_to '', @photo.photo.url, :class => 'fancy' %>
<%= link_to_photo @photo %>
</div>
<% end %>

View File

@ -27,7 +27,7 @@
<% @photos.each do |photo| %>
<div class="sg-5 photo" style="background: url('<%= photo.photo.url(:size5) %>')">
<%= link_to '', photo.photo.url, :class => 'fancy' %>
<%= link_to_photo photo %>
</div>
<% end %>

View File

@ -56,9 +56,16 @@ Photos::Application.routes.draw do
resources :categories do
resources :photos
member do
get :log_view
end
end
resources :photos
resources :photos do
member do
get :log_view
end
end
root :to => 'pages#index'

View File

@ -1,6 +1,9 @@
$(document).ready(function() {
$('.fancy').fancybox({
'titlePosition' : 'inside'
'titlePosition' : 'inside',
'onComplete' : function(links, index) {
$.get('/photos/'+$(links[index]).attr('id')+'/log_view')
}
});
if ($('#contact_form').length) {