"<a href='#{url}' modal-width='#{width}' class='open-modal #{clazz}' #{id}>#{h label}</a>"
end
+ # Add a <tfoot> section to a table with pagination details and links.
# Options :
- # :id
- # :colspan
- # :include_loading_icon - only if :id is set as well
+ # :id HTML id of the <tfoot> node
+ # :colspan number of columns in the table
+ # :include_loading_icon adds a hidden loading icon, only if value is true and if the option :id is set as well. The HTML id of the icon
+ # is '<id>_loading'
def table_pagination(pagination, options={}, &block)
html = '<tfoot'
html += " id='#{options[:id]}'" if options[:id]
html += ' '
end
end
- html+= '</div></td></tr></tfoot>'
+ html += '</div></td></tr></tfoot>'
html
end
end
-<tfoot>
-<tr>
- <td colspan="<%= colspan || 1 -%>">
- <% if pagination.count > 0 %>
- <%= message('x_results', :params => [pagination.count]) -%>
- <% end %>
- <%
- 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
- %>
- |
- <% 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>
-</tr>
-</tfoot>
\ No newline at end of file
+<%
+ # this template is deprecated. Please use the method table_pagination.
+%>
+<%= table_pagination(pagination, :colspan => (colspan||1)) { |label, page_id| link_to(label, params.merge({:page => page_id}))} -%>
\ No newline at end of file