BigW Consortium Gitlab

confirm_danger_modal.js.coffee 644 Bytes
Newer Older
1
class @ConfirmDangerModal
2 3 4 5 6 7 8 9 10
  constructor: (form, text) ->
    @form = form
    $('.js-confirm-text').text(text || '')
    $('.js-confirm-danger-input').val('')
    $('#modal-confirm-danger').modal('show')
    project_path = $('.js-confirm-danger-match').text()
    submit = $('.js-confirm-danger-submit')
    submit.disable()

11
    $('.js-confirm-danger-input').off 'input'
12 13 14 15 16 17
    $('.js-confirm-danger-input').on 'input', ->
      if rstrip($(@).val()) is project_path
        submit.enable()
      else
        submit.disable()

18
    $('.js-confirm-danger-submit').off 'click'
19 20
    $('.js-confirm-danger-submit').on 'click', =>
      @form.submit()