pagy 5.6.8 → 5.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +1 -1
- data/lib/javascripts/pagy.js.map +1 -1
- 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: 4a0769124a79924740926d3ad51cd5ef72e6f935a5b065045ce4f10e8e84ab67
|
4
|
+
data.tar.gz: a855520088ddd6b81fbeb76384c390bb5c886bd1d81cb3d23ff6b0dd8ac77153
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d2f70d1148feeaafa49c1e3ceb39b5e8891007215fc6197a0ea6dbf48f8a888edb6e2edc70a2c5fad9db36ca3b01a7527ff2c0941f53b6b9900156d40976a3b
|
7
|
+
data.tar.gz: 69fcd04e4eca0665a949f2cb8db57b2ad26d749c00e58ccfe75d18ab750b56acb84a18d7b5e95448390d1fdb11e16d9360971d6d93cab832adeea03e3b1e5f6e
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017-
|
3
|
+
Copyright (c) 2017-2022 Domizio Demichelis
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/lib/config/pagy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Pagy initializer file (5.6.
|
3
|
+
# Pagy initializer file (5.6.9)
|
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
|
|
data/lib/javascripts/pagy.js
CHANGED
@@ -1,3 +1,3 @@
|
|
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.
|
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.9",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 d=h.find(function(b){return null!==a.parentElement&&a.parentElement.clientWidth>b})||0;if(d!==g){var k=b.before,l=c[d.toString()],m=f[d.toString()];for(var p in l){var n=l[p],o=m[p];if("string"==typeof e&&1===n){var i=j(b.link,n.toString(),o);k+=Pagy.trim(i,e)}else k+="number"==typeof n?j(b.link,n.toString(),o):"gap"===n?b.gap:j(b.active,n,o)}k+=b.after,a.innerHTML="",a.insertAdjacentHTML("afterbegin",k),g=d}},a.pagyRender(),"undefined"!=typeof window&&window.addEventListener("resize",Pagy.throttleRenderNavs,!0)},throttleRenderNavsTID:0,throttleRenderNavsDelay:100,throttleRenderNavs:function throttleRenderNavs(){clearTimeout(Pagy.throttleRenderNavsTID),Pagy.throttleRenderNavsTID=window.setTimeout(Pagy.renderNavs,Pagy.throttleRenderNavsDelay)},renderNavs:function renderNavs(){var a=document.getElementsByClassName("pagy-njs");Array.from(a).forEach(function(a){return a.pagyRender()})},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()}})},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",a.select),a.addEventListener("focusout",b),a.addEventListener("keypress",function(a){"Enter"===a.key&&b()})},trim:function trim(a,b){var c=new RegExp("[?&]".concat(b,"=1\\b(?!&)|\\b").concat(b,"=1&"));return a.replace(c,"")}};
|
2
2
|
|
3
3
|
//# sourceMappingURL=pagy.js.map
|
data/lib/javascripts/pagy.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../ts/src/pagy.ts"],"names":[],"mappings":"mrDAkCA,GAAM,CAAA,IAAI,CAAG,CACT,OAAO,CAAE,OADA,CAIT,IAJS,eAIJ,CAJI,CAIM,OACL,CAA2B,CAAG,CAAG,WAAY,CAAA,WAAf,CAA6B,CAA7B,CAAmC,QAD5D,CAEL,CAAQ,CAAG,CAAM,CAAC,gBAAP,CAAwB,kBAAxB,CAFN,8BAGW,CAHX,MAGX,2BAAgC,IAArB,CAAA,CAAqB,SACtB,CAAI,CAAG,CAAO,CAAC,YAAR,CAAqB,gBAArB,CADe,CAE5B,GAAa,IAAT,GAAA,CAAJ,KAGI,CAAA,CAAI,CAAG,IAAI,CAAC,KAAL,CAAW,CAAX,CAHX,CAIM,CAAwC,CAAG,CAAI,CAAC,KAAL,EAJjD,CAKc,KAAV,GAAA,CALJ,CAMI,IAAI,CAAC,GAAL,OAAA,IAAI,EAAK,CAAL,4BAAsE,CAAtE,GANR,CAQmB,WAAV,GAAA,CART,CASI,IAAI,CAAC,SAAL,OAAA,IAAI,EAAW,CAAX,4BAAiD,CAAjD,GATR,CAWmB,gBAAV,GAAA,CAXT,EAYI,IAAI,CAAC,cAAL,OAAA,IAAI,EAAgB,CAAhB,4BAAsD,CAAtD,GAZR,CAcH,CAnBU,+BAoBd,CAxBQ,CA2BT,GA3BS,cA2BL,CA3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,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 ts`.\n\n// Add pagyRender to Element\ninterface Element {\n pagyRender():void;\n}\n\n// Add pagyRender to HTMLElement\ninterface HTMLElement {\n pagyRender():void;\n}\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|\"gap\")[];\n}\n\n// The Pagy object\nconst Pagy = {\n version: \"5.6.8\",\n\n // Scan for \"data-pagy-json\" elements, parse their JSON content and apply their functions\n init(arg?:any) {\n const target:Document|HTMLElement = 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\");\n if (json === null) {\n continue;\n }\n let args = JSON.parse(json);\n const fname:\"nav\"|\"combo_nav\"|\"items_selector\" = args.shift();\n if (fname === \"nav\") {\n Pagy.nav(element, ...<[NavTags, NavSequels, null|NavLabelSequels, string]>args);\n }\n else if (fname === \"combo_nav\") {\n Pagy.combo_nav(element, ...<[string, string, string]>args);\n }\n else if (fname === \"items_selector\") {\n Pagy.items_selector(element, ...<[number, string, string]>args);\n }\n }\n },\n\n // Power the *_nav_js helpers\n nav(pagyEl:Element, tags:NavTags, sequels:NavSequels, opt_label_sequels:null|NavLabelSequels, trimParam?:string) {\n let label_sequels:NavLabelSequels = {};\n // Handle null label_sequels\n if (opt_label_sequels === null) {\n for (const width in sequels) {\n label_sequels[width] = sequels[width].map((item) => item.toString());\n }\n }\n else {\n label_sequels = opt_label_sequels;\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 (this:Element) {\n let width:number = 0;\n for (const w of widths) {\n if (this.parentElement !== null && this.parentElement.clientWidth > w) {\n width = w;\n break;\n }\n }\n // Only if the width changed\n if (width !== lastWidth) {\n let html = tags.before;\n const series = sequels[width.toString()];\n const labels = label_sequels[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 }\n else if (typeof item === \"number\") {\n html += fillIn(tags.link, item.toString(), label);\n }\n else if (item === \"gap\") {\n html += tags.gap;\n }\n else { // active page\n html += fillIn(tags.active, item, label);\n }\n }\n html += tags.after;\n this.innerHTML = \"\";\n this.insertAdjacentHTML(\"afterbegin\", html);\n lastWidth = width;\n }\n }.bind(pagyEl);\n pagyEl.pagyRender();\n // If there is a window object then add a single \"resize\" event listener\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"resize\", Pagy.throttleRenderNavs, true);\n }\n },\n\n // throttleRenderNavs properties\n throttleRenderNavsTID: 0, // private\n throttleRenderNavsDelay: 100, // set a default delay\n\n // Avoid to fire the pagyRender multiple times\n throttleRenderNavs() {\n clearTimeout(Pagy.throttleRenderNavsTID);\n Pagy.throttleRenderNavsTID = window.setTimeout(Pagy.renderNavs, Pagy.throttleRenderNavsDelay);\n },\n\n // Render all *nav_js helpers (i.e. all the elements of class \"pagy-njs\")\n renderNavs() {\n const navs:HTMLCollectionOf<Element> = document.getElementsByClassName(\"pagy-njs\");\n for (const nav of navs) {\n nav.pagyRender();\n }\n },\n\n // Power the *_combo_nav_js helpers\n combo_nav(pagyEl:Element, page:string, link:string, trimParam?:string) {\n const input:HTMLInputElement = pagyEl.getElementsByTagName(\"input\")[0];\n const goToPage = function () {\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 Pagy.addInputBehavior(input, goToPage);\n },\n\n // Power the trim extra for js helpers\n trim(link:string, param:string):string {\n const re = new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`);\n return link.replace(re, \"\");\n },\n\n // Power the pagy_items_selector_js helper\n items_selector(pagyEl:Element, from:number, link:string, trimParam?:string) {\n const input:HTMLInputElement = pagyEl.getElementsByTagName(\"input\")[0];\n const current = input.value;\n const goToPage = function () {\n const items = input.value;\n if (items === \"0\" || items === \"\") {\n return;\n }\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 Pagy.addInputBehavior(input, goToPage);\n },\n\n // Add behavior to input fields\n addInputBehavior(input:HTMLInputElement, goToPage:Function) {\n // select the content on click: easier for direct typing\n input.addEventListener(\"click\", function (_e) {\n this.select();\n });\n // goToPage when the input loses focus\n input.addEventListener(\"focusout\", function (_e) {\n goToPage();\n });\n // goToPage when pressing enter while the input has focus\n input.addEventListener(\"keypress\", function (e:KeyboardEvent) {\n if (e.key === \"Enter\") {\n goToPage();\n }\n }.bind(this));\n }\n};\n"]}
|
1
|
+
{"version":3,"sources":["../../src/pagy.ts"],"names":[],"mappings":"mrDA6BA,GAAM,CAAA,IAAI,CAAG,CACT,OAAO,CAAE,OADA,CAIT,IAJS,eAIJ,CAJI,CAI6B,OA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AA5B,EAAiC,CAAjC,EAAoC,KAApC,EACH,CACJ,CACD,CACH,CApIQ,CAuIT,gBAvIS,2BAuIQ,CAvIR,CAuIgC,CAvIhC,CAuIqD,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,SAAC,CAAD,CAAqB,CACtC,OAAV,GAAA,CAAC,CAAC,GAD8C,EAEhD,CAAQ,EAEf,CAJD,CAKH,CAlJQ,CAqJT,IArJS,eAqJJ,CArJI,CAqJS,CArJT,CAqJ8B,CACnC,GAAM,CAAA,CAAE,CAAG,GAAI,CAAA,MAAJ,eAAkB,CAAlB,0BAAwC,CAAxC,QAAX,CACA,MAAO,CAAA,CAAI,CAAC,OAAL,CAAa,CAAb,CAAiB,EAAjB,CACV,CAxJQ,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// Add pagyRender to Element\ninterface Element {\n pagyRender():void;\n}\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|\"gap\")[];\n}\n\n// The Pagy object\nconst Pagy = {\n version: \"5.6.9\",\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\");\n if (json === null) {\n continue;\n }\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 [NavTags, NavSequels, null|NavLabelSequels, string]);\n } else if (fname === \"combo_nav\") {\n Pagy.combo_nav(element, ...args as [string, string, string]);\n } else if (fname === \"items_selector\") {\n Pagy.items_selector(element, ...args as [number, string, string]);\n }\n }\n },\n\n // Power the *_nav_js helpers\n nav(pagyEl:Element, tags:NavTags, sequels:NavSequels, opt_label_sequels:null|NavLabelSequels, trimParam?:string) {\n let label_sequels = {} as NavLabelSequels;\n // Handle null label_sequels\n if (opt_label_sequels === null) {\n for (const width in sequels) {\n label_sequels[width] = sequels[width].map((item) => item.toString());\n }\n } else {\n label_sequels = opt_label_sequels;\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 = () => {\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 = label_sequels[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 \"resize\" event listener\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"resize\", Pagy.throttleRenderNavs, true);\n }\n },\n\n // throttleRenderNavs properties\n throttleRenderNavsTID: 0, // private\n throttleRenderNavsDelay: 100, // set a default delay\n\n // Avoid to fire the pagyRender multiple times\n throttleRenderNavs() {\n clearTimeout(Pagy.throttleRenderNavsTID);\n Pagy.throttleRenderNavsTID = window.setTimeout(Pagy.renderNavs, Pagy.throttleRenderNavsDelay);\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 combo_nav(pagyEl:Element, page:string, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n const goToPage = () => {\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 Pagy.addInputBehavior(input, goToPage);\n },\n\n // Power the pagy_items_selector_js helper\n items_selector(pagyEl:Element, from:number, link:string, trimParam?:string) {\n const input = pagyEl.getElementsByTagName(\"input\")[0];\n const current = input.value;\n const goToPage = () => {\n const items = input.value;\n if (items === \"0\" || items === \"\") {\n return;\n }\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 Pagy.addInputBehavior(input, goToPage);\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:KeyboardEvent) => {\n if (e.key === \"Enter\") {\n goToPage();\n }\n });\n },\n\n // Power the trim extra for js helpers\n trim(link:string, param:string):string {\n const re = new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`);\n return link.replace(re, \"\");\n }\n};\n"]}
|
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.6.
|
4
|
+
version: 5.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
14
|
email:
|