From 220e8161559697fcef2e2fabe72119200f3cd203 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Mon, 30 Jun 2014 19:24:26 +0530 Subject: [PATCH] Gallery initiated --- app/assets/stylesheets/splash.css.scss | 11 ++++++++++ app/controllers/conference_controller.rb | 5 +++++ app/views/conference/_gallery.html.haml | 22 +++++++++++++++++++ app/views/conference/_gallery_photo.html.haml | 3 +++ app/views/conference/photos.js.haml | 3 +++ app/views/conference/show.html.haml | 3 ++- config/routes.rb | 1 + 7 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/views/conference/_gallery.html.haml create mode 100644 app/views/conference/_gallery_photo.html.haml create mode 100644 app/views/conference/photos.js.haml diff --git a/app/assets/stylesheets/splash.css.scss b/app/assets/stylesheets/splash.css.scss index 5388e8a8..d7074a3a 100644 --- a/app/assets/stylesheets/splash.css.scss +++ b/app/assets/stylesheets/splash.css.scss @@ -144,3 +144,14 @@ a:after { font-weight: 400; } } +#gallery{ + .modal-body{ + min-height: 500px; + i{ + margin-top: 35%; + } + } + #carousel-example-generic{ + visibility: hidden; + } +} diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 2bfeee3c..0ad2f58c 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -3,4 +3,9 @@ class ConferenceController < ApplicationController @conference = Conference.find_by_short_title(params[:id]) not_found unless @conference.make_conference_public? end + + def fetch_gallery_photos + @photos = Conference.find(params[:id].to_i).photos + render 'photos', formats: [:js] + end end diff --git a/app/views/conference/_gallery.html.haml b/app/views/conference/_gallery.html.haml new file mode 100644 index 00000000..a604b3d2 --- /dev/null +++ b/app/views/conference/_gallery.html.haml @@ -0,0 +1,22 @@ + +%div{ class: "modal fade", id: "gallery", tabindex: "-1", role: "dialog", "aria-labelledby" => "myModalLabel", "aria-hidden"=> "true" } + %div{ class: "modal-dialog" } + %div{ class: "modal-content" } + %div{ class: "modal-body" } + %div{ id: "carousel-example-generic", class: "carousel slide", "data-ride" => "carousel" } + + %div{ class: "carousel-inner" } + + + %a{ class: "left carousel-control", href: "#carousel-example-generic", role: "button", "data-slide" => "prev" } + %span{ class: "glyphicon glyphicon-chevron-left" } + %a{ class: "right carousel-control", href: "#carousel-example-generic", role: "button", "data-slide" => "next" } + %span{ class: "glyphicon glyphicon-chevron-right" } + + +:javascript + $('#gallery-btn').click(function(){ + $('#gallery .modal-body').append(''); + }); + + diff --git a/app/views/conference/_gallery_photo.html.haml b/app/views/conference/_gallery_photo.html.haml new file mode 100644 index 00000000..37df3584 --- /dev/null +++ b/app/views/conference/_gallery_photo.html.haml @@ -0,0 +1,3 @@ +- photos.each_with_index do |photo,index| + %div.item{ class: (index==0? 'active' : '') } + = image_tag(photo.picture) diff --git a/app/views/conference/photos.js.haml b/app/views/conference/photos.js.haml new file mode 100644 index 00000000..1f113760 --- /dev/null +++ b/app/views/conference/photos.js.haml @@ -0,0 +1,3 @@ +$('#gallery .carousel-inner').append("#{escape_javascript(render('gallery_photo', photos: @photos)) }"); +$('#gallery .modal-body').children('.fa').remove(); +$('#gallery #carousel-example-generic').css('visibility','visible'); diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index ce120949..6497bee1 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -17,7 +17,8 @@ .row-fluid .col-md-12.lead %p= @conference.description - + = link_to 'Gallery', fetch_gallery_photos_conference_path(@conference.id), class: 'btn btn-primary btn-lg', id: 'gallery-btn', data: {toggle: 'modal', target: '#gallery' }, remote: true + = render 'gallery' - if @conference.include_program_in_splash? %section{ id: 'program' } .pad diff --git a/config/routes.rb b/config/routes.rb index a907ff77..11908eae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -92,6 +92,7 @@ Osem::Application.routes.draw do get "/register" => "conference_registration#register" patch "/register" => "conference_registration#update" delete "/register" => "conference_registration#unregister" + get 'fetch_gallery_photos' end end