gitlab-org--gitlab-foss/app/assets/javascripts/ci/pager.js.coffee

43 lines
933 B
CoffeeScript
Raw Normal View History

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) =>
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: ->
CiPager.disable
2015-08-25 21:42:46 -04:00
callback: (i) =>
unless $(".loading").is(':visible')
$(".loading").show()
CiPager.getItems()