Sha256: 516102eb9126ff2b1333e5160280ede3816e34d67dba8666ae7d622e63d5b61b

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

module FlowPagination

  # FlowPagination renderer for (Mislav) WillPaginate Plugin
  class LinkRenderer < WillPaginate::LinkRenderer

    # Render flow navigation
    def to_html
      flow_pagination = ''

      if self.current_page < self.last_page
        flow_pagination = @template.link_to_remote(
            @template.t('flow_pagination.link', :default => 'more'),
            {:url => url_for(self.next_page),
             :method => @template.request.request_method}.
              merge(ajax_options) )
      end

      @template.content_tag(:div, flow_pagination, :id => 'flow_pagination')
    end

    def ajax_options
      return @ajax_options if @ajax_options
      @ajax_options = Hash[@options.select{ |k,v| [:loading, :loaded, :interactive, :success, :failure, :complete, :confirm, :condition, :before, :after, :submit, :with, :update, :position].include? k }]
    end

    protected

      # Get current page number
      def current_page
        @collection.current_page
      end

      # Get last page number
      def last_page
        @last_page ||= WillPaginate::ViewHelpers.total_pages_for_collection(@collection)
      end

      # Get next page number
      def next_page
        @collection.next_page
      end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ochko-flow_pagination-1.2.2 lib/flow_pagination.rb