2019-09-13 13:33:10 +00:00
|
|
|
const Dialogue = {
|
2022-08-08 16:58:20 +00:00
|
|
|
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
|
|
|
|
},
|
|
|
|
|
2019-09-13 13:33:10 +00:00
|
|
|
view: function(vnode) {
|
2022-08-08 16:58:20 +00:00
|
|
|
let data = Dialogue.showDialogueData
|
|
|
|
return data
|
2022-08-12 23:33:50 +00:00
|
|
|
? m('div.floating-container.main', {
|
|
|
|
onclick: this.onclose.bind(this),
|
|
|
|
}, m('dialogue', { onclick: function(e) { e.stopPropagation() } }, [
|
2022-08-08 16:58:20 +00:00
|
|
|
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
|
2019-09-13 13:33:10 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Dialogue
|