summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo <mokha@cisco.com>2017-09-02 16:16:53 -0600
committermo <mokha@cisco.com>2017-09-02 16:16:53 -0600
commita906c00f9cf9f97af6c2994d1b791e3c4f3b1e36 (patch)
treedce7b6d032faa427d6eb3aff411dc68a6973b6dc
parentd7eb1b1606ea9e2be6f985932d3bab33c9536f5e (diff)
replace more-button selector with data-infinite-scroll.
-rw-r--r--app/assets/javascripts/infrastructure/infinite_scroll.js.coffee5
-rw-r--r--app/views/cakes/_index.html.erb2
-rw-r--r--app/views/profiles/_index.html.erb2
3 files changed, 6 insertions, 3 deletions
diff --git a/app/assets/javascripts/infrastructure/infinite_scroll.js.coffee b/app/assets/javascripts/infrastructure/infinite_scroll.js.coffee
index 7c87c0ee..ab7d2b61 100644
--- a/app/assets/javascripts/infrastructure/infinite_scroll.js.coffee
+++ b/app/assets/javascripts/infrastructure/infinite_scroll.js.coffee
@@ -4,5 +4,8 @@ class CakeSide.InfiniteScroll extends CakeSide.Behaviour
@on "scroll"
execute: ->
+ $moreButton = $('[data-infinite-scroll]')
+ return if $moreButton.length == 0
+
if $(window).scrollTop() >= ($(document).height() - $(window).height())*0.8
- $('.more-button').trigger('click')
+ $moreButton.trigger('click')
diff --git a/app/views/cakes/_index.html.erb b/app/views/cakes/_index.html.erb
index 541aa4d6..0b3e0dda 100644
--- a/app/views/cakes/_index.html.erb
+++ b/app/views/cakes/_index.html.erb
@@ -13,5 +13,5 @@
<% end %>
</div>
<div id='more-button-row' class="row">
- <%= link_to_next_page @cakes, 'More...', params: { cache: false, sort: params[:sort], q: params[:q] }, remote: true, class: 'btn pull-right more-button hidden', data: { disable_with: 'loading...' } %>
+ <%= link_to_next_page @cakes, 'More...', params: { cache: false, sort: params[:sort], q: params[:q] }, remote: true, class: 'btn pull-right hidden', data: { disable_with: 'loading...', infinite_scroll: true } %>
</div>
diff --git a/app/views/profiles/_index.html.erb b/app/views/profiles/_index.html.erb
index ff10ad87..171a3926 100644
--- a/app/views/profiles/_index.html.erb
+++ b/app/views/profiles/_index.html.erb
@@ -12,5 +12,5 @@
<% end %>
</div>
<div id='more-button-row' class="row">
- <%= link_to_next_page @profiles, 'More...', params: { cache: false }, remote: true, class: 'more-button hidden', data: { disable_with: 'loading...' } %>
+ <%= link_to_next_page @profiles, 'More...', params: { cache: false }, remote: true, class: 'hidden', data: { disable_with: 'loading...', infinite_scroll: true } %>
</div>