BigW Consortium Gitlab

merge_requests.js.coffee 1.02 KB
Newer Older
1 2
#
# * Filter merge requests
Andrey Kumanyaev committed
3
#
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
@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')
19
    issues_url = form.attr('action') + '?' + form.serialize()
20 21 22 23 24 25 26 27 28 29

    $.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
30
        history.replaceState {page: issues_url}, document.title, issues_url
31 32 33 34 35
        MergeRequests.reload()
      dataType: "json"

  reload: ->
    $('#filter_issue_search').val($('#issue_search').val())