git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit ae5dc8ad4e093e668b8fcff19e4434330f5d9d24

route to views via hash fragment. tabs is just another view

Dominic Tarr committed on 7/22/2016, 3:51:01 AM
Parent: 79737575585dc62349a1a2dc95a1ca4f2558e6c5

Files changed

modules/index.jschanged
modules/tabs.jschanged
modules/app.jsadded
modules/index.jsView
@@ -1,7 +1,8 @@
11 module.exports = {
22 "_screen_view.js": require('./_screen_view.js'),
33 "about.js": require('./about.js'),
4+ "app.js": require('./app.js'),
45 "avatar-image.js": require('./avatar-image.js'),
56 "avatar-profile.js": require('./avatar-profile.js'),
67 "avatar.js": require('./avatar.js'),
78 "blob-url.js": require('./blob-url.js'),
modules/tabs.jsView
@@ -11,18 +11,21 @@
1111 return el
1212 }
1313
1414 var plugs = require('../plugs')
15-var screen_view = plugs.first(exports.screen_view = [])
15+var screen_view = plugs.first(exports._screen_view = [])
1616 var search_box = plugs.first(exports.search_box = [])
1717
1818 exports.message_render = []
1919
20-exports.app = function () {
20+exports.screen_view = function (path) {
21+ if(path !== 'tabs')
22+ return
23+
2124 var search
2225 var tabs = Tabs(function (name) {
2326 search.value = name
24- sessionStorage.selectedTab = tabs.selected
27+// sessionStorage.selectedTab = tabs.selected
2528 })
2629 // tabs.classList.add('screen')
2730
2831 search = search_box(function (path, change) {
@@ -33,18 +36,18 @@
3336 var el = screen_view(path)
3437 if(el) {
3538 el.scroll = keyscroll(el.querySelector('.scroller__content'))
3639 tabs.add(path, el, change)
37- localStorage.openTabs = JSON.stringify(tabs.tabs)
40+// localStorage.openTabs = JSON.stringify(tabs.tabs)
3841 return change
3942 }
4043 })
4144
4245 tabs.insertBefore(search, tabs.querySelector('.hypertabs__content'))
4346
4447 var saved = []
45- try { saved = JSON.parse(localStorage.openTabs) }
46- catch (_) { }
48+// try { saved = JSON.parse(localStorage.openTabs) }
49+// catch (_) { }
4750
4851 if(!saved || saved.length < 3)
4952 saved = ['/public', '/private', '/notifications']
5053
@@ -54,9 +57,10 @@
5457 el.scroll = keyscroll(el.querySelector('.scroller__content'))
5558 if(el) tabs.add(path, el, false)
5659 })
5760
58- tabs.select(sessionStorage.selectedTab || saved[0] || '/public')
61+// tabs.select(sessionStorage.selectedTab || saved[0] || '/public')
62+ tabs.select('/public')
5963
6064 tabs.onclick = function (ev) {
6165 var link = ancestor(ev.target)
6266 if(!link) return
@@ -74,9 +78,9 @@
7478 var el = screen_view(path)
7579 if(el) {
7680 el.scroll = keyscroll(el.querySelector('.scroller__content'))
7781 tabs.add(path, el, !ev.ctrlKey)
78- localStorage.openTabs = JSON.stringify(tabs.tabs)
82+// localStorage.openTabs = JSON.stringify(tabs.tabs)
7983 }
8084
8185 return false
8286 }
@@ -103,9 +107,9 @@
103107 if (tabs.selected && tabs.selected[0] !== '/') {
104108 var sel = tabs.selected
105109 tabs.selectRelative(-1)
106110 tabs.remove(sel)
107- localStorage.openTabs = JSON.stringify(tabs.tabs)
111+// localStorage.openTabs = JSON.stringify(tabs.tabs)
108112 }
109113 return
110114
111115 // activate the search field
@@ -150,5 +154,4 @@
150154 })
151155
152156 return tabs
153157 }
154-
modules/app.jsView
@@ -1,0 +1,30 @@
1+var plugs = require('../plugs')
2+var h = require('hyperscript')
3+
4+var screen_view = plugs.first(exports.screen_view = [])
5+
6+exports.app = function () {
7+ function hash() {
8+ return window.location.hash.substring(1)
9+ }
10+
11+ var view = screen_view(hash() || 'tabs')
12+
13+ var screen = h('div.screen.column', view)
14+
15+ window.onhashchange = function (ev) {
16+ var _view = view
17+ screen.replaceChild(view = screen_view(hash()), _view)
18+ }
19+
20+ return screen
21+
22+}
23+
24+
25+
26+
27+
28+
29+
30+

Built with git-ssb-web