mini_calendar.mustache 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <%
  2. # Copyright (C) 2011 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <%# cache expires at the top of the next hour %>
  19. <% cache(['mini_calendar_render', current.to_s, first_day.to_s].cache_key, :expires_in => (3600 - (Time.now.to_i % 3600)).seconds) do %>
  20. <div class="mini_month">
  21. <div class="mini-cal-header">
  22. <button class="prev_month_link Button Button--icon-action"><i class="icon-arrow-open-left"></i></button>
  23. <button class="next_month_link Button Button--icon-action"><i class="icon-arrow-open-right"></i></button>
  24. <span class="mini-cal-month-and-year">
  25. <span class="month_name"><%= I18n.t('date.month_names')[current.month] %></span>
  26. <span class="year_number"><%= current.year %></span>
  27. </span>
  28. </div>
  29. <div style="display: none;">
  30. <span class="month_number"><%= current.month %></span>
  31. </div>
  32. <% today = Time.zone.today %>
  33. <table class="mini_calendar" cellspacing="0">
  34. <caption class="screenreader-only"><%= I18n.t 'Calendar' %></caption>
  35. <% day = first_day %>
  36. <thead>
  37. <tr>
  38. <% 7.times do |day_number| %>
  39. <th scope="col">
  40. <span class="screenreader-only">
  41. <%= I18n.t('date.day_names')[day_number] %>
  42. </span>
  43. </th>
  44. <% end %>
  45. </tr>
  46. </thead>
  47. <tbody>
  48. <% 6.times do %>
  49. <tr class="mini_calendar_week">
  50. <% 7.times do %>
  51. <td id="<%= day.strftime("mini_day_%Y_%m_%d") %>" class="mini_calendar_day day <%= day.month == current.month ? 'current_month' : "other_month #{day.month == (current.month + 1) % 12 ? 'next_month' : 'previous_month'}" %><%= day == today ? ' today' : '' %> <%= day.strftime("date_%m_%d_%Y") %>">
  52. <div class="day_wrapper">
  53. <span class="day_number">
  54. <%= day.day %>
  55. </span>
  56. <span class="screenreader-only previous_month_text"><%= I18n.t 'Previous month' %></span>
  57. <span class="screenreader-only next_month_text"><%= I18n.t 'Next month' %></span>
  58. <span class="screenreader-only today_text"><%= I18n.t 'Today' %></span>
  59. <span class="screenreader-only event_link_text"><%= I18n.t 'Click to view event details' %></span>
  60. </div>
  61. </td>
  62. <% day = day.next %>
  63. <% end %>
  64. </tr>
  65. <% end %>
  66. </tbody>
  67. </table>
  68. </div>
  69. <% end %>