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 +4 -4
- data/README.md +6 -0
- data/app/helpers/effective_bootstrap_helper.rb +5 -3
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc2e1b351080ab147fc2d57106de0b7b3c9abd86
|
4
|
+
data.tar.gz: 74cb10a9820d2a4c92f5c3042926e64cf957142b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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..
|
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 >=
|
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
|