alphabetical_paginate 0.2.16 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module AlphabeticalPaginate
2
- VERSION = "0.2.16"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -41,14 +41,14 @@ module AlphabeticalPaginate
41
41
 
42
42
 
43
43
  if params[:pagination_class] != "none"
44
- pagination = '<div class="pagination %s">' % params[:pagination_class]
44
+ pagination = '<div class="pagination %s" id="alpha" style="height:35px;">' % params[:pagination_class]
45
45
  else
46
- pagination = '<div class="pagination">'
46
+ pagination = '<div class="pagination" id="alpha" style="height:35px;">'
47
47
  end
48
48
  pagination +=
49
49
  "<ul>" +
50
50
  links +
51
- "</ul" +
51
+ "</ul>" +
52
52
  "</div>"
53
53
 
54
54
  output += pagination.html_safe
@@ -1,18 +1,45 @@
1
1
  $(function() {
2
- var img = "<img src='/images/loader.gif' class='loading'/>"
3
- var text = "<span class='loading'>Page is loading...</span>"
2
+ var once = false;
4
3
 
5
- $(".pagination a").live("click", function(e) {
6
- //jQuery.setFragment({ "page" : jQuery.queryString(this.href).page })
7
- jQuery.getScript(this.href);
8
- jQuery(".pagination").html(text+img);
9
- history.pushState(null, document.title, this.href);
4
+ var img = "<img src='/images/loader.gif' class='loading'/>"
5
+
6
+ $(document).on("click", ".pagination#alpha a", function(e) {
7
+ var url = location.href,
8
+ letter = $(this).data("letter");
9
+ if (/letter/.test(url)){
10
+ url = url.replace(/letter=?./,"letter=" + letter);
11
+ }
12
+ else {
13
+ if (/\?/.test(url)) {
14
+ url += "&letter=" + letter
15
+ }
16
+ else {
17
+ url += "?letter=" + letter
18
+ }
19
+ }
20
+ $(".pagination").html(img);
21
+ //$.load(url + " #pagination_table");
22
+ $.get(url, function(result) {
23
+ $(".pagination").html($(".pagination", result));
24
+ $("#pagination_table").html($("#pagination_table", result));
25
+ });
26
+ history.pushState(null, document.title, url);
10
27
  e.preventDefault();
11
28
  });
12
29
 
13
- $(window).bind("popstate", function() {
14
- $.getScript(location.href);
15
- $(".pagination").html(text+img);
16
- });
30
+
31
+ // let navigate the browser throught the ajax history
32
+ $(window).bind("popstate", function() {
33
+ if (once) {
34
+ $(".pagination").html(img);
35
+ $.get(location.href, function(result) {
36
+ $(".pagination").html($(".pagination", result));
37
+ $("#pagination_table").html($("#pagination_table", result));
38
+ });
39
+ } else {
40
+ once = true;
41
+ }
42
+ });
43
+
17
44
 
18
45
  });
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: 0.2.16
4
+ version: 1.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-07-17 00:00:00.000000000 Z
12
+ date: 2013-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -101,7 +101,6 @@ files:
101
101
  - spec/alpha_example.rb
102
102
  - spec/alphabetical_paginate_spec.rb
103
103
  - spec/support/helpers.rb
104
- - vendor/assets/javascripts/.alphabetical_paginate.js.swp
105
104
  - vendor/assets/javascripts/alphabetical_paginate.js
106
105
  - vendor/assets/javascripts/index.js
107
106
  homepage: http://google.com