2012-12-01 07:49:21 -05:00
|
|
|
class CommitsList
|
|
|
|
@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) ->
|
|
|
|
$(".day-commits-table li.commit").live 'click', (event) ->
|
|
|
|
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()
|
|
|
|
|
2013-05-14 05:46:41 -04:00
|
|
|
this.CommitsList = CommitsList
|