diff options
author | Alex Legler <alex@a3li.li> | 2015-02-22 00:59:59 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2015-02-22 00:59:59 +0100 |
commit | 416dec280acb094e40338fe6198b682e71659ba8 (patch) | |
tree | 86d7bca5b881dab23787b1471cf47d3097ec7e01 /views | |
parent | Style message action buttons (diff) | |
download | frontend-416dec280acb094e40338fe6198b682e71659ba8.tar.gz frontend-416dec280acb094e40338fe6198b682e71659ba8.tar.bz2 frontend-416dec280acb094e40338fe6198b682e71659ba8.zip |
Limit pages shown in pagination
Diffstat (limited to 'views')
-rw-r--r-- | views/pagination.erb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/views/pagination.erb b/views/pagination.erb index 7d7be9c..9b85ec9 100644 --- a/views/pagination.erb +++ b/views/pagination.erb @@ -12,9 +12,15 @@ </a> <% end %> </li> - <% (1..max_pages).each do |page| %> + <% min = [1, current_page - 5].max ; max = [max_pages, current_page + 5].min %> + <% if min > 10 %> + <li><a href="1">1</a></li> + <% end %> + <% (min..max).each do |page| %> <li <% if page == current_page %><%= 'class="active"' %><% end %>><a href="<%= page %>"><%= page %></a></li> <% end %> + <% if (max_pages - max) > 10 %> + <li><a href="<%= max_pages %>"><%= max_pages %></a></li> <% if current_page == max_pages %> <li class="disabled"> <a href="#" aria-label="Next"> |