summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/merged_buttons.js.coffee
blob: 4929295c10b5baca7f81e8d872d4ec35a04c6b6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class @MergedButtons
  constructor: ->
    @$removeBranchWidget = $('.remove_source_branch_widget')
    @$removeBranchProgress = $('.remove_source_branch_in_progress')
    @$removeBranchFailed = $('.remove_source_branch_widget.failed')

    @cleanEventListeners()
    @initEventListeners()

  cleanEventListeners: ->
    $(document).off 'click', '.remove_source_branch'
    $(document).off 'ajax:success', '.remove_source_branch'
    $(document).off 'ajax:error', '.remove_source_branch'

  initEventListeners: ->
    $(document).on 'click', '.remove_source_branch', @removeSourceBranch
    $(document).on 'ajax:success', '.remove_source_branch', @removeBranchSuccess
    $(document).on 'ajax:error', '.remove_source_branch', @removeBranchError

  removeSourceBranch: =>
    @$removeBranchWidget.hide()
    @$removeBranchProgress.show()

  removeBranchSuccess: ->
    location.reload()

  removeBranchError: ->
    @$removeBranchWidget.hide()
    @$removeBranchProgress.hide()
    @$removeBranchFailed.show()