git ssb

16+

Dominic / patchbay



Tree: 6b5fd322755eecdeebda31ed6090e626cebdc243

Files: 6b5fd322755eecdeebda31ed6090e626cebdc243 / modules_core / external-confirm.js

1077 bytesRaw
1const lightbox = require('hyperlightbox')
2const fs = require('fs')
3const h = require('../h')
4const open = require('open-external')
5
6exports.gives = {
7 external_confirm: true,
8 mcss:true
9}
10
11exports.create = function (api) {
12 return {
13 external_confirm,
14 mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
15 }
16
17 function external_confirm (href) {
18 var lb = lightbox()
19 document.body.appendChild(lb)
20
21 var okay = h('button.okay', {
22 'ev-click': () => {
23 lb.remove()
24 open(href)
25 }},
26 'open'
27 )
28
29 var cancel = h('button.cancel', {
30 'ev-click': () => {
31 lb.remove()
32 }},
33 'cancel'
34 )
35
36 okay.addEventListener('keydown', function (ev) {
37 if (ev.keyCode === 27) cancel.click() // escape
38 })
39
40 lb.show(h('ExternalConfirm', [
41 h('header', 'External link'),
42 h('section.prompt', [
43 h('div.question', 'Open this link in your external browser?'),
44 h('pre.link', href)
45 ]),
46 h('section.actions', [cancel, okay])
47 ]))
48
49 okay.focus()
50 }
51}
52

Built with git-ssb-web