Sha256: 4db2054131682ca90814819fa02bb5b8ac331f6c115436f8d0ad1f076ebc4764

Contents?: true

Size: 1.75 KB

Versions: 97

Compression:

Stored size: 1.75 KB

Contents

module ActiveScaffold
  module Helpers
    module PaginationHelpers
      def pagination_ajax_link(page_number, params)
        url = url_for params.merge(:page => page_number)
        page_link = link_to_remote(page_number,
                  { :url => url,
                    :before => "addActiveScaffoldPageToHistory('#{url}', '#{controller_id}');",
                    :after => "$('#{loading_indicator_id(:action => :pagination)}').style.visibility = 'visible';",
                    :complete => "$('#{loading_indicator_id(:action => :pagination)}').style.visibility = 'hidden';",
                    :update => active_scaffold_content_id,
                    :failure => "ActiveScaffold.report_500_response('#{active_scaffold_id}')",
                    :method => :get },
                  { :href => url_for(params.merge(:page => page_number)) })
      end

      def pagination_ajax_links(current_page, params)
        start_number = current_page.number - 2
        end_number = current_page.number + 2
        start_number = 1 if start_number <= 0
        end_number = current_page.pager.last.number if end_number > current_page.pager.last.number

        html = []
        html << pagination_ajax_link(1, params) unless current_page.number <= 3
        html << ".." unless current_page.number <= 4
        start_number.upto(end_number) do |num|
          if current_page.number == num
            html << num
          else
            html << pagination_ajax_link(num, params)
          end
        end
        html << ".." unless current_page.number >= current_page.pager.last.number - 3
        html << pagination_ajax_link(current_page.pager.last.number, params) unless current_page.number >= current_page.pager.last.number - 2
        html.join(' ')
      end
    end
  end
end

Version data entries

97 entries across 97 versions & 2 rubygems

Version Path
six-updater-web-0.24.15 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.14 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.13 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.12 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.11 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.10 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.9 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.8 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.7 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.6 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.5 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.4 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.3 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.2 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.1 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.24.0 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.23.7 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.23.6 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.23.5 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb
six-updater-web-0.23.4 lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb