pagy 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66ae2dcfec4f4aefaa0a2531b5abe5e0d18b92a835edf6549251c0073ce2f38f
4
- data.tar.gz: 295ca05e50dc171da7c184d7d3e8dd9e3b7eaed1cf7387959471a3f758f6d169
3
+ metadata.gz: 48e9fa30f5123b3b985a58c0f20e00803b8708662d25e4b8116f786264adf382
4
+ data.tar.gz: fd51c8bf8bb897c01382459c4ab1a6baf3e28c7c9437213652382cbf5d01b8f8
5
5
  SHA512:
6
- metadata.gz: d96430c17d8936a27942e3da7c0fbcff4d80372afd1f99b7a0c12b4ed5eb694aa1921404d31b77889078dc0fc59b4bbc5bfb0e4a6c418f3ae50837436bc17262
7
- data.tar.gz: d7349c4e47d8b33cdadea01168d8a122ef36c6283164cf895dbcf197aca0f07c44437abce7e7d72b29d358f4d95b80586157d5bd5eeb4515e32b7001031329b8
6
+ metadata.gz: 073dd75676b37ba14baaccd30a58ce008e8d32dd8e1dfd8508bc02abf0f1d85bfe8a503a4790b4157cd8a36f3e8b1c89284ae3d83c0ea8cb6565e5e32a74985d
7
+ data.tar.gz: 449da76a99d14327a89fcc30fad843dc5581c8225fab8c5678aa72f9888b160ebbd09d6c1b6946d8bcd1002267803a72b97a28de7797ac1a0be28ece704475f6
data/lib/config/pagy.rb CHANGED
@@ -1,10 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (4.3.0)
3
+ # Pagy initializer file (4.4.0)
4
4
  # Customize only what you really need and notice that Pagy works also without any of the following lines.
5
5
  # Should you just cherry pick part of this file, please maintain the require-order of the extras
6
6
 
7
7
 
8
+ # Pagy Variables
9
+ # See https://ddnexus.github.io/pagy/api/pagy#variables
10
+ # All the Pagy::VARS are set for all the Pagy instances but can be overridden
11
+ # per instance by just passing them to Pagy.new or the #pagy controller method
12
+
13
+
14
+ # Instance variables
15
+ # See https://ddnexus.github.io/pagy/api/pagy#instance-variables
16
+ # Pagy::VARS[:page] = 1 # default
17
+ # Pagy::VARS[:items] = 20 # default
18
+ # Pagy::VARS[:outset] = 0 # default
19
+
20
+
21
+ # Other Variables
22
+ # See https://ddnexus.github.io/pagy/api/pagy#other-variables
23
+ # Pagy::VARS[:size] = [1,4,4,1] # default
24
+ # Pagy::VARS[:page_param] = :page # default
25
+ # Pagy::VARS[:params] = {} # default
26
+ # Pagy::VARS[:fragment] = '#fragment' # example
27
+ # Pagy::VARS[:link_extra] = 'data-remote="true"' # example
28
+ # Pagy::VARS[:i18n_key] = 'pagy.item_name' # default
29
+ # Pagy::VARS[:cycle] = true # example
30
+
31
+
8
32
  # Extras
9
33
  # See https://ddnexus.github.io/pagy/extras
10
34
 
@@ -18,7 +42,6 @@
18
42
  # Countless extra: Paginate without any count, saving one query per rendering
19
43
  # See https://ddnexus.github.io/pagy/extras/countless
20
44
  # require 'pagy/extras/countless'
21
- # Pagy::VARS[:cycle] = false # default
22
45
 
23
46
  # Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
24
47
  # See https://ddnexus.github.io/pagy/extras/elasticsearch_rails
@@ -87,6 +110,8 @@
87
110
  # require 'pagy/extras/items'
88
111
  # Pagy::VARS[:items_param] = :items # default
89
112
  # Pagy::VARS[:max_items] = 100 # default
113
+ # set to false if you want to make :enable_items_extra an opt-in variable
114
+ # Pagy::VARS[:enable_items_extra] = false # default true
90
115
 
91
116
  # Overflow extra: Allow for easy handling of overflowing pages
92
117
  # See https://ddnexus.github.io/pagy/extras/overflow
@@ -105,28 +130,8 @@
105
130
  # See https://ddnexus.github.io/pagy/extras/trim
