volt-pagination 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/pagination/controllers/main_controller.rb +18 -10
- data/app/pagination/views/main/index.html +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97092fa165322a627f18dec8619f08d6b3df8a64
|
4
|
+
data.tar.gz: 312fbd81cff5eac79ef99ed7716051d87b308e2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a84a600e3b0e1a7d83785ed5be43e00dc09e9dab0d550f3d867d969524f23c60e00a403acb60aefb107e924b9b273287ec537fbf16c537dbea01798fc6c314e
|
7
|
+
data.tar.gz: 7f4e5e7dc9454d800cb696ff34d1077ccc086dd7b3571b3bdc549e1762331d41614c0d5fae7d5e42537d59e994eca8e6e2ef2952c852d1bc461781a71ec4fa66
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ Assuming a page size of 10:
|
|
26
26
|
Then in your view you can add:
|
27
27
|
|
28
28
|
```html
|
29
|
-
<:pagination total="{{ store._items.size }}" per_page="10"
|
29
|
+
<:pagination total="{{ store._items.size }}" per_page="10" />
|
30
30
|
```
|
31
31
|
|
32
32
|
```per_page``` defaults to 10 and ```page``` defaults to params._page
|
@@ -35,6 +35,6 @@ The pagination tag supports the following options:
|
|
35
35
|
|
36
36
|
- total (required): the total number of items.
|
37
37
|
- per_page (default: 10): how many items per page.
|
38
|
-
- page (default: ```
|
38
|
+
- page-param-name (default: ```page```): the name of the page attribute stored in params (starting with 1)
|
39
39
|
- window (default: 5): the number of pages to show around the current page
|
40
40
|
- outer_window: (default: 1): the number of pages to show at the start and end of the pager.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -63,7 +63,7 @@ module Pagination
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def current_page
|
66
|
-
|
66
|
+
params.send(:"_#{page_param_name}").or(1).to_i
|
67
67
|
end
|
68
68
|
|
69
69
|
def total_pages
|
@@ -78,27 +78,35 @@ module Pagination
|
|
78
78
|
current_page == 1
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
81
|
+
def next_page_url
|
82
82
|
new_page = current_page + 1
|
83
83
|
if new_page <= total_pages
|
84
|
-
|
84
|
+
return ''
|
85
85
|
end
|
86
|
+
|
87
|
+
return url_for_page(new_page)
|
86
88
|
end
|
87
89
|
|
88
|
-
def
|
90
|
+
def previous_page_url
|
89
91
|
new_page = current_page - 1
|
90
92
|
if new_page >= 1
|
91
|
-
|
93
|
+
return ''
|
92
94
|
end
|
95
|
+
|
96
|
+
return url_for_page(new_page)
|
97
|
+
end
|
98
|
+
|
99
|
+
def page_param_name
|
100
|
+
attrs.page_param_name || :page
|
101
|
+
end
|
102
|
+
|
103
|
+
def url_for_page(page_number)
|
104
|
+
url_with({page_param_name => page_number})
|
93
105
|
end
|
94
106
|
|
95
107
|
def set_page(page_number)
|
96
108
|
page_number = page_number.to_i
|
97
|
-
|
98
|
-
attrs.page = page_number
|
99
|
-
else
|
100
|
-
params._page = page_number
|
101
|
-
end
|
109
|
+
params.send(:"_#{page_param_name}=", page_number)
|
102
110
|
end
|
103
111
|
end
|
104
112
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
<:Body>
|
2
2
|
<ul class="pagination">
|
3
3
|
<li class="{{ if first_page }}disabled{{ end }}">
|
4
|
-
<a
|
4
|
+
<a href="url_for_page(previous_page_number)">«</a>
|
5
5
|
</li>
|
6
6
|
{{ page_numbers.each do |page_number| }}
|
7
7
|
{{ if page_number.nil? }}
|
8
8
|
<li><a>...</a></li>
|
9
9
|
{{ else }}
|
10
10
|
<li class="{{ if current_page == page_number }}active{{ end }}">
|
11
|
-
<a
|
11
|
+
<a href="{{ url_for_page(page_number) }}">{{ page_number }}</a>
|
12
12
|
</li>
|
13
13
|
{{ end }}
|
14
14
|
{{ end }}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt-pagination
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: volt
|