Commit 330a9836 authored by Michael Iseard's avatar Michael Iseard
Browse files

Move trigger to options

parent 0d46e75d
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()
}
......
......@@ -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)
......
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