Class: Playbook::LinkRenderer
- Inherits:
-
WillPaginate::ActionView::LinkRenderer
- Object
- WillPaginate::ActionView::LinkRenderer
- Playbook::LinkRenderer
- Defined in:
- lib/playbook/pagination/pagination_renderer.rb
Instance Method Summary collapse
- #container_attributes ⇒ Object
- #gap ⇒ Object
- #next_page ⇒ Object
- #page_number(page) ⇒ Object
- #previous_or_next_page(page, text, classname) ⇒ Object
- #previous_page ⇒ Object
Instance Method Details
#container_attributes ⇒ Object
5 6 7 |
# File 'lib/playbook/pagination/pagination_renderer.rb', line 5 def container_attributes { class: "pb_pagination pagination" } end |
#gap ⇒ Object
25 26 27 |
# File 'lib/playbook/pagination/pagination_renderer.rb', line 25 def gap tag("li", tag("span", "…"), class: "disabled") end |
#next_page ⇒ Object
34 35 36 37 |
# File 'lib/playbook/pagination/pagination_renderer.rb', line 34 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'></i>", "next") end |
#page_number(page) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/playbook/pagination/pagination_renderer.rb', line 9 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
17 18 19 20 21 22 23 |
# File 'lib/playbook/pagination/pagination_renderer.rb', line 17 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_page ⇒ Object
29 30 31 32 |
# File 'lib/playbook/pagination/pagination_renderer.rb', line 29 def previous_page num = @collection.current_page > 1 && @collection.current_page - 1 previous_or_next_page(num, "<i class='far fa-chevron-left'></i>", "prev") end |