git ssb

0+

ev / minbase



Tree: b62ecd6f843b26f37e70c7b6d65c71db35bbf922

Files: b62ecd6f843b26f37e70c7b6d65c71db35bbf922 / modules / message-confirm.js

1451 bytesRaw
1var lightbox = require('hyperlightbox')
2var h = require('hyperscript')
3var u = require('../util')
4var self_id = require('../keys').id
5
6var plugs = require('../plugs')
7
8exports.needs = {
9 publish: 'first', message_content: 'first', avatar: 'first',
10 message_meta: 'map'
11}
12
13exports.gives = 'message_confirm'
14
15exports.create = function (api) {
16 return function (content, cb) {
17
18 cb = cb || function () {}
19
20 var lb = lightbox()
21 document.body.appendChild(lb)
22
23 var msg = {
24 key: "DRAFT",
25 value: {
26 author: self_id,
27 previous: null,
28 sequence: null,
29 timestamp: Date.now(),
30 content: content
31 }
32 }
33
34 var okay = h('button', 'Publish', {onclick: function () {
35 lb.remove()
36 api.publish(content, cb)
37 }})
38
39 var cancel = h('button', 'Cancel', {onclick: function () {
40 lb.remove()
41 cb(null)
42 }})
43
44 okay.addEventListener('keydown', function (ev) {
45 if(ev.keyCode === 27) cancel.click() //escape
46 })
47
48 lb.show(h('div.column.message-confirm',
49 h('div.message',
50 h('div.title.row',
51 h('div.avatar', api.avatar(msg.value.author, 'thumbnail')),
52 h('div.message_meta.row', api.message_meta(msg))
53 ),
54 h('div.message_content',
55 api.message_content(msg) || h('pre', JSON.stringify(msg, null, 2))),
56 h('div.row.message-confirm__controls', okay, cancel)
57 )
58 ))
59
60 okay.focus()
61 }
62}
63
64

Built with git-ssb-web