106
131
  # require 'pagy/extras/trim'
107
132
  # after requiring it will trim by default
108
- # set to false if you want to make :trim an opt-in variable
109
- # Pagy::VARS[:trim] = true # default
110
-
111
-
112
- # Pagy Variables
113
- # See https://ddnexus.github.io/pagy/api/pagy#variables
114
- # All the Pagy::VARS are set for all the Pagy instances but can be overridden
115
- # per instance by just passing them to Pagy.new or the #pagy controller method
116
-
117
-
118
- # Instance variables
119
- # See https://ddnexus.github.io/pagy/api/pagy#instance-variables
120
- # Pagy::VARS[:items] = 20 # default
121
-
122
-
123
- # Other Variables
124
- # See https://ddnexus.github.io/pagy/api/pagy#other-variables
125
- # Pagy::VARS[:size] = [1,4,4,1] # default
126
- # Pagy::VARS[:page_param] = :page # default
127
- # Pagy::VARS[:params] = {} # default
128
- # Pagy::VARS[:anchor] = '#anchor' # example
129
- # Pagy::VARS[:link_extra] = 'data-remote="true"' # example
133
+ # set to false if you want to make :enable_trim_extra an opt-in variable
134
+ # Pagy::VARS[:enable_trim_extra] = false # default true
130
135
 
131
136
 
132
137
  # Rails
@@ -2,34 +2,35 @@
2
2
 
3
3
  function Pagy(){}
4
4
 
5
- Pagy.version = '4.3.0';
5
+ Pagy.version = '4.4.0';
6
6
 
7
- Pagy.init = function(arg){
7
+ Pagy.timeout = 100;
8
+
9
+ Pagy.timeoutId = 0;
10
+
11
+ Pagy.init = function(arg) {
8
12
  var target = arg instanceof Event || arg === undefined ? document : arg,
9
13
  jsonTags = target.getElementsByClassName('pagy-json');
10
- if (target === document) { // reset resize-listeners on page load (#163)
11
- for (var id in Pagy.navResizeListeners) { window.removeEventListener('resize', Pagy.navResizeListeners[id], true) }
12
- Pagy.navResizeListeners = {};
13
- }
14
14
  for (var i = 0, len = jsonTags.length; i < len; i++) {
15
- var args = JSON.parse(jsonTags[i].innerHTML);
16
- Pagy[args.shift()].apply(null, args);
15
+ var args = JSON.parse(jsonTags[i].innerHTML),
16
+ fname = args.shift();
17
+ args.unshift(jsonTags[i].previousSibling);
18
+ Pagy[fname].apply(null, args);
17
19
  }
18
- };
20
+ }
19
21
 
20
- Pagy.nav = function(id, tags, sequels, param){
21
- var pagyEl = document.getElementById(id),
22
- lastWidth = undefined,
22
+ Pagy.nav = function(pagyEl, tags, sequels, param) {
23
+ var lastWidth = undefined,
23
24
  timeoutId = 0,
24
25
  pageREg = new RegExp(/__pagy_page__/g),
25
26
  widths = [],
26
- rendering = function(){ clearTimeout(timeoutId); timeoutId = setTimeout(pagyEl.render, 150) }; // suppress rapid firing rendering
27
+ wait = function() { clearTimeout(timeoutId); timeoutId = setTimeout(pagyEl.render, Pagy.timeout) };
27
28
 
28
29
  for (var width in sequels) { widths.push(parseInt(width)) } // fine with sequels structure
29
- widths.sort(function(a, b){return b-a});
30
+ widths.sort(function(a, b) { return b - a });
30
31
 
31
- pagyEl.render = function(){
32
- if (this.parentElement.clientWidth === 0) { rendering() }
32
+ pagyEl.render = function() {
33
+ if (this.parentElement.clientWidth === 0) { return wait() } // not ready yet
33
34
  var width, i, len;
34
35
  for (i = 0, len = widths.length; i < len; i++) {
35
36
  if (this.parentElement.clientWidth > widths[i]) { width = widths[i]; break }
@@ -50,57 +51,60 @@ Pagy.nav = function(id, tags, sequels, param){
50
51
  lastWidth = width;
51
52
  }
52
53
  }.bind(pagyEl);
53
-
54
- if (widths.length > 1) {
55
- // refresh the window resize listener (avoiding rendering multiple times)
56
- window.removeEventListener('resize', Pagy.navResizeListeners[id], true); // needed for AJAX init
57
- window.addEventListener('resize', rendering, true);
58
- Pagy.navResizeListeners[id] = rendering;
59
- }
60
54
  pagyEl.render();
61
- };
55
+ }
62
56
 
63
- Pagy.combo_nav = function(id, page, link, param){
64
- var pagyEl = document.getElementById(id),
65
- input = pagyEl.getElementsByTagName('input')[0],
66
- go = function(){
67
- if (page !== input.value) {
68
- var html = link.replace(/__pagy_page__/, input.value);
69
- if (typeof(param) === 'string' && input.value === '1') { html = Pagy.trim(html, param) }
70
- pagyEl.insertAdjacentHTML('afterbegin', html);
71
- pagyEl.getElementsByTagName('a')[0].click();
72
- }
73
- };
57
+ Pagy.combo_nav = function(pagyEl, page, link, param) {
58
+ var input = pagyEl.getElementsByTagName('input')[0],
59
+ go = function() {
60
+ if (page !== input.value) {
61
+ var html = link.replace(/__pagy_page__/, input.value);
62
+ if (typeof (param) === 'string' && input.value === '1') { html = Pagy.trim(html, param) }
63
+ pagyEl.insertAdjacentHTML('afterbegin', html);
64
+ pagyEl.getElementsByTagName('a')[0].click();
65
+ }
66
+ };
74
67
  Pagy.addInputEventListeners(input, go);
75
- };
68
+ }
76
69
 
77
- Pagy.items_selector = function(id, from, link, param){
78
- var pagyEl = document.getElementById(id),
79
- input = pagyEl.getElementsByTagName('input')[0],
70
+ Pagy.items_selector = function(pagyEl, from, link, param) {
71
+ var input = pagyEl.getElementsByTagName('input')[0],
80
72
  current = input.value,
81
- go = function(){
82
- var items = input.value;
83
- if (current !== items) {
84
- var page = Math.max(Math.ceil(from / items),1),
85
- html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, items);
86
- if (typeof(param) === 'string' && page === 1){ html = Pagy.trim(html, param) }
87
- pagyEl.insertAdjacentHTML('afterbegin', html);
88
- pagyEl.getElementsByTagName('a')[0].click();
89
- }
90
- };
73
+ go = function() {
74
+ var items = input.value;
75
+ if (current !== items) {
76
+ var page = Math.max(Math.ceil(from / items), 1),
77
+ html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, items);
78
+ if (typeof (param) === 'string' && page === 1) { html = Pagy.trim(html, param) }
79
+ pagyEl.insertAdjacentHTML('afterbegin', html);
80
+ pagyEl.getElementsByTagName('a')[0].click();
81
+ }
82
+ };
91
83
  Pagy.addInputEventListeners(input, go);
92
- };
84
+ }
93
85
 
94
- Pagy.addInputEventListeners = function(input, handler){
86
+ Pagy.addInputEventListeners = function(input, handler) {
95
87
  // select the content on click: easier for typing a number
96
- input.addEventListener('click', function(){ this.select() });
88
+ input.addEventListener('click', function() { this.select() });
97
89
  // go when the input looses focus
98
90
  input.addEventListener('focusout', handler);
99
91
  // … and when pressing enter inside the input
100
- input.addEventListener('keyup', function(e){ if (e.which === 13) handler() }.bind(this));
101
- };
92
+ input.addEventListener('keyup', function(e) { if (e.which === 13) {handler()} }.bind(this));
93
+ }
102
94
 
103
- Pagy.trim = function(html, param){
95
+ Pagy.trim = function(html, param) {
104
96
  var re = new RegExp('[?&]' + param + '=1\\b(?!&)|\\b' + param + '=1&');
105
97
  return html.replace(re, '');
106
- };
98
+ }
99
+
100
+ Pagy.renderNjs = function() {
101
+ var navs = document.getElementsByClassName('pagy-njs');
102
+ for (var i = 0, len = navs.length; i < len; i++) { navs[i].render() }
103
+ }
104
+
105
+ Pagy.wait = function() {
106
+ clearTimeout(Pagy.timeoutId);
107
+ Pagy.timeoutId = setTimeout(Pagy.renderNjs, Pagy.timeout);
108
+ }
109
+
110
+ window.addEventListener('resize', Pagy.wait, true);
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # main class
7
7
  class Pagy
