mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
refs #30 simplify rel attribute
* do not output rel="start" by default * do not output rel on first_page and last_page
This commit is contained in:
parent
1c6f72802b
commit
afc7dc1b44
9 changed files with 18 additions and 22 deletions
|
@ -7,5 +7,5 @@
|
|||
remote: data-remote
|
||||
-%>
|
||||
<span class="first<%= ' disabled' if current_page == 1 %>">
|
||||
<%= link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :rel => (current_page == 2) ? 'start prev':'start', :remote => remote %>
|
||||
<%= link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :remote => remote %>
|
||||
</span>
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
%span{:class => "first#{' disabled' if current_page == 1}"}
|
||||
= link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :rel => (current_page == 2) ? 'start prev':'start', :remote => remote
|
||||
= link_to_unless current_page == 1, raw(t 'views.pagination.first'), url, :remote => remote
|
||||
|
|
|
@ -7,6 +7,5 @@
|
|||
remote: data-remote
|
||||
-%>
|
||||
<span class="last<%= ' disabled' if current_page == num_pages %>">
|
||||
<% opts = {:remote => remote}; opts[:rel] = 'next' if current_page == num_pages - 1 %>
|
||||
<%= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, opts %>
|
||||
<%= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, {:remote => remote} %>
|
||||
</span>
|
||||
|
|
|
@ -6,6 +6,4 @@
|
|||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
%span{:class => "last#{' disabled' if current_page == num_pages}"}
|
||||
- opts = {:remote => remote};
|
||||
- opts[:rel] = 'next' if current_page == num_pages - 1
|
||||
= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, opts
|
||||
= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, {:remote => remote}
|
||||
|
|
|
@ -8,11 +8,5 @@
|
|||
remote: data-remote
|
||||
-%>
|
||||
<span class="page<%= ' current' if page.current? %>">
|
||||
<%
|
||||
opts = {:remote => remote}
|
||||
opts[:rel] = 'start' if page.first?
|
||||
opts[:rel] = 'next' if page.number == current_page + 1
|
||||
opts[:rel] = opts[:rel].nil? ? 'prev' : opts[:rel] + ' prev' if page.number == current_page - 1
|
||||
%>
|
||||
<%= link_to_unless page.current?, page, url, opts %>
|
||||
<%= link_to_unless page.current?, page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
|
||||
</span>
|
||||
|
|
|
@ -6,10 +6,5 @@
|
|||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
|
||||
%span{:class => "page#{' current' if page.current?}"}
|
||||
- opts = {:remote => remote}
|
||||
- opts[:rel] = 'start' if page.first?
|
||||
- opts[:rel] = 'next' if page.number == current_page + 1
|
||||
- opts[:rel] = opts[:rel].nil? ? 'prev' : opts[:rel] + ' prev' if page.number == current_page - 1
|
||||
= link_to_unless page.current?, page, url, opts
|
||||
= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
remote: data-remote
|
||||
-%>
|
||||
<span class="prev<%= ' disabled' if current_page == 1 %>">
|
||||
<%= link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => (current_page == 2) ? 'start prev':'prev', :remote => remote %>
|
||||
<%= link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
|
||||
</span>
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
%span{:class => "prev#{' disabled' if current_page == 1}"}
|
||||
= link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => (current_page == 2) ? 'start prev':'prev', :remote => remote
|
||||
= link_to_unless current_page == 1, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote
|
||||
|
|
|
@ -134,6 +134,16 @@ module Kaminari
|
|||
@page == @options[:num_pages]
|
||||
end
|
||||
|
||||
# the previous page or not
|
||||
def prev?
|
||||
@page == @options[:current_page] - 1
|
||||
end
|
||||
|
||||
# the next page or not
|
||||
def next?
|
||||
@page == @options[:current_page] + 1
|
||||
end
|
||||
|
||||
# within the left outer window or not
|
||||
def left_outer?
|
||||
@page <= @options[:left]
|
||||
|
|
Loading…
Reference in a new issue