Class: MaterializeLinkRenderer
- Inherits:
-
WillPaginate::ViewHelpers::LinkRenderer
- Object
- WillPaginate::ViewHelpers::LinkRenderer
- MaterializeLinkRenderer
- Defined in:
- app/helpers/materialize_link_renderer.rb
Constant Summary collapse
- GET_PARAMS_BLACKLIST =
[:script_name, :original_script_name]
Instance Method Summary collapse
- #add_current_page_param(url_params, page) ⇒ Object
- #default_url_params ⇒ Object
- #html_container(html) ⇒ Object
- #merge_get_params(url_params) ⇒ Object
- #merge_optional_params(url_params) ⇒ Object
- #page_number(page) ⇒ Object
- #prepare(collection, options, template) ⇒ Object
- #previous_or_next_page(page, text, classname) ⇒ Object
- #url(target) ⇒ Object
Instance Method Details
#add_current_page_param(url_params, page) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'app/helpers/materialize_link_renderer.rb', line 67 def add_current_page_param(url_params, page) unless param_name.index(/[^\w-]/) url_params[param_name.to_sym] = page else page_param = parse_query_parameters("#{param_name}=#{page}") symbolized_update(url_params, page_param) end end |
#default_url_params ⇒ Object
51 52 53 |
# File 'app/helpers/materialize_link_renderer.rb', line 51 def default_url_params {} end |
#html_container(html) ⇒ Object
26 27 28 |
# File 'app/helpers/materialize_link_renderer.rb', line 26 def html_container(html) tag(:ul, html, container_attributes) end |
#merge_get_params(url_params) ⇒ Object
55 56 57 58 59 60 |
# File 'app/helpers/materialize_link_renderer.rb', line 55 def merge_get_params(url_params) if @template.respond_to? :request and @template.request and @template.request.get? symbolized_update(url_params, @template.params, GET_PARAMS_BLACKLIST) end url_params end |
#merge_optional_params(url_params) ⇒ Object
62 63 64 65 |
# File 'app/helpers/materialize_link_renderer.rb', line 62 def merge_optional_params(url_params) symbolized_update(url_params, @options[:params]) if @options[:params] url_params end |
#page_number(page) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/materialize_link_renderer.rb', line 30 def page_number(page) classes= page==current_page ? "active" : "waves-effect" tag(:li,link(page, page, :rel => rel_value(page)),class: classes) end |
#prepare(collection, options, template) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/materialize_link_renderer.rb', line 3 def prepare(collection, , template) [:previous_label]=tag(:i,'chevron_left',class: "material-icons") [:next_label]=tag(:i,'chevron_right',class: "material-icons") super(collection, , template) end |
#previous_or_next_page(page, text, classname) ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/helpers/materialize_link_renderer.rb', line 41 def previous_or_next_page(page, text, classname) if page tag(:li,link(text,page), class: "waves-effect") else tag(:li,link(text,'#!'), class: "disabled") end end |
#url(target) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/materialize_link_renderer.rb', line 11 def url(target) @base_url_params ||= begin url_params = merge_get_params(default_url_params) url_params[:only_path] = true merge_optional_params(url_params) end url_params = @base_url_params.dup add_current_page_param(url_params, target) #@template.url_for(url_params) Rails.application.routes.url_helpers.url_for(url_params) end |