47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
const Dialogue = {
|
|
showDialogueData: null,
|
|
|
|
showDialogue: function(title, message, yes, yesclass, no, noclass, data, cb) {
|
|
Dialogue.showDialogueData = {
|
|
title: title,
|
|
message: message,
|
|
yes: yes,
|
|
yesclass: yesclass || '',
|
|
no: no,
|
|
noclass: noclass || '',
|
|
data: data,
|
|
cb: cb,
|
|
}
|
|
},
|
|
|
|
onclick: function(clickedYes) {
|
|
if (clickedYes) {
|
|
Dialogue.showDialogueData.cb(Dialogue.showDialogueData.data)
|
|
}
|
|
this.onclose()
|
|
m.redraw()
|
|
},
|
|
|
|
onclose: function() {
|
|
Dialogue.showDialogueData = null
|
|
},
|
|
|
|
view: function(vnode) {
|
|
let data = Dialogue.showDialogueData
|
|
return data
|
|
? m('div.floating-container.main', {
|
|
onclick: this.onclose.bind(this),
|
|
}, m('dialogue', { onclick: function(e) { e.stopPropagation() } }, [
|
|
m('h2.title', data.title),
|
|
m('p', data.message),
|
|
m('div.buttons', [
|
|
m('button', { class: data.yesclass , onclick: this.onclick.bind(this) }, data.yes),
|
|
m('button', { class: data.noclass, onclick: this.onclose.bind(this) }, data.no),
|
|
]),
|
|
])
|
|
)
|
|
: null
|
|
},
|
|
}
|
|
|
|
module.exports = Dialogue
|