Module: ActiveScaffold::Helpers::PaginationHelpers

Included in:
ViewHelpers
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb

Instance Method Summary collapse

Instance Method Details



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb', line 4

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


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb', line 17

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