Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
elements/modal: fix onexit logic in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Mar 16, 2017
1 parent 5dd34bf commit b08cff0
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions elements/modal.js
Expand Up @@ -246,9 +246,13 @@ function crashModal () {
}

function errorModal () {
return Modal({ render: render })
return Modal({
render: render,
onexit: onexit,
class: 'modal'
})

function render (message, onexit) {
function render (message) {
var exitButton = button.green('Ok', {
class: 'fr ml3',
onclick: onexit
Expand All @@ -268,12 +272,21 @@ function errorModal () {
</div>
`
}

function onexit () {
const el = document.querySelector('.modal')
if (el) el.parentNode.removeChild(el)
}
}

function warningModal () {
return Modal({ render: render })
return Modal({
render: render,
onexit: onexit,
class: 'modal'
})

function render (message, onexit) {
function render (message) {
var exitButton = button.green('Ok', {
class: 'fr ml3',
onclick: onexit
Expand All @@ -293,6 +306,11 @@ function warningModal () {
</div>
`
}

function onexit () {
const el = document.querySelector('.modal')
if (el) el.parentNode.removeChild(el)
}
}

function linkModal () {
Expand Down

0 comments on commit b08cff0

Please sign in to comment.