pagy 5.6.6 → 5.6.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39e1594de6e9b2ca3919cf666e3b7735c96656447d78c39ce0a4aaf85a737487
4
- data.tar.gz: ec8e032be1fe73b5890c1fc42c05d81c397015b468120a8cd97dcdd2bf88fcfa
3
+ metadata.gz: 0d1bf851d5e0ceba5250106974dc79d90346224bd25b149e28f78c307980ad90
4
+ data.tar.gz: fd0c607bf907c917b0aa637c08c7f773d0a403b6662738f59e23e0aa197f6f49
5
5
  SHA512:
6
- metadata.gz: 3df6ce4c03f578555b88c34691be3c667c1aaf2d4712382ebb1ddf905ad5f2f545987ce61270aa0a57705f1cfbe592ffbc649afb5c1137e8f69552388750e198
7
- data.tar.gz: c40c023541aaf714d0bfaa0fbaa4034edcb81d2d8b627a05f4e696d9eaa165f5f1aff7596497c9b4ccb9bf19773b65bb1aa79c7ba19765f3c993eab9e260e864
6
+ metadata.gz: 6b971d9c936a082e73dab19ceb624be6a041e1e8646a3d88d5742ddd93d2fa701669e7dae8ee13450397e4dcc9a2c921788c081aaa545fddb628e975bb669661
7
+ data.tar.gz: 4e2d4ccd5a85264e2b4b85319ccbac120139ea2f1cbadb6a4bb35740e44498027cc353c1aa9ea03f9a6adc6ece776353f879c85745b0c1941b5005b344592537
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (5.6.6)
3
+ # Pagy initializer file (5.6.7)
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
 
