Module: Card::Set::Abstract::Paging::PagingViews::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb

Constant Summary collapse

PAGE_LI_CLASS =
{ ellipses: "disabled", current: "active" }.freeze

Instance Method Summary collapse

Instance Method Details



53
54
55
56
57
58
59
60
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 53

def page_link text, page, options
  return (:div, text.html_safe, class: "page-link") unless page

  options.merge! class: "card-paging-link slotter page-link",
                 remote: true,
                 path: page_link_path_args(page)
  link_to raw(text), options
end

First page is 0 (not 1)



43
44
45
46
47
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 43

def page_link_li text, page, status, options={}
  wrap_with :li, class: page_link_li_class(status) do
    page_link text, page, options
  end
end


49
50
51
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 49

def page_link_li_class status
  ["page-item", PAGE_LI_CLASS[status]].compact.join " "
end


77
78
79
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 77

def page_link_path_args page
  paging_path_args.merge offset: page * limit
end


36
37
38
39
40
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 36

def paging_links
  PagingLinks.new(total_pages, current_page).build 5 do |text, page, status, options|
    page_link_li text, page, status, options
  end
end

#paging_path_args(local_args = {}) ⇒ Object



70
71
72
73
74
75
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 70

def paging_path_args local_args={}
  @paging_path_args ||= {}
  @paging_path_args.reverse_merge!(limit: limit, offset: offset)
  @paging_path_args.merge! extra_paging_path_args
  @paging_path_args.merge local_args
end

#view: pagingObject



34
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 34

view :paging, cache: :never, template: :haml

#with_paging(path_args = {}) ⇒ Object



28
29
30
31
32
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 28

def with_paging path_args={}
  with_paging_path_args path_args do
    output [yield(@paging_path_args), render_paging]
  end
end

#with_paging_path_args(args) ⇒ Object



62
63
64
65
66
67
68
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 62

def with_paging_path_args args
  tmp = @paging_path_args
  @paging_path_args = paging_path_args args
  yield
ensure
  @paging_path_args = tmp
end