git ssb

0+

dangerousbeans / patchbay-bootstrap



Commit 567b32727710add1401610208245e6950f200f06

Consolidate text field for search and channel

Charles Lehner committed on 6/28/2016, 3:08:02 AM
Parent: 29997160555aa9df4541f65ba3ca7b58d4a8c9c4

Files changed

modules/tabs.jschanged
modules/tabs.jsView
@@ -39,14 +39,14 @@
3939 style: {'float': 'right'},
4040 onkeydown: function (ev) {
4141 switch (ev.keyCode) {
4242 case 13: // enter
43- var path = '?' + search.value
43+ var path = search.value
4444 if(tabs.has(path)) return tabs.select(path)
4545 var el = screen_view(path)
4646 if(el) {
4747 el.scroll = keyscroll(el.querySelector('.scroller__content'))
48- tabs.add('?' + search.value, el, !ev.ctrlKey)
48+ tabs.add(path, el, !ev.ctrlKey)
4949 localStorage.openTabs = JSON.stringify(tabs.tabs)
5050 search.blur()
5151 }
5252 return
@@ -58,8 +58,19 @@
5858 }
5959 })
6060 tabs.insertBefore(search, tabs.querySelector('.hypertabs__content'))
6161
62+ function activateSearch(sigil, ev) {
63+ search.focus()
64+ ev.preventDefault()
65+ if (search.value[0] === sigil) {
66+ search.selectionStart = 1
67+ search.selectionEnd = search.value.length
68+ } else {
69+ search.value = sigil
70+ }
71+ }
72+
6273 var saved
6374 try { saved = JSON.parse(localStorage.openTabs) }
6475 catch (_) { saved = ['/public', '/private'] }
6576
@@ -120,13 +131,16 @@
120131 return
121132
122133 // activate the search field
123134 case 191: // /
124- ev.preventDefault()
125- search.focus()
126- search.selectionStart = 0
127- search.selectionEnd = search.value.length
135+ activateSearch('?', ev)
128136 return
137+
138+ // navigate to a channel
139+ case 51: // 3
140+ if (ev.shiftKey)
141+ activateSearch('#', ev)
142+ return
129143 }
130144 })
131145
132146 return tabs

Built with git-ssb-web