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
Boxiang Sun
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
$
from
'
jquery
'
;
import
{
rstrip
}
from
'
./lib/utils/common_utils
'
;
import
{
rstrip
}
from
'
./lib/utils/common_utils
'
;
window
.
ConfirmDangerModal
=
(
function
()
{
export
default
function
initConfirmDangerModal
(
$form
,
text
)
{
function
ConfirmDangerModal
(
form
,
text
)
{
var
project_path
,
submit
;
this
.
form
=
form
;
$
(
'
.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
'
);
project_path
=
$
(
'
.js-confirm-danger-match
'
).
text
();
submit
=
$
(
'
.js-confirm-danger-submit
'
);
const
confirmTextMatch
=
$
(
'
.js-confirm-danger-match
'
).
text
();
submit
.
disable
();
const
$submit
=
$
(
'
.js-confirm-danger-submit
'
);
$
(
'
.js-confirm-danger-input
'
).
off
(
'
input
'
);
$submit
.
disable
();
$
(
'
.js-confirm-danger-input
'
).
on
(
'
input
'
,
function
()
{
if
(
rstrip
(
$
(
this
).
val
())
===
project_path
)
{
$
(
'
.js-confirm-danger-input
'
).
off
(
'
input
'
).
on
(
'
input
'
,
function
handleInput
()
{
return
submit
.
enable
();
const
confirmText
=
rstrip
(
$
(
this
).
val
());
if
(
confirmText
===
confirmTextMatch
)
{
$submit
.
enable
();
}
else
{
}
else
{
return
submit
.
disable
();
$
submit
.
disable
();
}
}
});
});
$
(
'
.js-confirm-danger-submit
'
).
off
(
'
click
'
);
$
(
'
.js-confirm-danger-submit
'
).
off
(
'
click
'
).
on
(
'
click
'
,
()
=>
$form
.
submit
());
$
(
'
.js-confirm-danger-submit
'
).
on
(
'
click
'
,
(
function
(
_this
)
{
}
return
function
()
{
return
_this
.
form
.
submit
();
};
})(
this
));
}
return
ConfirmDangerModal
;
})();
app/assets/javascripts/main.js
View file @
43ff14e0
/* eslint-disable import/first */
/* eslint-disable import/first */
/* global ConfirmDangerModal */
/* global $ */
/* global $ */
import
jQuery
from
'
jquery
'
;
import
jQuery
from
'
jquery
'
;
...
@@ -21,7 +20,7 @@ import './behaviors/';
...
@@ -21,7 +20,7 @@ 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
'
./confirm_danger_modal
'
;
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
'
;
...
@@ -215,13 +214,11 @@ document.addEventListener('DOMContentLoaded', () => {
...
@@ -215,13 +214,11 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
$document
.
on
(
'
click
'
,
'
.js-confirm-danger
'
,
(
e
)
=>
{
$document
.
on
(
'
click
'
,
'
.js-confirm-danger
'
,
(
e
)
=>
{
const
btn
=
$
(
e
.
target
);
const
form
=
btn
.
closest
(
'
form
'
);
const
text
=
btn
.
data
(
'
confirmDangerMessage
'
);
e
.
preventDefault
();
e
.
preventDefault
();
const
$btn
=
$
(
e
.
target
);
// eslint-disable-next-line no-new
const
$form
=
$btn
.
closest
(
'
form
'
);
new
ConfirmDangerModal
(
form
,
text
);
const
text
=
$btn
.
data
(
'
confirmDangerMessage
'
);
initConfirmDangerModal
(
$form
,
text
);
});
});
$document
.
on
(
'
breakpoint:change
'
,
(
e
,
breakpoint
)
=>
{
$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