8
- VERSION = '4.3.0'
8
+ VERSION = '4.4.0'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
@@ -14,7 +14,7 @@ class Pagy
14
14
 
15
15
  # default vars
16
16
  VARS = { page: 1, items: 20, outset: 0, size: [1, 4, 4, 1], page_param: :page, # rubocop:disable Style/MutableConstant
17
- params: {}, anchor: '', link_extra: '', i18n_key: 'pagy.item_name', cycle: false }
17
+ params: {}, fragment: '', link_extra: '', i18n_key: 'pagy.item_name', cycle: false }
18
18
 
19
19
  attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :from, :to, :prev, :next
20
20
 
@@ -22,7 +22,8 @@ class Pagy
22
22
 
23
23
  # Merge and validate the options, do some simple arithmetic and set the instance variables
24
24
  def initialize(vars)
25
- @vars = VARS.merge( vars.delete_if{|_,v| v.nil? || v == '' } )
25
+ @vars = VARS.merge( vars.delete_if{|k,v| VARS.key?(k) && (v.nil? || v == '') } )
26
+ @vars[:fragment] = deprecated_var(:anchor, @vars[:anchor], :fragment, @vars[:fragment]) if @vars[:anchor]
26
27
 
27
28
  INSTANCE_VARS_MIN.each do |name,min|
28
29
  raise VariableError.new(self), "expected :#{name} >= #{min}; got #{@vars[name].inspect}" \
@@ -69,6 +70,7 @@ class Pagy
69
70
 
70
71
  end
71
72
 
73
+ require 'pagy/deprecation'
72
74
  require 'pagy/backend'
73
75
  require 'pagy/frontend'
74
76
  require 'pagy/exceptions'
data/lib/pagy/backend.rb CHANGED
@@ -19,6 +19,7 @@ class Pagy
19
19
 
20
20
  # Sub-method called only by #pagy: here for easy customization of variables by overriding
21
21
  def pagy_get_vars(collection, vars)
22
+ pagy_set_items_from_params(vars) if defined?(UseItemsExtra)
22
23
  vars[:count] ||= (c = collection.count(:all)).is_a?(Hash) ? c.size : c
23
24
  vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
24
25
  vars
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ class Pagy
3
+ class << self
4
+
5
+ # deprecated variables
6
+ def deprecated_var(var, val, new_var, new_val)
7
+ value = new_val || val
8
+ Warning.warn %([PAGY WARNING] deprecated use of `#{var}` var will not be supported in 5.0! Use `#{new_var}: #{value.inspect}` instead.)
9
+ value
10
+ end
11
+
12
+ # deprecated pagy_url_for argument order
13
+ def deprecated_order(pagy, page)
14
+ Warning.warn '[PAGY WARNING] inverted use of pagy/page in pagy_url_for will not be supported in 5.0! Use pagy_url_for(pagy, page) instead.'
15
+ [page, pagy]
16
+ end
17
+
18
+
19
+ # deprecated posiitioal arguments
20
+ def deprecated_arg(arg, val, new_key, new_val)
21
+ value = new_val || val # we use the new_val if present
22
+ Warning.warn %([PAGY WARNING] deprecated use of positional `#{arg}` arg will not be supported in 5.0! Use only the keyword arg `#{new_key}: #{value.inspect}` instead.)
23
+ value
24
+ end
25
+
26
+ end
27
+ end
@@ -11,6 +11,7 @@ class Pagy
11
11
  end
12
12
 
13
13
  def pagy_arel_get_vars(collection, vars)
14
+ pagy_set_items_from_params(vars) if defined?(UseItemsExtra)
14
15
  vars[:count] ||= pagy_arel_count(collection)
15
16
  vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
16
17
  vars
@@ -14,6 +14,7 @@ class Pagy
14
14
 
15
15
  # Sub-method called only by #pagy_array: here for easy customization of variables by overriding
16
16
  def pagy_array_get_vars(array, vars)
17
+ pagy_set_items_from_params(vars) if defined?(UseItemsExtra)
17
18
  vars[:count] ||= array.size
18
19
  vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
