git ssb

16+

Dominic / patchbay



Tree: 22ac3515bce601bc6b12f4d9711872d620a91d91

Files: 22ac3515bce601bc6b12f4d9711872d620a91d91 / modules / message-confirm.js

921 bytesRaw
1var lightbox = require('hyperlightbox')
2var h = require('hyperscript')
3var u = require('../util')
4//publish or add
5
6var plugs = require('../plugs')
7
8var publish = plugs.first(exports.publish = [])
9var message_content = plugs.first(exports.message_content = [])
10
11exports.message_confirm = function (content, cb) {
12
13 cb = cb || function () {}
14
15 var lb = lightbox()
16 document.body.appendChild(lb)
17
18 var okay = h('button', 'okay', {onclick: function () {
19 publish(content); lb.remove(); cb(null, content)
20 }})
21
22 var cancel = h('button', 'cancel', {onclick: function () {
23 lb.remove()
24 }})
25
26 okay.addEventListener('keydown', function (ev) {
27 if(ev.keyCode === 27) cancel.click() //escape
28 })
29
30 lb.show(h('div.column',
31 message_content({key: "DRAFT", value: {content: content}})
32 || h('pre', JSON.stringify(content, null, 2)),
33 h('div.row', okay, cancel)
34 ))
35
36 okay.focus()
37
38}
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

Built with git-ssb-web