class NeatPages::Helpers::Navigation
*************************************************************************************
Navigation take care of generating the html code for the pagination navigation. Output Example < Previous | 1 | 2 | 3 | Next >
*************************************************************************************
Public Instance Methods
generate()
click to toggle source
# File lib/neat_pages/helpers/navigation.rb, line 17 def generate return '' if not paginated? reset_builder navigation_standard end
Private Instance Methods
get_bounds_of_pages(nbr_items)
click to toggle source
# File lib/neat_pages/helpers/navigation.rb, line 89 def get_bounds_of_pages(nbr_items) half_nbr_items = nbr_items / 2 start = current_page > half_nbr_items ? (current_page - half_nbr_items + 1) : 1 finish = current_page >= total_pages - half_nbr_items ? total_pages : (start + nbr_items - 1) start = (finish - nbr_items + 1) if start - finish < nbr_items start = 1 if start < 1 return [start, finish] end
link_to(label, no_page, options={})
click to toggle source
# File lib/neat_pages/helpers/navigation.rb, line 27 def link_to(label, no_page, options={}) options = { class: '' }.merge(options) attributes = { "data-page" => no_page } attributes["href"] = (no_page == '#' ? '#' : path_to(no_page)) attributes["class"] = options[:class] if not options[:class].blank? return "<a " + attributes.map{ |k,v| "#{k}=\"#{v}\"" }.join(" ") + ">#{label}</a>" end
link_to_page(no_page)
click to toggle source
# File lib/neat_pages/helpers/navigation.rb, line 37 def link_to_page(no_page) link_to no_page, no_page end