@@ -1,136 +1 @@
1
- // See the Pagy documentation: https://ddnexus.github.io/pagy/extras#javascript
2
-
3
- // This code should be OK also with very old browsers
4
-
5
- // Container for the whole pagy stuff
6
- function Pagy(){}
7
-
8
- Pagy.version = '5.6.6'
9
-
10
- // Used by the waitForMe function
11
- Pagy.delay = 100
12
-
13
- // Scan the target for data-pagy-json elements and apply their functions
14
- Pagy.init =
15
- function(arg) {
16
- var target = arg instanceof Event || arg === undefined ? document : arg,
17
- elements = target.querySelectorAll('[data-pagy-json]')
18
- for (var i = 0, len = elements.length; i < len; i++) {
19
- var args = JSON.parse(elements[i].getAttribute('data-pagy-json')),
20
- fname = args.shift()
21
- args.unshift(elements[i])
22
- Pagy[fname].apply(null, args)
23
- }
24
- }
25
-
26
- // Power the pagy*_nav_js helpers
27
- Pagy.nav =
28
- function(pagyEl, tags, sequels, label_sequels, trimParam ) {
29
- label_sequels = (label_sequels === null) ? sequels : label_sequels
30
- var widths = [], lastWidth,
31
- fill = function(string, item, label) { return string.replace(/__pagy_page__/g, item)
32
- .replace(/__pagy_label__/g, label) }
33
- for (var width in sequels) {
34
- if (sequels.hasOwnProperty(width)) { widths.push(parseInt(width, 10)) }
35
- }
36
- widths.sort(function(a, b) { return b - a })
37
-
38
- pagyEl.render =
39
- function() {
40
- var width, i, len
41
- for (i = 0, len = widths.length; i < len; i++) {
42
- if (this.parentElement.clientWidth > widths[i]) { width = widths[i]; break }
43
- }
44
- if (width !== lastWidth) {
45
- var html = tags.before,
46
- series = sequels[width],
47
- labels = label_sequels[width]
48
- for (i = 0, len = series.length; i < len; i++) {
49
- var item = series[i],
50
- label = labels[i]
51
- if (typeof(trimParam) === 'string' && item === 1) { html += Pagy.trim(fill(tags.link, item, label), trimParam) }
52
- else if (typeof(item) === 'number') { html += fill(tags.link, item, label) }
53
- else if (item === 'gap') { html += tags.gap }
54
- else if (typeof(item) === 'string') { html += fill(tags.active, item, label) }
55
- }
56
- html += tags.after
57
- this.innerHTML = ''
58
- this.insertAdjacentHTML('afterbegin', html)
59
- lastWidth = width
60
- }
61
- }.bind(pagyEl)
62
- pagyEl.render()
63
- }
64
-
65
- // Power the pagy*_combo_nav_js helpers
66
- Pagy.combo_nav =
67
- function(pagyEl, page, link, trimParam) {
68
- var input = pagyEl.getElementsByTagName('input')[0],
69
- toPage =
70
- function() {
71
- if (page !== input.value) {
72
- var html = link.replace(/__pagy_page__/, input.value)
73
- if (typeof (trimParam) === 'string' && input.value === '1') { html = Pagy.trim(html, trimParam) }
74
- pagyEl.insertAdjacentHTML('afterbegin', html)
75
- pagyEl.getElementsByTagName('a')[0].click()
76
- }
77
- }
78
- Pagy.addInputEventListeners(input, toPage)
79
- }
80
-
81
- // Power the pagy_items_selector_js helper
82
- Pagy.items_selector =
83
- function(pagyEl, from, link, param) {
84
- var input = pagyEl.getElementsByTagName('input')[0],
85
- current = input.value,
86
- toPage =
87
- function() {
88
- var items = input.value
89
- if (items === 0 || items === '') { return }
90
- if (current !== items) {
91
- var page = Math.max(Math.ceil(from / items), 1),
92
- html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, items)
93
- if (typeof (param) === 'string' && page === 1) { html = Pagy.trim(html, param) }
94
- pagyEl.insertAdjacentHTML('afterbegin', html)
95
- pagyEl.getElementsByTagName('a')[0].click()
96
- }
97
- }
98
- Pagy.addInputEventListeners(input, toPage)
99
- }
100
-
101
- // Utility for input fields
102
- Pagy.addInputEventListeners =
103
- function(input, toPage) {
104
- // select the content on click: easier for typing a number
105
- input.addEventListener('click', function() { this.select() })
106
- // toPage when the input looses focus
107
- input.addEventListener('focusout', toPage)
108
- // … and when pressing enter inside the input
109
- input.addEventListener('keyup', function(e) { if (e.which === 13) {toPage()} }.bind(this))
110
- }
111
-
112
- // Power the trim extra for js helpers
113
- Pagy.trim =
114
- function(html, param) {
115
- var re = new RegExp('[?&]' + param + '=1\\b(?!&)|\\b' + param + '=1&')
116
- return html.replace(re, '')
117
- }
118
-
119
- // Render all *nav_js helpers
120
- Pagy.renderNavs =
121
- function() {
122
- var navs = document.getElementsByClassName('pagy-njs') // 'pagy-njs' is common to all *nav_js helpers
123
- for (var i = 0, len = navs.length; i < len; i++) { navs[i].render() }
124
- }
125
-
126
- // Throttle to avoid to fire multiple time the renderNavs on resize
127
- Pagy.waitForMe =
128
- function() {
129
- if (typeof(Pagy.tid) === 'number') { clearTimeout(Pagy.tid) }
130
- Pagy.tid = setTimeout(Pagy.renderNavs, Pagy.delay)
131
- }
132
-
133
- // If there is a window object then add the event listener on resize
134
- if (typeof window !== 'undefined') {
135
- window.addEventListener('resize', Pagy.waitForMe, true)
136
- }
1
+ "use strict";function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}var Pagy={version:"5.6.7",init:function init(a){var b,c=a instanceof HTMLElement?a:document,d=c.querySelectorAll("[data-pagy-json]"),e=_createForOfIteratorHelper(d);try{for(e.s();!(b=e.n()).done;){var f=b.value,g=f.getAttribute("data-pagy-json");if(null!==g){var h=JSON.parse(g),i=h.shift();"nav"===i?Pagy.nav.apply(Pagy,[f].concat(_toConsumableArray(h))):"combo_nav"===i?Pagy.combo_nav.apply(Pagy,[f].concat(_toConsumableArray(h))):"items_selector"===i&&Pagy.items_selector.apply(Pagy,[f].concat(_toConsumableArray(h)))}}}catch(a){e.e(a)}finally{e.f()}},nav:function nav(a,b,c,d,e){var f={};if(null===d)for(var k in c)f[k]=c[k].map(function(a){return a.toString()});else f=d;var g,h=Object.getOwnPropertyNames(c).map(function(a){return parseInt(a)}).sort(function(c,a){return a-c}),j=function(a,b,c){return a.replace(/__pagy_page__/g,b).replace(/__pagy_label__/g,c)};a.pagyRender=function(){var a,d=0,k=_createForOfIteratorHelper(h);try{for(k.s();!(a=k.n()).done;){var q=a.value;if(null!==this.parentElement&&this.parentElement.clientWidth>q){d=q;break}}}catch(a){k.e(a)}finally{k.f()}if(d!==g){var l=b.before,m=c[d.toString()],n=f[d.toString()];for(var r in m){var o=m[r],p=n[r];if("string"==typeof e&&1===o){var i=j(b.link,o.toString(),p);l+=Pagy.trim(i,e)}else l+="number"==typeof o?j(b.link,o.toString(),p):"gap"===o?b.gap:j(b.active,o,p)}l+=b.after,this.innerHTML="",this.insertAdjacentHTML("afterbegin",l),g=d}}.bind(a),a.pagyRender(),"undefined"!=typeof window&&window.addEventListener("resize",Pagy.throttleRenderNavs,!0)},throttleRenderNavsTID:0,throttleRenderNavsDelay:100,throttleRenderNavs:function throttleRenderNavs(){clearTimeout(Pagy.throttleRenderNavsTID),Pagy.throttleRenderNavsTID=setTimeout(Pagy.renderNavs,Pagy.throttleRenderNavsDelay)},renderNavs:function renderNavs(){var a,b=document.getElementsByClassName("pagy-njs"),c=_createForOfIteratorHelper(b);try{for(c.s();!(a=c.n()).done;){var d=a.value;d.pagyRender()}}catch(a){c.e(a)}finally{c.f()}},combo_nav:function combo_nav(a,b,c,d){var e=a.getElementsByTagName("input")[0];Pagy.addInputBehavior(e,function goToPage(){if(b!==e.value){var f=c.replace(/__pagy_page__/,e.value);"string"==typeof d&&"1"===e.value&&(f=Pagy.trim(f,d)),a.insertAdjacentHTML("afterbegin",f),a.getElementsByTagName("a")[0].click()}})},trim:function trim(a,b){var c=new RegExp("[?&]".concat(b,"=1\\b(?!&)|\\b").concat(b,"=1&"));return a.replace(c,"")},items_selector:function items_selector(a,b,c,d){var e=a.getElementsByTagName("input")[0],f=e.value;Pagy.addInputBehavior(e,function goToPage(){var g=Math.max,h=Math.ceil,i=e.value;if("0"!==i&&""!==i&&f!==i){var j=g(h(b/parseInt(i)),1).toString(),k=c.replace(/__pagy_page__/,j).replace(/__pagy_items__/,i);"string"==typeof d&&"1"===j&&(k=Pagy.trim(k,d)),a.insertAdjacentHTML("afterbegin",k),a.getElementsByTagName("a")[0].click()}})},addInputBehavior:function addInputBehavior(a,b){a.addEventListener("click",function(){this.select()}),a.addEventListener("focusout",function(){b()}),a.addEventListener("keypress",function(a){"Enter"===a.key&&b()}.bind(this))}};
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # Core class
7
7
  class Pagy
8
- VERSION = '5.6.6'
8
+ VERSION = '5.6.7'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
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.6.6
4
+ version: 5.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Agnostic pagination in plain ruby. It does it all. Better.
14
14
  email:
@@ -111,6 +111,11 @@ licenses:
111
111
  - MIT
112
112
  metadata:
113
113
  rubygems_mfa_required: 'true'
114
+ homepage_uri: https://github.com/ddneus/pagy
115
+ documentation_uri: https://ddnexus.github.io/pagy
116
+ bug_tracker_uri: https://github.com/ddnexus/pagy/issues
117
+ changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
118
+ live_support: https://gitter.im/ruby-pagy/Lobby
114
119
  post_install_message:
115
120
  rdoc_options: []
116
121
  require_paths: