git ssb

16+

Dominic / patchbay



Commit c37f01bff040ba1ea95748935110553a28c61bfa

Merge branch 'externalConfirm'

mix irving committed on 1/12/2017, 8:47:17 AM
Parent: 735a21fa879fddd250e0fe6224dbb269061f32d6
Parent: 968dba2f62d9e537fe3cd9013e6faa8f753e38a2

Files changed

modules_basic/message-backlinks.jschanged
modules_core/index.jschanged
modules_core/tabs.jschanged
modules_core/external-confirm.jsadded
modules_basic/message-backlinks.jsView
@@ -1,7 +1,11 @@
11 const fs = require('fs')
22 const h = require('../h')
33
4 +exports.needs = {
5 + message_name: 'first'
6 +}
7 +
48 exports.gives = {
59 message_backlinks: true,
610 mcss: true
711 }
@@ -26,14 +30,19 @@
2630 }
2731
2832 if (links.length === 0) return null
2933
34 + var hrefList = h('ul')
35 + links.forEach(link => {
36 + api.message_name(link, (err, name) => {
37 + if (err) throw err
38 + hrefList.appendChild(h('li',
39 + h('a -backlink', { href: `#${link}` }, name)
40 + ))
41 + })
42 + })
3043 return h('MessageBacklinks', [
3144 h('header', 'backlinks:'),
32- h('ul', links.map(link => {
33- return h('li', [
34- h('a -backlink', { href: `#${link}` }, link)
35- ])
36- }))
45 + hrefList
3746 ])
3847 }
3948 }
modules_core/index.jsView
@@ -2,8 +2,9 @@
22 // "_screen_view.js": require('./_screen_view.js'),
33 "app.js": require('./app.js'),
44 "blob-url.js": require('./blob-url.js'),
55 "crypto.js": require('./crypto.js'),
6 + "external-confirm.js": require('./external-confirm.js'),
67 "file-input.js": require('./file-input.js'),
78 "menu.js": require('./menu.js'),
89 "message-confirm.js": require('./message-confirm.js'),
910 "tabs.js": require('./tabs.js'),
modules_core/tabs.jsView
@@ -15,9 +15,9 @@
1515 //var screen_view = plugs.first(exports._screen_view = [])
1616 //var search_box = plugs.first(exports.search_box = [])
1717 //var menu = plugs.first(exports.menu = [])
1818
19-exports.needs = {screen_view: 'first', search_box: 'first', menu: 'first'}
19 +exports.needs = {screen_view: 'first', search_box: 'first', menu: 'first', 'external_confirm':'first'}
2020
2121 exports.gives = 'screen_view'
2222
2323 exports.create = function (api) {
@@ -94,9 +94,9 @@
9494 if (link.getAttribute('href') === '#') return
9595
9696 //open external links.
9797 //this ought to be made into something more runcible
98- if(open.isExternal(link.href)) return open(link.href)
98 + if(link.href && open.isExternal(link.href)) return api.external_confirm(link.href)
9999
100100 if(tabs.has(path))
101101 return tabs.select(path, !ev.ctrlKey, !!ev.shiftKey)
102102
modules_core/external-confirm.jsView
@@ -1,0 +1,37 @@
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.message-confirm',
26 + h('div.message',
27 + h('div.title.row',
28 + h('div.message_meta.row', h('strong', 'warning: '), 'please confirm opening the following link in your OSes browser:')
29 + ),
30 + h('div.message_content', h('pre', href))
31 + ),
32 + h('div.row.message-confirm__controls', okay, cancel)
33 + ))
34 +
35 + okay.focus()
36 + }
37 +}

Built with git-ssb-web