2014-10-20 16:48:07 -04:00
|
|
|
class @CommitsList
|
2012-12-01 07:49:21 -05:00
|
|
|
@data =
|
|
|
|
ref: null
|
|
|
|
limit: 0
|
|
|
|
offset: 0
|
|
|
|
@disable = false
|
2013-11-28 04:38:20 -05:00
|
|
|
|
2012-12-01 07:49:21 -05:00
|
|
|
@showProgress: ->
|
|
|
|
$('.loading').show()
|
2013-11-28 04:38:20 -05:00
|
|
|
|
2012-12-01 07:49:21 -05:00
|
|
|
@hideProgress: ->
|
|
|
|
$('.loading').hide()
|
2013-11-28 04:38:20 -05:00
|
|
|
|
2012-12-01 07:49:21 -05:00
|
|
|
@init: (ref, limit) ->
|
2014-05-23 08:07:42 -04:00
|
|
|
$("body").on "click", ".day-commits-table li.commit", (event) ->
|
2012-12-01 07:49:21 -05:00
|
|
|
if event.target.nodeName != "A"
|
|
|
|
location.href = $(this).attr("url")
|
|
|
|
e.stopPropagation()
|
|
|
|
return false
|
|
|
|
|
|
|
|
@data.ref = ref
|
|
|
|
@data.limit = limit
|
|
|
|
@data.offset = limit
|
2013-11-28 04:38:20 -05:00
|
|
|
|
2012-12-01 07:49:21 -05:00
|
|
|
this.initLoadMore()
|
2013-05-14 05:46:41 -04:00
|
|
|
this.showProgress()
|
2012-12-01 07:49:21 -05:00
|
|
|
|
|
|
|
@getOld: ->
|
|
|
|
this.showProgress()
|
|
|
|
$.ajax
|
|
|
|
type: "GET"
|
|
|
|
url: location.href
|
|
|
|
data: @data
|
|
|
|
complete: this.hideProgress
|
2013-11-28 04:38:20 -05:00
|
|
|
success: (data) ->
|
|
|
|
CommitsList.append(data.count, data.html)
|
|
|
|
dataType: "json"
|
2012-12-01 07:49:21 -05:00
|
|
|
|
|
|
|
@append: (count, html) ->
|
|
|
|
$("#commits-list").append(html)
|
|
|
|
if count > 0
|
|
|
|
@data.offset += count
|
|
|
|
else
|
|
|
|
@disable = true
|
2013-11-28 04:38:20 -05:00
|
|
|
|
2013-05-14 05:46:41 -04:00
|
|
|
@initLoadMore: ->
|
2013-06-04 01:07:33 -04:00
|
|
|
$(document).unbind('scroll')
|
2012-12-01 07:49:21 -05:00
|
|
|
$(document).endlessScroll
|
|
|
|
bottomPixels: 400
|
|
|
|
fireDelay: 1000
|
|
|
|
fireOnce: true
|
|
|
|
ceaseFire: =>
|
|
|
|
@disable
|
|
|
|
callback: =>
|
|
|
|
this.getOld()
|