Makes all pagination-like links use #link_to_content_update (#5138).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5301 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-04-03 14:01:32 +00:00 committed by Eric Davis
parent 844c0d97aa
commit 07cf681d61
7 changed files with 26 additions and 49 deletions

View File

@ -340,15 +340,15 @@ module ApplicationHelper
html = '' html = ''
if paginator.current.previous if paginator.current.previous
html << link_to_remote_content_update('&#171; ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' ' html << link_to_content_update('&#171; ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
end end
html << (pagination_links_each(paginator, options) do |n| html << (pagination_links_each(paginator, options) do |n|
link_to_remote_content_update(n.to_s, url_param.merge(page_param => n)) link_to_content_update(n.to_s, url_param.merge(page_param => n))
end || '') end || '')
if paginator.current.next if paginator.current.next
html << ' ' + link_to_remote_content_update((l(:label_next) + ' &#187;'), url_param.merge(page_param => paginator.current.next)) html << ' ' + link_to_content_update((l(:label_next) + ' &#187;'), url_param.merge(page_param => paginator.current.next))
end end
unless count.nil? unless count.nil?
@ -363,10 +363,7 @@ module ApplicationHelper
def per_page_links(selected=nil) def per_page_links(selected=nil)
links = Setting.per_page_options_array.collect do |n| links = Setting.per_page_options_array.collect do |n|
n == selected ? n : link_to_remote(n, {:update => "content", n == selected ? n : link_to_content_update(n, params.merge(:per_page => n))
:url => params.merge(:per_page => n),
:method => :get},
{:href => url_for(params.merge(:per_page => n))})
end end
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
end end
@ -944,11 +941,10 @@ module ApplicationHelper
return self return self
end end
def link_to_remote_content_update(text, url_params) def link_to_content_update(text, url_params = {}, html_options = {})
link_to_remote(text, link_to_remote(text,
{:url => url_params, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:url => url_params, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_params)} {:href => url_for(:params => url_params)}.merge(html_options)
) )
end end
end end

View File

@ -32,14 +32,6 @@ module CalendarsHelper
end end
def link_to_month(link_name, year, month, options={}) def link_to_month(link_name, year, month, options={})
project_id = options[:project].present? ? options[:project].to_param : nil link_to_content_update(link_name, params.merge(:year => year, :month => month))
link_target = calendar_path(:year => year, :month => month, :project_id => project_id)
link_to_remote(link_name,
{:update => "content", :url => link_target, :method => :get},
{:href => link_target})
end end
end end

View File

@ -21,20 +21,18 @@ module GanttHelper
case in_or_out case in_or_out
when :in when :in
if gantt.zoom < 4 if gantt.zoom < 4
link_to_remote(l(:text_zoom_in), link_to_content_update l(:text_zoom_in),
{:url => gantt.params.merge(:zoom => (gantt.zoom+1)), :method => :get, :update => 'content'}, params.merge(gantt.params.merge(:zoom => (gantt.zoom+1))),
{:href => url_for(gantt.params.merge(:zoom => (gantt.zoom+1))), :class => 'icon icon-zoom-in'
:class => 'icon icon-zoom-in'})
else else
content_tag('span', l(:text_zoom_in), :class => 'icon icon-zoom-in') content_tag('span', l(:text_zoom_in), :class => 'icon icon-zoom-in')
end end
when :out when :out
if gantt.zoom > 1 if gantt.zoom > 1
link_to_remote(l(:text_zoom_out), link_to_content_update l(:text_zoom_out),
{:url => gantt.params.merge(:zoom => (gantt.zoom-1)), :method => :get, :update => 'content'}, params.merge(gantt.params.merge(:zoom => (gantt.zoom-1))),
{:href => url_for(gantt.params.merge(:zoom => (gantt.zoom-1))), :class => 'icon icon-zoom-out'
:class => 'icon icon-zoom-out'})
else else
content_tag('span', l(:text_zoom_out), :class => 'icon icon-zoom-out') content_tag('span', l(:text_zoom_out), :class => 'icon icon-zoom-out')
end end

View File

@ -206,10 +206,7 @@ module SortHelper
# Add project_id to url_options # Add project_id to url_options
url_options = url_options.merge(:project_id => params[:project_id]) if params.has_key?(:project_id) url_options = url_options.merge(:project_id => params[:project_id]) if params.has_key?(:project_id)
link_to_remote(caption, link_to_content_update(caption, url_options, :class => css)
{:update => "content", :url => url_options, :method => :get},
{:href => url_for(url_options),
:class => css})
end end
# Returns a table header <th> tag with a sort link for the named column # Returns a table header <th> tag with a sort link for the named column

View File

@ -21,16 +21,14 @@
<%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %> <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
<div style="float:left;"> <div style="float:left;">
<%= link_to_remote(('&#171; ' + l(:label_previous)), <%= link_to_content_update('&#171; ' + l(:label_previous),
{:update => "content", :url => params.merge(:from => @date_to - @days - 1), :method => :get, :complete => 'window.scrollTo(0,0)'}, params.merge(:from => @date_to - @days - 1),
{:href => url_for(params.merge(:from => @date_to - @days - 1)), :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))) %>
:title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))}) %>
</div> </div>
<div style="float:right;"> <div style="float:right;">
<%= link_to_remote((l(:label_next) + ' &#187;'), <%= link_to_content_update(l(:label_next) + ' &#187;',
{:update => "content", :url => params.merge(:from => @date_to + @days - 1), :method => :get, :complete => 'window.scrollTo(0,0)'}, params.merge(:from => @date_to + @days - 1),
{:href => url_for(params.merge(:from => @date_to + @days - 1)), :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to >= Date.today %>
:title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))}) unless @date_to >= Date.today %>
</div> </div>
&nbsp; &nbsp;
<% other_formats_links do |f| %> <% other_formats_links do |f| %>

View File

@ -178,8 +178,8 @@ if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
<table width="100%"> <table width="100%">
<tr> <tr>
<td align="left"><%= link_to_remote ('&#171; ' + l(:label_previous)), {:url => @gantt.params_previous, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_previous)} %></td> <td align="left"><%= link_to_content_update('&#171; ' + l(:label_previous), params.merge(@gantt.params_previous)) %></td>
<td align="right"><%= link_to_remote (l(:label_next) + ' &#187;'), {:url => @gantt.params_next, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_next)} %></td> <td align="right"><%= link_to_content_update(l(:label_next) + ' &#187;', params.merge(@gantt.params_next)) %></td>
</tr> </tr>
</table> </table>

View File

@ -35,16 +35,12 @@
<p><center> <p><center>
<% if @pagination_previous_date %> <% if @pagination_previous_date %>
<%= link_to_remote ('&#171; ' + l(:label_previous)), <%= link_to_content_update('&#171; ' + l(:label_previous),
{:update => :content, params.merge(:previous => 1, :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))) %>&nbsp;
:url => params.merge(:previous => 1, :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))
}, :href => url_for(params.merge(:previous => 1, :offset => @pagination_previous_date.strftime("%Y%m%d%H%M%S"))) %>&nbsp;
<% end %> <% end %>
<% if @pagination_next_date %> <% if @pagination_next_date %>
<%= link_to_remote (l(:label_next) + ' &#187;'), <%= link_to_content_update(l(:label_next) + ' &#187;',
{:update => :content, params.merge(:previous => nil, :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))) %>
:url => params.merge(:previous => nil, :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))
}, :href => url_for(params.merge(:previous => nil, :offset => @pagination_next_date.strftime("%Y%m%d%H%M%S"))) %>
<% end %> <% end %>
</center></p> </center></p>