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