2013-01-04 20:18:39 -05:00
|
|
|
#
|
|
|
|
# * Filter merge requests
|
2013-01-23 11:43:23 -05:00
|
|
|
#
|
2015-03-12 19:20:58 -04:00
|
|
|
@MergeRequests =
|
|
|
|
init: ->
|
|
|
|
MergeRequests.initSearch()
|
|
|
|
|
|
|
|
# Make sure we trigger ajax request only after user stop typing
|
|
|
|
initSearch: ->
|
|
|
|
@timer = null
|
|
|
|
$("#issue_search").keyup ->
|
|
|
|
clearTimeout(@timer)
|
|
|
|
@timer = setTimeout(MergeRequests.filterResults, 500)
|
|
|
|
|
|
|
|
filterResults: =>
|
|
|
|
form = $("#issue_search_form")
|
|
|
|
search = $("#issue_search").val()
|
|
|
|
$('.merge-requests-holder').css("opacity", '0.5')
|
2016-01-01 17:40:10 -05:00
|
|
|
issues_url = form.attr('action') + '?' + form.serialize()
|
2015-03-12 19:20:58 -04:00
|
|
|
|
|
|
|
$.ajax
|
|
|
|
type: "GET"
|
|
|
|
url: form.attr('action')
|
|
|
|
data: form.serialize()
|
|
|
|
complete: ->
|
|
|
|
$('.merge-requests-holder').css("opacity", '1.0')
|
|
|
|
success: (data) ->
|
|
|
|
$('.merge-requests-holder').html(data.html)
|
|
|
|
# Change url so if user reload a page - search results are saved
|
2016-01-01 17:40:10 -05:00
|
|
|
history.replaceState {page: issues_url}, document.title, issues_url
|
2015-03-12 19:20:58 -04:00
|
|
|
MergeRequests.reload()
|
|
|
|
dataType: "json"
|
|
|
|
|
|
|
|
reload: ->
|
|
|
|
$('#filter_issue_search').val($('#issue_search').val())
|