Files: c2421901bdd957ae5e4d3f66accdd85bfd7cd5c8 / modules / message-confirm.js
1039 bytesRaw
1 | var lightbox = require('hyperlightbox') |
2 | var h = require('../lib/h') |
3 | var plugs = require('patchbay/plugs') |
4 | var get_id = plugs.first(exports.get_id = []) |
5 | var publish = plugs.first(exports.sbot_publish = []) |
6 | var message_render = plugs.first(exports.message_render = []) |
7 | |
8 | exports.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