Files: c05e98ca66758d61b5968645419a1efaaad16bfd / app / html / external-confirm.js
1027 bytesRaw
1 | const nest = require('depnest') |
2 | const lightbox = require('hyperlightbox') |
3 | const { h } = require('mutant') |
4 | const open = require('open-external') |
5 | |
6 | exports.gives = nest('app.html.externalConfirm') |
7 | |
8 | exports.create = function (api) { |
9 | return nest('app.html.externalConfirm', externalConfirm) |
10 | |
11 | function externalConfirm (href) { |
12 | var lb = lightbox() |
13 | document.body.appendChild(lb) |
14 | |
15 | var okay = h('button.okay', { |
16 | 'ev-click': () => { |
17 | lb.remove() |
18 | open(href) |
19 | }}, |
20 | 'open' |
21 | ) |
22 | |
23 | var cancel = h('button.cancel', { |
24 | 'ev-click': () => { |
25 | lb.remove() |
26 | }}, |
27 | 'cancel' |
28 | ) |
29 | |
30 | okay.addEventListener('keydown', function (ev) { |
31 | if (ev.keyCode === 27) cancel.click() // escape |
32 | }) |
33 | |
34 | lb.show(h('ExternalConfirm', [ |
35 | h('header', 'External link'), |
36 | h('section.prompt', [ |
37 | h('div.question', 'Open this link in your external browser?'), |
38 | h('pre.link', href) |
39 | ]), |
40 | h('section.actions', [cancel, okay]) |
41 | ])) |
42 | |
43 | okay.focus() |
44 | } |
45 | } |
46 |
Built with git-ssb-web