git ssb

16+

Dominic / patchbay



Tree: 26afbb3703400ed773df3fdb62dd05be51b56dab

Files: 26afbb3703400ed773df3fdb62dd05be51b56dab / modules / tabs.js

1039 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 console.log(link)
33
34 ev.preventDefault()
35 ev.stopPropagation()
36
37 if(!path)
38 return require('shell').openExternal(link.href)
39
40 if(tabs.has(path)) return tabs.select(path)
41
42 var el = screen(path)
43 if(el) tabs.add(path, el, !ev.ctrlKey)
44
45 }
46
47 return tabs
48}
49
50exports.message_render = []
51exports.screen_view = []
52
53
54
55

Built with git-ssb-web