bring link_tag generation logic back into the main logic
This commit is contained in:
parent
5b76f94b51
commit
a1a3d64a8d
|
@ -12,7 +12,13 @@
|
||||||
<% if page.current? -%>
|
<% if page.current? -%>
|
||||||
<%= current_page_tag %>
|
<%= current_page_tag %>
|
||||||
<% elsif page.left_outer? || page.right_outer? || page.inside_window? -%>
|
<% elsif page.left_outer? || page.right_outer? || page.inside_window? -%>
|
||||||
|
<% if page.first? -%>
|
||||||
|
<%= first_page_link_tag %>
|
||||||
|
<% elsif page.last? -%>
|
||||||
|
<%= last_page_link_tag %>
|
||||||
|
<% else -%>
|
||||||
<%= page_link_tag %>
|
<%= page_link_tag %>
|
||||||
|
<% end -%>
|
||||||
<% elsif !page.was_truncated? -%>
|
<% elsif !page.was_truncated? -%>
|
||||||
<%= truncated_span_tag %>
|
<%= truncated_span_tag %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
- if page.current?
|
- if page.current?
|
||||||
= current_page_tag
|
= current_page_tag
|
||||||
- elsif page.left_outer? || page.right_outer? || page.inside_window?
|
- elsif page.left_outer? || page.right_outer? || page.inside_window?
|
||||||
|
- if page.first?
|
||||||
|
= first_page_link_tag
|
||||||
|
- elsif page.last?
|
||||||
|
= last_page_link_tag
|
||||||
|
- else
|
||||||
= page_link_tag
|
= page_link_tag
|
||||||
- elsif !page.was_truncated?
|
- elsif !page.was_truncated?
|
||||||
= truncated_span_tag
|
= truncated_span_tag
|
||||||
|
|
|
@ -13,19 +13,12 @@ module Kaminari
|
||||||
@left, @window, @right = (options[:left] || options[:outer_window] || 1), (options[:window] || options[:inner_window] || 4), (options[:right] || options[:outer_window] || 1)
|
@left, @window, @right = (options[:left] || options[:outer_window] || 1), (options[:window] || options[:inner_window] || 4), (options[:right] || options[:outer_window] || 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_page_tag
|
%w[current_page first_page_link last_page_link page_link].each do |tag|
|
||||||
@last = CurrentPage.new self, :page => @page
|
eval <<-DEF
|
||||||
|
def #{tag}_tag
|
||||||
|
@last = #{tag.classify}.new self, :page => @page
|
||||||
end
|
end
|
||||||
|
DEF
|
||||||
def page_link_tag
|
|
||||||
@last = case @page
|
|
||||||
when 1
|
|
||||||
FirstPageLink
|
|
||||||
when @options[:num_pages]
|
|
||||||
LastPageLink
|
|
||||||
else
|
|
||||||
PageLink
|
|
||||||
end.new self, :page => @page
|
|
||||||
end
|
end
|
||||||
|
|
||||||
%w[prev_link prev_span next_link next_span truncated_span].each do |tag|
|
%w[prev_link prev_span next_link next_span truncated_span].each do |tag|
|
||||||
|
@ -109,6 +102,14 @@ module Kaminari
|
||||||
@page == @renderer.options[:current_page]
|
@page == @renderer.options[:current_page]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def first?
|
||||||
|
@page == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def last?
|
||||||
|
@page == @renderer.options[:num_pages]
|
||||||
|
end
|
||||||
|
|
||||||
def left_outer?
|
def left_outer?
|
||||||
@page <= @renderer.left + 1
|
@page <= @renderer.left + 1
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue