Mercurial > hg > soundsoftware-site
comparison app/helpers/.svn/text-base/calendars_helper.rb.svn-base @ 22:40f7cfd4df19
* Update to SVN trunk rev 4173
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 24 Sep 2010 14:06:04 +0100 |
parents | |
children | cbce1fd3b1b7 |
comparison
equal
deleted
inserted
replaced
14:1d32c0a0efbf | 22:40f7cfd4df19 |
---|---|
1 module CalendarsHelper | |
2 def link_to_previous_month(year, month, options={}) | |
3 target_year, target_month = if month == 1 | |
4 [year - 1, 12] | |
5 else | |
6 [year, month - 1] | |
7 end | |
8 | |
9 name = if target_month == 12 | |
10 "#{month_name(target_month)} #{target_year}" | |
11 else | |
12 "#{month_name(target_month)}" | |
13 end | |
14 | |
15 link_to_month(('« ' + name), target_year, target_month, options) | |
16 end | |
17 | |
18 def link_to_next_month(year, month, options={}) | |
19 target_year, target_month = if month == 12 | |
20 [year + 1, 1] | |
21 else | |
22 [year, month + 1] | |
23 end | |
24 | |
25 name = if target_month == 1 | |
26 "#{month_name(target_month)} #{target_year}" | |
27 else | |
28 "#{month_name(target_month)}" | |
29 end | |
30 | |
31 link_to_month((name + ' »'), target_year, target_month, options) | |
32 end | |
33 | |
34 def link_to_month(link_name, year, month, options={}) | |
35 project_id = options[:project].present? ? options[:project].to_param : nil | |
36 | |
37 link_target = calendar_path(:year => year, :month => month, :project_id => project_id) | |
38 | |
39 link_to_remote(link_name, | |
40 {:update => "content", :url => link_target, :method => :put}, | |
41 {:href => link_target}) | |
42 | |
43 end | |
44 | |
45 end |