jquery-infinite-pages 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTFlZjg0ZGNkYTk4MmZiODI0YTljZmQ4YTZmYWQ4MGViYzEwZjUzZg==
4
+ MWZkNmRmZmUzMDM4ZjgwMzBlYzM1YWMwYmU1ZjkzNTU1NzNjNTcwMA==
5
5
  data.tar.gz: !binary |-
6
- ZmY0ZmNmMmI5NGNlMWIzZDkzNmNmYmFlOTE2Y2Q1ZTNiZDYwMGYxMQ==
6
+ MGM2YTJkNGE5NjI5NmM2ZDYzMWU5MTZhZjJhNDFiZDc0MWRmZDY4NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDdmZDJmMmJhNGQ1ZDIwZjZmMGQyOTEzOWM1NmZlZjU5NDUwNGYyMGIwNzAz
10
- OGQ1MGY4YTdkOWIwYWFmOTk5MWM5NDRmMjZhNDZhZmRhZGFlODE0Y2I2MTUy
11
- ODdmYjQxMzU4NjZkMjNjOTcxMDY4N2RlMGM0NGQxMjEzODJhZmM=
9
+ MTQyMThmOTBhZDc5ZjBkYTBhZDg2NTgxOTk4NWJjMzFlM2NmZjk4YzgyN2Zm
10
+ ZTJjNzZmMDgwNjJhMjlkNjE4OTdiNzc4YTk3NjMwY2RmODUwMGVmMWJjZDY4
11
+ ZTdjM2M5ZTllNWUyYzJiZjcwNDg2MmJjNjkyMmYyNWQ1MzQ0NTI=
12
12
  data.tar.gz: !binary |-
13
- NzVmNjg5YjVjMDM1NGFhZDM5MGYxOGQwNzU3YWQ0YmIxMTQyY2YyNjk3OWVm
14
- MjFlMDNmOWZlOTkwYjI4Zjg1Y2U2ZGM1MzFmN2E3ODIzMGFlNzI2NjIxYzA4
15
- ODE1NGI3ZDM4OTdjY2QxYTAwMDMxMmE5YzhhYjU5MWZjOTQ2ZTM=
13
+ NDhiMTVjODdkYzY0OTE3MTkwY2Y0OTVmZmViNDNhZWRkMTc4MTgwOWVhNzM5
14
+ ZmY2Yjk4ZGMyZDY3NTE2ZTQ5YjhjZjE3Y2YyMWIzYmJhMTYyZDhjZTYxYWJh
15
+ YTQwYTMwNTdmN2VlNjJjNGVkYjVjMTdhOGM4YjMxMzAwOTc2OTQ=
data/README.md CHANGED
@@ -47,6 +47,7 @@ pagination link.
47
47
  $('.infinite-table').infinitePages
48
48
  debug: true
49
49
  buffer: 200 # load new page when within 200px of nav link
50
+ context: '.pane' # define the scrolling container (defaults to window)
50
51
  loading: ->
51
52
  # jQuery callback on the nav element
52
53
  $(this).text("Loading...")
@@ -98,7 +99,7 @@ Write the template for your list of lessons in `index.html.erb`:
98
99
  <%= render :partial => 'lessons', :object => @lessons %>
99
100
  </table>
100
101
  <p class="pagination">
101
- <%= link_to_next_page(@lessons, 'Next Page', :remote => true))%>
102
+ <%= link_to_next_page(@lessons, 'Next Page', :remote => true) %>
102
103
  </p>
103
104
  </div>
104
105
  ```
@@ -122,11 +123,11 @@ $("<%=j render(:partial => 'lessons', :object => @lessons) %>")
122
123
  .appendTo($(".infinite-table table"));
123
124
 
124
125
  // Update pagination link
125
- <% if answers.last_page? %>
126
+ <% if @lessons.last_page? %>
126
127
  $('.pagination').html("That's all, folks!");
127
128
  <% else %>
128
129
  $('.pagination')
129
- .html("<%=j link_to_next_page(@lessons, 'Next Page', :remote => true))%>");
130
+ .html("<%=j link_to_next_page(@lessons, 'Next Page', :remote => true) %>");
130
131
  <% end %>
131
132
  ```
132
133
 
@@ -1,5 +1,5 @@
1
1
  ###
2
- jQuery Infinite Pages v0.1.1
2
+ jQuery Infinite Pages v0.2.0
3
3
  https://github.com/magoosh/jquery-infinite-pages
4
4
 
5
5
  Released under the MIT License
