Commit 1fff345e authored by Mike Greiling's avatar Mike Greiling

move confirm_danger_modal bindings directly into the only two pages that need it

parent 43ff14e0
import $ from 'jquery'; import $ from 'jquery';
import { rstrip } from './lib/utils/common_utils'; import { rstrip } from './lib/utils/common_utils';
export default function initConfirmDangerModal($form, text) { function openConfirmDangerModal($form, text) {
$('.js-confirm-text').text(text || ''); $('.js-confirm-text').text(text || '');
$('.js-confirm-danger-input').val(''); $('.js-confirm-danger-input').val('');
$('#modal-confirm-danger').modal('show'); $('#modal-confirm-danger').modal('show');
...@@ -20,3 +20,13 @@ export default function initConfirmDangerModal($form, text) { ...@@ -20,3 +20,13 @@ export default function initConfirmDangerModal($form, text) {
}); });
$('.js-confirm-danger-submit').off('click').on('click', () => $form.submit()); $('.js-confirm-danger-submit').off('click').on('click', () => $form.submit());
} }
export default function initConfirmDangerModal() {
$(document).on('click', '.js-confirm-danger', (e) => {
e.preventDefault();
const $btn = $(e.target);
const $form = $btn.closest('form');
const text = $btn.data('confirmDangerMessage');
openConfirmDangerModal($form, text);
});
}
...@@ -20,7 +20,6 @@ import './behaviors/'; ...@@ -20,7 +20,6 @@ import './behaviors/';
// everything else // everything else
import loadAwardsHandler from './awards_handler'; import loadAwardsHandler from './awards_handler';
import bp from './breakpoints'; import bp from './breakpoints';
import initConfirmDangerModal from './confirm_danger_modal';
import Flash, { removeFlashClickListener } from './flash'; import Flash, { removeFlashClickListener } from './flash';
import './gl_dropdown'; import './gl_dropdown';
import initTodoToggle from './header'; import initTodoToggle from './header';
...@@ -213,14 +212,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -213,14 +212,6 @@ document.addEventListener('DOMContentLoaded', () => {
$(document).trigger('toggle.comments'); $(document).trigger('toggle.comments');
}); });
$document.on('click', '.js-confirm-danger', (e) => {
e.preventDefault();
const $btn = $(e.target);
const $form = $btn.closest('form');
const text = $btn.data('confirmDangerMessage');
initConfirmDangerModal($form, text);
});
$document.on('breakpoint:change', (e, breakpoint) => { $document.on('breakpoint:change', (e, breakpoint) => {
if (breakpoint === 'sm' || breakpoint === 'xs') { if (breakpoint === 'sm' || breakpoint === 'xs') {
const $gutterIcon = $sidebarGutterToggle.find('i'); const $gutterIcon = $sidebarGutterToggle.find('i');
......
import groupAvatar from '~/group_avatar'; import groupAvatar from '~/group_avatar';
import TransferDropdown from '~/groups/transfer_dropdown'; import TransferDropdown from '~/groups/transfer_dropdown';
import initConfirmDangerModal from '~/confirm_danger_modal';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
groupAvatar(); groupAvatar();
new TransferDropdown(); // eslint-disable-line no-new new TransferDropdown(); // eslint-disable-line no-new
initConfirmDangerModal();
}); });
import initSettingsPanels from '~/settings_panels'; import initSettingsPanels from '~/settings_panels';
import setupProjectEdit from '~/project_edit'; import setupProjectEdit from '~/project_edit';
import initConfirmDangerModal from '~/confirm_danger_modal';
import ProjectNew from '../shared/project_new'; import ProjectNew from '../shared/project_new';
import projectAvatar from '../shared/project_avatar'; import projectAvatar from '../shared/project_avatar';
import initProjectPermissionsSettings from '../shared/permissions'; import initProjectPermissionsSettings from '../shared/permissions';
...@@ -11,4 +12,5 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -11,4 +12,5 @@ document.addEventListener('DOMContentLoaded', () => {
initSettingsPanels(); initSettingsPanels();
projectAvatar(); projectAvatar();
initProjectPermissionsSettings(); initProjectPermissionsSettings();
initConfirmDangerModal();
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment