summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/confirm_danger_modal.js
blob: b375b61202eea1b311fa3fd80440a76dcdc2f5cb (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
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, camelcase, one-var-declaration-per-line, no-else-return, max-len */

window.ConfirmDangerModal = (function() {
  function ConfirmDangerModal(form, text) {
    var project_path, submit;
    this.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();
    $('.js-confirm-danger-input').off('input');
    $('.js-confirm-danger-input').on('input', function() {
      if (gl.utils.rstrip($(this).val()) === project_path) {
        return submit.enable();
      } else {
        return submit.disable();
      }
    });
    $('.js-confirm-danger-submit').off('click');
    $('.js-confirm-danger-submit').on('click', (function(_this) {
      return function() {
        return _this.form.submit();
      };
    })(this));
  }

  return ConfirmDangerModal;
})();