Commit 2f3a722c authored by Michael Iseard's avatar Michael Iseard
Browse files

Create events for showing and closing the modal

parent f3c76d3b
......@@ -77,7 +77,7 @@ $(() => {
if ($kudosButtons.length) {
// Setup button action
$kudosButtons.each(function () {
$kudosButtons.each(function (e) {
const target = $(this).data('target')
......@@ -86,6 +86,10 @@ $(() => {
MicroModal.show(target, {
onShow(modal) {
// Create and dispatch event
const modalEvent = new CustomEvent('kudosShowModal', {detail: modal})
window.dispatchEvent(modalEvent)
// Clear error message
$(modal)
.find('.kudos_error_message')
......@@ -108,14 +112,11 @@ $(() => {
$form.validate().resetForm()
$form[0].reset()
}
// Progress bar
let progressBar = modal.querySelector('.kudos-campaign-progress')
if(progressBar) {
let percent = progressBar.dataset.percent / 100
let bar = progressBar.querySelector('.kudos-progress-bar')
setTimeout(() => bar.style.transform = "scaleX(" + percent + ")", 500)
}
},
onClose(modal) {
// Create and dispatch event
const modalEvent = new CustomEvent('kudosCloseModal', {detail: modal})
window.dispatchEvent(modalEvent)
},
awaitCloseAnimation: true,
})
......
Supports Markdown
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