pagy 5.6.10 → 5.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy-dev.js +117 -0
- data/lib/javascripts/pagy.js +1 -3
- data/lib/javascripts/pagy.mjs +118 -0
- data/lib/pagy/extras/bootstrap.rb +6 -5
- data/lib/pagy/extras/bulma.rb +7 -5
- data/lib/pagy/extras/foundation.rb +6 -5
- data/lib/pagy/extras/items.rb +1 -1
- data/lib/pagy/extras/materialize.rb +6 -5
- data/lib/pagy/extras/navs.rb +6 -5
- data/lib/pagy/extras/semantic.rb +6 -5
- data/lib/pagy/extras/uikit.rb +6 -5
- data/lib/pagy.rb +1 -1
- metadata +4 -3
- data/lib/javascripts/pagy.js.map +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b065a7027d07b5bc504cbd2b80389a2e25168a075a7485d6a0155bd54b36bf4
|
4
|
+
data.tar.gz: 345c15d964cf6511adcbdf60514f605c64b83e51dd172849f98d337fcff67696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16b5e3b3cee1cde9f609260324ad045e45b97ecbb457eb648044b726fcc0735dd16f7909f49066ae21c01589e3dafdf303be19a865d0d71fcebe3e9b325e9fe1
|
7
|
+
data.tar.gz: df2a7604efbd881c69977e05a23b4b4125eaf0660410d619dbeafbfed7f42de2f4382f01b91f591bd66a6a799c8f5970deb782ea6ca48e9cb8fe95c018428feb
|
data/lib/config/pagy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Pagy initializer file (5.
|
3
|
+
# Pagy initializer file (5.7.3)
|
4
4
|
# Customize only what you really need and notice that the core 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
|
|
@@ -0,0 +1,117 @@
|
|
1
|
+
// The Pagy object
|
2
|
+
const Pagy = {
|
3
|
+
version: "5.7.3",
|
4
|
+
// Scan for "data-pagy-json" elements, parse their JSON content and call their init functions
|
5
|
+
init(arg) {
|
6
|
+
const target = arg instanceof Element ? arg : document;
|
7
|
+
const elements = target.querySelectorAll("[data-pagy-json]");
|
8
|
+
const warn = (el, err) => console.warn("Pagy.init() skipped element: %o\n%s", el, err);
|
9
|
+
for (const element of elements) {
|
10
|
+
const json = element.getAttribute("data-pagy-json");
|
11
|
+
try {
|
12
|
+
const [keyword, ...args] = JSON.parse(json);
|
13
|
+
if (keyword === "nav") {
|
14
|
+
Pagy.initNav(element, args);
|
15
|
+
}
|
16
|
+
else if (keyword === "combo") {
|
17
|
+
Pagy.initCombo(element, args);
|
18
|
+
}
|
19
|
+
else if (keyword === "selector") {
|
20
|
+
Pagy.initSelector(element, args);
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
warn(element, `Illegal PagyJSON keyword: expected "nav"|"combo"|"selector", got "${keyword}"`);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
catch (err) {
|
27
|
+
warn(element, err);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
// Init the *_nav_js helpers
|
32
|
+
initNav(el, [tags, sequels, labelSequels, trimParam]) {
|
33
|
+
const container = el.parentElement ?? el;
|
34
|
+
const widths = Object.getOwnPropertyNames(sequels).map(w => parseInt(w)).sort((a, b) => b - a);
|
35
|
+
let lastWidth = -1;
|
36
|
+
const fillIn = (link, page, label) => link.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);
|
37
|
+
(el.pagyRender = function () {
|
38
|
+
const width = widths.find(w => w < container.clientWidth) || 0;
|
39
|
+
if (width === lastWidth) {
|
40
|
+
return;
|
41
|
+
} // no change: abort
|
42
|
+
let html = tags.before;
|
43
|
+
const series = sequels[width.toString()];
|
44
|
+
const labels = labelSequels?.[width.toString()] ?? series.map(l => l.toString());
|
45
|
+
for (const i in series) {
|
46
|
+
const item = series[i];
|
47
|
+
const label = labels[i];
|
48
|
+
if (typeof trimParam === "string" && item === 1) {
|
49
|
+
html += Pagy.trim(fillIn(tags.link, item.toString(), label), trimParam);
|
50
|
+
}
|
51
|
+
else if (typeof item === "number") {
|
52
|
+
html += fillIn(tags.link, item.toString(), label);
|
53
|
+
}
|
54
|
+
else if (item === "gap") {
|
55
|
+
html += tags.gap;
|
56
|
+
}
|
57
|
+
else { // active page
|
58
|
+
html += fillIn(tags.active, item, label);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
html += tags.after; // eslint-disable-line align-assignments/align-assignments
|
62
|
+
el.innerHTML = "";
|
63
|
+
el.insertAdjacentHTML("afterbegin", html);
|
64
|
+
lastWidth = width;
|
65
|
+
})();
|
66
|
+
if (el.classList.contains("pagy-rjs")) {
|
67
|
+
Pagy.rjsObserver.observe(container);
|
68
|
+
}
|
69
|
+
},
|
70
|
+
// The observer instance for responsive navs
|
71
|
+
rjsObserver: new ResizeObserver(entries => {
|
72
|
+
entries.filter(e => e.contentBoxSize)
|
73
|
+
.forEach(e => e.target.querySelectorAll(".pagy-rjs")
|
74
|
+
.forEach(rjs => rjs.pagyRender()));
|
75
|
+
}),
|
76
|
+
// Init the *_combo_nav_js helpers
|
77
|
+
initCombo(el, [link, trimParam]) {
|
78
|
+
Pagy.initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);
|
79
|
+
},
|
80
|
+
// Init the items_selector_js helper
|
81
|
+
initSelector(el, [from, link, trimParam]) {
|
82
|
+
Pagy.initInput(el, inputValue => {
|
83
|
+
const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
|
84
|
+
const html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
|
85
|
+
return [page, html];
|
86
|
+
}, trimParam);
|
87
|
+
},
|
88
|
+
// Init the input element
|
89
|
+
initInput(el, getVars, trimParam) {
|
90
|
+
const input = el.querySelector("input");
|
91
|
+
const initial = input.value;
|
92
|
+
const action = function () {
|
93
|
+
if (input.value === initial) {
|
94
|
+
return;
|
95
|
+
} // not changed
|
96
|
+
const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);
|
97
|
+
if (val < min || val > max) { // reset invalid/out-of-range
|
98
|
+
input.value = initial;
|
99
|
+
input.select();
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
let [page, html] = getVars(input.value); // eslint-disable-line prefer-const
|
103
|
+
if (typeof trimParam === "string" && page === "1") {
|
104
|
+
html = Pagy.trim(html, trimParam);
|
105
|
+
}
|
106
|
+
el.insertAdjacentHTML("afterbegin", html);
|
107
|
+
el.querySelector("a").click();
|
108
|
+
};
|
109
|
+
["change", "focus"].forEach(e => input.addEventListener(e, input.select)); // auto-select
|
110
|
+
input.addEventListener("focusout", action); // trigger action
|
111
|
+
input.addEventListener("keypress", e => { if (e.key === "Enter") {
|
112
|
+
action();
|
113
|
+
} }); // trigger action
|
114
|
+
},
|
115
|
+
// Trim the ${page-param}=1 params in links
|
116
|
+
trim: (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "")
|
117
|
+
};
|
data/lib/javascripts/pagy.js
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
//# sourceMappingURL=pagy.js.map
|
1
|
+
!function(){function t(t){if(Array.isArray(t))return t}function n(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function e(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function r(r,i){return t(r)||n(r)||e()}var i={version:"5.7.3",init:function(r){var a,o=(r instanceof Element?r:document).querySelectorAll("[data-pagy-json]"),c=function(t,n){return console.warn("Pagy.init() skipped element: %o\n%s",t,n)},u=!0,l=!1,f=void 0;try{for(var p,s=o[Symbol.iterator]();!(u=(p=s.next()).done);u=!0){var v=p.value,g=v.getAttribute("data-pagy-json");try{var y=t(a=JSON.parse(g))||n(a)||e(),d=y[0],m=y.slice(1);"nav"===d?i.initNav(v,m):"combo"===d?i.initCombo(v,m):"selector"===d?i.initSelector(v,m):c(v,'Illegal PagyJSON keyword: expected "nav"|"combo"|"selector", got "'.concat(d,'"'))}catch(t){c(v,t)}}}catch(t){l=!0,f=t}finally{try{u||null==s.return||s.return()}finally{if(l)throw f}}},initNav:function(t,n){var e,a=r(n),o=a[0],c=a[1],u=a[2],l=a[3],f=null!==(e=t.parentElement)&&void 0!==e?e:t,p=Object.getOwnPropertyNames(c).map((function(t){return parseInt(t)})).sort((function(t,n){return n-t})),s=-1,v=function(t,n,e){return t.replace(/__pagy_page__/g,n).replace(/__pagy_label__/g,e)};(t.pagyRender=function(){var n=p.find((function(t){return t<f.clientWidth}))||0;if(n!==s){var e,r=o.before,a=c[n.toString()],g=null!==(e=null==u?void 0:u[n.toString()])&&void 0!==e?e:a.map((function(t){return t.toString()}));for(var y in a){var d=a[y],m=g[y];r+="string"==typeof l&&1===d?i.trim(v(o.link,d.toString(),m),l):"number"==typeof d?v(o.link,d.toString(),m):"gap"===d?o.gap:v(o.active,d,m)}r+=o.after,t.innerHTML="",t.insertAdjacentHTML("afterbegin",r),s=n}})(),t.classList.contains("pagy-rjs")&&i.rjsObserver.observe(f)},rjsObserver:new ResizeObserver((function(t){t.filter((function(t){return t.contentBoxSize})).forEach((function(t){return t.target.querySelectorAll(".pagy-rjs").forEach((function(t){return t.pagyRender()}))}))})),initCombo:function(t,n){var e=r(n),a=e[0],o=e[1];i.initInput(t,(function(t){return[t,a.replace(/__pagy_page__/,t)]}),o)},initSelector:function(t,n){var e=r(n),a=e[0],o=e[1],c=e[2];i.initInput(t,(function(t){var n=Math.max(Math.ceil(a/parseInt(t)),1).toString();return[n,o.replace(/__pagy_page__/,n).replace(/__pagy_items__/,t)]}),c)},initInput:function(t,n,e){var a=t.querySelector("input"),o=a.value,c=function(){if(a.value!==o){var c=r([a.min,a.value,a.max].map((function(t){return parseInt(t)||0}))),u=c[0],l=c[1],f=c[2];if(l<u||l>f)return a.value=o,void a.select();var p=r(n(a.value)),s=p[0],v=p[1];"string"==typeof e&&"1"===s&&(v=i.trim(v,e)),t.insertAdjacentHTML("afterbegin",v),t.querySelector("a").click()}};["change","focus"].forEach((function(t){return a.addEventListener(t,a.select)})),a.addEventListener("focusout",c),a.addEventListener("keypress",(function(t){"Enter"===t.key&&c()}))},trim:function(t,n){return t.replace(new RegExp("[?&]".concat(n,"=1\\b(?!&)|\\b").concat(n,"=1&")),"")}},a=i;window.Pagy=a}();
|
@@ -0,0 +1,118 @@
|
|
1
|
+
// The Pagy object
|
2
|
+
const Pagy = {
|
3
|
+
version: "5.7.3",
|
4
|
+
// Scan for "data-pagy-json" elements, parse their JSON content and call their init functions
|
5
|
+
init(arg) {
|
6
|
+
const target = arg instanceof Element ? arg : document;
|
7
|
+
const elements = target.querySelectorAll("[data-pagy-json]");
|
8
|
+
const warn = (el, err) => console.warn("Pagy.init() skipped element: %o\n%s", el, err);
|
9
|
+
for (const element of elements) {
|
10
|
+
const json = element.getAttribute("data-pagy-json");
|
11
|
+
try {
|
12
|
+
const [keyword, ...args] = JSON.parse(json);
|
13
|
+
if (keyword === "nav") {
|
14
|
+
Pagy.initNav(element, args);
|
15
|
+
}
|
16
|
+
else if (keyword === "combo") {
|
17
|
+
Pagy.initCombo(element, args);
|
18
|
+
}
|
19
|
+
else if (keyword === "selector") {
|
20
|
+
Pagy.initSelector(element, args);
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
warn(element, `Illegal PagyJSON keyword: expected "nav"|"combo"|"selector", got "${keyword}"`);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
catch (err) {
|
27
|
+
warn(element, err);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
// Init the *_nav_js helpers
|
32
|
+
initNav(el, [tags, sequels, labelSequels, trimParam]) {
|
33
|
+
const container = el.parentElement ?? el;
|
34
|
+
const widths = Object.getOwnPropertyNames(sequels).map(w => parseInt(w)).sort((a, b) => b - a);
|
35
|
+
let lastWidth = -1;
|
36
|
+
const fillIn = (link, page, label) => link.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);
|
37
|
+
(el.pagyRender = function () {
|
38
|
+
const width = widths.find(w => w < container.clientWidth) || 0;
|
39
|
+
if (width === lastWidth) {
|
40
|
+
return;
|
41
|
+
} // no change: abort
|
42
|
+
let html = tags.before;
|
43
|
+
const series = sequels[width.toString()];
|
44
|
+
const labels = labelSequels?.[width.toString()] ?? series.map(l => l.toString());
|
45
|
+
for (const i in series) {
|
46
|
+
const item = series[i];
|
47
|
+
const label = labels[i];
|
48
|
+
if (typeof trimParam === "string" && item === 1) {
|
49
|
+
html += Pagy.trim(fillIn(tags.link, item.toString(), label), trimParam);
|
50
|
+
}
|
51
|
+
else if (typeof item === "number") {
|
52
|
+
html += fillIn(tags.link, item.toString(), label);
|
53
|
+
}
|
54
|
+
else if (item === "gap") {
|
55
|
+
html += tags.gap;
|
56
|
+
}
|
57
|
+
else { // active page
|
58
|
+
html += fillIn(tags.active, item, label);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
html += tags.after; // eslint-disable-line align-assignments/align-assignments
|
62
|
+
el.innerHTML = "";
|
63
|
+
el.insertAdjacentHTML("afterbegin", html);
|
64
|
+
lastWidth = width;
|
65
|
+
})();
|
66
|
+
if (el.classList.contains("pagy-rjs")) {
|
67
|
+
Pagy.rjsObserver.observe(container);
|
68
|
+
}
|
69
|
+
},
|
70
|
+
// The observer instance for responsive navs
|
71
|
+
rjsObserver: new ResizeObserver(entries => {
|
72
|
+
entries.filter(e => e.contentBoxSize)
|
73
|
+
.forEach(e => e.target.querySelectorAll(".pagy-rjs")
|
74
|
+
.forEach(rjs => rjs.pagyRender()));
|
75
|
+
}),
|
76
|
+
// Init the *_combo_nav_js helpers
|
77
|
+
initCombo(el, [link, trimParam]) {
|
78
|
+
Pagy.initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);
|
79
|
+
},
|
80
|
+
// Init the items_selector_js helper
|
81
|
+
initSelector(el, [from, link, trimParam]) {
|
82
|
+
Pagy.initInput(el, inputValue => {
|
83
|
+
const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
|
84
|
+
const html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
|
85
|
+
return [page, html];
|
86
|
+
}, trimParam);
|
87
|
+
},
|
88
|
+
// Init the input element
|
89
|
+
initInput(el, getVars, trimParam) {
|
90
|
+
const input = el.querySelector("input");
|
91
|
+
const initial = input.value;
|
92
|
+
const action = function () {
|
93
|
+
if (input.value === initial) {
|
94
|
+
return;
|
95
|
+
} // not changed
|
96
|
+
const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);
|
97
|
+
if (val < min || val > max) { // reset invalid/out-of-range
|
98
|
+
input.value = initial;
|
99
|
+
input.select();
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
let [page, html] = getVars(input.value); // eslint-disable-line prefer-const
|
103
|
+
if (typeof trimParam === "string" && page === "1") {
|
104
|
+
html = Pagy.trim(html, trimParam);
|
105
|
+
}
|
106
|
+
el.insertAdjacentHTML("afterbegin", html);
|
107
|
+
el.querySelector("a").click();
|
108
|
+
};
|
109
|
+
["change", "focus"].forEach(e => input.addEventListener(e, input.select)); // auto-select
|
110
|
+
input.addEventListener("focusout", action); // trigger action
|
111
|
+
input.addEventListener("keypress", e => { if (e.key === "Enter") {
|
112
|
+
action();
|
113
|
+
} }); // trigger action
|
114
|
+
},
|
115
|
+
// Trim the ${page-param}=1 params in links
|
116
|
+
trim: (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "")
|
117
|
+
};
|
118
|
+
export default Pagy;
|
@@ -29,8 +29,9 @@ class Pagy # :nodoc:
|
|
29
29
|
html << %(</ul></nav>)
|
30
30
|
end
|
31
31
|
|
32
|
-
# Javascript pagination for bootstrap: it returns a nav and a JSON tag used by the
|
32
|
+
# Javascript pagination for bootstrap: it returns a nav and a JSON tag used by the pagy.js file
|
33
33
|
def pagy_bootstrap_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
34
|
+
sequels = pagy.sequels(**vars)
|
34
35
|
p_id = %( id="#{pagy_id}") if pagy_id
|
35
36
|
link = pagy_link_proc(pagy, link_extra: %(class="page-link" #{link_extra}))
|
36
37
|
tags = { 'before' => %(<ul class="pagination">#{pagy_bootstrap_prev_html pagy, link}),
|
@@ -39,11 +40,11 @@ class Pagy # :nodoc:
|
|
39
40
|
'gap' => %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t 'pagy.nav.gap'}</a></li>),
|
40
41
|
'after' => %(#{pagy_bootstrap_next_html pagy, link}</ul>) }
|
41
42
|
|
42
|
-
%(<nav#{p_id} class="pagy-
|
43
|
-
pagy_json_attr(pagy, :nav, tags,
|
43
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-bootstrap-nav-js" aria-label="pager" #{
|
44
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
44
45
|
end
|
45
46
|
|
46
|
-
# Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the
|
47
|
+
# Javascript combo pagination for bootstrap: it returns a nav and a JSON tag used by the pagy.js file
|
47
48
|
def pagy_bootstrap_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
|
48
49
|
p_id = %( id="#{pagy_id}") if pagy_id
|
49
50
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
@@ -54,7 +55,7 @@ class Pagy # :nodoc:
|
|
54
55
|
p_pages.to_s.length + 1}rem;">)
|
55
56
|
|
56
57
|
%(<nav#{p_id} class="pagy-bootstrap-combo-nav-js pagination" aria-label="pager"><div class="btn-group" role="group" #{
|
57
|
-
pagy_json_attr pagy, :
|
58
|
+
pagy_json_attr pagy, :combo, pagy_marked_link(link)}>#{
|
58
59
|
if (p_prev = pagy.prev)
|
59
60
|
link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous" class="prev btn btn-primary"'
|
60
61
|
else
|
data/lib/pagy/extras/bulma.rb
CHANGED
@@ -7,7 +7,7 @@ class Pagy # :nodoc:
|
|
7
7
|
# Frontend modules are specially optimized for performance.
|
8
8
|
# The resulting code may not look very elegant, but produces the best benchmarks
|
9
9
|
module BulmaExtra
|
10
|
-
# Pagination for
|
10
|
+
# Pagination for bulma: it returns the html with the series of links to the pages
|
11
11
|
def pagy_bulma_nav(pagy, pagy_id: nil, link_extra: '', **vars)
|
12
12
|
p_id = %( id="#{pagy_id}") if pagy_id
|
13
13
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
@@ -30,7 +30,9 @@ class Pagy # :nodoc:
|
|
30
30
|
html << %(</ul></nav>)
|
31
31
|
end
|
32
32
|
|
33
|
+
# Javascript pagination for bulma: it returns a nav and a JSON tag used by the Pagy.nav javascript
|
33
34
|
def pagy_bulma_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
35
|
+
sequels = pagy.sequels(**vars)
|
34
36
|
p_id = %( id="#{pagy_id}") if pagy_id
|
35
37
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
36
38
|
tags = { 'before' => %(#{pagy_bulma_prev_next_html(pagy, link)}<ul class="pagination-list">),
|
@@ -42,11 +44,11 @@ class Pagy # :nodoc:
|
|
42
44
|
'gap' => %(<li><span class="pagination-ellipsis">#{pagy_t 'pagy.nav.gap'}</span></li>),
|
43
45
|
'after' => '</ul>' }
|
44
46
|
|
45
|
-
%(<nav#{p_id} class="pagy-
|
46
|
-
pagy_json_attr(pagy, :nav, tags,
|
47
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-bulma-nav-js pagination is-centered" aria-label="pagination" #{
|
48
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
47
49
|
end
|
48
50
|
|
49
|
-
# Javascript combo pagination for
|
51
|
+
# Javascript combo pagination for bulma: it returns a nav and a JSON tag used by the pagy.js file
|
50
52
|
def pagy_bulma_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
|
51
53
|
p_id = %( id="#{pagy_id}") if pagy_id
|
52
54
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
@@ -57,7 +59,7 @@ class Pagy # :nodoc:
|
|
57
59
|
|
58
60
|
html = %(<nav#{p_id} class="pagy-bulma-combo-nav-js" aria-label="pagination">)
|
59
61
|
%(#{html}<div class="field is-grouped is-grouped-centered" role="group" #{
|
60
|
-
pagy_json_attr pagy, :
|
62
|
+
pagy_json_attr pagy, :combo, pagy_marked_link(link)}>#{
|
61
63
|
if (p_prev = pagy.prev)
|
62
64
|
%(<p class="control">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'class="button" aria-label="previous page"'}</p>)
|
63
65
|
else
|
@@ -26,8 +26,9 @@ class Pagy # :nodoc:
|
|
26
26
|
html << %(</ul></nav>)
|
27
27
|
end
|
28
28
|
|
29
|
-
# Javascript pagination for foundation: it returns a nav and a JSON tag used by the
|
29
|
+
# Javascript pagination for foundation: it returns a nav and a JSON tag used by the pagy.js file
|
30
30
|
def pagy_foundation_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
31
|
+
sequels = pagy.sequels(**vars)
|
31
32
|
p_id = %( id="#{pagy_id}") if pagy_id
|
32
33
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
33
34
|
tags = { 'before' => %(<ul class="pagination">#{pagy_foundation_prev_html pagy, link}),
|
@@ -36,11 +37,11 @@ class Pagy # :nodoc:
|
|
36
37
|
'gap' => %(<li class="ellipsis gap" aria-hidden="true"></li>),
|
37
38
|
'after' => %(#{pagy_foundation_next_html pagy, link}</ul>) }
|
38
39
|
|
39
|
-
%(<nav#{p_id} class="pagy-
|
40
|
-
pagy_json_attr(pagy, :nav, tags,
|
40
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-foundation-nav-js" aria-label="Pagination" #{
|
41
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
41
42
|
end
|
42
43
|
|
43
|
-
# Javascript combo pagination for Foundation: it returns a nav and a JSON tag used by the
|
44
|
+
# Javascript combo pagination for Foundation: it returns a nav and a JSON tag used by the pagy.js file
|
44
45
|
def pagy_foundation_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
|
45
46
|
p_id = %( id="#{pagy_id}") if pagy_id
|
46
47
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
@@ -51,7 +52,7 @@ class Pagy # :nodoc:
|
|
51
52
|
p_pages.to_s.length + 1}rem; padding: 0 0.3rem; margin: 0 0.3rem;">)
|
52
53
|
|
53
54
|
%(<nav#{p_id} class="pagy-foundation-combo-nav-js" aria-label="Pagination"><div class="input-group" #{
|
54
|
-
pagy_json_attr pagy, :
|
55
|
+
pagy_json_attr pagy, :combo, pagy_marked_link(link)}>#{
|
55
56
|
if (p_prev = pagy.prev)
|
56
57
|
link.call p_prev, pagy_t('pagy.nav.prev'),
|
57
58
|
'style="margin-bottom: 0" aria-label="previous" class="prev button primary"'
|
data/lib/pagy/extras/items.rb
CHANGED
@@ -39,7 +39,7 @@ class Pagy # :nodoc:
|
|
39
39
|
link = pagy_marked_link(pagy_link_proc(pagy, link_extra: link_extra))
|
40
40
|
p_vars[:items] = p_items # restore the items
|
41
41
|
|
42
|
-
html = +%(<span#{p_id} class="pagy-items-selector-js" #{pagy_json_attr pagy, :
|
42
|
+
html = +%(<span#{p_id} class="pagy-items-selector-js" #{pagy_json_attr pagy, :selector, pagy.from, link}>)
|
43
43
|
input = %(<input type="number" min="1" max="#{p_vars[:max_items]}" value="#{
|
44
44
|
p_items}" style="padding: 0; text-align: center; width: #{p_items.to_s.length + 1}rem;">)
|
45
45
|
html << pagy_t('pagy.items_selector_js', item_name: item_name || pagy_t(i18n_key || p_vars[:i18n_key], count: p_items),
|
@@ -26,8 +26,9 @@ class Pagy # :nodoc:
|
|
26
26
|
html << %(</ul></div>)
|
27
27
|
end
|
28
28
|
|
29
|
-
# Javascript pagination for materialize: it returns a nav and a JSON tag used by the
|
29
|
+
# Javascript pagination for materialize: it returns a nav and a JSON tag used by the pagy.js file
|
30
30
|
def pagy_materialize_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
31
|
+
sequels = pagy.sequels(**vars)
|
31
32
|
p_id = %( id="#{pagy_id}") if pagy_id
|
32
33
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
33
34
|
|
@@ -37,11 +38,11 @@ class Pagy # :nodoc:
|
|
37
38
|
'gap' => %(<li class="gap disabled"><a href="#">#{pagy_t 'pagy.nav.gap'}</a></li>),
|
38
39
|
'after' => %(#{pagy_materialize_next_html pagy, link}</ul>) }
|
39
40
|
|
40
|
-
%(<div#{p_id} class="pagy-
|
41
|
-
pagy_json_attr(pagy, :nav, tags,
|
41
|
+
%(<div#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-materialize-nav-js" role="navigation" aria-label="pager" #{
|
42
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></div>)
|
42
43
|
end
|
43
44
|
|
44
|
-
# Javascript combo pagination for materialize: it returns a nav and a JSON tag used by the
|
45
|
+
# Javascript combo pagination for materialize: it returns a nav and a JSON tag used by the pagy.js file
|
45
46
|
def pagy_materialize_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
|
46
47
|
p_id = %( id="#{pagy_id}") if pagy_id
|
47
48
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
@@ -53,7 +54,7 @@ class Pagy # :nodoc:
|
|
53
54
|
|
54
55
|
html = %(<ul#{p_id} class="pagy-materialize-combo-nav-js pagination chip" role="navigation")
|
55
56
|
%(#{html} aria-label="pager" style="padding-right: 0" #{
|
56
|
-
pagy_json_attr pagy, :
|
57
|
+
pagy_json_attr pagy, :combo, pagy_marked_link(link)}>#{
|
57
58
|
pagy_materialize_prev_html pagy, link, style}<li class="pagy-combo-input">#{
|
58
59
|
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages}</li>#{
|
59
60
|
pagy_materialize_next_html pagy, link, style}</ul>)
|
data/lib/pagy/extras/navs.rb
CHANGED
@@ -7,8 +7,9 @@ class Pagy # :nodoc:
|
|
7
7
|
# Frontend modules are specially optimized for performance.
|
8
8
|
# The resulting code may not look very elegant, but produces the best benchmarks
|
9
9
|
module NavsExtra
|
10
|
-
# Javascript pagination: it returns a nav and a JSON tag used by the
|
10
|
+
# Javascript pagination: it returns a nav and a JSON tag used by the pagy.js file
|
11
11
|
def pagy_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
12
|
+
sequels = pagy.sequels(**vars)
|
12
13
|
p_id = %( id="#{pagy_id}") if pagy_id
|
13
14
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
14
15
|
tags = { 'before' => pagy_nav_prev_html(pagy, link),
|
@@ -17,11 +18,11 @@ class Pagy # :nodoc:
|
|
17
18
|
'gap' => %(<span class="page gap">#{pagy_t 'pagy.nav.gap'}</span> ),
|
18
19
|
'after' => pagy_nav_next_html(pagy, link) }
|
19
20
|
|
20
|
-
%(<nav#{p_id} class="pagy-
|
21
|
-
pagy_json_attr(pagy, :nav, tags,
|
21
|
+
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-nav-js pagination" aria-label="pager" #{
|
22
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></nav>)
|
22
23
|
end
|
23
24
|
|
24
|
-
# Javascript combo pagination: it returns a nav and a JSON tag used by the
|
25
|
+
# Javascript combo pagination: it returns a nav and a JSON tag used by the pagy.js file
|
25
26
|
def pagy_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
|
26
27
|
p_id = %( id="#{pagy_id}") if pagy_id
|
27
28
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
@@ -31,7 +32,7 @@ class Pagy # :nodoc:
|
|
31
32
|
p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length + 1}rem;">)
|
32
33
|
|
33
34
|
%(<nav#{p_id} class="pagy-combo-nav-js pagination" aria-label="pager" #{
|
34
|
-
pagy_json_attr pagy, :
|
35
|
+
pagy_json_attr pagy, :combo, pagy_marked_link(link)}>#{
|
35
36
|
pagy_nav_prev_html pagy, link
|
36
37
|
}<span class="pagy-combo-input" style="margin: 0 0.6rem;">#{
|
37
38
|
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
|
data/lib/pagy/extras/semantic.rb
CHANGED
@@ -26,8 +26,9 @@ class Pagy # :nodoc:
|
|
26
26
|
html << %(</div>)
|
27
27
|
end
|
28
28
|
|
29
|
-
# Javascript pagination for semantic: it returns a nav and a JSON tag used by the
|
29
|
+
# Javascript pagination for semantic: it returns a nav and a JSON tag used by the pagy.js file
|
30
30
|
def pagy_semantic_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
31
|
+
sequels = pagy.sequels(**vars)
|
31
32
|
p_id = %( id="#{pagy_id}") if pagy_id
|
32
33
|
link = pagy_link_proc(pagy, link_extra: %(class="item" #{link_extra}))
|
33
34
|
tags = { 'before' => pagy_semantic_prev_html(pagy, link),
|
@@ -36,11 +37,11 @@ class Pagy # :nodoc:
|
|
36
37
|
'gap' => %(<div class="disabled item">#{pagy_t('pagy.nav.gap')}</div>),
|
37
38
|
'after' => pagy_semantic_next_html(pagy, link) }
|
38
39
|
|
39
|
-
%(<div#{p_id} class="pagy-
|
40
|
-
pagy_json_attr(pagy, :nav, tags,
|
40
|
+
%(<div#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-semantic-nav-js ui pagination menu" role="navigation" #{
|
41
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></div>)
|
41
42
|
end
|
42
43
|
|
43
|
-
# Combo pagination for semantic: it returns a nav and a JSON tag used by the
|
44
|
+
# Combo pagination for semantic: it returns a nav and a JSON tag used by the pagy.js file
|
44
45
|
def pagy_semantic_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
|
45
46
|
p_id = %( id="#{pagy_id}") if pagy_id
|
46
47
|
link = pagy_link_proc(pagy, link_extra: %(class="item" #{link_extra}))
|
@@ -50,7 +51,7 @@ class Pagy # :nodoc:
|
|
50
51
|
p_page}" style="padding: 0; text-align: center; width: #{p_pages.to_s.length + 1}rem; margin: 0 0.3rem">)
|
51
52
|
|
52
53
|
%(<div#{p_id} class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" #{
|
53
|
-
pagy_json_attr pagy, :
|
54
|
+
pagy_json_attr pagy, :combo, pagy_marked_link(link)}>#{
|
54
55
|
pagy_semantic_prev_html pagy, link
|
55
56
|
}<div class="pagy-combo-input item">#{
|
56
57
|
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
|
data/lib/pagy/extras/uikit.rb
CHANGED
@@ -25,8 +25,9 @@ class Pagy # :nodoc:
|
|
25
25
|
html << %(</ul>)
|
26
26
|
end
|
27
27
|
|
28
|
-
# Javascript pagination for uikit: it returns a nav and a JSON tag used by the
|
28
|
+
# Javascript pagination for uikit: it returns a nav and a JSON tag used by the pagy.js file
|
29
29
|
def pagy_uikit_nav_js(pagy, pagy_id: nil, link_extra: '', **vars)
|
30
|
+
sequels = pagy.sequels(**vars)
|
30
31
|
p_id = %( id="#{pagy_id}") if pagy_id
|
31
32
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
32
33
|
tags = { 'before' => pagy_uikit_prev_html(pagy, link),
|
@@ -35,11 +36,11 @@ class Pagy # :nodoc:
|
|
35
36
|
'gap' => %(<li class="uk-disabled"><span>#{pagy_t 'pagy.nav.gap'}</span></li>),
|
36
37
|
'after' => pagy_uikit_next_html(pagy, link) }
|
37
38
|
|
38
|
-
%(<ul#{p_id} class="pagy-
|
39
|
-
pagy_json_attr(pagy, :nav, tags,
|
39
|
+
%(<ul#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-uikit-nav-js uk-pagination uk-flex-center" #{
|
40
|
+
pagy_json_attr(pagy, :nav, tags, sequels, pagy.label_sequels(sequels))}></ul>)
|
40
41
|
end
|
41
42
|
|
42
|
-
# Javascript combo pagination for uikit: it returns a nav and a JSON tag used by the
|
43
|
+
# Javascript combo pagination for uikit: it returns a nav and a JSON tag used by the pagy.js file
|
43
44
|
def pagy_uikit_combo_nav_js(pagy, pagy_id: nil, link_extra: '')
|
44
45
|
p_id = %( id="#{pagy_id}") if pagy_id
|
45
46
|
link = pagy_link_proc(pagy, link_extra: link_extra)
|
@@ -49,7 +50,7 @@ class Pagy # :nodoc:
|
|
49
50
|
p_page}" style="text-align: center; width: #{p_pages.to_s.length + 1}rem;">)
|
50
51
|
|
51
52
|
%(<ul#{p_id} class="pagy-uikit-combo-nav-js uk-button-group uk-pagination uk-flex-center" #{
|
52
|
-
pagy_json_attr pagy, :
|
53
|
+
pagy_json_attr pagy, :combo, pagy_marked_link(link)
|
53
54
|
}>#{
|
54
55
|
pagy_uikit_prev_html pagy, link
|
55
56
|
}<li>#{
|
data/lib/pagy.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
14
|
email:
|
@@ -19,8 +19,9 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- LICENSE.txt
|
21
21
|
- lib/config/pagy.rb
|
22
|
+
- lib/javascripts/pagy-dev.js
|
22
23
|
- lib/javascripts/pagy.js
|
23
|
-
- lib/javascripts/pagy.
|
24
|
+
- l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FQ,CAIM,QAArB,QAAO,CAAA,CAAP,EAA0C,GAAT,GAAA,CAJlB,GAKf,CAAI,CAAG,IAAI,CAAC,IAAL,CAAU,CAAV,CAAgB,CAAhB,CALQ,EAOnB,CAAM,CAAC,kBAAP,CAA0B,YAA1B,CAAwC,CAAxC,CAPmB,CAQnB,CAAM,CAAC,oBAAP,CAA4B,GAA5B,EAAiC,CAAjC,EAAoC,KAApC,EACH,CACJ,CAbD,CAcH,CA3HQ,CA8HT,gBA9HS,2BA8HQ,CA9HR,CA8HgC,CA9HhC,CA8HqD,CAE1D,CAAK,CAAC,gBAAN,CAAuB,OAAvB,CAAgC,CAAK,CAAC,MAAtC,CAF0D,CAI1D,CAAK,CAAC,gBAAN,CAAuB,UAAvB,CAAmC,CAAnC,CAJ0D,CAM1D,CAAK,CAAC,gBAAN,CAAuB,UAAvB,CAAmC,SAAA,CAAC,CAAI,CAAgB,OAAV,GAAA,CAAC,CAAC,GAAR,EAA2B,CAAQ,EAAM,CAAjF,CACH,CArIQ,CAuIT,IAAI,CAAE,cAAC,CAAD,CAAc,CAAd,QACI,CAAA,CAAI,CAAC,OAAL,CAAa,GAAI,CAAA,MAAJ,eAAkB,CAAlB,0BAAwC,CAAxC,QAAb,CAAkE,EAAlE,CADJ,CAvIG,CAAb","file":"pagy.js","sourcesContent":["// This file is the source that generates pagy.js, polyfilled with the `@babel/preset-env` `\"useBuiltIns\": \"entry\"`.\n// You can generate a custom targeted javascript file for the browsers you need by changing that settings in package.json,\n// then compile it with `npm run compile -w src`.\n\n// Args types from data-pagy-json\ntype NavArgs = [NavTags, NavSequels, null|NavLabelSequels, string]\ntype ComboNavArgs = [string, string, string]\ntype ItemsSelectorArgs = [number, string, string]\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavTags {\n readonly before:string;\n readonly link:string;\n readonly active:string;\n readonly gap:string;\n readonly after:string;\n}\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavSequels {\n readonly [width:string]:(string|number|\"gap\")[];\n}\n\n// Tags from the data-pagy-json of *nav_js helpers\ninterface NavLabelSequels {\n [width:string]:string[];\n}\n\n// Add pagyRender to Element\ninterface Element {\n pagyRender():void;\n}\n\n// The Pagy object\nconst Pagy = {\n version: \"5.6.10\",\n\n // Scan for \"data-pagy-json\" elements, parse their JSON content and apply their functions\n init(arg?:HTMLElement|Document|Event) {\n const target = arg instanceof HTMLElement ? arg : document;\n const elements = target.querySelectorAll(\"[data-pagy-json]\");\n for (const element of elements) {\n const json = element.getAttribute(\"data-pagy-json\") as string;\n try {\n const args = JSON.parse(json);\n const fname = args.shift() as \"nav\"|\"combo_nav\"|\"items_selector\";\n if (fname === \"nav\") {\n Pagy.nav(element, ...args as NavArgs);\n } else if (fname === \"combo_nav\") {\n Pagy.comboNav(element, ...args as ComboNavArgs);\n } else if (fname === \"items_selector\") {\n Pagy.itemsSelector(element, ...args as ItemsSelectorArgs);\n }\n } catch (err) {\n console.warn(\"Pagy.init() skipped element: %o\\n%s\", element, err);\n }\n }\n },\n\n // Power the *_nav_js helpers\n nav(pagyEl:Element, tags:NavTags, sequels:NavSequels, optLabelSequels:null|NavLabelSequels, trimParam?:string) {\n let labelSequels = {} as NavLabelSequels;\n // Handle null labelSequels\n if (optLabelSequels === null) {\n for (const width in sequels) {\n labelSequels[width] = sequels[width].map(item => item.toString());\n }\n } else {\n labelSequels = optLabelSequels;\n }\n // Set and sort the widths as number[]\n const widths = Object.getOwnPropertyNames(sequels)\n .map(w => parseInt(w))\n .sort((a, b) => b - a);\n let lastWidth:number;\n const fillIn = (string:string, item:string, label:string):string =>\n string.replace(/__pagy_page__/g, item)\n .replace(/__pagy_label__/g, label);\n\n pagyEl.pagyRender = function () {\n // Find the width that fits in parent\n const width = widths.find(w => pagyEl.parentElement !== null && pagyEl.parentElement.clientWidth > w) || 0;\n // Only if the width changed\n if (width !== lastWidth) {\n let html = tags.before;\n const series = sequels[width.toString()];\n const labels = labelSequels[width.toString()];\n for (const i in series) {\n const item = series[i];\n const label = labels[i];\n if (typeof trimParam === \"string\" && item === 1) {\n const link = fillIn(tags.link, item.toString(), label);\n html += Pagy.trim(link, trimParam);\n } else if (typeof item === \"number\") {\n html += fillIn(tags.link, item.toString(), label);\n } else if (item === \"gap\") {\n html += tags.gap;\n } else { // active page\n html += fillIn(tags.active, item, label);\n }\n }\n html += tags.after;\n pagyEl.innerHTML = \"\";\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n lastWidth = width;\n }\n };\n pagyEl.pagyRender();\n // If there is a window object then add a single throttled \"resize\" event listener\n if (typeof window !== \"undefined\") {\n let tid = 0;\n window.addEventListener(\"resize\", () => {\n clearTimeout(tid);\n tid = window.setTimeout(Pagy.renderNavs, 100);\n }, true);\n }\n },\n\n // Render all *nav_js helpers (i.e. all the elements of class \"pagy-njs\")\n renderNavs() {\n const navs = document.getElementsByClassName(\"pagy-njs\");\n Array.from(navs).forEach(nav => nav.pagyRender());\n },\n\n // Power the *_combo_nav_js helpers\n comboNav(pagyEl:Element, page:string, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n Pagy.addInputBehavior(input, () => {\n if (page !== input.value) {\n let html = link.replace(/__pagy_page__/, input.value);\n if (typeof trimParam === \"string\" && input.value === \"1\") {\n html = Pagy.trim(html, trimParam);\n }\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n pagyEl.getElementsByTagName(\"a\")[0].click();\n }\n });\n },\n\n // Power the pagy_items_selector_js helper\n itemsSelector(pagyEl:Element, from:number, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n const current = input.value;\n Pagy.addInputBehavior(input, () => {\n const items = input.value;\n if (items === \"0\" || items === \"\") { return }\n if (current !== items) {\n const page = Math.max(Math.ceil(from / parseInt(items)), 1).toString();\n let html = link.replace(/__pagy_page__/, page)\n .replace(/__pagy_items__/, items);\n if (typeof trimParam === \"string\" && page === \"1\") {\n html = Pagy.trim(html, trimParam);\n }\n pagyEl.insertAdjacentHTML(\"afterbegin\", html);\n pagyEl.getElementsByTagName(\"a\")[0].click();\n }\n });\n },\n\n // Add behavior to input fields\n addInputBehavior(input:HTMLInputElement, goToPage:() => void) {\n // select the content on click: easier for direct typing\n input.addEventListener(\"click\", input.select);\n // goToPage when the input loses focus\n input.addEventListener(\"focusout\", goToPage);\n // goToPage when pressing enter while the input has focus\n input.addEventListener(\"keypress\", e => { if (e.key === \"Enter\") { goToPage() } });\n },\n\n trim: (link:string, param:string):string =>\n link.replace(new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`), \"\")\n};\n"]}
|