git ssb

3+

dangerousbeans / scuttle-vue



Tree: 8dc25143a3f37f1618f7a92b3c46dec512b43bfd

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

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

Built with git-ssb-web