git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit ab14307386b2d8b56021d853931dbd6d636cff45

update hypertabs

Dominic Tarr committed on 8/28/2016, 11:07:43 AM
Parent: 3e6a0dc32fcfbe12e6fe6d56679d8bd4687ca841

Files changed

modules/tabs.jschanged
package.jsonchanged
modules/tabs.jsView
@@ -20,13 +20,20 @@
2020 exports.screen_view = function (path) {
2121 if(path !== 'tabs')
2222 return
2323
24+ function setSelected (indexes) {
25+ var ids = indexes.map(function (index) {
26+ return tabs.get(index).id
27+ })
28+ if(ids.length > 1)
29+ search.value = 'split('+ids.join(',')+')'
30+ else
31+ search.value = ids[0]
32+ }
33+
2434 var search
25- var tabs = Tabs(function (name) {
26- search.value = name
27-// sessionStorage.selectedTab = tabs.selected
28- })
35+ var tabs = Tabs(setSelected)
2936 // tabs.classList.add('screen')
3037
3138 search = search_box(function (path, change) {
3239 if(tabs.has(path)) {
@@ -35,9 +42,9 @@
3542 }
3643 var el = screen_view(path)
3744 if(el) {
3845 el.scroll = keyscroll(el.querySelector('.scroller__content'))
39- tabs.add(path, el, change)
46+ tabs.add(el, change)
4047 // localStorage.openTabs = JSON.stringify(tabs.tabs)
4148 return change
4249 }
4350 })
@@ -52,16 +59,17 @@
5259 saved = ['/public', '/private', '/notifications']
5360
5461 saved.forEach(function (path) {
5562 var el = screen_view(path)
63+ el.id = el.id || path
5664 if (!el) return
5765 el.scroll = keyscroll(el.querySelector('.scroller__content'))
58- if(el) tabs.add(path, el, false)
66+ if(el) tabs.add(el, false, false)
5967 })
6068
61-// tabs.select(sessionStorage.selectedTab || saved[0] || '/public')
62- tabs.select('/public')
69+ tabs.select(0)
6370
71+ //handle link clicks
6472 window.onclick = function (ev) {
6573 var link = ancestor(ev.target)
6674 if(!link) return
6775 var path = link.hash.substring(1)
@@ -72,14 +80,16 @@
7280 //open external links.
7381 //this ought to be made into something more runcible
7482 if(open.isExternal(link.href)) return open(link.href)
7583
76- if(tabs.has(path)) return tabs.select(path)
77-
84+ if(tabs.has(path))
85+ return tabs.select(path, !ev.ctrlKey, !!ev.shiftKey)
86+
7887 var el = screen_view(path)
7988 if(el) {
89+ el.id = el.id || path
8090 el.scroll = keyscroll(el.querySelector('.scroller__content'))
81- tabs.add(path, el, !ev.ctrlKey)
91+ tabs.add(el, !ev.ctrlKey, !!ev.shiftKey)
8292 // localStorage.openTabs = JSON.stringify(tabs.tabs)
8393 }
8494
8595 return false
@@ -97,19 +107,19 @@
97107 return tabs.selectRelative(1)
98108
99109 // scroll through messages
100110 case 74: // j
101- return tabs.selectedTab.scroll(1)
111+ return tabs.get(tabs.selected[0]).scroll(1)
102112 case 75: // k
103- return tabs.selectedTab.scroll(-1)
113+ return tabs.get(tabs.selected[0]).scroll(-1)
104114
105115 // close a tab
106116 case 88: // x
107- if (tabs.selected/* && tabs.selected[0] !== '/'*/) {
117+ if (tabs.selected) {
108118 var sel = tabs.selected
109- tabs.selectRelative(-1)
119+ var i = sel.reduce(function (a, b) { return Math.min(a, b) })
110120 tabs.remove(sel)
111-// localStorage.openTabs = JSON.stringify(tabs.tabs)
121+ tabs.select(Math.max(i-1, 0))
112122 }
113123 return
114124
115125 // activate the search field
@@ -154,4 +164,5 @@
154164 })
155165
156166 return tabs
157167 }
168+
package.jsonView
@@ -17,9 +17,9 @@
1717 "hyperfile": "^1.1.0",
1818 "hyperlightbox": "^0.1.3",
1919 "hyperprogress": "0.1.0",
2020 "hyperscript": "^1.4.7",
21- "hypertabs": "^1.2.0",
21+ "hypertabs": "^2.1.0",
2222 "is-visible": "^2.0.4",
2323 "map-filter-reduce": "^3.0.1",
2424 "mime-types": "^2.1.11",
2525 "moment": "^2.13.0",

Built with git-ssb-web