Index: lib/calendar_helper.rb =================================================================== --- lib/calendar_helper.rb (revision 194) +++ lib/calendar_helper.rb (working copy) @@ -22,7 +22,13 @@ # Use (0..2) for the first three letters, (0..0) for the first, and # (0..-1) for the entire name. # :first_day_of_week => 0 # Renders calendar starting on Sunday. Use 1 for Monday, and so on. - # + # :accessible => true # Turns on accessibility mode. This suffixes dates within the + # # calendar that are outside the range defined in the with + # # + # + # # You'll need to define an appropriate style in order to make this disappear. + # # Choose your own method of hiding content appropriately. + # # For more customization, you can pass a code block to this method, that will get one argument, a Date object, # and return a values for the individual table cells. The block can return an array, [cell_text, cell_attrs], # cell_text being the text that is displayed and cell_attrs a hash containing the attributes for the tag @@ -63,7 +69,8 @@ :day_name_class => 'dayName', :day_class => 'day', :abbrev => (0..2), - :first_day_of_week => 0 + :first_day_of_week => 0, + :accessible => false } options = defaults.merge options @@ -79,13 +86,23 @@ end cal = %() - cal << %() - day_names.each {|d| cal << ""} + cal << %() + day_names.each do |d| + unless d[options[:abbrev]].eql? d + cal << "" + else + cal << "" + end + end cal << "" beginning_of_week(first, first_weekday).upto(first - 1) do |d| cal << %() + if options[:accessible] + cal << %(">#{d.day}) + else + cal << %(">#{d.day}) + end end unless first.wday == first_weekday first.upto(last) do |cur| cell_text, cell_attrs = block.call(cur) @@ -99,7 +116,11 @@ (last + 1).upto(beginning_of_week(last + 7, first_weekday) - 1) do |d| cal << %() + if options[:accessible] + cal << %(">#{d.day}) + else + cal << %(">#{d.day}) + end end unless last.wday == last_weekday cal << "
#{Date::MONTHNAMES[options[:month]]}
#{d[options[:abbrev]]}
#{Date::MONTHNAMES[options[:month]]}
#{d[options[:abbrev]]}#{d[options[:abbrev]]}
#{d.day}#{d.day}
" end