From 25038a2c2226dea540e48681cb62e51d26a47af7 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Thu, 22 May 2014 16:32:50 +0530 Subject: [PATCH 1/2] Call for papers component for splash page --- .../conference/_call_for_papers.html.haml | 57 +++++++++++++++++++ app/views/conference/show.html.haml | 2 + app/views/home/_conference_details.html.haml | 2 +- spec/factories/call_for_papers.rb | 1 + spec/views/conference/show.html.haml_spec.rb | 6 ++ 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 app/views/conference/_call_for_papers.html.haml diff --git a/app/views/conference/_call_for_papers.html.haml b/app/views/conference/_call_for_papers.html.haml new file mode 100644 index 00000000..3a4113a5 --- /dev/null +++ b/app/views/conference/_call_for_papers.html.haml @@ -0,0 +1,57 @@ += content_for :splash_nav do + %li + %a{ href: '#callforpapers' } Call For Papers + +%div.container#callforpapers.text-center + %div.row + %div.col-md-12 + %h1 + Call For Papers + - if !@conference.call_for_papers.description.blank? + %p + = @conference.call_for_papers.description + %p Proposals will be accepted between #{ date_string(@conference.call_for_papers.start_date, @conference.call_for_papers.end_date) } + - if @conference.cfp_open? + %div.row.col-md-12.col-md-offset-2 + %div.col-md-2 + %h2#days + %p Days + %div.col-md-2 + %h2#hours + %p Hours + %div.col-md-2 + %h2#minutes + %p Minutes + %div.col-md-2 + %h2#seconds + %p Seconds + %p + = link_to "Submit Your Proposals Today", conference_proposal_index_path(@conference.short_title), class: 'btn btn-info', target: '_blank' + +:javascript + $( document ).ready(function(){ + var target_date = new Date("#{@conference.call_for_papers.end_date}").getTime(); + + var days, hours, minutes, seconds; + + setInterval(function () { + + var current_date = new Date().getTime(); + var seconds_left = (target_date - current_date) / 1000; + + days = parseInt(seconds_left / 86400); + seconds_left = seconds_left % 86400; + + hours = parseInt(seconds_left / 3600); + seconds_left = seconds_left % 3600; + + minutes = parseInt(seconds_left / 60); + seconds = parseInt(seconds_left % 60); + + $('#days').text(days) + $('#hours').text(hours); + $('#minutes').text(minutes); + $('#seconds').text(seconds); + }, 1000); + }); + diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 7489d2a9..cbadd6d3 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -4,4 +4,6 @@ = render 'program' %div#registration = render 'registration' +%div#callforpapers + = render 'call_for_papers' diff --git a/app/views/home/_conference_details.html.haml b/app/views/home/_conference_details.html.haml index 335b25ed..1e4a0c18 100644 --- a/app/views/home/_conference_details.html.haml +++ b/app/views/home/_conference_details.html.haml @@ -9,7 +9,7 @@ = conference.title %small %b - = conference_date_string(conference) + = conference_date_string(conference.start_date, conference.end_date) - if conference.venue.name and conference.venue.website and conference.venue.address %p %small diff --git a/spec/factories/call_for_papers.rb b/spec/factories/call_for_papers.rb index eba5dc9e..5bd5720b 100644 --- a/spec/factories/call_for_papers.rb +++ b/spec/factories/call_for_papers.rb @@ -6,5 +6,6 @@ FactoryGirl.define do end_date Date.today + 7 hard_deadline Date.today + 8 description 'We call for papers' + conference end end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index c1d5b43a..8e32e586 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -5,9 +5,11 @@ describe 'conference/show.html.haml' do registration_start_date: Date.today, registration_end_date: Date.tomorrow, description: 'Lorem Ipsum') + @conference.call_for_papers = create(:call_for_papers, conference: @conference) assign :conference, @conference render end + it 'renders program partial' do expect(render).to include("#{@conference.description}") expect(view).to render_template(partial: 'conference/_program') @@ -17,4 +19,8 @@ describe 'conference/show.html.haml' do expect(rendered).to include("#{@conference.registration_description}") expect(view).to render_template(partial: 'conference/_registration') end + + it 'renders call_for_papers partial' do + expect(render).to include("#{@conference.call_for_papers.description}") + end end From c567b0d0ab3a01e7776a8436243659a43facb850 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Wed, 28 May 2014 11:10:05 +0530 Subject: [PATCH 2/2] Rebased and changes in countdown timer logic --- .../conference/_call_for_papers.html.haml | 66 ++++++++++--------- app/views/home/_conference_details.html.haml | 2 +- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/views/conference/_call_for_papers.html.haml b/app/views/conference/_call_for_papers.html.haml index 3a4113a5..72a81b45 100644 --- a/app/views/conference/_call_for_papers.html.haml +++ b/app/views/conference/_call_for_papers.html.haml @@ -12,46 +12,48 @@ = @conference.call_for_papers.description %p Proposals will be accepted between #{ date_string(@conference.call_for_papers.start_date, @conference.call_for_papers.end_date) } - if @conference.cfp_open? - %div.row.col-md-12.col-md-offset-2 - %div.col-md-2 - %h2#days - %p Days - %div.col-md-2 - %h2#hours - %p Hours - %div.col-md-2 - %h2#minutes - %p Minutes - %div.col-md-2 - %h2#seconds - %p Seconds + - if @conference.call_for_papers.end_date.to_time < Time.now + %p Today is the last day. Hurry Up! + - else + %div.row.col-md-12.col-md-offset-2 + %div.col-md-2 + %h2#days + %p Days + %div.col-md-2 + %h2#hours + %p Hours + %div.col-md-2 + %h2#minutes + %p Minutes + %div.col-md-2 + %h2#seconds + %p Seconds %p = link_to "Submit Your Proposals Today", conference_proposal_index_path(@conference.short_title), class: 'btn btn-info', target: '_blank' + -else + %h3 Deadline has ended :javascript $( document ).ready(function(){ var target_date = new Date("#{@conference.call_for_papers.end_date}").getTime(); + if(target_date > new Date().getTime()) + var days, hours, minutes, seconds; + setInterval(function () { + var current_date = new Date().getTime(); + var seconds_left = (target_date - current_date) / 1000; + days = parseInt(seconds_left / 86400); + seconds_left = seconds_left % 86400; - var days, hours, minutes, seconds; + hours = parseInt(seconds_left / 3600); + seconds_left = seconds_left % 3600; - setInterval(function () { + minutes = parseInt(seconds_left / 60); + seconds = parseInt(seconds_left % 60); - var current_date = new Date().getTime(); - var seconds_left = (target_date - current_date) / 1000; - - days = parseInt(seconds_left / 86400); - seconds_left = seconds_left % 86400; - - hours = parseInt(seconds_left / 3600); - seconds_left = seconds_left % 3600; - - minutes = parseInt(seconds_left / 60); - seconds = parseInt(seconds_left % 60); - - $('#days').text(days) - $('#hours').text(hours); - $('#minutes').text(minutes); - $('#seconds').text(seconds); - }, 1000); + $('#days').text(days); + $('#hours').text(hours); + $('#minutes').text(minutes); + $('#seconds').text(seconds); + }, 1000); }); diff --git a/app/views/home/_conference_details.html.haml b/app/views/home/_conference_details.html.haml index 1e4a0c18..335b25ed 100644 --- a/app/views/home/_conference_details.html.haml +++ b/app/views/home/_conference_details.html.haml @@ -9,7 +9,7 @@ = conference.title %small %b - = conference_date_string(conference.start_date, conference.end_date) + = conference_date_string(conference) - if conference.venue.name and conference.venue.website and conference.venue.address %p %small