2015-04-26 12:48:37 +05:30
|
|
|
class @CommitsList
|
2016-01-14 18:37:52 +05:30
|
|
|
@timer = null
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
@init: (limit) ->
|
2014-09-02 18:07:02 +05:30
|
|
|
$("body").on "click", ".day-commits-table li.commit", (event) ->
|
|
|
|
if event.target.nodeName != "A"
|
|
|
|
location.href = $(this).attr("url")
|
|
|
|
e.stopPropagation()
|
|
|
|
return false
|
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
Pager.init limit, false
|
|
|
|
|
|
|
|
@content = $("#commits-list")
|
|
|
|
@searchField = $("#commits-search")
|
|
|
|
@initSearch()
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
@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()
|
|
|
|
@content.fadeTo('fast', 0.5)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
$.ajax
|
|
|
|
type: "GET"
|
2016-01-14 18:37:52 +05:30
|
|
|
url: form.attr("action")
|
|
|
|
data: form.serialize()
|
|
|
|
complete: =>
|
|
|
|
@content.fadeTo('fast', 1.0)
|
|
|
|
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
|
2014-09-02 18:07:02 +05:30
|
|
|
dataType: "json"
|