Commit 121e0539 authored by edavis10's avatar edavis10

Refactor: extract ternary operators to temps.

git-svn-id: https://svn.redmine.org/redmine/trunk@4043 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent be7288c3
module CalendarsHelper
def link_to_previous_month(year, month)
link_to_remote ('« ' + (month==1 ? "#{month_name(12)} #{year-1}" : "#{month_name(month-1)}")),
{:update => "content", :url => { :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1) }},
{:href => url_for(:action => 'show', :year => (month==1 ? year-1 : year), :month =>(month==1 ? 12 : month-1))}
target_year, target_month = if month == 1
[year - 1, 12]
else
[year, month - 1]
end
name = if target_month == 12
"#{month_name(target_month)} #{target_year}"
else
"#{month_name(target_month)}"
end
link_to_remote ('« ' + name),
{:update => "content", :url => { :year => target_year, :month => target_month }},
{:href => url_for(:action => 'show', :year => target_year, :month => target_month)}
end
def link_to_next_month(year, month)
link_to_remote ((month==12 ? "#{month_name(1)} #{year+1}" : "#{month_name(month+1)}") + ' »'),
{:update => "content", :url => { :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1) }},
{:href => url_for(:action => 'show', :year => (month==12 ? year+1 : year), :month =>(month==12 ? 1 : month+1))}
target_year, target_month = if month == 12
[year + 1, 1]
else
[year, month + 1]
end
name = if target_month == 1
"#{month_name(target_month)} #{target_year}"
else
"#{month_name(target_month)}"
end
link_to_remote (name + ' »'),
{:update => "content", :url => { :year => target_year, :month => target_month }},
{:href => url_for(:action => 'show', :year => target_year, :month =>target_month)}
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment