Sha256: be7b820b955400e3b526a83eb32d3f510eec0ce9e5d85d7bdf7214e553b6ec0b

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module Releaf
  module PaginationRenderer
    # This class does the heavy lifting of actually building the pagination
    # links. It is used by +will_paginate+ helper internally.

    # This is used in admin/base/_index.footer view

    class LinkRenderer < WillPaginate::ActionView::LinkRenderer

      protected

      def page_number(page)
        unless page == current_page
          link(page, page, :rel => rel_value(page), :class => 'button')
        else
          tag(:em, "<span>#{page}</span>", :class => 'current active button')
        end
      end

      def gap
        text = '&hellip;'
        %(<span class="gap button disabled">#{text}</span>)
      end

      def previous_or_next_page(page, text, classname)
        if page
          link(text, page, :class => classname + ' button')
        else
          tag(:span, "<span>#{text}</span>", :class => classname + ' button disabled')
        end
      end

      def link(text, target, attributes = {})
        if target.is_a? Fixnum
          attributes[:rel] = rel_value(target)
          target = url(target)
        end
        attributes[:href] = target
        tag(:a, "<span>#{text}</span>", attributes)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
releaf-0.1.2 app/helpers/releaf/pagination_renderer.rb
releaf-0.1.1 app/helpers/releaf/pagination_renderer.rb