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:
parent
54ea0d9c33
commit
67e7f0eb12
@ -19,5 +19,6 @@ class PhotosController < ApplicationController
|
||||
def log_view
|
||||
@photo = Photo.find(params[:id])
|
||||
@photo.log_view
|
||||
render :nothing => true
|
||||
end
|
||||
end
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 %>
|
||||
|
||||
@ -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 %>
|
||||
|
||||
|
||||
@ -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 %>
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user