git ssb

16+

Dominic / patchbay



Tree: 134d423c26820a78c6bbfbc506df577e0673b6b2

Files: 134d423c26820a78c6bbfbc506df577e0673b6b2 / modules / tabs.js

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

Built with git-ssb-web