19
20
  vars
@@ -7,10 +7,11 @@ class Pagy
7
7
  module Frontend
8
8
 
9
9
  # Pagination for bootstrap: it returns the html with the series of links to the pages
10
- def pagy_bootstrap_nav(pagy)
11
- link = pagy_link_proc(pagy, 'class="page-link"')
10
+ def pagy_bootstrap_nav(pagy, pagy_id: nil, link_extra: '')
11
+ p_id = %( id="#{pagy_id}") if pagy_id
12
+ link = pagy_link_proc(pagy, link_extra: %(class="page-link" #{link_extra}))
12
13
 
13
- html = +%(<nav class="pagy-bootstrap-nav" role="navigation" aria-label="pager"><ul class="pagination">)
14
+ html = +%(<nav#{p_id} class="pagy-bootstrap-nav" role="navigation" aria-label="pager"><ul class="pagination">)
14
15
  html << pagy_bootstrap_prev_html(pagy, link)
15
16
  pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
16
17
  html << case item
@@ -24,26 +25,30 @@ class Pagy
24
25
  end
25
26
 
26
27
  # Javascript pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.nav javascript
27
- def pagy_bootstrap_nav_js(pagy, id=pagy_id)
28
- link = pagy_link_proc(pagy, 'class="page-link"')
28
+ def pagy_bootstrap_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '', steps: nil)
29
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
30
+ p_id = %( id="#{pagy_id}") if pagy_id
31
+ link = pagy_link_proc(pagy, link_extra: %(class="page-link" #{link_extra}))
29
32
  tags = { 'before' => %(<ul class="pagination">#{pagy_bootstrap_prev_html pagy, link}),
30
33
  'link' => %(<li class="page-item">#{mark = link.call(PAGE_PLACEHOLDER)}</li>),
31
34
  'active' => %(<li class="page-item active">#{mark}</li>),
32
35
  'gap' => %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t 'pagy.nav.gap'}</a></li>),
33
36
  'after' => %(#{pagy_bootstrap_next_html pagy, link}</ul>) }
34
37
 
35
- html = %(<nav id="#{id}" class="pagy-bootstrap-nav-js" role="navigation" aria-label="pager"></nav>)
36
- html << pagy_json_tag(pagy, :nav, id, tags, pagy.sequels)
38
+ html = %(<nav#{p_id} class="pagy-njs pagy-bootstrap-nav-js" role="navigation" aria-label="pager"></nav>)
39
+ html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
37
40
  end
38
41
 
39
42
  # Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
40
- def pagy_bootstrap_combo_nav_js(pagy, id=pagy_id)
41
- link = pagy_link_proc(pagy)
43
+ def pagy_bootstrap_combo_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '')
44
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
45
+ p_id = %( id="#{pagy_id}") if pagy_id
46
+ link = pagy_link_proc(pagy, link_extra: link_extra)
42
47
  p_page = pagy.page
43
48
  p_pages = pagy.pages
44
49
  input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" class="text-primary" style="padding: 0; border: none; text-align: center; width: #{p_pages.to_s.length+1}rem;">)
45
50
 
46
- %(<nav id="#{id}" class="pagy-bootstrap-combo-nav-js pagination" role="navigation" aria-label="pager"><div class="btn-group" role="group">#{
51
+ %(<nav#{p_id} class="pagy-bootstrap-combo-nav-js pagination" role="navigation" aria-label="pager"><div class="btn-group" role="group">#{
47
52
  if (p_prev = pagy.prev)
48
53
  link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous" class="prev btn btn-primary"'
49
54
  else
@@ -56,7 +61,7 @@ class Pagy
56
61
  %(<a class="next btn btn-primary disabled" href="#">#{pagy_t 'pagy.nav.next' }</a>)
57
62
  end
58
63
  }</div></nav>#{
59
- pagy_json_tag pagy, :combo_nav, id, p_page, pagy_marked_link(link)
64
+ pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
60
65
  })
61
66
  end
62
67
 
@@ -7,10 +7,11 @@ class Pagy
7
7
  module Frontend
8
8
 
9
9
  # Pagination for Bulma: it returns the html with the series of links to the pages
10
- def pagy_bulma_nav(pagy)
11
- link = pagy_link_proc(pagy)
10
+ def pagy_bulma_nav(pagy, pagy_id: nil, link_extra: '')
11
+ p_id = %( id="#{pagy_id}") if pagy_id
12
+ link = pagy_link_proc(pagy, link_extra: link_extra)
12
13
 
13
- html = +%(<nav class="pagy-bulma-nav pagination is-centered" role="navigation" aria-label="pagination">)
14
+ html = +%(<nav#{p_id} class="pagy-bulma-nav pagination is-centered" role="navigation" aria-label="pagination">)
14
15
  html << pagy_bulma_prev_next_html(pagy, link)
15
16
  html << %(<ul class="pagination-list">)
16
17
  pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
@@ -23,26 +24,30 @@ class Pagy
23
24
  html << %(</ul></nav>)
24
25
  end
25
26
 
26
- def pagy_bulma_nav_js(pagy, id=pagy_id)
27
- link = pagy_link_proc(pagy)
27
+ def pagy_bulma_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '', steps: nil)
28
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
29
+ p_id = %( id="#{pagy_id}") if pagy_id
30
+ link = pagy_link_proc(pagy, link_extra: link_extra)
28
31
  tags = { 'before' => %(#{pagy_bulma_prev_next_html(pagy, link)}<ul class="pagination-list">),
29
32
  'link' => %(<li>#{link.call PAGE_PLACEHOLDER, PAGE_PLACEHOLDER, %(class="pagination-link" aria-label="goto page #{PAGE_PLACEHOLDER}")}</li>),
30
33
  'active' => %(<li>#{link.call PAGE_PLACEHOLDER, PAGE_PLACEHOLDER, %(class="pagination-link is-current" aria-current="page" aria-label="page #{PAGE_PLACEHOLDER}")}</li>),
31
34
  'gap' => %(<li><span class="pagination-ellipsis">#{pagy_t 'pagy.nav.gap' }</span></li>),
32
35
  'after' => '</ul>' }
33
36
 
34
- html = %(<nav id="#{id}" class="pagy-bulma-nav-js pagination is-centered" role="navigation" aria-label="pagination"></nav>)
35
- html << pagy_json_tag(pagy, :nav, id, tags, pagy.sequels)
37
+ html = %(<nav#{p_id} class="pagy-njs pagy-bulma-nav-js pagination is-centered" role="navigation" aria-label="pagination"></nav>)
38
+ html << pagy_json_tag(pagy, :nav, tags, pagy.sequels(steps))
36
39
  end
37
40
 
38
41
  # Javascript combo pagination for Bulma: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
39
- def pagy_bulma_combo_nav_js(pagy, id=pagy_id)
40
- link = pagy_link_proc(pagy)
42
+ def pagy_bulma_combo_nav_js(pagy, deprecated_id=nil, pagy_id: nil, link_extra: '')
43
+ pagy_id = Pagy.deprecated_arg(:id, deprecated_id, :pagy_id, pagy_id) if deprecated_id
44
+ p_id = %( id="#{pagy_id}") if pagy_id
45
+ link = pagy_link_proc(pagy, link_extra: link_extra)
41
46
  p_page = pagy.page
42
47
  p_pages = pagy.pages
43
48
  input = %(<input class="input" type="number" min="1" max="#{p_pages}" value="#{p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length+1}rem; margin:0 0.3rem;">)
44
49
 
45
- %(<nav id="#{id}" class="pagy-bulma-combo-nav-js" role="navigation" aria-label="pagination"><div class="field is-grouped is-grouped-centered" role="group">#{
50
+ %(<nav#{p_id} class="pagy-bulma-combo-nav-js" role="navigation" aria-label="pagination"><div class="field is-grouped is-grouped-centered" role="group">#{
46
51
  if (p_prev = pagy.prev)
47
52
  %(<p class="control">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'class="button" aria-label="previous page"'}</p>)
48
53
  else
@@ -55,7 +60,7 @@ class Pagy
55
60
  %(<p class="control"><a class="button" disabled>#{pagy_t 'pagy.nav.next'}</a></p>)
56
61
  end
57
62
  }</div></nav>#{
58
- pagy_json_tag pagy, :combo_nav, id, p_page, pagy_marked_link(link)
63
+ pagy_json_tag pagy, :combo_nav, p_page, pagy_marked_link(link)
59
64
  })
60
65
  end
61
66