@@ -1,38 +1,42 | |||||
1 | module CalendarsHelper |
|
1 | module CalendarsHelper | |
2 | def link_to_previous_month(year, month) |
|
2 | def link_to_previous_month(year, month) | |
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_remote ('« ' + name), |
|
15 | link_target = calendar_path(:year => target_year, :month => target_month) | |
16 | {:update => "content", :url => { :year => target_year, :month => target_month }}, |
|
16 | ||
17 | {:href => url_for(:action => 'show', :year => target_year, :month => target_month)} |
|
17 | link_to_remote(('« ' + name), | |
|
18 | {:update => "content", :url => link_target, :method => :put}, | |||
|
19 | {:href => link_target}) | |||
18 | end |
|
20 | end | |
19 |
|
21 | |||
20 | def link_to_next_month(year, month) |
|
22 | def link_to_next_month(year, month) | |
21 | target_year, target_month = if month == 12 |
|
23 | target_year, target_month = if month == 12 | |
22 | [year + 1, 1] |
|
24 | [year + 1, 1] | |
23 | else |
|
25 | else | |
24 | [year, month + 1] |
|
26 | [year, month + 1] | |
25 | end |
|
27 | end | |
26 |
|
28 | |||
27 | name = if target_month == 1 |
|
29 | name = if target_month == 1 | |
28 | "#{month_name(target_month)} #{target_year}" |
|
30 | "#{month_name(target_month)} #{target_year}" | |
29 | else |
|
31 | else | |
30 | "#{month_name(target_month)}" |
|
32 | "#{month_name(target_month)}" | |
31 | end |
|
33 | end | |
32 |
|
34 | |||
33 | link_to_remote (name + ' »'), |
|
35 | link_target = calendar_path(:year => target_year, :month => target_month) | |
34 | {:update => "content", :url => { :year => target_year, :month => target_month }}, |
|
36 | ||
35 | {:href => url_for(:action => 'show', :year => target_year, :month =>target_month)} |
|
37 | link_to_remote((name + ' »'), | |
|
38 | {:update => "content", :url => link_target, :method => :put}, | |||
|
39 | {:href => link_target}) | |||
36 |
|
40 | |||
37 | end |
|
41 | end | |
38 | end |
|
42 | end |
General Comments 0
You need to be logged in to leave comments.
Login now