git ssb

1+

ev / minbay



Tree: afe7de9580840925af61711b5ab0d6c57d1131a4

Files: afe7de9580840925af61711b5ab0d6c57d1131a4 / modules / message-confirm.js

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

Built with git-ssb-web