mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
use PageProxy for current_page
This commit is contained in:
parent
bfb09e61ad
commit
cd50d41476
15 changed files with 42 additions and 33 deletions
|
@ -1,11 +1,11 @@
|
|||
<%# Link to the "First" page
|
||||
- available local variables
|
||||
url: url to the first page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
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, :remote => remote %>
|
||||
<span class="first<%= ' disabled' if current_page.first? %>">
|
||||
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
|
||||
</span>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-# Link to the "First" page
|
||||
- available local variables
|
||||
url: url to the first page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
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, :remote => remote
|
||||
%span{:class => "first#{' disabled' if current_page.first?}"}
|
||||
= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%# Non-link tag that stands for skipped pages...
|
||||
- available local variables
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-# Non-link tag that stands for skipped pages...
|
||||
- available local variables
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<%# Link to the "Last" page
|
||||
- available local variables
|
||||
url: url to the last page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
-%>
|
||||
<span class="last<%= ' disabled' if current_page == num_pages %>">
|
||||
<%= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, {:remote => remote} %>
|
||||
<span class="last<%= ' disabled' if current_page.last? %>">
|
||||
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
|
||||
</span>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-# Link to the "Last" page
|
||||
- available local variables
|
||||
url: url to the last page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
%span{:class => "last#{' disabled' if current_page == num_pages}"}
|
||||
= link_to_unless current_page == num_pages, raw(t 'views.pagination.last'), url, {:remote => remote}
|
||||
%span{:class => "last#{' disabled' if current_page.last?}"}
|
||||
= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<%# Link to the "Next" page
|
||||
- available local variables
|
||||
url: url to the next page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
-%>
|
||||
<span class="next<%= ' disabled' if current_page == num_pages %>">
|
||||
<%= link_to_unless current_page == num_pages, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
|
||||
<span class="next<%= ' disabled' if current_page.last? %>">
|
||||
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
|
||||
</span>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-# Link to the "Next" page
|
||||
- available local variables
|
||||
url: url to the next page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
%span{:class => "next#{' disabled' if current_page == num_pages}"}
|
||||
= link_to_unless current_page == num_pages, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
|
||||
%span{:class => "next#{' disabled' if current_page.last?}"}
|
||||
= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<%# Link showing page number
|
||||
- available local variables
|
||||
page: the PageProxy for the current page
|
||||
page: a page object for "this" page
|
||||
url: url to this page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
-# Link showing page number
|
||||
- available local variables
|
||||
page: the PageProxy for the current page
|
||||
page: a page object for "this" page
|
||||
url: url to this page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%# The container tag
|
||||
- available local variables
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-# The container tag
|
||||
- available local variables
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
per_page: number of items to fetch per page
|
||||
remote: data-remote
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<%# Link to the "Previous" page
|
||||
- available local variables
|
||||
url: url to the previous page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
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 => 'prev', :remote => remote %>
|
||||
<span class="prev<%= ' disabled' if current_page.first? %>">
|
||||
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
|
||||
</span>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
-# Link to the "Previous" page
|
||||
- available local variables
|
||||
url: url to the previous page
|
||||
current_page: the page number of currently displayed page
|
||||
current_page: a page object for the currently displayed page
|
||||
num_pages: total number of pages
|
||||
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 => 'prev', :remote => remote
|
||||
%span{:class => "prev#{' disabled' if current_page.first?}"}
|
||||
= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote
|
||||
|
|
|
@ -12,6 +12,7 @@ module Kaminari
|
|||
h[:right] = options.delete(:right) || outer_window || 0
|
||||
end
|
||||
@template, @options = template, options
|
||||
@options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil
|
||||
# so that this instance can actually "render". Black magic?
|
||||
@output_buffer = ActionView::OutputBuffer.new
|
||||
end
|
||||
|
@ -117,7 +118,7 @@ module Kaminari
|
|||
|
||||
# inside the inner window or not
|
||||
def inside_window?
|
||||
(@page - @options[:current_page]).abs <= @options[:window]
|
||||
(@options[:current_page] - @page).abs <= @options[:window]
|
||||
end
|
||||
|
||||
# The last rendered tag was "truncated" or not
|
||||
|
@ -133,6 +134,14 @@ module Kaminari
|
|||
number.to_s
|
||||
end
|
||||
|
||||
def +(other)
|
||||
to_i + other.to_i
|
||||
end
|
||||
|
||||
def -(other)
|
||||
to_i - other.to_i
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
to_i <=> other.to_i
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue