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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 310b22b4b98f5b94dbad6ebc49f538d918f66ebf
4
- data.tar.gz: 563ec32d329e77171b036ee814c9e6caad0ced38
3
+ metadata.gz: 97092fa165322a627f18dec8619f08d6b3df8a64
4
+ data.tar.gz: 312fbd81cff5eac79ef99ed7716051d87b308e2e
5
5
  SHA512:
6
- metadata.gz: 4adc24aa55ad5e945cb2c83981d4b728055f337172eb3c955eaa3fac66b76e29b8dd0635955a206ab6667b7e4e245d86f5a1b58c3b6fe282187bb012406c7625
7
- data.tar.gz: 21225cfd957e5b6e21cb3c2a259ed8451844c51fde50da02c10b75c7a18bc739c5d8da96cc957106af55a75de0a63ae34d45d27336a8464c42b1133eaea7b311
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" page="{{ params._page }}" />
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: ```params._page```): the number of the current page (starting with 1)
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.3
1
+ 0.0.4
@@ -63,7 +63,7 @@ module Pagination
63
63
  end
64
64
 
65
65
  def current_page
66
- (attrs.page || params._page).or(1).to_i
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 next_page
81
+ def next_page_url
82
82
  new_page = current_page + 1
83
83
  if new_page <= total_pages
84
- set_page(new_page)
84
+ return ''
85
85
  end
86
+
87
+ return url_for_page(new_page)
86
88
  end
87
89
 
88
- def previous_page
90
+ def previous_page_url
89
91
  new_page = current_page - 1
90
92
  if new_page >= 1
91
- set_page(new_page)
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
- if attrs.respond_to?(:page=)
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 e-click="previous_page">&laquo;</a>
4
+ <a href="url_for_page(previous_page_number)">&laquo;</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 e-click="set_page(page_number)">{{ page_number }}</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.3
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-07 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: volt