Skip to content

Commit

Permalink
Multiple ajax calls fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
gopesht committed Jul 1, 2014
1 parent 220e816 commit 1244f93
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/splash.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ a:after {
}
}
#gallery{
min-height: 500px;
.modal-body{
min-height: 500px;
i{
margin-top: 35%;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/conference_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ def show

def fetch_gallery_photos
@photos = Conference.find(params[:id].to_i).photos
render 'photos', formats: [:js]
render "photos", formats: [:js]
end
end
2 changes: 1 addition & 1 deletion app/models/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Photo < ActiveRecord::Base
belongs_to :conference
validates_presence_of :picture
has_attached_file :picture,
styles: { thumb: '100x100>', large: '300x300>' }
styles: { thumb: "100x100>", large: "300x300>", banner: "500x300>" }

validates_attachment_content_type :picture,
content_type: [/jpg/, /jpeg/, /png/, /gif/],
Expand Down
12 changes: 11 additions & 1 deletion app/views/conference/_gallery.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@
:javascript
var count = 0;
$('#gallery-btn').click(function(){
$('#gallery .modal-body').append('<i class="fa fa-spinner fa-spin fa-4x"></i>');
if(count == 0){
$('#gallery').modal('show');
$('#gallery .modal-body').append('<i class="fa fa-spinner fa-spin fa-4x"></i>');
count +=1;
}
else{
$('#gallery').modal('show');
return false;
}
});
2 changes: 1 addition & 1 deletion app/views/conference/_gallery_photo.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
- photos.each_with_index do |photo,index|
%div.item{ class: (index==0? 'active' : '') }
= image_tag(photo.picture)
= image_tag(photo.picture(:banner))
1 change: 1 addition & 0 deletions app/views/conference/photos.js.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
$('#gallery .carousel-inner').append("#{escape_javascript(render('gallery_photo', photos: @photos)) }");
$('#gallery .modal-body').children('.fa').remove();
$('#gallery #carousel-example-generic').css('visibility','visible');

2 changes: 1 addition & 1 deletion app/views/conference/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
.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
= link_to 'Gallery', fetch_gallery_photos_conference_path(@conference.id), class: 'btn btn-primary btn-lg', id: 'gallery-btn', remote: true
= render 'gallery'
- if @conference.include_program_in_splash?
%section{ id: 'program' }
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
get "/register" => "conference_registration#register"
patch "/register" => "conference_registration#update"
delete "/register" => "conference_registration#unregister"
get 'fetch_gallery_photos'
get "fetch_gallery_photos"
end
end

Expand Down

0 comments on commit 1244f93

Please sign in to comment.