annotate app/helpers/calendars_helper.rb @ 45:65d9e2cabaa3 luisf

Added tipoftheday to the config/settings in order to correct previous issues. Tip of the day is now working correctly. Added the heading strings to the locales files.
author luisf
date Tue, 23 Nov 2010 11:50:01 +0000
parents 40f7cfd4df19
children cbce1fd3b1b7
rev   line source
chris@22 1 module CalendarsHelper
chris@22 2 def link_to_previous_month(year, month, options={})
chris@22 3 target_year, target_month = if month == 1
chris@22 4 [year - 1, 12]
chris@22 5 else
chris@22 6 [year, month - 1]
chris@22 7 end
chris@22 8
chris@22 9 name = if target_month == 12
chris@22 10 "#{month_name(target_month)} #{target_year}"
chris@22 11 else
chris@22 12 "#{month_name(target_month)}"
chris@22 13 end
chris@22 14
chris@22 15 link_to_month(('« ' + name), target_year, target_month, options)
chris@22 16 end
chris@22 17
chris@22 18 def link_to_next_month(year, month, options={})
chris@22 19 target_year, target_month = if month == 12
chris@22 20 [year + 1, 1]
chris@22 21 else
chris@22 22 [year, month + 1]
chris@22 23 end
chris@22 24
chris@22 25 name = if target_month == 1
chris@22 26 "#{month_name(target_month)} #{target_year}"
chris@22 27 else
chris@22 28 "#{month_name(target_month)}"
chris@22 29 end
chris@22 30
chris@22 31 link_to_month((name + ' »'), target_year, target_month, options)
chris@22 32 end
chris@22 33
chris@22 34 def link_to_month(link_name, year, month, options={})
chris@22 35 project_id = options[:project].present? ? options[:project].to_param : nil
chris@22 36
chris@22 37 link_target = calendar_path(:year => year, :month => month, :project_id => project_id)
chris@22 38
chris@22 39 link_to_remote(link_name,
chris@22 40 {:update => "content", :url => link_target, :method => :put},
chris@22 41 {:href => link_target})
chris@22 42
chris@22 43 end
chris@22 44
chris@22 45 end