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

commits.js.coffee « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c183e78e513ed62a5f98ac13cfc41a15db308c41 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
class @CommitsList
  @data =
    ref: null
    limit: 0
    offset: 0
  @disable = false

  @showProgress: ->
    $('.loading').show()

  @hideProgress: ->
    $('.loading').hide()

  @init: (ref, limit) ->
    $("body").on "click", ".day-commits-table li.commit", (event) ->
      if event.target.nodeName != "A"
        location.href = $(this).attr("url")
        e.stopPropagation()
        return false

    @data.ref = ref
    @data.limit = limit
    @data.offset = limit

    this.initLoadMore()
    this.showProgress()

  @getOld: ->
    this.showProgress()
    $.ajax
      type: "GET"
      url: location.href
      data: @data
      complete: this.hideProgress
      success: (data) ->
        CommitsList.append(data.count, data.html)
      dataType: "json"

  @append: (count, html) ->
    $("#commits-list").append(html)
    if count > 0
      @data.offset += count
    else
      @disable = true

  @initLoadMore: ->
    $(document).unbind('scroll')
    $(document).endlessScroll
      bottomPixels: 400
      fireDelay: 1000
      fireOnce: true
      ceaseFire: =>
        @disable
      callback: =>
        this.getOld()