debian-mirror-gitlab/app/assets/javascripts/pager.js.coffee

44 lines
950 B
CoffeeScript
Raw Normal View History

2014-09-02 18:07:02 +05:30
@Pager =
init: (@limit = 0, preload, @disable = false) ->
2016-06-02 11:05:42 +05:30
@loading = $('.loading').first()
2014-09-02 18:07:02 +05:30
if preload
@offset = 0
@getOld()
else
@offset = @limit
@initLoadMore()
getOld: ->
@loading.show()
$.ajax
type: "GET"
2015-09-11 14:41:01 +05:30
url: $(".content_list").data('href') || location.href
2014-09-02 18:07:02 +05:30
data: "limit=" + @limit + "&offset=" + @offset
complete: =>
@loading.hide()
success: (data) ->
Pager.append(data.count, data.html)
dataType: "json"
append: (count, html) ->
$(".content_list").append html
if count > 0
@offset += count
else
@disable = true
initLoadMore: ->
$(document).unbind('scroll')
$(document).endlessScroll
bottomPixels: 400
fireDelay: 1000
fireOnce: true
ceaseFire: ->
Pager.disable
callback: (i) =>
unless @loading.is(':visible')
@loading.show()
Pager.getOld()