Commit 567b32727710add1401610208245e6950f200f06
Consolidate text field for search and channel
Charles Lehner committed on 6/28/2016, 3:08:02 AMParent: 29997160555aa9df4541f65ba3ca7b58d4a8c9c4
Files changed
modules/tabs.js | changed |
modules/tabs.js | ||
---|---|---|
@@ -39,14 +39,14 @@ | ||
39 | 39 | style: {'float': 'right'}, |
40 | 40 | onkeydown: function (ev) { |
41 | 41 | switch (ev.keyCode) { |
42 | 42 | case 13: // enter |
43 | - var path = '?' + search.value | |
43 | + var path = search.value | |
44 | 44 | if(tabs.has(path)) return tabs.select(path) |
45 | 45 | var el = screen_view(path) |
46 | 46 | if(el) { |
47 | 47 | el.scroll = keyscroll(el.querySelector('.scroller__content')) |
48 | - tabs.add('?' + search.value, el, !ev.ctrlKey) | |
48 | + tabs.add(path, el, !ev.ctrlKey) | |
49 | 49 | localStorage.openTabs = JSON.stringify(tabs.tabs) |
50 | 50 | search.blur() |
51 | 51 | } |
52 | 52 | return |
@@ -58,8 +58,19 @@ | ||
58 | 58 | } |
59 | 59 | }) |
60 | 60 | tabs.insertBefore(search, tabs.querySelector('.hypertabs__content')) |
61 | 61 | |
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 | + | |
62 | 73 | var saved |
63 | 74 | try { saved = JSON.parse(localStorage.openTabs) } |
64 | 75 | catch (_) { saved = ['/public', '/private'] } |
65 | 76 | |
@@ -120,13 +131,16 @@ | ||
120 | 131 | return |
121 | 132 | |
122 | 133 | // activate the search field |
123 | 134 | case 191: // / |
124 | - ev.preventDefault() | |
125 | - search.focus() | |
126 | - search.selectionStart = 0 | |
127 | - search.selectionEnd = search.value.length | |
135 | + activateSearch('?', ev) | |
128 | 136 | return |
137 | + | |
138 | + // navigate to a channel | |
139 | + case 51: // 3 | |
140 | + if (ev.shiftKey) | |
141 | + activateSearch('#', ev) | |
142 | + return | |
129 | 143 | } |
130 | 144 | }) |
131 | 145 | |
132 | 146 | return tabs |
Built with git-ssb-web