Files: bfe1cc1971947547bf1a8c0d9facad16ba4eb786 / modules_core / message-confirm.js
952 bytesRaw
1 | var lightbox = require('hyperlightbox') |
2 | var h = require('hyperscript') |
3 | var u = require('../util') |
4 | //publish or add |
5 | |
6 | var plugs = require('../plugs') |
7 | |
8 | var publish = plugs.first(exports.sbot_publish = []) |
9 | var message_content = plugs.first(exports.message_content = []) |
10 | |
11 | exports.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 | lb.remove() |
20 | publish(content, cb) |
21 | }}) |
22 | |
23 | var cancel = h('button', 'cancel', {onclick: function () { |
24 | lb.remove() |
25 | cb(null) |
26 | }}) |
27 | |
28 | okay.addEventListener('keydown', function (ev) { |
29 | if(ev.keyCode === 27) cancel.click() //escape |
30 | }) |
31 | |
32 | lb.show(h('div.column.message-confirm', |
33 | message_content({key: "DRAFT", value: {content: content}}) |
34 | || h('pre', JSON.stringify(content, null, 2)), |
35 | h('div.row.message-confirm__controls', okay, cancel) |
36 | )) |
37 | |
38 | okay.focus() |
39 | |
40 | } |
41 | |
42 |
Built with git-ssb-web