git ssb

16+

Dominic / patchbay



Tree: cdcccc55e2a0881ced884e834c3ebda3fd1e9ceb

Files: cdcccc55e2a0881ced884e834c3ebda3fd1e9ceb / modules / tabs.js

1162 bytesRaw
1var Tabs = require('hypertabs')
2var h = require('hyperscript')
3var pull = require('pull-stream')
4var u = require('../util')
5
6
7function ancestor (el) {
8 if(!el) return
9 if(el.tagName !== 'A') return ancestor(el.parentElement)
10 return el
11}
12
13var plugs = require('../plugs')
14var screen_view = plugs.first(exports.screen_view = [])
15
16exports.message_render = []
17
18
19exports.app = function (_, sbot) {
20 var tabs = Tabs()
21 tabs.classList.add('screen')
22
23 var public = screen_view('/public')
24 if(public) tabs.add('public', public, true)
25
26 var private = screen_view('/private')
27 if(private) tabs.add('private', private, true)
28
29 tabs.select('public')
30
31
32 tabs.onclick = function (ev) {
33 var link = ancestor(ev.target)
34 if(!link) return
35 var path = link.hash.substring(1)
36
37 ev.preventDefault()
38 ev.stopPropagation()
39
40 //open external links.
41 //this ought to be made into something more runcible
42 if(/^https?/.test(link.href))
43 return require('electron').shell.openExternal(link.href)
44
45 if(tabs.has(path)) return tabs.select(path)
46
47 var el = screen_view(path)
48 if(el) tabs.add(path, el, !ev.ctrlKey)
49
50 }
51
52 return tabs
53}
54
55
56
57
58

Built with git-ssb-web