git ssb

16+

Dominic / patchbay



Tree: 813918c942c3e2bf314279eb10a587d09d7826dc

Files: 813918c942c3e2bf314279eb10a587d09d7826dc / modules_core / external-confirm.js

933 bytesRaw
1var lightbox = require('hyperlightbox')
2var h = require('hyperscript')
3var open = require('open-external')
4
5exports.gives = 'external_confirm'
6
7exports.create = function (api) {
8 return function (href) {
9 var lb = lightbox()
10 document.body.appendChild(lb)
11
12 var okay = h('button', 'open', {onclick: function () {
13 lb.remove()
14 open(href)
15 }})
16
17 var cancel = h('button', 'Cancel', {onclick: function () {
18 lb.remove()
19 }})
20
21 okay.addEventListener('keydown', function (ev) {
22 if (ev.keyCode === 27) cancel.click() // escape
23 })
24
25 lb.show(h('div.column',
26 h('div', [
27 h('div.title.row', [
28 h('strong.row', [
29 'Do you want to open this external link in your default browser:'
30 ])
31 ]),
32 h('div', [
33 h('pre', href)
34 ])
35 ]),
36 h('div.row', [
37 okay,
38 cancel
39 ])
40 ))
41
42 okay.focus()
43 }
44}
45

Built with git-ssb-web