@@ -1,37 +1,37 | |||||
1 | module CalendarsHelper |
|
1 | module CalendarsHelper | |
2 | def link_to_previous_month(year, month, options={}) |
|
2 | def link_to_previous_month(year, month, options={}) | |
3 | target_year, target_month = if month == 1 |
|
3 | target_year, target_month = if month == 1 | |
4 | [year - 1, 12] |
|
4 | [year - 1, 12] | |
5 | else |
|
5 | else | |
6 | [year, month - 1] |
|
6 | [year, month - 1] | |
7 | end |
|
7 | end | |
8 |
|
8 | |||
9 | name = if target_month == 12 |
|
9 | name = if target_month == 12 | |
10 | "#{month_name(target_month)} #{target_year}" |
|
10 | "#{month_name(target_month)} #{target_year}" | |
11 | else |
|
11 | else | |
12 | "#{month_name(target_month)}" |
|
12 | "#{month_name(target_month)}" | |
13 | end |
|
13 | end | |
14 |
|
14 | |||
15 | link_to_month(('« ' + name), target_year, target_month, options) |
|
15 | link_to_month(('« ' + name), target_year, target_month, options) | |
16 | end |
|
16 | end | |
17 |
|
17 | |||
18 | def link_to_next_month(year, month, options={}) |
|
18 | def link_to_next_month(year, month, options={}) | |
19 | target_year, target_month = if month == 12 |
|
19 | target_year, target_month = if month == 12 | |
20 | [year + 1, 1] |
|
20 | [year + 1, 1] | |
21 | else |
|
21 | else | |
22 | [year, month + 1] |
|
22 | [year, month + 1] | |
23 | end |
|
23 | end | |
24 |
|
24 | |||
25 | name = if target_month == 1 |
|
25 | name = if target_month == 1 | |
26 | "#{month_name(target_month)} #{target_year}" |
|
26 | "#{month_name(target_month)} #{target_year}" | |
27 | else |
|
27 | else | |
28 | "#{month_name(target_month)}" |
|
28 | "#{month_name(target_month)}" | |
29 | end |
|
29 | end | |
30 |
|
30 | |||
31 | link_to_month((name + ' »'), target_year, target_month, options) |
|
31 | link_to_month((name + ' »'), target_year, target_month, options) | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def link_to_month(link_name, year, month, options={}) |
|
34 | def link_to_month(link_name, year, month, options={}) | |
35 | link_to_content_update(link_name, params.merge(:year => year, :month => month)) |
|
35 | link_to_content_update(h(link_name), params.merge(:year => year, :month => month)) | |
36 | end |
|
36 | end | |
37 | end |
|
37 | end |
General Comments 0
You need to be logged in to leave comments.
Login now