mirror of
https://github.com/openSUSE/osem.git
synced 2026-04-21 15:30:41 -04:00
The schedule takes you to the current day and time
The schedule takes you to the current day and time in case that the current date belongs to the conference schedule. Closes https://github.com/openSUSE/osem/issues/1057
This commit is contained in:
@@ -24,6 +24,13 @@ class ConferenceController < ApplicationController
|
||||
@conf_start = 9
|
||||
conf_end = 20
|
||||
@conf_period = conf_end - @conf_start
|
||||
|
||||
# the schedule takes you to today if it is a date of the schedule
|
||||
@current_day = @conference.current_conference_day
|
||||
@day = @current_day.present? ? @current_day : @dates.first
|
||||
return unless @current_day
|
||||
# the schedule takes you to the current time if it is beetween the start and the end time.
|
||||
@hour_column = @conference.hours_from_start_time(@conf_start, conf_end)
|
||||
end
|
||||
|
||||
def events
|
||||
|
||||
@@ -335,4 +335,14 @@ module ApplicationHelper
|
||||
# speaker picture padding: 4px 2px; and we want the picture to be a circle
|
||||
speaker_height(rooms) - 4
|
||||
end
|
||||
|
||||
def carousel_item_class(number, carousel_number, num_cols, col)
|
||||
item_class = 'item'
|
||||
item_class += ' first' if number == 0
|
||||
item_class += ' last' if number == (carousel_number - 1)
|
||||
if (col && ((col / num_cols) == number)) || (!col && number == 0)
|
||||
item_class += ' active'
|
||||
end
|
||||
item_class
|
||||
end
|
||||
end
|
||||
|
||||
@@ -615,6 +615,15 @@ class Conference < ActiveRecord::Base
|
||||
day if (start_date..end_date).cover? day
|
||||
end
|
||||
|
||||
# Returns the number of hours since the conference start hour (9) to the
|
||||
# current hour, in case that the current hour is beetween the start and the
|
||||
# end hour (20). Otherwise, returns 0
|
||||
def hours_from_start_time(start_hour, end_hour)
|
||||
current_time = Time.find_zone(timezone).now
|
||||
current_hour = current_time.strftime('%H').to_i
|
||||
(start_hour..(end_hour-1)).cover?(current_hour) ? current_hour - start_hour : 0
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns a different html colour for every i and consecutive colors are
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
.carousel-inner
|
||||
- start_time = DateTime.parse("#{date} #{@conf_start}:00")
|
||||
- (0..carousel_number-1).each do |number|
|
||||
%div{ class: "item #{ number == 0 ? 'active first' : ( number == carousel_number-1 ? 'last' : '') }" }
|
||||
%div{ class: "#{ carousel_item_class(number, carousel_number, number_columns, @hour_column)}" }
|
||||
%table.table.table-bordered.schedule-table#schedule
|
||||
%tr
|
||||
%th
|
||||
|
||||
@@ -7,16 +7,16 @@
|
||||
= @conference.title
|
||||
.dropdown.schedule-dropdown
|
||||
%button{ type: "button", class: "btn btn-default dropdown-toggle", 'data-toggle' => "dropdown" }
|
||||
= @dates.first
|
||||
= @day
|
||||
%span.caret
|
||||
%ul.dropdown-menu
|
||||
- @dates.each do |date|
|
||||
%li.li-dropdown-schedule
|
||||
%li.li-dropdown-schedule{ class: "#{ 'active' if @day == date }" }
|
||||
= link_to date, "#" + "#{date}", "data-toggle" => "tab", "class" => "date-tab"
|
||||
|
||||
.tab-content
|
||||
- @dates.each do |date|
|
||||
%div{ class: "tab-pane #{ 'active' if @dates.first == date }", id: "#{ date }" }
|
||||
%div{ class: "tab-pane #{ 'active' if @day == date }", id: "#{ date }" }
|
||||
|
||||
.visible-xs-inline
|
||||
= render partial: 'carousel', locals: { date: date, number_columns: 1 }
|
||||
@@ -28,7 +28,7 @@
|
||||
= render partial: 'carousel', locals: { date: date, number_columns: 3 }
|
||||
|
||||
:javascript
|
||||
// change of active tab and the button title when a date clicked
|
||||
// change of active tab and the button title when a date is clicked
|
||||
$(function() {
|
||||
$('.date-tab').on('click', function(e) {
|
||||
$('.li-dropdown-schedule').removeClass('active');
|
||||
@@ -43,14 +43,22 @@
|
||||
$(this).children('.right.carousel-control').show();
|
||||
if($(this).find('.first').hasClass('active')) {
|
||||
$(this).children('.left.carousel-control').hide();
|
||||
} else if($(this).find('.last').hasClass('active')) {
|
||||
}
|
||||
if($(this).find('.last').hasClass('active')) {
|
||||
$(this).children('.right.carousel-control').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
// hide the left control when the page is ready
|
||||
$('.carousel').children('.left.carousel-control').hide();
|
||||
$('.carousel').each(function() {
|
||||
if($(this).find('.first').hasClass('active')) {
|
||||
$(this).children('.left.carousel-control').hide();
|
||||
}
|
||||
if($(this).find('.last').hasClass('active')) {
|
||||
$(this).children('.right.carousel-control').hide();
|
||||
}
|
||||
});
|
||||
|
||||
// carousel swipe
|
||||
$(".carousel-inner").swiperight(function() {
|
||||
@@ -60,10 +68,14 @@
|
||||
$(this).parent().carousel('next');
|
||||
});
|
||||
|
||||
// use the date tag in the url to select a tab and the title of the button
|
||||
var hash = window.location.hash;
|
||||
if(hash && !(hash === '#schedule')){
|
||||
hash && $('ul a[href="' + hash + '"]').tab('show');
|
||||
$('button.dropdown-toggle').text(hash.substr(1));
|
||||
var day = "#{@current_day}";
|
||||
// we only go to the date tag in the url if the conference is not taking place now
|
||||
if(day === ""){
|
||||
// use the date tag in the url to select a tab and the title of the button
|
||||
var hash = window.location.hash;
|
||||
if(hash && !(hash === '#schedule')){
|
||||
hash && $('ul a[href="' + hash + '"]').tab('show');
|
||||
$('button.dropdown-toggle').text(hash.substr(1));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user