Files: 449d051990b8d8149dd2a3bb9078e269533e324e / modules_core / external-confirm.js
933 bytesRaw
1 | var lightbox = require('hyperlightbox') |
2 | var h = require('hyperscript') |
3 | var open = require('open-external') |
4 | |
5 | exports.gives = 'external_confirm' |
6 | |
7 | exports.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