Class: Symphonia::BootstrapLinkRender
- Inherits:
-
WillPaginate::ActionView::LinkRenderer
- Object
- WillPaginate::ActionView::LinkRenderer
- Symphonia::BootstrapLinkRender
- Defined in:
- lib/symphonia/bootstrap_link_render.rb
Instance Method Summary collapse
- #default_url_params ⇒ Object
- #page_number(page) ⇒ Object
- #pagination ⇒ Object
- #previous_or_next_page(page, text, classname, aria_label = nil) ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#default_url_params ⇒ Object
34 35 36 |
# File 'lib/symphonia/bootstrap_link_render.rb', line 34 def default_url_params @options[:query] && @options[:query].to_params || {} end |
#page_number(page) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/symphonia/bootstrap_link_render.rb', line 38 def page_number(page) = @options[:link_options] || {} aria_label = @template.will_paginate_translate(:page_aria_label, :page => page.to_i) { "Page #{page}" } if page == current_page tag(:span, page, :class => 'page-link current_page current', :"aria-label" => aria_label, :"aria-current" => 'page') else .merge! class: 'page-link', rel: rel_value(page) link(page, page, {:'data-remote' => @options[:remote], :"aria-label" => aria_label}.merge()) end end |
#pagination ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/symphonia/bootstrap_link_render.rb', line 5 def pagination items = @options[:page_links] ? windowed_page_numbers : [] unless @options[:page_links] == :only items.unshift :previous_page items.push :next_page end items end |
#previous_or_next_page(page, text, classname, aria_label = nil) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/symphonia/bootstrap_link_render.rb', line 49 def previous_or_next_page(page, text, classname, aria_label = nil) if page link(text, page, :'data-remote' => @options[:remote], :'aria-label' => aria_label, class: "page-link #{classname}") else tag(:span, text, class: "page-link #{classname} disabled", :'aria-label' => aria_label) end end |
#to_html ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/symphonia/bootstrap_link_render.rb', line 14 def to_html html = pagination.map do |item| if @options[:remote] if item == :next_page tag :li,next_page, class: 'page-item' end else tag(:li, (item.is_a?(Integer) ? page_number(item) : send(item)).html_safe, class: 'page-item' + (item == current_page ? ' active' : '')) end end.join(@options[:link_separator]) container_classes = %w(pagination justify-content-center) container_classes << 'pagination-sm' if @options[:small] container_classes << 'pagination-lg' if @options[:large] nav = tag(:ul, html.html_safe, class: container_classes.join(' ')) tag :nav, nav, class: 'd-print-none' end |