Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add selected option for table cell #14

Closed
wants to merge 1 commit into from

1 participant

@scudco

This allows you to pass a selected option to #calendar_for. The table cell with the day that matches the selected date will be given the selected class.

@scudco

Closing out unaddressed Pull Requests

@scudco scudco closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2012
  1. @scudco
This page is out of date. Refresh to see the latest.
View
2  lib/table_builder/calendar_helper.rb
@@ -25,6 +25,7 @@ def initialize(objects, template, calendar, options)
super(objects, template, options)
@calendar = calendar.new(options)
@today = options[:today] || Time.now
+ @selected = options[:selected]
@row_header = options[:row_header] || false
end
@@ -64,6 +65,7 @@ def td_options(day, id_pattern)
options = {}
css_classes = []
css_classes << 'today' if day.strftime("%Y-%m-%d") == @today.strftime("%Y-%m-%d")
+ css_classes << 'selected' if @selected && day.strftime("%Y-%m-%d") == @selected.strftime("%Y-%m-%d")
css_classes << 'notmonth' if day.month != @calendar.month
css_classes << 'weekend' if day.wday == 0 or day.wday == 6
css_classes << 'future' if day > @today.to_date
View
4 test/calendar_helper_test.rb
@@ -64,7 +64,7 @@ def test_calendar_for_with_events
end
def test_calendar_for_sets_css_classes
- output = calendar_for([], :year=> 2008, :month => 12, :today => Date.civil(2008, 12, 15)) do |c|
+ output = calendar_for([], :year=> 2008, :month => 12, :selected => Date.civil(2008,12,14), :today => Date.civil(2008, 12, 15)) do |c|
c.day do |day, events|
concat(events.collect{|e| e.id}.join)
end
@@ -73,7 +73,7 @@ def test_calendar_for_sets_css_classes
%(<tbody>) <<
%(<tr><td class="notmonth weekend"></td><td></td><td></td><td></td><td></td><td></td><td class="weekend"></td></tr>) <<
%(<tr><td class="weekend"></td><td></td><td></td><td></td><td></td><td></td><td class="weekend"></td></tr>) <<
- %(<tr><td class="weekend"></td><td class="today"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="weekend future"></td></tr>) <<
+ %(<tr><td class="selected weekend"></td><td class="today"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="weekend future"></td></tr>) <<
%(<tr><td class="weekend future"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="weekend future"></td></tr>) <<
%(<tr><td class="weekend future"></td><td class="future"></td><td class="future"></td><td class="future"></td><td class="notmonth future"></td><td class="notmonth future"></td><td class="notmonth weekend future"></td></tr>) <<
%(</tbody>) <<
Something went wrong with that request. Please try again.