alphabetical_paginate 1.6.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -1
- data/lib/alphabetical_paginate/array.rb +1 -1
- data/lib/alphabetical_paginate/controller_helper.rb +2 -1
- data/lib/alphabetical_paginate/version.rb +1 -1
- data/lib/alphabetical_paginate/view_helpers.rb +5 -4
- data/vendor/assets/javascripts/alphabetical_paginate.js +25 -17
- metadata +2 -2
data/README.md
CHANGED
@@ -8,7 +8,7 @@ AlphabeticalPaginate incorporates efficient javascript partial page rerendering
|
|
8
8
|
|
9
9
|
It has two modes - if you're working with MySQL, it allows for low level database regex queries. Otherwise, it uses a buffered search to build an array. You should be able to easily modify the gem to work with other SQL databases (please make a pull-request if you do!).
|
10
10
|
|
11
|
-
We also now have Russian language support.
|
11
|
+
We also now have Russian language support and Bootstrap 3 support.
|
12
12
|
|
13
13
|
Some code was inspired by [will_paginate](https://github.com/mislav/will_paginate).
|
14
14
|
|
@@ -111,6 +111,7 @@ Key | Value | Default |Description
|
|
111
111
|
`:pagination_class` | `String` | `"pagination-centered"` | All the classes you would like to add to the rendered pagination selector div (for CSS purposes).
|
112
112
|
`:js` | `Boolean` | `"true"` | If you want the javascript with page-rerendering to be enabled.
|
113
113
|
`:support_language` | `Symbol` | `:en` | If you want russian letters support set this value to `:ru` (only if `I18n.locale` in your application set to `:ru`).
|
114
|
+
`:bootstrap3` | `Boolean` | `false` | If you want to enable bootstrap 3 support
|
114
115
|
|
115
116
|
## Advanced Pagination
|
116
117
|
|
@@ -3,7 +3,7 @@ class Array
|
|
3
3
|
def alpha_paginate current_field, params = {enumerate:false, default_field: "a",
|
4
4
|
paginate_all: false, numbers: true, include_all: true,
|
5
5
|
others: true, pagination_class: "pagination-centered",
|
6
|
-
js: true, support_language: :en}
|
6
|
+
js: true, support_language: :en, bootstrap3: false}
|
7
7
|
params[:paginate_all] ||= false
|
8
8
|
params[:support_language] ||= :en
|
9
9
|
params[:language] = AlphabeticalPaginate::Language.new(params[:support_language])
|
@@ -9,7 +9,8 @@ module AlphabeticalPaginate
|
|
9
9
|
others: true, pagination_class: "pagination-centered",
|
10
10
|
batch_size: 500, db_mode: false,
|
11
11
|
db_field: "id", include_all: true,
|
12
|
-
js: true, support_language: :en
|
12
|
+
js: true, support_language: :en,
|
13
|
+
bootstrap3: false}
|
13
14
|
params[:paginate_all] ||= false
|
14
15
|
params[:support_language] ||= :en
|
15
16
|
params[:language] = AlphabeticalPaginate::Language.new(params[:support_language])
|
@@ -46,15 +46,16 @@ module AlphabeticalPaginate
|
|
46
46
|
end
|
47
47
|
|
48
48
|
|
49
|
+
element = params[:bootstrap3] ? 'ul' : 'div'
|
49
50
|
if params[:pagination_class] != "none"
|
50
|
-
pagination = '
|
51
|
+
pagination = '<#{element} class="pagination %s alpha" style="height:35px;">' % params[:pagination_class]
|
51
52
|
else
|
52
|
-
pagination = '
|
53
|
+
pagination = '<#{element} class="pagination alpha" style="height:35px;">'
|
53
54
|
end
|
54
55
|
pagination +=
|
55
|
-
"<ul>" +
|
56
|
+
params[:bootstrap3] ? "" : "<ul>" +
|
56
57
|
links +
|
57
|
-
"</ul>" +
|
58
|
+
params[:bootstrap3] ? "" : "</ul>" +
|
58
59
|
"</div>"
|
59
60
|
|
60
61
|
output += pagination
|
@@ -5,30 +5,38 @@ $(function() {
|
|
5
5
|
// RAILS 3.0 USERS -> Please delete the above line and uncomment the bottom line
|
6
6
|
//var img = "<img src='/images/aloader.gif' class='loading'/>";
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
|
9
|
+
var navbar = $(".pagination.alpha a");
|
10
|
+
// Pick the handler list: just a quick check for the jQuery version (see here: http://bugs.jquery.com/ticket/10589)
|
11
|
+
var handlers = navbar.data ? navbar.data('events').click : jQuery._data(navbar[0], 'events').click;
|
12
|
+
|
13
|
+
if (-1 !== $.inArray(onNavbarClick, handlers)) {
|
14
|
+
$(document).on("click", ".pagination.alpha a", onNavbarClick);
|
15
|
+
}
|
16
|
+
|
17
|
+
function onNavbarClick(e) {
|
18
|
+
e.preventDefault();
|
19
|
+
var url = location.href,
|
20
|
+
letter = $(this).data("letter");
|
21
|
+
if (/letter/.test(url)) {
|
22
|
+
url = url.replace(/letter=[^&]*/, "letter=" + letter);
|
23
|
+
}
|
14
24
|
else {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
if (/\?/.test(url)) {
|
26
|
+
url += "&letter=" + letter;
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
url += "?letter=" + letter;
|
30
|
+
}
|
21
31
|
}
|
22
32
|
$(".pagination").html(img);
|
23
33
|
//$.load(url + " #pagination_table");
|
24
34
|
$.get(url, function(result) {
|
25
|
-
|
26
|
-
|
35
|
+
$(".pagination").html($(".pagination", result));
|
36
|
+
$("#pagination_table").html($("#pagination_table", result));
|
27
37
|
});
|
28
38
|
history.pushState(null, document.title, url);
|
29
|
-
|
30
|
-
});
|
31
|
-
|
39
|
+
}
|
32
40
|
|
33
41
|
// let navigate the browser throught the ajax history
|
34
42
|
$(window).bind("popstate", function() {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alphabetical_paginate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|