pagy 3.3.1 → 3.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/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +16 -15
- data/lib/pagy.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10ba8b6d06ab5a7b5a8200742565f8193484e664eaecd342102ff001a03c9dd5
|
4
|
+
data.tar.gz: 273c70974fafb3b8c01392254ba45a86af6654a2442229afb403ec29407b76ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f98ade89e75ce830bd933a2a21c8075c9b00e1f08de5e0797a1178d058707931956b16d5cd2cc818427bbb24464a398c4ebc114b92fde6d671667aedf79d6b
|
7
|
+
data.tar.gz: f70784721380571f8286379cf70e34badd30cea3d57ac89f70b5c99704d1b4719192f2cca0e59b7aa34f0cc0f32b22175752d224f187dbba7aadd1eb7b404320
|
data/lib/config/pagy.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Pagy initializer file (3.3.
|
4
|
+
# Pagy initializer file (3.3.2)
|
5
5
|
# Customize only what you really need and notice that Pagy works also without any of the following lines.
|
6
6
|
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
7
7
|
|
data/lib/javascripts/pagy.js
CHANGED
@@ -5,6 +5,10 @@ function Pagy(){}
|
|
5
5
|
Pagy.init = function(arg){
|
6
6
|
var target = arg instanceof Event || arg === undefined ? document : arg,
|
7
7
|
jsonTags = target.getElementsByClassName('pagy-json');
|
8
|
+
if (target === document) { // reset resize-listeners on page load (#163)
|
9
|
+
for (var id in Pagy.navResizeListeners) { window.removeEventListener('resize', Pagy.navResizeListeners[id], true) }
|
10
|
+
Pagy.navResizeListeners = {};
|
11
|
+
}
|
8
12
|
for (var i = 0, len = jsonTags.length; i < len; i++) {
|
9
13
|
var args = JSON.parse(jsonTags[i].innerHTML);
|
10
14
|
Pagy[args.shift()].apply(null, args);
|
@@ -13,19 +17,20 @@ Pagy.init = function(arg){
|
|
13
17
|
|
14
18
|
Pagy.nav = function(id, tags, sequels, param){
|
15
19
|
var pagyEl = document.getElementById(id),
|
16
|
-
container = pagyEl.parentElement,
|
17
20
|
lastWidth = undefined,
|
18
21
|
timeoutId = 0,
|
19
22
|
pageREg = new RegExp(/__pagy_page__/g),
|
20
|
-
widths = []
|
23
|
+
widths = [],
|
24
|
+
rendering = function(){ clearTimeout(timeoutId); timeoutId = setTimeout(pagyEl.render, 150) }; // suppress rapid firing rendering
|
25
|
+
|
21
26
|
for (var width in sequels) { widths.push(parseInt(width)) } // fine with sequels structure
|
22
27
|
widths.sort(function(a, b){return b-a});
|
23
28
|
|
24
|
-
|
25
|
-
if (
|
29
|
+
pagyEl.render = function(){
|
30
|
+
if (this.parentElement.clientWidth === 0) { rendering() }
|
26
31
|
var width, i, len;
|
27
32
|
for (i = 0, len = widths.length; i < len; i++) {
|
28
|
-
if (
|
33
|
+
if (this.parentElement.clientWidth > widths[i]) { width = widths[i]; break }
|
29
34
|
}
|
30
35
|
if (width !== lastWidth) {
|
31
36
|
var html = tags.before,
|
@@ -38,21 +43,19 @@ Pagy.nav = function(id, tags, sequels, param){
|
|
38
43
|
else if (typeof(item) === 'string') { html += tags.active.replace(pageREg, item) }
|
39
44
|
}
|
40
45
|
html += tags.after;
|
41
|
-
|
42
|
-
|
46
|
+
this.innerHTML = '';
|
47
|
+
this.insertAdjacentHTML('afterbegin', html);
|
43
48
|
lastWidth = width;
|
44
49
|
}
|
45
|
-
}
|
46
|
-
// suppress rapid firing rendering
|
47
|
-
rendering = function(){ clearTimeout(timeoutId); timeoutId = setTimeout(render, 150) };
|
50
|
+
}.bind(pagyEl);
|
48
51
|
|
49
52
|
if (widths.length > 1) {
|
50
53
|
// refresh the window resize listener (avoiding rendering multiple times)
|
51
|
-
window.removeEventListener('resize', Pagy.
|
54
|
+
window.removeEventListener('resize', Pagy.navResizeListeners[id], true); // needed for AJAX init
|
52
55
|
window.addEventListener('resize', rendering, true);
|
53
|
-
Pagy.
|
56
|
+
Pagy.navResizeListeners[id] = rendering;
|
54
57
|
}
|
55
|
-
render();
|
58
|
+
pagyEl.render();
|
56
59
|
};
|
57
60
|
|
58
61
|
Pagy.combo_nav = function(id, page, link, param){
|
@@ -86,8 +89,6 @@ Pagy.items_selector = function(id, from, link, param){
|
|
86
89
|
Pagy.addInputEventListeners(input, go);
|
87
90
|
};
|
88
91
|
|
89
|
-
Pagy.windowListeners = {};
|
90
|
-
|
91
92
|
Pagy.addInputEventListeners = function(input, handler){
|
92
93
|
// select the content on click: easier for typing a number
|
93
94
|
input.addEventListener('click', function(){ this.select() });
|
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: 3.3.
|
4
|
+
version: 3.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Agnostic pagination in plain ruby: it works with any framework, ORM
|
14
14
|
and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays,
|