2013-01-27 11:47:19 -05:00
|
|
|
@Pager =
|
2014-06-24 09:08:18 -04:00
|
|
|
init: (@limit = 0, preload, @disable = false) ->
|
|
|
|
@loading = $(".loading")
|
2013-01-27 11:47:19 -05:00
|
|
|
if preload
|
|
|
|
@offset = 0
|
|
|
|
@getOld()
|
|
|
|
else
|
2014-06-24 09:08:18 -04:00
|
|
|
@offset = @limit
|
2013-01-27 11:47:19 -05:00
|
|
|
@initLoadMore()
|
|
|
|
|
|
|
|
getOld: ->
|
2014-06-24 09:08:18 -04:00
|
|
|
@loading.show()
|
2013-01-27 11:47:19 -05:00
|
|
|
$.ajax
|
|
|
|
type: "GET"
|
2015-07-13 12:24:15 -04:00
|
|
|
url: $(".content_list").data('href') || location.href
|
2013-01-27 11:47:19 -05:00
|
|
|
data: "limit=" + @limit + "&offset=" + @offset
|
2014-06-24 09:08:18 -04:00
|
|
|
complete: =>
|
|
|
|
@loading.hide()
|
2013-11-28 04:38:20 -05:00
|
|
|
success: (data) ->
|
|
|
|
Pager.append(data.count, data.html)
|
|
|
|
dataType: "json"
|
2013-01-27 11:47:19 -05:00
|
|
|
|
|
|
|
append: (count, html) ->
|
|
|
|
$(".content_list").append html
|
|
|
|
if count > 0
|
|
|
|
@offset += count
|
|
|
|
else
|
|
|
|
@disable = true
|
|
|
|
|
|
|
|
initLoadMore: ->
|
2013-05-29 14:41:12 -04:00
|
|
|
$(document).unbind('scroll')
|
2013-01-27 11:47:19 -05:00
|
|
|
$(document).endlessScroll
|
|
|
|
bottomPixels: 400
|
|
|
|
fireDelay: 1000
|
|
|
|
fireOnce: true
|
|
|
|
ceaseFire: ->
|
|
|
|
Pager.disable
|
|
|
|
|
2014-06-24 09:08:18 -04:00
|
|
|
callback: (i) =>
|
|
|
|
unless @loading.is(':visible')
|
|
|
|
@loading.show()
|
|
|
|
Pager.getOld()
|