pagy 43.3.0 → 43.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/apps/calendar.ru +13 -3
- data/apps/demo.ru +31 -10
- data/apps/keynav+root_key.ru +1 -1
- data/apps/keynav.ru +1 -1
- data/apps/keyset.ru +1 -1
- data/apps/keyset_sequel.ru +1 -1
- data/apps/rails.ru +1 -1
- data/apps/repro.ru +1 -1
- data/config/pagy.rb +1 -1
- data/javascripts/pagy.js +6 -3
- data/javascripts/pagy.js.map +3 -3
- data/javascripts/pagy.min.js +1 -1
- data/javascripts/pagy.mjs +5 -2
- data/lib/pagy/classes/calendar/unit.rb +1 -0
- data/lib/pagy/classes/keyset/adapters/active_record.rb +2 -2
- data/lib/pagy/classes/keyset/keynav.rb +2 -0
- data/lib/pagy/classes/offset/offset.rb +2 -1
- data/lib/pagy/modules/i18n/i18n.rb +4 -4
- data/lib/pagy/toolbox/helpers/anchor_tags.rb +6 -4
- data/lib/pagy/toolbox/helpers/bootstrap/input_nav_js.rb +17 -15
- data/lib/pagy/toolbox/helpers/bootstrap/previous_next_html.rb +13 -11
- data/lib/pagy/toolbox/helpers/bootstrap/series_nav.rb +22 -20
- data/lib/pagy/toolbox/helpers/bootstrap/series_nav_js.rb +14 -12
- data/lib/pagy/toolbox/helpers/bulma/input_nav_js.rb +14 -12
- data/lib/pagy/toolbox/helpers/bulma/previous_next_html.rb +15 -13
- data/lib/pagy/toolbox/helpers/bulma/series_nav.rb +21 -19
- data/lib/pagy/toolbox/helpers/bulma/series_nav_js.rb +13 -11
- data/lib/pagy/toolbox/helpers/info_tag.rb +23 -21
- data/lib/pagy/toolbox/helpers/input_nav_js.rb +12 -10
- data/lib/pagy/toolbox/helpers/limit_tag_js.rb +16 -14
- data/lib/pagy/toolbox/helpers/loaders.rb +55 -0
- data/lib/pagy/toolbox/helpers/series_nav.rb +21 -19
- data/lib/pagy/toolbox/helpers/series_nav_js.rb +12 -10
- data/lib/pagy/toolbox/helpers/support/a_lambda.rb +1 -1
- data/lib/pagy.rb +8 -3
- data/sig/pagy.rbs +312 -0
- metadata +3 -2
- data/lib/pagy/toolbox/helpers/loader.rb +0 -36
|
@@ -4,20 +4,22 @@ require_relative 'previous_next_html'
|
|
|
4
4
|
require_relative '../support/wrap_series_nav_js'
|
|
5
5
|
|
|
6
6
|
class Pagy
|
|
7
|
-
|
|
7
|
+
module NumericHelpers
|
|
8
|
+
private
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
# Javascript pagination for bootstrap: it returns a nav with a data-pagy attribute used by the pagy.js file
|
|
11
|
+
def bootstrap_series_nav_js(classes: 'pagination', **)
|
|
12
|
+
a_lambda = a_lambda(**)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
tokens = { before: %(<ul class="#{classes}">#{bootstrap_html_for(:previous, a_lambda)}),
|
|
15
|
+
anchor: %(<li class="page-item">#{a_lambda.(PAGE_TOKEN, LABEL_TOKEN, classes: 'page-link')}</li>),
|
|
16
|
+
current: %(<li class="page-item active"><a role="link" class="page-link" ) +
|
|
17
|
+
%(aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</a></li>),
|
|
18
|
+
gap: %(<li class="page-item gap disabled"><a role="link" class="page-link" aria-disabled="true">#{
|
|
19
|
+
I18n.translate('pagy.gap')}</a></li>),
|
|
20
|
+
after: %(#{bootstrap_html_for(:next, a_lambda)}</ul>) }
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
wrap_series_nav_js(tokens, 'pagy-bootstrap series-nav-js', **)
|
|
23
|
+
end
|
|
22
24
|
end
|
|
23
25
|
end
|
|
@@ -4,21 +4,23 @@ require_relative 'previous_next_html'
|
|
|
4
4
|
require_relative '../support/wrap_input_nav_js'
|
|
5
5
|
|
|
6
6
|
class Pagy
|
|
7
|
-
|
|
7
|
+
module NumericHelpers
|
|
8
|
+
private
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
# Javascript combo pagination for bulma: it returns a nav with a data-pagy attribute used by the pagy.js file
|
|
11
|
+
def bulma_input_nav_js(classes: 'pagination', **)
|
|
12
|
+
a_lambda = a_lambda(**)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
input = %(<input name="page" type="number" min="1" max="#{@last}" value="#{@page}" aria-current="page") +
|
|
15
|
+
%(style="text-align: center; width: #{@page.to_s.length + 1}rem; line-height: 1.2rem; ) +
|
|
16
|
+
%(border: none; border-radius: .25rem; padding: .0625rem; color: white; ) +
|
|
17
|
+
%(background-color: #485fc7;">#{A_TAG})
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
html = %(<ul class="pagination-list">#{bulma_html_for(:previous, a_lambda)}<li class="pagination-link"><label>#{
|
|
20
|
+
I18n.translate('pagy.input_nav_js', page_input: input, pages: @last)
|
|
21
|
+
}</label></li>#{bulma_html_for(:next, a_lambda)}</ul>)
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
wrap_input_nav_js(html, "pagy-bulma input-nav-js #{classes}", **)
|
|
24
|
+
end
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Pagy
|
|
4
|
-
|
|
4
|
+
module NumericHelpers
|
|
5
|
+
private
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
# Return the enabled/disabled previous/next page anchor tag
|
|
8
|
+
def bulma_html_for(which, a_lambda)
|
|
9
|
+
%(<li>#{
|
|
10
|
+
if send(which)
|
|
11
|
+
a_lambda.(send(which), I18n.translate("pagy.#{which}"),
|
|
12
|
+
classes: "pagination-#{which}",
|
|
13
|
+
aria_label: I18n.translate("pagy.aria_label.#{which}"))
|
|
14
|
+
else
|
|
15
|
+
%(<a role="link" class="pagination-#{which}" disabled aria-disabled="true" aria-label="#{
|
|
16
|
+
I18n.translate("pagy.aria_label.#{which}")}">#{I18n.translate("pagy.#{which}")}</a>)
|
|
17
|
+
end
|
|
18
|
+
}</li>)
|
|
19
|
+
end
|
|
18
20
|
end
|
|
19
21
|
end
|
|
@@ -4,27 +4,29 @@ require_relative 'previous_next_html'
|
|
|
4
4
|
require_relative '../support/wrap_series_nav'
|
|
5
5
|
|
|
6
6
|
class Pagy
|
|
7
|
-
|
|
7
|
+
module NumericHelpers
|
|
8
|
+
private
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
# Pagination for bulma: it returns the html with the series of links to the pages
|
|
11
|
+
def bulma_series_nav(classes: 'pagination', **)
|
|
12
|
+
a_lambda = a_lambda(**)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
html = %(<ul class="pagination-list">#{bulma_html_for(:previous, a_lambda)})
|
|
15
|
+
series(**).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
|
16
|
+
html << case item
|
|
17
|
+
when Integer
|
|
18
|
+
%(<li>#{a_lambda.(item, page_label(item), classes: 'pagination-link')}</li>)
|
|
19
|
+
when String
|
|
20
|
+
%(<li><a role="link" class="pagination-link is-current" aria-current="page" aria-disabled="true">#{
|
|
21
|
+
page_label(item)}</a></li>)
|
|
22
|
+
when :gap
|
|
23
|
+
%(<li><span class="pagination-ellipsis">#{I18n.translate('pagy.gap')}</span></li>)
|
|
24
|
+
else raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
html << %(#{bulma_html_for(:next, a_lambda)}</ul>)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
wrap_series_nav(html, "pagy-bulma series-nav #{classes}", **)
|
|
30
|
+
end
|
|
29
31
|
end
|
|
30
32
|
end
|
|
@@ -4,19 +4,21 @@ require_relative 'previous_next_html'
|
|
|
4
4
|
require_relative '../support/wrap_series_nav_js'
|
|
5
5
|
|
|
6
6
|
class Pagy
|
|
7
|
-
|
|
7
|
+
module NumericHelpers
|
|
8
|
+
private
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
# Javascript pagination for bulma: it returns a nav with a data-pagy attribute used by the Pagy.nav javascript
|
|
11
|
+
def bulma_series_nav_js(classes: 'pagination', **)
|
|
12
|
+
a_lambda = a_lambda(**)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
tokens = { before: %(<ul class="pagination-list">#{bulma_html_for(:previous, a_lambda)}),
|
|
15
|
+
anchor: %(<li>#{a_lambda.(PAGE_TOKEN, LABEL_TOKEN, classes: 'pagination-link')}</li>),
|
|
16
|
+
current: %(<li><a role="link" class="pagination-link is-current" ) +
|
|
17
|
+
%(aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</a></li>),
|
|
18
|
+
gap: %(<li><span class="pagination-ellipsis">#{I18n.translate('pagy.gap')}</span></li>),
|
|
19
|
+
after: %(#{bulma_html_for(:next, a_lambda)}</ul>) }
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
wrap_series_nav_js(tokens, "pagy-bulma series-nav-js #{classes}", **)
|
|
22
|
+
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Pagy
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
module NumericHelpers
|
|
5
|
+
# Instances with count return "Displaying items 41-60 of 324 in total" or "Displaying Products 41-60 of 324 in total"
|
|
6
|
+
# Instances with no count return only page info: "Page 3 of 100"
|
|
7
|
+
def info_tag(id: nil, item_name: nil)
|
|
8
|
+
i18n_key = if @count.nil?
|
|
9
|
+
'pagy.info_tag.no_count'
|
|
10
|
+
elsif @count.zero?
|
|
11
|
+
'pagy.info_tag.no_items'
|
|
12
|
+
elsif @in == @count
|
|
13
|
+
'pagy.info_tag.single_page'
|
|
14
|
+
else
|
|
15
|
+
'pagy.info_tag.multiple_pages'
|
|
16
|
+
end
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
info_data = if @count.nil?
|
|
19
|
+
{ page: @page, pages: @last }
|
|
20
|
+
else
|
|
21
|
+
{ item_name: item_name || I18n.translate('pagy.item_name', count: @count),
|
|
22
|
+
count: @count,
|
|
23
|
+
from: @from,
|
|
24
|
+
to: @to }
|
|
25
|
+
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
%(<span#{%( id="#{id}") if id} class="pagy info">#{I18n.translate(i18n_key, **info_data)}</span>)
|
|
28
|
+
end
|
|
27
29
|
end
|
|
28
30
|
end
|
|
@@ -3,19 +3,21 @@
|
|
|
3
3
|
require_relative 'support/wrap_input_nav_js'
|
|
4
4
|
|
|
5
5
|
class Pagy
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
module NumericHelpers
|
|
7
|
+
# JavaScript input pagination: it returns a nav with a data-pagy attribute used by the pagy.js file
|
|
8
|
+
def input_nav_js(style = nil, **)
|
|
9
|
+
return send(:"#{style}_input_nav_js", **) if style && style.to_s != 'pagy'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
a_lambda = a_lambda(**)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
input = %(<input name="page" type="number" min="1" max="#{@last}" value="#{@page}" aria-current="page" ) +
|
|
14
|
+
%(style="text-align: center; width: #{@page.to_s.length + 1}rem; padding: 0;">#{A_TAG})
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
html = %(#{previous_tag(a_lambda)}<label>#{
|
|
17
|
+
I18n.translate('pagy.input_nav_js', page_input: input, pages: @last)}</label>#{
|
|
18
|
+
next_tag(a_lambda)})
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
wrap_input_nav_js(html, 'pagy input-nav-js', **)
|
|
21
|
+
end
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -3,22 +3,24 @@
|
|
|
3
3
|
require_relative 'support/data_pagy_attribute'
|
|
4
4
|
|
|
5
5
|
class Pagy
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
module NumericHelpers
|
|
7
|
+
# Return the limit selector HTML. For example "Show [20] items per page"
|
|
8
|
+
def limit_tag_js(id: nil, item_name: nil, client_max_limit: @options[:client_max_limit], **)
|
|
9
|
+
raise OptionError.new(self, :client_max_limit, 'to be truthy', client_max_limit) unless client_max_limit
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
limit_input = %(<input name="limit" type="number" min="1" max="#{client_max_limit}" value="#{
|
|
12
|
+
@limit}" style="padding: 0; text-align: center; width: #{@limit.to_s.length + 1}rem;">#{A_TAG})
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
url_token = compose_page_url(PAGE_TOKEN, limit: LIMIT_TOKEN)
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
%(<span#{%( id="#{id}") if id} class="pagy limit-tag-js" #{
|
|
17
|
+
data_pagy_attribute(:ltj, @from, url_token, PAGE_TOKEN, LIMIT_TOKEN)
|
|
18
|
+
}><label>#{
|
|
19
|
+
I18n.translate('pagy.limit_tag_js',
|
|
20
|
+
item_name: item_name || I18n.translate('pagy.item_name', count: @limit),
|
|
21
|
+
limit_input:,
|
|
22
|
+
count: @limit)
|
|
23
|
+
}</label></span>)
|
|
24
|
+
end
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Pagy
|
|
4
|
+
# The aliaser defines loader methods and aliases them.
|
|
5
|
+
# When a method is called for the first time, its loader will load the full implementation
|
|
6
|
+
# which will overwrite the alias and will be executed.
|
|
7
|
+
# Subsequent calls will run the full implementation directly.
|
|
8
|
+
aliaser = lambda do |receiver, paths|
|
|
9
|
+
receiver.instance_eval do
|
|
10
|
+
paths.each do |visibility, methods|
|
|
11
|
+
methods.each do |method, path|
|
|
12
|
+
loader_name = :"_pagy_loader_for_#{method}"
|
|
13
|
+
define_method(loader_name) do |*args, **kwargs|
|
|
14
|
+
# Tests shadow the usage of these lines
|
|
15
|
+
# :nocov:
|
|
16
|
+
require_relative path
|
|
17
|
+
send(method, *args, **kwargs)
|
|
18
|
+
# :nocov:
|
|
19
|
+
end
|
|
20
|
+
alias_method method, loader_name
|
|
21
|
+
send(visibility, method)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module HelperLoader
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
paths = { public: { page_url: 'page_url',
|
|
31
|
+
data_hash: 'data_hash',
|
|
32
|
+
headers_hash: 'headers_hash',
|
|
33
|
+
urls_hash: 'urls_hash',
|
|
34
|
+
next_tag: 'anchor_tags' } }.freeze
|
|
35
|
+
|
|
36
|
+
aliaser.(HelperLoader, paths)
|
|
37
|
+
|
|
38
|
+
module NumericHelperLoader
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
paths = { public: { previous_tag: 'anchor_tags',
|
|
42
|
+
input_nav_js: 'input_nav_js',
|
|
43
|
+
info_tag: 'info_tag',
|
|
44
|
+
limit_tag_js: 'limit_tag_js',
|
|
45
|
+
series_nav: 'series_nav',
|
|
46
|
+
series_nav_js: 'series_nav_js' },
|
|
47
|
+
protected: { bootstrap_series_nav: 'bootstrap/series_nav',
|
|
48
|
+
bootstrap_series_nav_js: 'bootstrap/series_nav_js',
|
|
49
|
+
bootstrap_input_nav_js: 'bootstrap/input_nav_js',
|
|
50
|
+
bulma_series_nav: 'bulma/series_nav',
|
|
51
|
+
bulma_series_nav_js: 'bulma/series_nav_js',
|
|
52
|
+
bulma_input_nav_js: 'bulma/input_nav_js' } }.freeze
|
|
53
|
+
|
|
54
|
+
aliaser.(NumericHelperLoader, paths)
|
|
55
|
+
end
|
|
@@ -3,27 +3,29 @@
|
|
|
3
3
|
require_relative 'support/wrap_series_nav'
|
|
4
4
|
|
|
5
5
|
class Pagy
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
module NumericHelpers
|
|
7
|
+
# Return the HTML with the series of links to the pages
|
|
8
|
+
def series_nav(style = nil, **)
|
|
9
|
+
return send(:"#{style}_series_nav", **) if style && style.to_s != 'pagy'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
a_lambda = a_lambda(**)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
html = previous_tag(a_lambda)
|
|
14
|
+
series(**).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
|
15
|
+
html << case item
|
|
16
|
+
when Integer
|
|
17
|
+
a_lambda.(item)
|
|
18
|
+
when String
|
|
19
|
+
%(<a role="link" aria-disabled="true" aria-current="page">#{page_label(item)}</a>)
|
|
20
|
+
when :gap
|
|
21
|
+
%(<a role="separator" aria-disabled="true">#{I18n.translate('pagy.gap')}</a>)
|
|
22
|
+
else
|
|
23
|
+
raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
html << next_tag(a_lambda)
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
wrap_series_nav(html, 'pagy series-nav', **)
|
|
29
|
+
end
|
|
28
30
|
end
|
|
29
31
|
end
|
|
@@ -3,17 +3,19 @@
|
|
|
3
3
|
require_relative 'support/wrap_series_nav_js'
|
|
4
4
|
|
|
5
5
|
class Pagy
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
module NumericHelpers
|
|
7
|
+
# Return a nav with a data-pagy attribute used by the pagy.js file
|
|
8
|
+
def series_nav_js(style = nil, **)
|
|
9
|
+
return send(:"#{style}_series_nav_js", **) if style && style.to_s != 'pagy'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
a_lambda = a_lambda(**)
|
|
12
|
+
tokens = { before: previous_tag(a_lambda),
|
|
13
|
+
anchor: a_lambda.(PAGE_TOKEN, LABEL_TOKEN),
|
|
14
|
+
current: %(<a role="link" aria-current="page" aria-disabled="true">#{LABEL_TOKEN}</a>),
|
|
15
|
+
gap: %(<a role="separator" aria-disabled="true">#{I18n.translate('pagy.gap')}</a>),
|
|
16
|
+
after: next_tag(a_lambda) }
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
wrap_series_nav_js(tokens, 'pagy series-nav-js', **)
|
|
19
|
+
end
|
|
18
20
|
end
|
|
19
21
|
end
|
|
@@ -18,7 +18,7 @@ class Pagy
|
|
|
18
18
|
%( #{anchor_string}) if anchor_string}).split(PAGE_TOKEN, 2)
|
|
19
19
|
|
|
20
20
|
lambda do |page, text = page_label(page), classes: nil, aria_label: nil|
|
|
21
|
-
title = if (counts = @options[:counts])
|
|
21
|
+
title = if calendar? && (counts = @options[:counts])
|
|
22
22
|
count = counts[page - 1]
|
|
23
23
|
classes = classes ? "#{classes} empty-page" : 'empty-page' if count.zero?
|
|
24
24
|
info_key = count.zero? ? 'pagy.info_tag.no_items' : 'pagy.info_tag.single_page'
|
data/lib/pagy.rb
CHANGED
|
@@ -5,12 +5,12 @@ require 'pathname'
|
|
|
5
5
|
require_relative 'pagy/classes/exceptions'
|
|
6
6
|
require_relative 'pagy/modules/abilities/linkable'
|
|
7
7
|
require_relative 'pagy/modules/abilities/configurable'
|
|
8
|
-
require_relative 'pagy/toolbox/helpers/
|
|
8
|
+
require_relative 'pagy/toolbox/helpers/loaders'
|
|
9
9
|
|
|
10
10
|
# Top superclass: it defines only what's common to all the subclasses
|
|
11
11
|
# noinspection RubyMismatchedArgumentType
|
|
12
12
|
class Pagy
|
|
13
|
-
VERSION = '43.3.
|
|
13
|
+
VERSION = '43.3.2'
|
|
14
14
|
ROOT = Pathname.new(__dir__).parent.freeze
|
|
15
15
|
DEFAULT = { limit: 20, limit_key: 'limit', page_key: 'page' }.freeze
|
|
16
16
|
PAGE_TOKEN = EscapedValue.new('P ')
|
|
@@ -36,7 +36,7 @@ class Pagy
|
|
|
36
36
|
|
|
37
37
|
extend Configurable
|
|
38
38
|
include Linkable
|
|
39
|
-
include
|
|
39
|
+
include HelperLoader
|
|
40
40
|
|
|
41
41
|
attr_reader :page, :next, :in, :limit, :options
|
|
42
42
|
|
|
@@ -78,4 +78,9 @@ class Pagy
|
|
|
78
78
|
clean_options = options.delete_if { |k, v| default.key?(k) && (v.nil? || v == '') }
|
|
79
79
|
@options = default.merge!(clean_options).freeze
|
|
80
80
|
end
|
|
81
|
+
|
|
82
|
+
# Hook module for numeric UI helpers
|
|
83
|
+
module NumericHelpers
|
|
84
|
+
include NumericHelperLoader
|
|
85
|
+
end
|
|
81
86
|
end
|