Sha256: 1df940a298fa1404003297bd2125080fe282aebd9d9526e980e506dbb071be3a

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

class SomaticLinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
  
  def to_html
    links = @options[:page_links] ? windowed_links : []
    # previous/next buttons
    links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
    links.push    page_link_or_span(@collection.next_page,     'disabled next_page', @options[:next_label])
    
    html = links.join(@options[:separator])
    html += "( #{@collection.offset+1}-#{@collection.offset + @collection.per_page}/#{@collection.total_entries} )"
    @options[:container] ? @template.content_tag(:p, html, html_attributes) : html
  end
  
  def prepare(collection, options, template)
    super
    @collection_name = template.controller.controller_name
    @param_name = "#{@collection_name}_page"
    @options[:previous_label] = I18n.t(:previous)
    @options[:next_label] = I18n.t(:next)
  end
  
protected

  def page_link(page, text, attributes = {})
    # @template.content_tag(:li, @template.link_to(text, url_for(page)), attributes)
    # @template.link_to(text, url_for(page), attributes)
    @template.link_to(text,{
        :url => url_for(page),
        :update => 'content',
        :method => :get
    },attributes.merge({
      :href => url_for(page)
    }),:remote=>true
    )
  end

  def page_span(page, text, attributes = {})
    # @template.content_tag(:li, text, attributes)
    @template.content_tag(:span, text, attributes)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
somatics3-generators-0.0.8 lib/generators/somatics/install/templates/lib/somatic_link_renderer.rb
somatics3-generators-0.0.7 lib/generators/somatics/install/templates/lib/somatic_link_renderer.rb
somatics3-generators-0.0.6 lib/generators/somatics/install/templates/lib/somatic_link_renderer.rb
somatics3-generators-0.0.5 lib/generators/somatics/install/templates/lib/somatic_link_renderer.rb
somatics3-generators-0.0.4 lib/generators/somatics/install/templates/lib/somatic_link_renderer.rb