2014-10-20 16:48:07 -04:00
|
|
|
class @CommitsList
|
2016-01-06 06:58:15 -05:00
|
|
|
@timer = null
|
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
|
|
|
|
|
2016-01-07 06:38:35 -05:00
|
|
|
Pager.init limit, false
|
2016-01-06 06:58:15 -05:00
|
|
|
|
|
|
|
@content = $("#commits-list")
|
|
|
|
@searchField = $("#commits-search")
|
|
|
|
@initSearch()
|
2013-11-28 04:38:20 -05:00
|
|
|
|
2016-01-06 06:58:15 -05:00
|
|
|
@initSearch: ->
|
|
|
|
@timer = null
|
|
|
|
@searchField.keyup =>
|
|
|
|
clearTimeout(@timer)
|
|
|
|
@timer = setTimeout(@filterResults, 500)
|
|
|
|
|
|
|
|
@filterResults: =>
|
|
|
|
form = $(".commits-search-form")
|
|
|
|
search = @searchField.val()
|
|
|
|
commitsUrl = form.attr("action") + '?' + form.serialize()
|
2016-01-07 09:15:21 -05:00
|
|
|
@content.fadeTo('fast', 0.5)
|
2012-12-01 07:49:21 -05:00
|
|
|
|
|
|
|
$.ajax
|
|
|
|
type: "GET"
|
2016-01-06 06:58:15 -05:00
|
|
|
url: form.attr("action")
|
|
|
|
data: form.serialize()
|
|
|
|
complete: =>
|
2016-01-07 09:15:21 -05:00
|
|
|
@content.fadeTo('fast', 1.0)
|
2016-01-06 06:58:15 -05:00
|
|
|
success: (data) =>
|
|
|
|
@content.html(data.html)
|
|
|
|
# Change url so if user reload a page - search results are saved
|
|
|
|
history.replaceState {page: commitsUrl}, document.title, commitsUrl
|
2013-11-28 04:38:20 -05:00
|
|
|
dataType: "json"
|