git ssb

16+

Dominic / patchbay



Tree: 7b8459c024b593664fa22d32c9b9bcccfe02a2fa

Files: 7b8459c024b593664fa22d32c9b9bcccfe02a2fa / modules / tabs.js

943 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
13exports.app = function (_, sbot) {
14 function screen (path) {
15 return u.firstPlug(exports.screen_view, path, sbot)
16 }
17
18 var tabs = Tabs()
19 tabs.classList.add('screen')
20 var main = screen('/')
21 if(main) tabs.add('main', main, true)
22
23 var private = screen('/private')
24 if(private) tabs.add('private', private, true)
25
26
27 tabs.onclick = function (ev) {
28 var link = ancestor(ev.target)
29 if(!link) return
30 var path = link.hash.substring(1)
31
32 ev.preventDefault()
33 ev.stopPropagation()
34
35 if(tabs.has(path)) return tabs.select(path)
36
37 var el = screen(path)
38 if(el) tabs.add(path, el, !ev.ctrlKey)
39
40 }
41
42 return tabs
43}
44
45exports.message_render = []
46exports.screen_view = []
47
48
49
50

Built with git-ssb-web