Class: PaginationListLinkRenderer
- Inherits:
-
WillPaginate::ViewHelpers::LinkRenderer
- Object
- WillPaginate::ViewHelpers::LinkRenderer
- PaginationListLinkRenderer
- Defined in:
- lib/pagination_list_link_renderer.rb
Instance Method Summary collapse
- #alphabetic_page_href(character) ⇒ Object
- #alphabetic_page_link(character, options = {}) ⇒ Object
- #alphabetic_pagination ⇒ Object
- #html_container(html) ⇒ Object
- #per_page_href(count) ⇒ Object
- #per_page_link(count) ⇒ Object
Instance Method Details
#alphabetic_page_href(character) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/pagination_list_link_renderer.rb', line 36 def alphabetic_page_href(character) # Add character to query search_params = @params.merge(:by_character => character) params = @template.params.merge(@search_key => search_params) # Drop page index params.delete(:page) @template.url_for(params) end |
#alphabetic_page_link(character, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/pagination_list_link_renderer.rb', line 26 def alphabetic_page_link(character, = {}) if character == @params[:by_character] link = "<em>%s</em>" % character.upcase else link = "<a class='per_page' href='%s'>%s</a>" % [alphabetic_page_href(([:link_keyword] ? [:link_keyword] : character)), character.upcase] end link end |
#alphabetic_pagination ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pagination_list_link_renderer.rb', line 13 def alphabetic_pagination paginated_scope = @template.instance_variable_get(:@paginated_scope) return "" unless paginated_scope characters = paginated_scope.character_list page_links = characters.map{|character| alphabetic_page_link(character)} all_links = Array.new all_links << alphabetic_page_link(I18n.t('katalog.show_all'), :link_keyword => '') all_links.concat(page_links) all_links.join('') end |
#html_container(html) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/pagination_list_link_renderer.rb', line 3 def html_container(html) @search_key = :search @params = @template.params[@search_key] || {} html = [per_page_link(25), per_page_link(50), per_page_link(200)].join('') + "<span>|</span>" + html html += "</div><div style='clear: both; padding-top: 0.5em;'>" + alphabetic_pagination html = "<div style='clear: both'>" + html + "</div>" tag(:div, html, container_attributes) end |
#per_page_href(count) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/pagination_list_link_renderer.rb', line 56 def per_page_href(count) params = @template.params.merge({:per_page => count}) # Drop page index params.delete(:page) @template.url_for(params) end |
#per_page_link(count) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/pagination_list_link_renderer.rb', line 46 def per_page_link(count) if count == @template.params[:per_page].to_i link = "<em>%s</em>" % count else link = "<a class='per_page' href='%s'>%s</a>" % [per_page_href(count), count] end link end |