git ssb

16+

Dominic / patchbay



Tree: c1a1dc7a8dc3f88bd242e418cb5715798385f4e4

Files: c1a1dc7a8dc3f88bd242e418cb5715798385f4e4 / app / html / external-confirm.js

1031 bytesRaw
1const nest = require('depnest')
2const lightbox = require('hyperlightbox')
3const { h } = require('mutant')
4const open = require('open-external')
5
6exports.gives = nest('app.html.externalConfirm')
7
8exports.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.-subtle', {
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