add arrows to paginator

This commit is contained in:
albert 2012-12-24 16:35:17 -05:00
parent 66e9954ace
commit a7a03a241b
2 changed files with 12 additions and 2 deletions

View File

@ -102,7 +102,7 @@ GEM
newrelic_rpm (3.4.1)
nokogiri (1.5.5)
ntlm-http (0.1.1)
pg (0.14.0)
pg (0.12.2)
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.3)
@ -197,7 +197,7 @@ DEPENDENCIES
mocha
newrelic_rpm
nokogiri
pg
pg (= 0.12.2)
pry
rails (= 3.2.3)
rmagick

View File

@ -25,6 +25,11 @@ module PaginationHelper
html = '<div class="paginator"><menu>'
window = 3
if records.current_page >= 2
html << link_to("&lt;&lt;", params.merge(:page => 1))
end
if records.total_pages <= (window * 2) + 5
1.upto(records.total_pages) do |page|
html << numbered_paginator_item(page, records.current_page)
@ -50,6 +55,11 @@ module PaginationHelper
html << numbered_paginator_item("...", records.current_page)
html << numbered_paginator_final_item(records.total_pages, records.current_page)
end
if records.current_page == records.total_pages
html << link_to("&gt;&gt;", params.merge(:page => records.total_pages))
end
html << "</menu></div>"
html.html_safe
end