]> source.dussan.org Git - redmine.git/commitdiff
Refactor: extract link to previous and next month into helpers.
authorEric Davis <edavis@littlestreamsoftware.com>
Thu, 26 Aug 2010 16:37:05 +0000 (16:37 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Thu, 26 Aug 2010 16:37:05 +0000 (16:37 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4042 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/calendars_helper.rb [new file with mode: 0644]
app/views/calendars/show.html.erb

diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb
new file mode 100644 (file)
index 0000000..d3544f2
--- /dev/null
@@ -0,0 +1,14 @@
+module CalendarsHelper
+  def link_to_previous_month(year, month)
+     link_to_remote ('&#171; ' + (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))}
+  end
+
+  def link_to_next_month(year, month)
+    link_to_remote ((month==12 ? "#{month_name(1)} #{year+1}" : "#{month_name(month+1)}") + ' &#187;'), 
+                        {: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))}
+
+  end
+end
index afbceb9cd10ef78f09b714300311e5aae972b653..09bf7ddf2a16bcbaa2254180888a1c825f4550b6 100644 (file)
 </fieldset>
 
 <p style="float:right;">
-<%= link_to_remote ('&#171; ' + (@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))}
-                        %> |
-<%= link_to_remote ((@month==12 ? "#{month_name(1)} #{@year+1}" : "#{month_name(@month+1)}") + ' &#187;'), 
-                        {: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))}
-                        %>
+  <%= link_to_previous_month(@year, @month) %> | <%= link_to_next_month(@year, @month) %>
 </p>
 
 <p class="buttons">