pagy 2.1.3 → 2.1.4

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: 52910775222a48757dc11693abdddf545286075c466c1df557cb37cf14374099
4
- data.tar.gz: 61c3495ce8cebbd44f9bf77e9ccb722aec0967523909b5543754561318cebf42
3
+ metadata.gz: e12b109cdfa036177939e12f0252a8f80d8ff7212dda373285cbc617dd560354
4
+ data.tar.gz: 43678554d764fa960ebae93ceee27adda79b35b304c4c6d90b1f2ac9e03406bb
5
5
  SHA512:
6
- metadata.gz: 3c521f55be0d8177cfd4b3c7235b2f79ebd888033f0018fa4031f59e731340560ea744b2a952203256cce7e0c8cff40a3b4c6279840a3dad3ff5c18696bcfeec
7
- data.tar.gz: e8c836e90b051c9330c1771e1b31bc82ca40e672bb379e89d6c58d8953429b8818e1f08f2704ce5cb8fc94a3468631a0a0c8d83bdc0de284775bfa5c8c427e06
6
+ metadata.gz: 750e5d774204787364b1e8a658c721e4a3a19349f50c06e6764fdb436550513128b5ab22f438a01c46576476f404b0953188c42345dc0c898ce025217acd76aa
7
+ data.tar.gz: 16f9efe431559d358efe7532c896dafeedac33b468b18259f72a430258892d13cf313d864bd2a2bb38585b6eb2782d5655b05c67403b41e0e1475235adf3cf59
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Pagy initializer file (v2.1.3)
4
+ # Pagy initializer file (v2.1.4)
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
 
@@ -60,8 +60,8 @@
60
60
 
61
61
  # Breakpoints var used by the responsive nav helpers
62
62
  # See https://ddnexus.github.io/pagy/extras/plain#breakpoints
63
- # width/size pairs: example for bootstrap4 sm-md-lg internal container widths
64
- # Pagy::VARS[:breakpoints] = { 0 => [1,0,0,1], 540 => [2,3,3,2], 720 => [3,4,4,3] }
63
+ # Pagy::VARS[:breakpoints] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] }
64
+
65
65
 
66
66
  # Feature Extras
67
67
 
@@ -53,27 +53,29 @@ Pagy.responsive = function(id, tags, widths, series){
53
53
  var pagyEl = document.getElementById(id),
54
54
  container = pagyEl.parentElement,
55
55
  lastWidth = undefined,
56
- resizeId = 0,
56
+ timeoutId = 0,
57
57
  render = function(){
58
- if (container.clientWidth === 0){ clearTimeout(resizeId); return setTimeout(render, 300) }
59
- var width = widths.find(function(w) {return container.clientWidth > w});
58
+ if (container.clientWidth === 0) { rendering() }
59
+ var width, i, len;
60
+ for (i = 0, len = widths.length; i < len; i++) {
61
+ if (container.clientWidth > widths[i]) { width = widths[i]; break }
62
+ }
60
63
  if (width !== lastWidth) {
61
64
  while (pagyEl.firstChild) { pagyEl.removeChild(pagyEl.firstChild) }
62
- var html = tags['before'];
63
- series[width].forEach(function(item) {html += tags[item]});
65
+ var html = tags['before'],
66
+ items = series[width];
67
+ for (i = 0, len = items.length; i < len; i++) { html += tags[items[i]] }
64
68
  html += tags['after'];
65
69
  pagyEl.insertAdjacentHTML('beforeend', html);
66
70
  lastWidth = width;
67
71
  }
68
72
  },
69
- resize = function(){ // call render once, after window.resize is done
70
- clearTimeout(resizeId);
71
- resizeId = setTimeout(render, 300);
72
- };
73
- // remove the previous window resize listener which may result in firing the render multiple times
73
+ // suppress rapid firing rendering
74
+ rendering = function(){ clearTimeout(timeoutId); timeoutId = setTimeout(render, 150) };
75
+ // refresh the window resize listener (avoiding rendering multiple times)
74
76
  window.removeEventListener('resize', Pagy.windowListeners[id], true);
75
- window.addEventListener('resize', resize, true);
76
- Pagy.windowListeners[id] = resize;
77
+ window.addEventListener('resize', rendering, true);
78
+ Pagy.windowListeners[id] = rendering;
77
79
  render();
78
80
  };
79
81
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- class Pagy ; VERSION = '2.1.3'
7
+ class Pagy ; VERSION = '2.1.4'
8
8
 
9
9
  class OverflowError < StandardError; attr_reader :pagy; def initialize(pagy) @pagy = pagy end; end
10
10
 
@@ -14,9 +14,9 @@ class Pagy
14
14
  # Pagy.new count:1000, page: 20, breakpoints: {0 => [1,2,2,1], 350 => [2,3,3,2], 550 => [3,4,4,3]}
15
15
  # it returns something like:
16
16
  # { :items => [1, :gap, 18, 19, "20", 21, 22, 50, 2, 17, 23, 49, 3, 16, 24, 48],
17
- # :series => { 0 =>[1, :gap, 18, 19, "20", 21, 22, :gap, 50],
18
- # 350 =>[1, 2, :gap, 17, 18, 19, "20", 21, 22, 23, :gap, 49, 50],
19
- # 550 =>[1, 2, 3, :gap, 16, 17, 18, 19, "20", 21, 22, 23, 24, :gap, 48, 49, 50] },
17
+ # :series => { 0 => [1, :gap, 18, 19, "20", 21, 22, :gap, 50],
18
+ # 350 => [1, 2, :gap, 17, 18, 19, "20", 21, 22, 23, :gap, 49, 50],
19
+ # 550 => [1, 2, 3, :gap, 16, 17, 18, 19, "20", 21, 22, 23, 24, :gap, 48, 49, 50] },
20
20
  # :widths => [550, 350, 0] }
21
21
  # where :items is the unordered array union of all the page numbers for all sizes (passed to the PagyResponsive javascript function)
22
22
  # :series is the hash of the series keyed by width (used by the *_responsive helpers to create the JSON string)
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: 2.1.3
4
+ version: 2.1.4
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-03-20 00:00:00.000000000 Z
11
+ date: 2019-03-25 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,