Class: Playbook::Pagination::Rails

Inherits:
WillPaginate::ActionView::LinkRenderer
  • Object
show all
Defined in:
lib/playbook/pagination_renderer.rb

Instance Method Summary collapse

Instance Method Details

#container_attributesObject



8
9
10
# File 'lib/playbook/pagination_renderer.rb', line 8

def container_attributes
  { class: "pb_pagination" }
end

#gapObject



28
# File 'lib/playbook/pagination_renderer.rb', line 28

def gap; end

#next_pageObject



35
36
37
38
# File 'lib/playbook/pagination_renderer.rb', line 35

def next_page
  num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
  previous_or_next_page(num, "<i class='far fa-chevron-right fa-xs'></i>", "next")
end

#page_number(page) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/playbook/pagination_renderer.rb', line 12

def page_number(page)
  if page == current_page
    tag("li", tag("span", page), class: "active")
  else
    tag("li", link(page, page, rel: rel_value(page)))
  end
end

#previous_or_next_page(page, text, classname) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/playbook/pagination_renderer.rb', line 20

def previous_or_next_page(page, text, classname)
  if page
    tag("li", link(text, page), class: classname)
  else
    tag("li", tag("span", text), class: "%s disabled")
  end
end

#previous_pageObject



30
31
32
33
# File 'lib/playbook/pagination_renderer.rb', line 30

def previous_page
  num = @collection.current_page > 1 && @collection.current_page - 1
  previous_or_next_page(num, "<i class='far fa-chevron-left fa-xs'></i>", "prev")
end