method added to autocycle through sponsors based on sponsor level and code added to inherit twitter env variables

This commit is contained in:
AnithaPal 2016-08-01 15:44:01 -04:00
parent 881518f1f3
commit e8d3177ec1
14 changed files with 89 additions and 163 deletions

View file

@ -1,21 +1,32 @@
$(document).ready(function() {
// will call refreshCurrentEvents every 15 minutes
setInterval(refreshCurrentEvents, 900000)
// To cycle through tweets
var tweets = $('div[id^="tweet"]').hide();
var i = 0;
setInterval(refreshCurrentEvents,900000);
(function cycle() {
tweets.eq(i).show(0)
.delay(5000)
.hide(0, cycle);
i = ++i % tweets.length;
})();
// Only show the first child of tweet and sponsor containers on page load
$('#tweet-container').children().hide();
$('#tweet-container').children().eq(0).show();
$('#sponsor-container').children().hide();
$('#sponsor-container').children().eq(0).show();
});
setInterval(function(){ cycleVisibleElement($('#tweet-container'))}, 5000)
setInterval(function(){ cycleVisibleElement($('#sponsor-container'))}, 10000)
});
// Makes an ajax call for fresh data
function refreshCurrentEvents(){
$.ajax({
url: "conference_wide_screen.js"
});
};
// Cycle through children in a container and toggles visibility
function cycleVisibleElement(container){
var childrens = $(container).children();
for(var i = 0; i < childrens.length; i++ ){
if(childrens.eq(i).is(":visible")){
childrens.eq(i).hide();
childrens.eq(++i % childrens.length).show();
return
}
}
};

View file

@ -8,7 +8,6 @@
*= require osem-schedule-print
*= require osem-dashboard
*= require osem-splash
*= require osem-conference-wide-screen
*= require font-awesome
*= require osem-fonts
*= require bootstrap-markdown

View file

@ -1,77 +0,0 @@
@import "breakpoints.css.scss";
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by 2 times the footer height */
// margin-bottom: 60px;
/* Margin bottom by navbar height */
padding-top: 10px;
}
#main-display {
// Counter the general padding for #content
// margin-bottom: -60px;
section {
padding: 10px;
}
#main-heading {
position: absolute;
top: 0;
width: 100%;
height: 120px;
background-color: #abcdef;
}
#event-display{
position: absolute;
bottom:480px;
width: 100%;
top: 120px;
background-color: #00FF00;
}
#tweets-display {
position: absolute;
height: 150px;
bottom: 330px;
width: 100%;
background-color: #F63;
}
#sponsor-display {
position: absolute;
bottom: 0;
width: 100%;
max-height: 330px;
background-color: #FF1493;
.container {
background-color: yellow;
max-height: 310px;
}
.img-sponsor {
max-height: 50px;
margin: 2% auto;
}
.img-sponsor-1 {
max-height: 90px;
}
.img-sponsor-2 {
max-height: 70px;
}
.img-sponsor-3 {
max-height: 50px;
}
@include breakpoint(xs) {
.img-sponsor, .img-sponsor-1, .img-sponsor-3, .img-sponsor-3{
max-height: unset;
max-width: 280px;
}
}
}
}

View file

@ -175,10 +175,9 @@ module Admin
def conference_wide_screen
# To display sponsors in the conference wide information page
@conference = Conference.find_by(short_title: params[:id])
@sponsors = @conference.sponsors
@program = @conference.program
@current_events = @conference.program.events.confirmed.select(&:current?)
@current_events = @conference.program.events.current
@tweets = twitter_client.search_tweets(15, @conference.contact.social_tag)
respond_to do |format|

View file

@ -41,6 +41,7 @@ class Event < ActiveRecord::Base
scope :canceled, -> { where(state: 'canceled') }
scope :withdrawn, -> { where(state: 'withdrawn') }
scope :highlighted, -> { where(is_highlight: true) }
scope :current, -> { joins(:event_type).where('start_time <= ? AND state = ?', Time.current, 'confirmed').map { |e| e if e.end_time > Time.current }.compact }
state_machine initial: :new do
state :new
@ -248,10 +249,10 @@ class Event < ActiveRecord::Base
end
##
# Compares event start_time, end_with with current time to predict current events
# Returns end of the event
#
def current?
Time.current >= self.start_time && Time.current <= self.end_time
def end_time
self.start_time + self.event_type.length.minutes
end
private
@ -308,5 +309,4 @@ class Event < ActiveRecord::Base
def current?
Time.current >= self.start_time && Time.current <= self.end_time
end
end

View file

@ -1,8 +1,14 @@
.container
.row
.col-md-12.text-center
%h2 Conference Tweets
- @tweets.each do |tweet|
%div#tweet
= tweet.user.name
= tweet.text
%h2
= "#" + @conference.contact.social_tag + " Tweets"
%div#tweet-container
- @tweets.each do |tweet|
%div#tweet
%blockquote.twitter-tweet
%p{:lang => "en"}
= tweet.text
= link_to "— @" + tweet.user.name, "http://www.twitter.com/#{tweet.user.name}", target: "_blank"
= link_to tweet.url, tweet.url.to_s

View file

@ -2,10 +2,11 @@
.row
.col-md-12.text-center
%h2 Sponsors
- @conference.sponsorship_levels.each do |sponsorship_level|
-if sponsorship_level.sponsors.any?
- sponsorship_level.sponsors.each_slice(3) do |slice|
.row.row-centered
- slice.each do |sponsor|
.col-md-4.col-sm-4.col-centered.col-top
= image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}"
%div#sponsor-container
- @conference.sponsorship_levels.each do |sponsorship_level|
-if sponsorship_level.sponsors.any?
- sponsorship_level.sponsors.each_slice(3) do |slice|
.row.row-centered#sponsor
- slice.each do |sponsor|
.col-md-4.col-sm-4.col-centered.col-top
= image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}"

View file

@ -6,11 +6,11 @@
- if @conference.description.present?
%h3
= @conference.description
- if @program.present?
.row
- if @current_events.present?
.row#current-events
= render 'current_events'
- if @conference.contact.social_tag.present? && @tweets.present?
.row
.row#conference-tweets
= render 'conference_tweets'
- if @sponsors.any?
= render 'sponsors'

View file

@ -1 +1,4 @@
$('#current-events').html("#{escape_javascript(render 'current_events', data: @current_events)}");
$('#conference-tweets').html("#{escape_javascript(render 'conference_tweets', data: @tweets)}");
$('#tweet-container').children().hide();
$('#tweet-container').children().eq(0).show();