lib/lipstick/helpers/pagination_link_renderer.rb in aaf-lipstick-3.0.4 vs lib/lipstick/helpers/pagination_link_renderer.rb in aaf-lipstick-3.0.5
- old
+ new
@@ -29,15 +29,17 @@
private
def prefix
return [:prev] if !show_first? || short_list?
return [:prev, 1, :gap] if prefix_gap?
+
[:prev, 1]
end
def middle
return page_range(1, total) if short_list?
+
page_range(*page_window)
end
# Decides which pages to show in the links surrounding the "current" page.
def page_window
@@ -50,10 +52,11 @@
end
def suffix
return [:next] if !show_last? || short_list?
return [:gap, total, :next] if suffix_gap?
+
[total, :next]
end
def page_range(start, finish)
[start, 1].max.upto([finish, total].min)
@@ -94,16 +97,18 @@
def prev_item
icon = template.content_tag('span', "\u25C0", 'aria-hidden': 'true')
return disabled_item(icon) if current < 2
+
link_to_page(icon, page: current - 1, 'aria-label': 'Previous')
end
def next_item
icon = template.content_tag('span', "\u25B6", 'aria-hidden': 'true')
return disabled_item(icon) if current >= total
+
link_to_page(icon, page: current + 1, 'aria-label': 'Next')
end
def gap_item
template.content_tag('li') do