Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/assets/stylesheets/simple_calendar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
text-align: left;
}

thead{
background: pink;
}

td {
padding: 6px;
vertical-align: top;
Expand Down Expand Up @@ -76,3 +80,9 @@

.has-events {}
}

.select-month{
width: 15%;
margin-top: -30px;
margin-left: 880px;
}
15 changes: 13 additions & 2 deletions app/views/simple_calendar/_month_calendar.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<div class="simple-calendar">
<div class="calendar-heading">
<ul class="nav select-month" role="navigation">
<li class="Months">
<%= link_to 'Select Month <b class="caret"></b>'.html_safe, root_path, :'data-toggle' => 'dropdown', :class => 'dropdown-toggle' %>
<ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
<% n = t('date.month_names').count-1 %>
<% (1..n).each do |i| %>
<li class="dropdown-link"><%= link_to t('date.month_names')[i], calendar.custom_month(t('date.month_names')[i]) %></li>
<% end%>
</ul>
</li>
</ul>
<%= link_to t('simple_calendar.previous', default: 'Previous'), calendar.url_for_previous_view %>
<span class="calendar-title"><%= t('date.month_names')[start_date.month] %> <%= start_date.year %></span>
<%= link_to t('simple_calendar.next', default: 'Next'), calendar.url_for_next_view %>
Expand All @@ -20,9 +31,9 @@
<% week.each do |day| %>
<%= content_tag :td, class: calendar.td_classes_for(day) do %>
<% if defined?(Haml) && respond_to?(:block_is_haml?) && block_is_haml?(block) %>
<% capture_haml(day, sorted_events.fetch(day, []), &block) %>
<% capture_haml(day.day, sorted_events.fetch(day, []), &block) %>
<% else %>
<% block.call day, sorted_events.fetch(day, []) %>
<% block.call day.day, sorted_events.fetch(day, []) %>
<% end %>
<% end %>
<% end %>
Expand Down
17 changes: 15 additions & 2 deletions lib/simple_calendar/calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,24 @@ def td_classes_for(day)
td_class << 'prev-month' if start_date.month != day.month && day < start_date
td_class << 'next-month' if start_date.month != day.month && day > start_date
td_class << 'current-month' if start_date.month == day.month
td_class << 'has-events' if sorted_events.fetch(day, []).any?

if sorted_events.fetch(day, []).any?
td_class << 'has-events'
if sorted_events.fetch(day, []).first.type == "federal"
td_class << 'federal'
elsif sorted_events.fetch(day, []).first.type == "holiday"
td_class << 'holiday'
else
td_class << 'system'
end
end
td_class
end

def custom_month(month)
custom_date = month.to_date
view_context.url_for(@params.merge(start_date_param => custom_date))
end

def url_for_next_view
view_context.url_for(@params.merge(start_date_param => date_range.last + 1.day))
end
Expand Down