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
|
def log_view
|
||||||
@photo = Photo.find(params[:id])
|
@photo = Photo.find(params[:id])
|
||||||
@photo.log_view
|
@photo.log_view
|
||||||
|
render :nothing => true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,2 +1,5 @@
|
|||||||
module PhotosHelper
|
module PhotosHelper
|
||||||
|
def link_to_photo(photo)
|
||||||
|
link_to '', photo.photo.url, :rel => 'photos', :class => 'fancy', :id => photo.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
<% @photos.each do |photo| %>
|
<% @photos.each do |photo| %>
|
||||||
|
|
||||||
<div class="sg-11 photo" style="background: url('<%= photo.photo.url(:size11) %>')">
|
<div class="sg-11 photo" style="background: url('<%= photo.photo.url(:size11) %>')">
|
||||||
<%= link_to '', photo.photo.url, :class => 'fancy' %>
|
<%= link_to_photo photo %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<% if @photo %>
|
<% if @photo %>
|
||||||
<div class="sg-17 photo" style="background: url('<%= @photo.photo.url(:size17) %>')">
|
<div class="sg-17 photo" style="background: url('<%= @photo.photo.url(:size17) %>')">
|
||||||
<%= link_to '', @photo.photo.url, :class => 'fancy' %>
|
<%= link_to_photo @photo %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
<% @photos.each do |photo| %>
|
<% @photos.each do |photo| %>
|
||||||
|
|
||||||
<div class="sg-5 photo" style="background: url('<%= photo.photo.url(:size5) %>')">
|
<div class="sg-5 photo" style="background: url('<%= photo.photo.url(:size5) %>')">
|
||||||
<%= link_to '', photo.photo.url, :class => 'fancy' %>
|
<%= link_to_photo photo %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -56,9 +56,16 @@ Photos::Application.routes.draw do
|
|||||||
|
|
||||||
resources :categories do
|
resources :categories do
|
||||||
resources :photos
|
resources :photos
|
||||||
|
member do
|
||||||
|
get :log_view
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :photos
|
resources :photos do
|
||||||
|
member do
|
||||||
|
get :log_view
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
root :to => 'pages#index'
|
root :to => 'pages#index'
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('.fancy').fancybox({
|
$('.fancy').fancybox({
|
||||||
'titlePosition' : 'inside'
|
'titlePosition' : 'inside',
|
||||||
|
'onComplete' : function(links, index) {
|
||||||
|
$.get('/photos/'+$(links[index]).attr('id')+'/log_view')
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($('#contact_form').length) {
|
if ($('#contact_form').length) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user