2017-01-10 18:02:20 -05:00
|
|
|
/* 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 */
|
2017-09-06 04:01:01 -04:00
|
|
|
import { rstrip } from './lib/utils/common_utils';
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-03-11 02:30:44 -05:00
|
|
|
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() {
|
2017-09-06 04:01:01 -04:00
|
|
|
if (rstrip($(this).val()) === project_path) {
|
2017-03-11 02:30:44 -05:00
|
|
|
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;
|
|
|
|
})();
|