Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Kudos-Donations
Commits
330a9836
Commit
330a9836
authored
Oct 12, 2021
by
Michael Iseard
Browse files
Move trigger to options
parent
0d46e75d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/public/KudosModal.js
View file @
330a9836
class
KudosModal
{
constructor
(
modal
,
trigger
=
null
,
options
=
[])
{
constructor
(
modal
,
options
=
[])
{
this
.
isOpen
=
false
this
.
modal
=
document
.
getElementById
(
modal
)
this
.
trigger
=
trigger
this
.
closeModal
=
this
.
modal
.
querySelectorAll
(
'
[data-modal-close]
'
)
this
.
options
=
{
timeOut
:
options
.
timeOut
??
300
,
triggerElement
:
options
.
triggerElement
,
escapeClose
:
options
.
escapeClose
??
true
,
overlayClose
:
options
.
overlayClose
??
false
,
openClass
:
options
.
openClass
??
'
is-open
'
,
...
...
@@ -35,8 +35,8 @@ class KudosModal {
this
.
handleClick
=
this
.
handleClick
.
bind
(
this
)
// Click event listener for trigger element
if
(
this
.
trigger
)
{
this
.
trigger
.
addEventListener
(
"
click
"
,
()
=>
{
if
(
this
.
options
.
triggerElement
)
{
this
.
options
.
triggerElement
.
addEventListener
(
"
click
"
,
()
=>
{
if
(
this
.
isOpen
)
{
return
this
.
close
()
}
...
...
src/public/kudos-public.js
View file @
330a9836
...
...
@@ -101,7 +101,8 @@ jQuery(document).ready(($) => {
const
modal
=
button
.
dataset
.
kudosTarget
new
KudosModal
(
modal
,
button
,
{
new
KudosModal
(
modal
,
{
triggerElement
:
button
,
onOpen
:
(
modal
)
=>
{
const
form
=
modal
.
querySelector
(
'
.kudos-form
'
)
animateProgressBar
(
form
)
...
...
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