##// END OF EJS Templates
Refactor: extract ternary operators to temps....
Eric Davis -
r3929:91380eeaab30
parent child
Show More
@@ -1,14 +1,38
1 module CalendarsHelper
1 module CalendarsHelper
2 def link_to_previous_month(year, month)
2 def link_to_previous_month(year, month)
3 link_to_remote ('« ' + (month==1 ? "#{month_name(12)} #{year-1}" : "#{month_name(month-1)}")),
3 target_year, target_month = if month == 1
4 {:update => "content", :url => { :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1) }},
4 [year - 1, 12]
5 {:href => url_for(:action => 'show', :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1))}
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_remote ('« ' + name),
16 {:update => "content", :url => { :year => target_year, :month => target_month }},
17 {:href => url_for(:action => 'show', :year => target_year, :month => target_month)}
6 end
18 end
7
19
8 def link_to_next_month(year, month)
20 def link_to_next_month(year, month)
9 link_to_remote ((month==12 ? "#{month_name(1)} #{year+1}" : "#{month_name(month+1)}") + ' »'),
21 target_year, target_month = if month == 12
10 {:update => "content", :url => { :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1) }},
22 [year + 1, 1]
11 {:href => url_for(:action => 'show', :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1))}
23 else
24 [year, month + 1]
25 end
26
27 name = if target_month == 1
28 "#{month_name(target_month)} #{target_year}"
29 else
30 "#{month_name(target_month)}"
31 end
32
33 link_to_remote (name + ' »'),
34 {:update => "content", :url => { :year => target_year, :month => target_month }},
35 {:href => url_for(:action => 'show', :year => target_year, :month =>target_month)}
12
36
13 end
37 end
14 end
38 end
General Comments 0
You need to be logged in to leave comments. Login now