effective_bootstrap 0.5.6 → 0.5.7

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
  SHA1:
3
- metadata.gz: fed9040bd034c8360e211400e6c028d53fa70fe2
4
- data.tar.gz: f3012062b2c332d41bed498ce439a9492bba2e7a
3
+ metadata.gz: cc2e1b351080ab147fc2d57106de0b7b3c9abd86
4
+ data.tar.gz: 74cb10a9820d2a4c92f5c3042926e64cf957142b
5
5
  SHA512:
6
- metadata.gz: ece6c140fdd1789e027d9a003190ae7cc48746bcf1b5f71c3dfcd562991109769f41889841109729914f3390dfc7b5c8a3cf8bdd26571618b7a2e94144c05000
7
- data.tar.gz: c0fd95a31e68baef499142c267eb92909b1dfdbb94991f4af230e7fe9b98ff7d4fb709aeed17d55b9f451c1e95216a087ccfce8975a0d1aba653d0e6087dffce
6
+ metadata.gz: df51a066ba5923efdff4ff59ab6a1248f3aa3b48eb591c89b75cf14238ac533fb90d0aa02b4f66c4a1e304d2c782333b0dbda0a0abdaa2e27afced7f6bcb59e3
7
+ data.tar.gz: 516b46f0c26202271e3c0d29fecebdbb290a181432bf5be06adb926207473b25deaf21f3b18859e51ec99cebee7753e89bac4a65f2f40038bf7ea3dfb6726072
data/README.md CHANGED
@@ -153,6 +153,12 @@ Add this to your view:
153
153
  %nav= paginate(@posts, per_page: 10)
154
154
  ```
155
155
 
156
+ or
157
+
158
+ ```haml
159
+ %nav.d-flex.justify-content-center= paginate(@posts, per_page: 10)
160
+ ```
161
+
156
162
  ### Tabs
157
163
 
158
164
  https://getbootstrap.com/docs/4.0/components/navs/#tabs
@@ -199,7 +199,9 @@ module EffectiveBootstrapHelper
199
199
  count = collection.limit(nil).offset(nil).count
200
200
 
201
201
  page = (params[:page] || 1).to_i
202
- pages = (count.to_f / per_page).ceil
202
+ last = (count.to_f / per_page).ceil
203
+
204
+ return unless last > 1 # If there's only 1 page, don't render a pagination at all.
203
205
 
204
206
  uri = URI(url || request.fullpath)
205
207
  params = Rack::Utils.parse_nested_query(uri.query)
@@ -210,12 +212,12 @@ module EffectiveBootstrapHelper
210
212
  link_to(url + params.merge('page' => page - 1).to_query, class: 'page-link', 'aria-label': 'Previous', title: 'Previous') do
211
213
  content_tag(:span, '«'.html_safe, 'aria-hidden': true) + content_tag(:span, 'Previous', class: 'sr-only')
212
214
  end
213
- end + (1..pages).map do |index|
215
+ end + (1..last).map do |index|
214
216
  content_tag(:li, class: ['page-item', ('active' if index == page)].compact.join(' '), title: "Page #{index}") do
215
217
  link_to(index, (url + params.merge('page' => index).to_query), class: 'page-link')
216
218
  end
217
219
  end.join.html_safe +
218
- content_tag(:li, class: ['page-item', ('disabled' if page >= pages)].compact.join(' ')) do
220
+ content_tag(:li, class: ['page-item', ('disabled' if page >= last)].compact.join(' ')) do
219
221
  link_to(url + params.merge('page' => page + 1).to_query, class: 'page-link', 'aria-label': 'Next', title: 'Next') do
220
222
  content_tag(:span, '»'.html_safe, 'aria-hidden': true) + content_tag(:span, 'Next', class: 'sr-only')
221
223
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.5.6'.freeze
2
+ VERSION = '0.5.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect