git ssb

16+

Dominic / patchbay



Tree: d329f1c18ca119d1dbf61156fbba8b18bc65efc3

Files: d329f1c18ca119d1dbf61156fbba8b18bc65efc3 / modules / tabs.js

1128 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
30 tabs.onclick = function (ev) {
31 var link = ancestor(ev.target)
32 if(!link) return
33 var path = link.hash.substring(1)
34
35 ev.preventDefault()
36 ev.stopPropagation()
37
38 //open external links.
39 //this ought to be made into something more runcible
40 if(/^https?/.test(link.href))
41 return require('shell').openExternal(link.href)
42
43 if(tabs.has(path)) return tabs.select(path)
44
45 var el = screen_view(path)
46 if(el) tabs.add(path, el, !ev.ctrlKey)
47
48 }
49
50 return tabs
51}
52
53
54
55
56

Built with git-ssb-web