git ssb

16+

Dominic / patchbay



Tree: 8ecc2b31db3e6fad1ecee253703e89b979f4ae62

Files: 8ecc2b31db3e6fad1ecee253703e89b979f4ae62 / modules / message-confirm.js

956 bytesRaw
1var lightbox = require('hyperlightbox')
2var h = require('hyperscript')
3var u = require('../util')
4//publish or add
5
6var plugs = require('../plugs')
7
8var publish = plugs.first(exports.sbot_publish = [])
9var message_content = plugs.first(exports.message_content = [])
10
11exports.message_confirm = function (content, cb) {
12
13 cb = cb || function () {}
14
15 var lb = lightbox()
16 document.body.appendChild(lb)
17
18 var okay = h('button', 'okay', {onclick: function () {
19 lb.remove()
20 publish(content, cb)
21 }})
22
23 var cancel = h('button', 'cancel', {onclick: function () {
24 lb.remove()
25 }})
26
27 okay.addEventListener('keydown', function (ev) {
28 if(ev.keyCode === 27) cancel.click() //escape
29 })
30
31 lb.show(h('div.column.message-confirm',
32 message_content({key: "DRAFT", value: {content: content}})
33 || h('pre', JSON.stringify(content, null, 2)),
34 h('div.row.message-confirm__controls', okay, cancel)
35 ))
36
37 okay.focus()
38
39}
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

Built with git-ssb-web