Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pager.js.coffee « ci « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b57e7c736e937579e76629c9babf31f869415544 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@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) =>
        Pager.append(data.count, data.html)
      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: ->
        Pager.disable

      callback: (i) =>
        unless $(".loading").is(':visible')
          $(".loading").show()
          Pager.getItems()