@@ -13,7 +13,7 @@ Released under the MIT License
13
13
  (($, window) ->
14
14
  # Define the plugin class
15
15
  class InfinitePages
16
-
16
+
17
17
  # Default settings
18
18
  defaults:
19
19
  debug: false # set to true to log messages to the console
@@ -22,10 +22,11 @@ Released under the MIT License
22
22
  loading: null # optional callback when next-page request begins
23
23
  success: null # optional callback when next-page request finishes
24
24
  error: null # optional callback when next-page request fails
25
+ context: window # context to define the scrolling container
25
26
  state:
26
27
  paused: false
27
28
  loading: false
28
-
29
+
29
30
  # Constructs the new InfinitePages object
30
31
  #
31
32
  # container - the element containing the infinite table and pagination links
@@ -33,26 +34,26 @@ Released under the MIT License
33
34
  @options = $.extend({}, @defaults, options)
34
35
  @$container = $(container)
35
36
  @$table = $(container).find('table')
36
-
37
+ @$context = $(@options.context)
37
38
  @init()
38
-
39
+
39
40
  # Setup and bind to related events
40
41
  init: ->
41
-
42
+
42
43
  # Debounce scroll event to improve performance
43
44
  scrollTimeout = null
44
45
  scrollHandler = (=> @check())
45
-
46
- $(window).scroll ->
46
+
47
+ @$context.scroll ->
47
48
  if scrollTimeout
48
49
  clearTimeout(scrollTimeout)
49
50
  scrollTimeout = null
50
51
  scrollTimeout = setTimeout(scrollHandler, 250)
51
-
52
+
52
53
  # Internal helper for logging messages
53
54
  _log: (msg) ->
54
55
  console?.log(msg) if @options.debug
55
-
56
+
56
57
  # Check the distance of the nav selector from the bottom of the window and fire
57
58
  # load event if close enough
58
59
  check: ->
@@ -60,9 +61,9 @@ Released under the MIT License
60
61
  if nav.size() == 0
61
62
  @_log "No more pages to load"
62
63
  else
63
- windowBottom = $(window).scrollTop() + $(window).height()
64
+ windowBottom = @$context.scrollTop() + @$context.height()
64
65
  distance = nav.offset().top - windowBottom
65
-
66
+
66
67
  if @options.state.paused
67
68
  @_log "Paused"
68
69
  else if @options.state.loading
@@ -71,56 +72,56 @@ Released under the MIT License
71
72
  @_log "#{distance - @options.buffer}px remaining..."
72
73
  else
73
74
  @next() # load the next page
74
-
75
+
75
76
  # Load the next page
76
77
  next: ->
77
78
  if @options.state.done
78
79
  @_log "Loaded all pages"
79
80
  else
80
81
  @_loading()
81
-
82
+
82
83
  $.getScript(@$container.find(@options.navSelector).attr('href'))
83
84
  .done(=> @_success())
84
85
  .fail(=> @_error())
85
-
86
+
86
87
  _loading: ->
87
88
  @options.state.loading = true
88
89
  @_log "Loading next page..."
89
90
  if typeof @options.loading is 'function'
90
91
  @$container.find(@options.navSelector).each(@options.loading)
91
-
92
+
92
93
  _success: ->
93
94
  @options.state.loading = false
94
95
  @_log "New page loaded!"
95
96
  if typeof @options.success is 'function'
96
97
  @$container.find(@options.navSelector).each(@options.success)
97
-
98
+
98
99
  _error: ->
99
100
  @options.state.loading = false
100
101
  @_log "Error loading new page :("
101
102
  if typeof @options.error is 'function'
102
103
  @$container.find(@options.navSelector).each(@options.error)
103
-
104
+
104
105
  # Pause firing of events on scroll
105
106
  pause: ->
106
107
  @options.state.paused = true
107
108
  @_log "Scroll checks paused"
108
-
109
+
109
110
  # Resume firing of events on scroll
110
111
  resume: ->
111
112
  @options.state.paused = false
112
113
  @_log "Scroll checks resumed"
113
114
  @check()
114
-
115
+
115
116
  # Define the plugin
116
117
  $.fn.extend infinitePages: (option, args...) ->
117
118
  @each ->
118
119
  $this = $(this)
119
120
  data = $this.data('infinitepages')
120
-
121
+
121
122
  if !data
122
123
  $this.data 'infinitepages', (data = new InfinitePages(this, option))
123
124
  if typeof option == 'string'
124
125
  data[option].apply(data, args)
125
-
126
+
126
127
  ) window.jQuery, window
@@ -1,3 +1,3 @@
1
1
  module JqueryInfinitePages
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-infinite-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Millman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-script
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: railties
29
43
  requirement: !ruby/object:Gem::Requirement