git ssb

10+

Matt McKegg / patchwork



Tree: 2cccc563e935c542ce7c37f90eab873bdc17f1ac

Files: 2cccc563e935c542ce7c37f90eab873bdc17f1ac / modules / message-confirm.js

1039 bytesRaw
1var lightbox = require('hyperlightbox')
2var h = require('../lib/h')
3var plugs = require('patchbay/plugs')
4var get_id = plugs.first(exports.get_id = [])
5var publish = plugs.first(exports.sbot_publish = [])
6var message_render = plugs.first(exports.message_render = [])
7
8exports.message_confirm = function (content, cb) {
9 cb = cb || function () {}
10
11 var lb = lightbox()
12 document.body.appendChild(lb)
13
14 var msg = {
15 value: {
16 author: get_id(),
17 previous: null,
18 sequence: null,
19 timestamp: Date.now(),
20 content: content
21 }
22 }
23
24 var okay = h('button', {
25 'ev-click': function () {
26 lb.remove()
27 publish(content, cb)
28 },
29 'ev-keydown': function (ev) {
30 if (ev.keyCode === 27) cancel.click() // escape
31 }
32 }, [
33 'okay'
34 ])
35
36 var cancel = h('button', {'ev-click': function () {
37 lb.remove()
38 cb(null)
39 }}, [
40 'Cancel'
41 ])
42
43 lb.show(h('MessageConfirm', [
44 h('section', [
45 message_render(msg)
46 ]),
47 h('footer', [okay, cancel])
48 ]))
49
50 okay.focus()
51}
52

Built with git-ssb-web