ecole_eft_app/app/views/public/photos/_show.html.haml
2013-07-18 01:23:48 +02:00

122 lines
3.7 KiB
Plaintext

%table.large_photo
%tr
%td.prev-photo
<
%td.photo_place
.photo_artwork.artwork{:id => @photo.id, :style => "", :data => {:photo_thumb => "photo_"+@photo.id.to_s}}
.frame{:style => "display:inline-block;"}
.img{:style => "width:100%;float:none;"}
=image_tag(@photo.image.large.url,:style => "max-height:100%;", :class => "close_large")
%h3
=@photo.title
%td.next-photo
>
:coffeescript
$(".next-photo").click ->
active = $("#"+$(this).closest(".large_photo").find(".photo_artwork").data("photo-thumb"))
if active.next(".photo").length > 0
$.ajax(url:active.next(".photo").find("a:first").attr("href"),dataType:"script")
else
$.ajax(url:$("#photos").children(".photo:first").find("a:first").attr("href"),dataType:"script")
$(".prev-photo").click ->
active = $("#"+$(this).closest(".large_photo").find(".photo_artwork").data("photo-thumb"))
if active.prev(".photo").length > 0
$.ajax(url:active.prev(".photo").find("a:first").attr("href"),dataType:"script")
else
$.ajax(url:$("#photos").children(".photo:last").find("a:first").attr("href"),dataType:"script")
%p
Cette image pourrait être associée aux sages paroles suivantes, par exemple (
=link_to "ou vous pouvez proposer une citation pour cette photo", newphoto_public_quotes_path(:photo_id => @photo.id), :remote => true
):
.photo_quotes
%table
%tr
%td.prev-quote
<
%td.quotes
=render Quote.where(:enabled => true, :photo_id => @photo.id).all
-if @photo.tags.size > 0
-quotes = Quote.joins(:tag_taggables).where(["enabled = ? and (photo_id <> ? or photo_id IS NULL)",true, @photo.id]).where("tag_taggables.taggable_type == 'Quote' and tag_taggables.tag_id in (?)", @photo.tag_ids).group(:id)
-else
-quotes = Quote.where(["enabled = ? and (photo_id <> ? or photo_id IS NULL)",true, @photo.id]).all
-quotes.each do |quote, count|
=render quote
:coffeescript
$(".photo_quotes .quote").click ->
$(this).fadeOut(300)
$(this).removeClass("active")
if $(this).next(".quote").length > 0
$(this).next(".quote").delay(300).fadeIn(300).addClass("active")
else
$(".photo_quotes .quotes").children(".quote:first").delay(600).fadeIn(300).addClass("active")
$(".next-quote").click ->
active = $(".photo_quotes .active:first")
active.fadeOut(300).removeClass("active")
if active.next(".quote").length > 0
active.next(".quote").delay(300).fadeIn(300).addClass("active")
else
$(".photo_quotes .quotes").children(".quote:first").delay(600).fadeIn(300).addClass("active")
$(".prev-quote").click ->
active = $(".photo_quotes .active:first")
active.fadeOut(300).removeClass("active")
if active.prev(".quote").length > 0
active.prev(".quote").delay(300).fadeIn(300).addClass("active")
else
$(".photo_quotes .quotes").children(".quote:last").delay(600).fadeIn(300).addClass("active")
$(".photo_quotes .quotes").children(".quote:first").show().addClass("active")
resize_photo_artwork = ->
$(".photo_artwork").delay(600).css "height", ($(window).height()- 250)
resize_photo_artwork()
$(window).on "resize", ->
resize_photo_artwork()
%td.next-quote
>