summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/confirm_danger_modal.js12
-rw-r--r--app/assets/javascripts/main.js9
-rw-r--r--app/assets/javascripts/pages/groups/edit/index.js2
-rw-r--r--app/assets/javascripts/pages/projects/edit/index.js2
4 files changed, 15 insertions, 10 deletions
diff --git a/app/assets/javascripts/confirm_danger_modal.js b/app/assets/javascripts/confirm_danger_modal.js
index c21c52b0086..1638e09132b 100644
--- a/app/assets/javascripts/confirm_danger_modal.js
+++ b/app/assets/javascripts/confirm_danger_modal.js
@@ -1,7 +1,7 @@
import $ from 'jquery';
import { rstrip } from './lib/utils/common_utils';
-export default function initConfirmDangerModal($form, text) {
+function openConfirmDangerModal($form, text) {
$('.js-confirm-text').text(text || '');
$('.js-confirm-danger-input').val('');
$('#modal-confirm-danger').modal('show');
@@ -20,3 +20,13 @@ export default function initConfirmDangerModal($form, text) {
});
$('.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);
+ });
+}
diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js
index c867f5f3236..2c80baba10b 100644
--- a/app/assets/javascripts/main.js
+++ b/app/assets/javascripts/main.js
@@ -20,7 +20,6 @@ import './behaviors/';
// everything else
import loadAwardsHandler from './awards_handler';
import bp from './breakpoints';
-import initConfirmDangerModal from './confirm_danger_modal';
import Flash, { removeFlashClickListener } from './flash';
import './gl_dropdown';
import initTodoToggle from './header';
@@ -213,14 +212,6 @@ document.addEventListener('DOMContentLoaded', () => {
$(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) => {
if (breakpoint === 'sm' || breakpoint === 'xs') {
const $gutterIcon = $sidebarGutterToggle.find('i');
diff --git a/app/assets/javascripts/pages/groups/edit/index.js b/app/assets/javascripts/pages/groups/edit/index.js
index d44874c8741..bb91ac84ffb 100644
--- a/app/assets/javascripts/pages/groups/edit/index.js
+++ b/app/assets/javascripts/pages/groups/edit/index.js
@@ -1,7 +1,9 @@
import groupAvatar from '~/group_avatar';
import TransferDropdown from '~/groups/transfer_dropdown';
+import initConfirmDangerModal from '~/confirm_danger_modal';
document.addEventListener('DOMContentLoaded', () => {
groupAvatar();
new TransferDropdown(); // eslint-disable-line no-new
+ initConfirmDangerModal();
});
diff --git a/app/assets/javascripts/pages/projects/edit/index.js b/app/assets/javascripts/pages/projects/edit/index.js
index 064de22dfd6..be37df36be8 100644
--- a/app/assets/javascripts/pages/projects/edit/index.js
+++ b/app/assets/javascripts/pages/projects/edit/index.js
@@ -1,5 +1,6 @@
import initSettingsPanels from '~/settings_panels';
import setupProjectEdit from '~/project_edit';
+import initConfirmDangerModal from '~/confirm_danger_modal';
import ProjectNew from '../shared/project_new';
import projectAvatar from '../shared/project_avatar';
import initProjectPermissionsSettings from '../shared/permissions';
@@ -11,4 +12,5 @@ document.addEventListener('DOMContentLoaded', () => {
initSettingsPanels();
projectAvatar();
initProjectPermissionsSettings();
+ initConfirmDangerModal();
});