class Showbuilder::ShowPaginateRenderer
Public Instance Methods
to_html()
click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 6 def to_html links = @options[:page_links] ? windowed_links : [] links.unshift(page_link_or_span(@collection.previous_page, 'prev', @options[:previous_label])) links.push(page_link_or_span(@collection.next_page, 'next', @options[:next_label])) html = links.join(@options[:link_separator]) html_content = @template.content_tag(:div, :class => :pagination) do @template.content_tag(:ul, html.html_safe) end @options[:container] ? html_content : html end
Protected Instance Methods
gap_marker()
click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 54 def gap_marker @template.will_paginate_translate(:page_gap) { '…' } end
page_link(page, text, attributes = {})
click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 42 def page_link(page, text, attributes = {}) @template.content_tag(:li, attributes) do @template.link_to(text, url(page)).html_safe end end
page_link_or_span(page, span_class, text = nil)
click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 26 def page_link_or_span(page, span_class, text = nil) text ||= page.to_s if page == :gap text = gap_marker end if page && page != current_page && page != :gap page_link(page, text, :class => span_class) else if page == current_page || page == :gap page_span(page, text, :class => span_class) else previous_or_next_page(page) end end end
page_span(page, text, attributes = {})
click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 48 def page_span(page, text, attributes = {}) @template.content_tag :li, attributes do @template.content_tag(:a, text) end end
previous_or_next_page(page)
click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 58 def previous_or_next_page(page) if @collection.current_page <= 1 && @collection.current_page - 1 <= 0 return page_span(page, @options[:previous_label], :class => "prev disabled") end if @collection.current_page <= @collection.total_pages && @collection.current_page + 1 >= @collection.total_pages return page_span(page, @options[:next_label], :class => "next disabled") end end
windowed_links()
click to toggle source
# File lib/showbuilder/show_paginate_renderer.rb, line 22 def windowed_links windowed_page_numbers.map { |n| page_link_or_span(n, (n == current_page ? 'active' : nil)) } end