debian-mirror-gitlab/app/assets/javascripts/confirm_danger_modal.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05: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 */
2018-03-17 18:26:18 +05:30
import { rstrip } from './lib/utils/common_utils';
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
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() {
2018-03-17 18:26:18 +05:30
if (rstrip($(this).val()) === project_path) {
2017-08-17 22:00:37 +05:30
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));
}
2016-09-13 17:45:13 +05:30
2017-08-17 22:00:37 +05:30
return ConfirmDangerModal;
})();