Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
43ff14e0
Commit
43ff14e0
authored
Mar 20, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor ConfirmDangerModal into ES module
parent
5f675418
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
37 deletions
+23
-37
app/assets/javascripts/confirm_danger_modal.js
app/assets/javascripts/confirm_danger_modal.js
+18
-29
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+5
-8
No files found.
app/assets/javascripts/confirm_danger_modal.js
View file @
43ff14e0
/* 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 */
import
$
from
'
jquery
'
;
import
{
rstrip
}
from
'
./lib/utils/common_utils
'
;
window
.
ConfirmDangerModal
=
(
function
()
{
function
ConfirmDangerModal
(
form
,
text
)
{
var
project_path
,
submit
;
this
.
form
=
form
;
export
default
function
initConfirmDangerModal
(
$form
,
text
)
{
$
(
'
.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
(
rstrip
(
$
(
this
).
val
())
===
project_path
)
{
return
submit
.
enable
();
const
confirmTextMatch
=
$
(
'
.js-confirm-danger-match
'
).
text
();
const
$submit
=
$
(
'
.js-confirm-danger-submit
'
);
$submit
.
disable
();
$
(
'
.js-confirm-danger-input
'
).
off
(
'
input
'
).
on
(
'
input
'
,
function
handleInput
()
{
const
confirmText
=
rstrip
(
$
(
this
).
val
());
if
(
confirmText
===
confirmTextMatch
)
{
$submit
.
enable
();
}
else
{
return
submit
.
disable
();
$
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
;
})();
$
(
'
.js-confirm-danger-submit
'
).
off
(
'
click
'
).
on
(
'
click
'
,
()
=>
$form
.
submit
());
}
app/assets/javascripts/main.js
View file @
43ff14e0
/* eslint-disable import/first */
/* global ConfirmDangerModal */
/* global $ */
import
jQuery
from
'
jquery
'
;
...
...
@@ -21,7 +20,7 @@ import './behaviors/';
// everything else
import
loadAwardsHandler
from
'
./awards_handler
'
;
import
bp
from
'
./breakpoints
'
;
import
'
./confirm_danger_modal
'
;
import
initConfirmDangerModal
from
'
./confirm_danger_modal
'
;
import
Flash
,
{
removeFlashClickListener
}
from
'
./flash
'
;
import
'
./gl_dropdown
'
;
import
initTodoToggle
from
'
./header
'
;
...
...
@@ -215,13 +214,11 @@ document.addEventListener('DOMContentLoaded', () => {
});
$document
.
on
(
'
click
'
,
'
.js-confirm-danger
'
,
(
e
)
=>
{
const
btn
=
$
(
e
.
target
);
const
form
=
btn
.
closest
(
'
form
'
);
const
text
=
btn
.
data
(
'
confirmDangerMessage
'
);
e
.
preventDefault
();
// eslint-disable-next-line no-new
new
ConfirmDangerModal
(
form
,
text
);
const
$btn
=
$
(
e
.
target
);
const
$form
=
$btn
.
closest
(
'
form
'
);
const
text
=
$btn
.
data
(
'
confirmDangerMessage
'
);
initConfirmDangerModal
(
$form
,
text
);
});
$document
.
on
(
'
breakpoint:change
'
,
(
e
,
breakpoint
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment