<th class="left"><%= message('name') -%> <span style="font-weight: normal">[<%= link_to_function(message('rules_configuration.expand'), "expand_rules()") %> / <%= link_to_function(message('rules_configuration.collapse'), "collapse_rules()") %>]</span></th>
</tr>
</thead>
+
+<%= render :partial => 'utils/tfoot_pagination', :locals => {:pagination => @pagination, :colspan => 2} %>
+
<tbody>
<% if @current_rules.empty? %>
<tr><td colspan="3" class="even"><%= message('no_results') -%>.</td></tr>
<% end %>
</tbody>
</table>
-<%= render :partial => 'utils/tfoot_pagination', :locals => {:pagination => @pagination, :colspan => 2} %>
<script type="text/javascript">
function replaceTextField(span_id, key) {
<tfoot>
<tr>
<td colspan="<%= colspan || 1 -%>">
- <% if pagination.count>0 %>
- <%= message('x_results', :params => [pagination.count]) -%>
+ <% if pagination.count > 0 %>
+ <%= message('x_results', :params => [pagination.count]) -%>
<% end %>
<%
- if pagination.pages>1
+ if pagination.pages > 1
+ max_pages = pagination.pages
+ current_page = pagination.page
+ start_page = 1
+ end_page = max_pages
+ if max_pages > 20
+ if current_page < 12
+ start_page = 1
+ end_page = 20
+ elsif current_page > max_pages-10
+ start_page = max_pages-20
+ end_page = max_pages
+ else
+ start_page = current_page-10
+ end_page = current_page+9
+ end
+ end
%>
|
- <%= link_to_if pagination.previous?, message('paging_previous'), params.merge(:page => pagination.page-1) %>
- <%= link_to_if pagination.next?, message('paging_next'), params.merge(:page => pagination.page+1) %>
- |
- <% for index in 1..pagination.pages %>
- <%= link_to_if index!=pagination.page, index.to_s, params.merge(:page => index) %>
+ <% if max_pages > 20 && start_page > 1 %>
+ <%= link_to_if current_page != 1, message('paging_first'), params.merge(:page => 1) %>
<% end %>
- <%
+ <%= link_to_if pagination.previous?, message('paging_previous'), params.merge(:page => current_page-1) %>
+ <% for index in start_page..end_page %>
+ <%= link_to_if index != current_page, index.to_s, params.merge(:page => index) %>
+ <% end %>
+ <%= link_to_if pagination.next?, message('paging_next'), params.merge(:page => current_page+1) %>
+ <% if max_pages > 20 && end_page < max_pages %>
+ <%= link_to_if current_page != max_pages, message('paging_last'), params.merge(:page => max_pages) %>
+ <% end %>
+ <%
end
%>
</td>