2015-08-25 21:42:46 -04:00
|
|
|
@CiPager =
|
|
|
|
init: (@url, @limit = 0, preload, @disable = false) ->
|
|
|
|
if preload
|
|
|
|
@offset = 0
|
|
|
|
@getItems()
|
|
|
|
else
|
|
|
|
@offset = @limit
|
|
|
|
@initLoadMore()
|
|
|
|
|
|
|
|
getItems: ->
|
|
|
|
$(".loading").show()
|
|
|
|
$.ajax
|
|
|
|
type: "GET"
|
|
|
|
url: @url
|
|
|
|
data: "limit=" + @limit + "&offset=" + @offset
|
|
|
|
complete: =>
|
|
|
|
$(".loading").hide()
|
|
|
|
success: (data) =>
|
2015-09-11 13:59:39 -04:00
|
|
|
CiPager.append(data.count, data.html)
|
2015-08-25 21:42:46 -04:00
|
|
|
dataType: "json"
|
|
|
|
|
|
|
|
append: (count, html) ->
|
|
|
|
if count > 1
|
|
|
|
$(".content-list").append html
|
|
|
|
if count == @limit
|
|
|
|
@offset += count
|
|
|
|
else
|
|
|
|
@disable = true
|
|
|
|
|
|
|
|
initLoadMore: ->
|
|
|
|
$(document).unbind('scroll')
|
|
|
|
$(document).endlessScroll
|
|
|
|
bottomPixels: 400
|
|
|
|
fireDelay: 1000
|
|
|
|
fireOnce: true
|
|
|
|
ceaseFire: ->
|
2015-09-11 13:59:39 -04:00
|
|
|
CiPager.disable
|
2015-08-25 21:42:46 -04:00
|
|
|
|
|
|
|
callback: (i) =>
|
|
|
|
unless $(".loading").is(':visible')
|
|
|
|
$(".loading").show()
|
2015-09-11 13:59:39 -04:00
|
|
|
CiPager.getItems()
|