yippie-io/iUPB

View on GitHub
app/views/timetable/index.html.erb

Summary

Maintainability
Test Coverage
<%  title t("layouts.application.timetable") %>
<%= content_for "page-attributes" do %>id="timetablePage"<% end %>

<h1><%= t ".your_timetable" %></h1>
  
  <h2 id="timetable-duration-label" class="center">
      <a href="#" title="<%= t ".prev_week" %>" id="prev_link" style="left;"><i class="icon-chevron-left"></i></a> 
      <span id="day_title"><%= l @start_time.to_date, format: :weekday_date %> - <%= l @end_time.to_date, format: :weekday_date %></span> 
      <a href="#" title="<%= t ".next_week" %>" id="next_link" style="right;"><i class="icon-chevron-right"></i></a>
  </h2>
  
<div id="timetable">
<% @days.each do |col| %>
    <div class="col box_round" data-tt-col-day="<%= col.to_s %>" id="col_<%= col.to_s %>">
        <div class="label"><h3 class="day_label"><% unless col == 0 %> <%= t ".day_"+col.to_s %><% end %>&nbsp;</h3></div> 
        
        <% @slots.each do |slot| %>
            <div data-tt-start-time="<%= slot[0].sub(":", "") %>" data-tt-end-time="<%= slot[1].sub(":", "") %>" data-tt-day="<%= col.to_s %>" class="slot truncate" style="height:<%= (slot[1].sub(":", "").to_i - slot[0].sub(":", "").to_i) / 3 %>px;">
            <% if col == 0 %>
                <span class="cell_label cell_label_first"><%= slot[0] %> - <%= slot[1] %></span>
            <% else %>
                <span class="cell_label cell_label_middle"><%= slot[0] %> - <%= slot[1] %> </span> 
                <span class="cell">&nbsp;</span>
            <% end %>
            </div>
        <%     
        end %>
    </div>
<% end %>
</div>

<h3 style="clear:both"><%= t ".list" %></h3>
<ul class="no-bullets no-left-margin" id="events_overview">
    <% @events.each do |event| %>
        <li class="well single_event"><h6 id="<%= event.id %>"><%= event.name %></h6>
            <p><%= l event.start_time.utc, format: :short %>
            <% if event.end_time && event.end_time > event.start_time %>
             - <%= l event.end_time.utc, format: :short %>
            <% end %>
            </p>
            <p class="expandeble">
                <%= event.description %>
            </p>
            <% if event.respond_to?(:link) && event.link %>
                <p><%= link_to "&raquo; ".html_safe + t(".details"), event.link %>
            <% end %>
        </li>
    <% end %>
</ul>
<p class="center">
    <% if is_device?("android") %>
        <a href="http://www.google.com/calendar/render?cid=<%= u timetable_export_path(format: "ics", only_path: false, auth_token: current_user.authentication_token) %>" target="_blank" title="add to google calendar"><img src="//www.google.com/calendar/images/ext/gc_button6.gif"></a>
    <% else %>
      <% if Rails.env.production? %>
        <a class="btn btn-small btn-info" href="<%= timetable_export_path(format: "ics", only_path: false, host: "i-upb.de", auth_token: current_user.authentication_token) %>">
            <i class="icon-download-alt icon-white"></i> <%= t ".download_ical" %>
        </a>
        <span class="hidden-phone"> <%= t "or" %> <a class="btn btn-small" href="<%= timetable_export_path(format: "ics", only_path: false, protocol: "webcal", host: "i-upb.de", auth_token: current_user.authentication_token) %>"><%= t ".subscribe_ical" %></a>
        </span>
      <% else %>
        <a class="btn btn-small btn-info" href="<%= timetable_export_path(format: "ics") %>">
            <i class="icon-download-alt icon-white"></i> <%= t ".download_ical" %>
        </a>
        <span class="hidden-phone"> <%= t "or" %> <a class="btn btn-small" href="<%= timetable_export_path(format: "ics", only_path: false, protocol: "webcal", auth_token: current_user.authentication_token) %>"><%= t ".subscribe_ical" %></a>
        </span>
      <% end %>
    <% end %>
</p>
<% content_for :javascript do %>
<script>
$(document).ready(function() {
  window.iUPB.Timetable.setUpPage($("#timetable"), <%= @year_js %>, <%= @week_js %> + 1);
  <% if @userHasNoCourses %>
      <% if canvas? %>
          alert("<%= t(".popover.content")%>");
      <% else # normal website
          %>
        $("#paul-link").popover({title: "<%= t(".popover.title")%>", content: "<%= t(".popover.content")%>" , placement: "bottom", trigger:"manual"}); 
        $("#menu_collapse_link").trigger("click");
        $("#paul-link").popover("toggle");
        setTimeout(function() {
          $("#paul-link").popover("toggle");
          $("#menu_collapse_link").trigger("click");
        }, 10000);
    <% end %>
  <% else %>
      $("div[data-tt-col-day='<%= (@start_time > Time.now ? 0 : Time.now.wday) %>']").get(0).scrollIntoView(true);
  <% end %>
});
</script>
<% end %>