affichage galeries

This commit is contained in:
Nicolas Bally 2014-02-13 23:47:31 +01:00
parent e62c5f563c
commit d6c486679c
7 changed files with 134 additions and 36 deletions

View File

@ -42,16 +42,73 @@ $.fn.animateBG = (x, y, speed) ->
$ -> $ ->
prev_link = ""
$(document).on "click", ".gallery .photo a", ->
prev_link = $(this)
$('#photo_large_place').fadeIn();
$('#photo_large_place .big_img').attr("src", $(this).attr("href"))
$('#photo_large_place .big_img').css("max-height", ($(window).height()-130)+"px")
$('#photo_large_place').find("h3").html($(this).closest(".photo").find("h3").html())
return false
$("#photo_large_place .next-photo").click ->
if prev_link.closest(".photo").next(".photo").length > 0
photo = prev_link.closest(".photo").next(".photo")
$("a[rel^='prettyPhoto']:visible").fancybox({ else
helpers : { photo = prev_link.closest(".gallery").children(".photo:first")
title: {
type: 'inside' link = photo.find("a:first")
} titre = photo.find("h3")
} $('#photo_large_place .big_img').attr("src", link.attr("href"))
}) $('#photo_large_place').find("h3").html(titre.html())
prev_link = link
$("#photo_large_place .prev-photo").click ->
if prev_link.closest(".photo").prev(".photo").length > 0
photo = prev_link.closest(".photo").prev(".photo")
else
photo = prev_link.closest(".gallery").children(".photo:last")
link = photo.find("a:first")
titre = photo.find("h3")
$('#photo_large_place .big_img').attr("src", link.attr("href"))
$('#photo_large_place').find("h3").html(titre.html())
prev_link = link
$(document).on "click", '#photo_large_place .close_large', ->
$('#photo_large_place').fadeOut()

View File

@ -1,3 +1,10 @@
.big_img{
max-height:100%;
}
#main_content{ #main_content{
.row-fluid{ .row-fluid{
margin:0px; margin:0px;

View File

@ -221,6 +221,20 @@ z-index:7;
display:none; display:none;
}
#photo_large_place{
background:rgba(233,229,226,1);
position:fixed;
text-align:center;
top:0;
left:0;
width:100%;
height:100%;
z-index:7;
display:none;
} }
@media only screen and (max-width: 1100px) { @media only screen and (max-width: 1100px) {

View File

@ -4,7 +4,7 @@ class GalleryContent < ActiveRecord::Base
has_one :portlet, :as => :content, :dependent => :destroy has_one :portlet, :as => :content, :dependent => :destroy
STYLES = [["Petites miniatures",1], ["Diaporama",2], ["Petits carrés",3], ["Réalisations",4]] STYLES = [["Petites miniatures",1], ["Carrés",2]]
def dup def dup
@new = GalleryContent.new(self.attributes) @new = GalleryContent.new(self.attributes)

View File

@ -4,7 +4,7 @@ class GalleryImage < ActiveRecord::Base
belongs_to :gallery belongs_to :gallery
belongs_to :gallery_content belongs_to :gallery_content
validates :title, :presence => true #validates :title, :presence => true
def tags_class def tags_class

View File

@ -86,9 +86,36 @@
%h3 Danielle Riche %h3 Danielle Riche
#large_place #large_place
#photo_large_place
%table.large_photo
%tr
%td.prev-photo
<
%td.photo_place
.photo_artwork.artwork
.frame{:style => "display:inline-block;"}
.img{:style => "width:100%;float:none;"}
=image_tag("",:style => "max-height:100%;", :class => "close_large big_img")
%h3
%td.next-photo
>
:coffeescript :coffeescript
$(document).on "click", '#large_place .close_large', -> $(document).on "click", '#large_place .close_large', ->
$('#large_place').fadeOut() $('#large_place').fadeOut()

View File

@ -99,38 +99,31 @@
-elsif input.style==2 -elsif input.style==2
</div> .gallery
#slider -input.gallery_images.each do |gallery_image|
<div id="wrapper" > .photo{:style => "height:250px;"}
<div id="carousel" > %a{:href => gallery_image.image_file.file.large.url, :"data-remote" => true}
.img
=image_tag(gallery_image.image_file.file.square.url, :alt => "#{gallery_image.title}")
-input.gallery_images.each do |gallery_images| %h3{:style => "display:none;"}
=image_tag gallery_images.image_file.file.large.medium.url =gallery_image.title
</div>
</div>
<div class="row-fluid">
-elsif input.style==1 -elsif input.style==1
.portlet.input .gallery
%table.gallery_images
=raw "<tr>"
- i = 0 -input.gallery_images.each do |gallery_image|
-input.gallery_images.each do |gallery_images|
- i = i+1
%td=link_to image_tag(gallery_images.image_file.file.large.medium.small.thumb.url, :alt => "#{gallery_images.title}"), gallery_images.image_file.file.large.url, :rel => "prettyPhoto" .photo{:style => "height:250px;"}
%a{:href => gallery_image.image_file.file.large.url, :"data-remote" => true}
.img
=image_tag(gallery_image.image_file.file.large.medium.small.thumb.url, :alt => "#{gallery_image.title}")
-if i % 4 == 0 %h3{:style => "display:none;"}
=raw "</tr><tr>" =gallery_image.title
=raw "</tr>"