pagy 8.0.1 → 8.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{gem/apps → apps}/calendar.ru +1 -1
- data/{gem/apps → apps}/demo.ru +1 -1
- data/{gem/apps → apps}/rails.ru +10 -10
- data/{gem/apps → apps}/repro.ru +1 -1
- data/{gem/bin → bin}/pagy +1 -1
- data/{gem/config → config}/pagy.rb +9 -9
- data/javascripts/pagy-dev.js +114 -0
- data/{gem/javascripts → javascripts}/pagy-module.js +4 -2
- data/javascripts/pagy.js +1 -0
- data/{gem/lib → lib}/pagy/calendar/day.rb +1 -1
- data/{gem/lib → lib}/pagy/calendar/month.rb +1 -1
- data/{gem/lib → lib}/pagy/calendar/quarter.rb +1 -1
- data/{gem/lib → lib}/pagy/calendar/week.rb +1 -1
- data/{gem/lib → lib}/pagy/calendar/year.rb +1 -1
- data/{gem/lib → lib}/pagy/calendar.rb +4 -4
- data/{gem/lib → lib}/pagy/console.rb +2 -2
- data/{gem/lib → lib}/pagy/countless.rb +10 -7
- data/{gem/lib → lib}/pagy/extras/bootstrap.rb +2 -2
- data/{gem/lib → lib}/pagy/extras/bulma.rb +3 -2
- data/{gem/lib → lib}/pagy/extras/calendar.rb +2 -2
- data/{gem/lib → lib}/pagy/extras/countless.rb +1 -1
- data/{gem/lib → lib}/pagy/extras/foundation.rb +2 -2
- data/lib/pagy/extras/gearbox.rb +55 -0
- data/{gem/lib → lib}/pagy/extras/headers.rb +1 -1
- data/{gem/lib → lib}/pagy/extras/items.rb +2 -2
- data/{gem/lib → lib}/pagy/extras/js_tools.rb +3 -0
- data/{gem/lib → lib}/pagy/extras/jsonapi.rb +1 -1
- data/{gem/lib → lib}/pagy/extras/materialize.rb +3 -2
- data/{gem/lib → lib}/pagy/extras/metadata.rb +1 -1
- data/{gem/lib → lib}/pagy/extras/pagy.rb +2 -2
- data/{gem/lib → lib}/pagy/extras/semantic.rb +3 -2
- data/{gem/lib → lib}/pagy/extras/standalone.rb +2 -2
- data/{gem/lib → lib}/pagy/extras/uikit.rb +2 -2
- data/{gem/lib → lib}/pagy/frontend.rb +2 -2
- data/{gem/lib → lib}/pagy/url_helpers.rb +8 -8
- data/{gem/lib → lib}/pagy.rb +26 -28
- data/{gem/locales → locales}/ru.yml +5 -7
- metadata +93 -93
- data/gem/javascripts/pagy-dev.js +0 -112
- data/gem/javascripts/pagy.js +0 -1
- data/gem/lib/pagy/extras/gearbox.rb +0 -54
- /data/{gem/javascripts → javascripts}/pagy-module.d.ts +0 -0
- /data/{gem/lib → lib}/optimist.rb +0 -0
- /data/{gem/lib → lib}/pagy/backend.rb +0 -0
- /data/{gem/lib → lib}/pagy/calendar/helper.rb +0 -0
- /data/{gem/lib → lib}/pagy/exceptions.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/arel.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/array.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/elasticsearch_rails.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/i18n.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/meilisearch.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/overflow.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/searchkick.rb +0 -0
- /data/{gem/lib → lib}/pagy/extras/trim.rb +0 -0
- /data/{gem/lib → lib}/pagy/i18n.rb +0 -0
- /data/{gem/locales → locales}/ar.yml +0 -0
- /data/{gem/locales → locales}/be.yml +0 -0
- /data/{gem/locales → locales}/bg.yml +0 -0
- /data/{gem/locales → locales}/bs.yml +0 -0
- /data/{gem/locales → locales}/ca.yml +0 -0
- /data/{gem/locales → locales}/ckb.yml +0 -0
- /data/{gem/locales → locales}/cs.yml +0 -0
- /data/{gem/locales → locales}/da.yml +0 -0
- /data/{gem/locales → locales}/de.yml +0 -0
- /data/{gem/locales → locales}/en.yml +0 -0
- /data/{gem/locales → locales}/es.yml +0 -0
- /data/{gem/locales → locales}/fr.yml +0 -0
- /data/{gem/locales → locales}/hr.yml +0 -0
- /data/{gem/locales → locales}/id.yml +0 -0
- /data/{gem/locales → locales}/it.yml +0 -0
- /data/{gem/locales → locales}/ja.yml +0 -0
- /data/{gem/locales → locales}/km.yml +0 -0
- /data/{gem/locales → locales}/ko.yml +0 -0
- /data/{gem/locales → locales}/nb.yml +0 -0
- /data/{gem/locales → locales}/nl.yml +0 -0
- /data/{gem/locales → locales}/nn.yml +0 -0
- /data/{gem/locales → locales}/pl.yml +0 -0
- /data/{gem/locales → locales}/pt-BR.yml +0 -0
- /data/{gem/locales → locales}/pt.yml +0 -0
- /data/{gem/locales → locales}/sr.yml +0 -0
- /data/{gem/locales → locales}/sv-SE.yml +0 -0
- /data/{gem/locales → locales}/sv.yml +0 -0
- /data/{gem/locales → locales}/sw.yml +0 -0
- /data/{gem/locales → locales}/ta.yml +0 -0
- /data/{gem/locales → locales}/tr.yml +0 -0
- /data/{gem/locales → locales}/uk.yml +0 -0
- /data/{gem/locales → locales}/vi.yml +0 -0
- /data/{gem/locales → locales}/zh-CN.yml +0 -0
- /data/{gem/locales → locales}/zh-HK.yml +0 -0
- /data/{gem/locales → locales}/zh-TW.yml +0 -0
- /data/{gem/stylesheets → stylesheets}/pagy.css +0 -0
- /data/{gem/stylesheets → stylesheets}/pagy.scss +0 -0
- /data/{gem/stylesheets → stylesheets}/pagy.tailwind.css +0 -0
@@ -1,54 +0,0 @@
|
|
1
|
-
# See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/gearbox
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
class Pagy # :nodoc:
|
5
|
-
DEFAULT[:gearbox_extra] = true # extra enabled by default
|
6
|
-
DEFAULT[:gearbox_items] = [15, 30, 60, 100]
|
7
|
-
|
8
|
-
# Automatically change the number of items per page depending on the page number
|
9
|
-
# accepts an array as the :gearbox_items variable, that will determine the items for the first pages
|
10
|
-
module GearboxExtra
|
11
|
-
# Setup @items based on the :gearbox_items variable
|
12
|
-
def setup_items_var
|
13
|
-
return super if !@vars[:gearbox_extra] || @vars[:items_extra]
|
14
|
-
|
15
|
-
gearbox_items = @vars[:gearbox_items]
|
16
|
-
raise VariableError.new(self, :gearbox_items, 'to be an Array of positives', gearbox_items) \
|
17
|
-
unless gearbox_items.is_a?(Array) && gearbox_items.all? { |num| num.positive? rescue false } # rubocop:disable Style/RescueModifier
|
18
|
-
|
19
|
-
@items = gearbox_items[@page - 1] || gearbox_items.last
|
20
|
-
end
|
21
|
-
|
22
|
-
# Setup @pages and @last based on the :gearbox_items variable (not used by Pagy::Countless)
|
23
|
-
def setup_pages_var
|
24
|
-
return super if !@vars[:gearbox_extra] || @vars[:items_extra]
|
25
|
-
|
26
|
-
gearbox_items = @vars[:gearbox_items]
|
27
|
-
# This algorithm is thousands of times faster than the one in the geared_pagination gem
|
28
|
-
@pages = @last = (if @count > (sum = gearbox_items.sum)
|
29
|
-
[((@count - sum).to_f / gearbox_items.last).ceil, 1].max + gearbox_items.count
|
30
|
-
else
|
31
|
-
pages = 0
|
32
|
-
remainder = @count
|
33
|
-
while remainder.positive?
|
34
|
-
pages += 1
|
35
|
-
remainder -= gearbox_items[pages - 1]
|
36
|
-
end
|
37
|
-
[pages, 1].max
|
38
|
-
end)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Setup @offset based on the :gearbox_items variable
|
42
|
-
def setup_offset_var
|
43
|
-
return super if !@vars[:gearbox_extra] || @vars[:items_extra]
|
44
|
-
|
45
|
-
gearbox_items = @vars[:gearbox_items]
|
46
|
-
@offset = if @page <= gearbox_items.count
|
47
|
-
gearbox_items[0, @page - 1].sum
|
48
|
-
else
|
49
|
-
gearbox_items.sum + (gearbox_items.last * (@page - gearbox_items.count - 1))
|
50
|
-
end + @outset
|
51
|
-
end
|
52
|
-
end
|
53
|
-
prepend GearboxExtra
|
54
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|