2015-03-09 15:31:06 +01:00
|
|
|
<div id="schedule-content">
|
|
|
|
|
<h1 class="text-center"> Schedule for <%= @conference.title %></h1>
|
|
|
|
|
<ul class="nav nav-tabs">
|
|
|
|
|
<% @dates.each do |date| %>
|
|
|
|
|
<li <%= "class=active" if @dates.first == date %>>
|
|
|
|
|
<%= link_to date, "#" + "#{date}", "data-toggle" => "tab" %>
|
|
|
|
|
</li>
|
|
|
|
|
<% end %>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div class="tab-content">
|
|
|
|
|
<% @dates.each do |date| %>
|
|
|
|
|
<div class="tab-pane <%= 'active' if @dates.first == date %>" id ="<%= date %>" >
|
|
|
|
|
<table class="table table-bordered" id="schedule" width="100%">
|
|
|
|
|
<tr>
|
2016-05-30 20:04:08 +02:00
|
|
|
<th>Rooms</th>
|
2016-06-01 11:22:22 +02:00
|
|
|
<% (@start_hour..@end_hour-1).each do |i| %>
|
2016-05-30 20:04:08 +02:00
|
|
|
<th colspan="4"><%= "#{i}:00" %></th>
|
2015-03-09 15:31:06 +01:00
|
|
|
<% end %>
|
|
|
|
|
</tr>
|
2016-05-30 20:04:08 +02:00
|
|
|
<% @rooms.each do |room| %>
|
|
|
|
|
<% span = 1 %>
|
2015-03-09 15:31:06 +01:00
|
|
|
<tr>
|
2016-05-30 20:04:08 +02:00
|
|
|
<td><%= room.name %></td>
|
|
|
|
|
<% events_for_date = room.events.find_all{ |e| e.start_time.to_date == date } %>
|
2016-06-01 11:22:22 +02:00
|
|
|
<% start_time = DateTime.parse("#{date} #{@start_hour}:00") %>
|
|
|
|
|
<% (1..@intervals).each do |i| %>
|
2016-05-30 20:04:08 +02:00
|
|
|
<% events_for_time = events_for_date.find_all{|e| e.start_time == start_time} %>
|
|
|
|
|
<% if !events_for_time.empty? %>
|
|
|
|
|
<% event = events_for_time[0] %>
|
|
|
|
|
<!-- There is an event, calculate the span and show it -->
|
2016-06-01 11:22:22 +02:00
|
|
|
<% span = event.span %>
|
|
|
|
|
<%= render partial: 'schedule_item', locals: {event: event, span: span, width: @width} %>
|
2016-05-30 20:04:08 +02:00
|
|
|
<% span += 1 %>
|
|
|
|
|
<% elsif span > 1 %>
|
|
|
|
|
<% span -= 1 %>
|
2015-03-09 15:31:06 +01:00
|
|
|
<% end %>
|
2016-05-30 20:04:08 +02:00
|
|
|
<% if span == 1 %>
|
2015-03-09 15:31:06 +01:00
|
|
|
<!-- span equals 1 show an empty td -->
|
2016-06-01 11:22:22 +02:00
|
|
|
<td style="width: <%= @width %>%"></td>
|
2015-03-09 15:31:06 +01:00
|
|
|
<% end %>
|
2016-06-01 11:22:22 +02:00
|
|
|
<% start_time += @step_minutes %>
|
2016-05-30 20:04:08 +02:00
|
|
|
<% end %>
|
2015-03-09 15:31:06 +01:00
|
|
|
</tr>
|
2016-05-30 20:04:08 +02:00
|
|
|
<% end %>
|
2015-03-09 15:31:06 +01:00
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<% end %>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<%= javascript_tag do %>
|
|
|
|
|
$(function() {
|
|
|
|
|
// add a hash to the URL when the user clicks on a tab
|
|
|
|
|
$('a[data-toggle="tab"]').on('click', function(e) {
|
|
|
|
|
history.pushState(null, null, $(this).attr('href'));
|
|
|
|
|
});
|
|
|
|
|
// navigate to a tab when the history changes
|
|
|
|
|
window.addEventListener("popstate", function(e) {
|
|
|
|
|
var activeTab = $('[href=' + location.hash + ']');
|
|
|
|
|
if (activeTab.length) {
|
|
|
|
|
activeTab.tab('show');
|
|
|
|
|
} else {
|
|
|
|
|
$('.nav-tabs a[href=#<%= j @today %>]').tab('show');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(function() {
|
|
|
|
|
var hash = window.location.hash;
|
|
|
|
|
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
<% end %>
|