pagy 3.3.1 → 3.3.2

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: 5e120aa3e069608ec73236cf7814a9b1e1292afd8b20e00208cfd2412e9422f1
4
- data.tar.gz: fe66d484cc2a926ee36d9b50892f92c3c0437c9fecb74dc3020dc902e2cd1618
3
+ metadata.gz: 10ba8b6d06ab5a7b5a8200742565f8193484e664eaecd342102ff001a03c9dd5
4
+ data.tar.gz: 273c70974fafb3b8c01392254ba45a86af6654a2442229afb403ec29407b76ad
5
5
  SHA512:
6
- metadata.gz: a519633530e20b2213c8bb8f3b90fd4ed77d64f67057eafdd22620239500de1e2417d9e6a146204b27eab199f0a7c53d58e1e177a72beb5758704b9a12c0076e
7
- data.tar.gz: 5c99aed2660d0fcd7a43128d524f53655b6a35be55baaf765ba2bffbaed8f7b840e4a0a16f350ebb7a49ab80434d64362fc90b563078bcb048b39ea8095090e4
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.1)
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
 
@@ -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
- var render = function(){
25
- if (container.clientWidth === 0) { rendering() }
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 (container.clientWidth > widths[i]) { width = widths[i]; break }
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
- pagyEl.innerHTML = '';
42
- pagyEl.insertAdjacentHTML('afterbegin', html);
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.windowListeners[id], true);
54
+ window.removeEventListener('resize', Pagy.navResizeListeners[id], true); // needed for AJAX init
52
55
  window.addEventListener('resize', rendering, true);
53
- Pagy.windowListeners[id] = rendering;
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
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- class Pagy ; VERSION = '3.3.1'
7
+ class Pagy ; VERSION = '3.3.2'
8
8
 
9
9
  # Root pathname to get the path of Pagy files like templates or dictionaries
10
10
  def self.root; @root ||= Pathname.new(__FILE__).dirname.freeze end
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.1
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-02 00:00:00.000000000 Z
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,