Commit 29160dfc50920ef4a843f78792e42bf1f2a71353
re link the page ids to the "command" bar
mix irving committed on 2/2/2017, 11:00:41 PMParent: 6ae6f1ce78d440dea5e42c9ab6d0112732b161f6
Files changed
modules_core/search-box.js | changed |
modules_core/tabs.js | changed |
modules_extra/search.js | changed |
modules_core/search-box.js | |||
---|---|---|---|
@@ -26,9 +26,8 @@ | |||
26 | 26 … | placeholder: 'Commands', | |
27 | 27 … | 'ev-keyup': ev => { | |
28 | 28 … | switch (ev.keyCode) { | |
29 | 29 … | case 13: // enter | |
30 | - console.log(ev) | ||
31 | 30 … | ev.stopPropagation() | |
32 | 31 … | suggestBox.complete() | |
33 | 32 … | ||
34 | 33 … | if (go(input.value.trim(), !ev.ctrlKey)) | |
@@ -42,8 +41,9 @@ | |||
42 | 41 … | } | |
43 | 42 … | }) | |
44 | 43 … | const search = h('Search', input) | |
45 | 44 … | ||
45 … | + search.input = input | ||
46 | 46 … | search.activate = (sigil, ev) => { | |
47 | 47 … | input.focus() | |
48 | 48 … | ev.preventDefault() | |
49 | 49 … | if (input.value[0] === sigil) { |
modules_core/tabs.js | ||
---|---|---|
@@ -23,39 +23,34 @@ | ||
23 | 23 … | return function (path) { |
24 | 24 … | if(path !== 'tabs') return |
25 | 25 … | |
26 | 26 … | function setSelected (indexes) { |
27 | - var ids = indexes.map(function (index) { | |
28 | - return tabs.get(index).id | |
29 | - }) | |
27 … | + const ids = indexes.map(index => tabs.get(index).content.id) | |
30 | 28 … | if(search) |
31 | 29 … | if(ids.length > 1) |
32 | - search.value = 'split('+ids.join(',')+')' | |
30 … | + search.input.value = 'split('+ids.join(',')+')' | |
33 | 31 … | else |
34 | - search.value = ids[0] | |
32 … | + search.input.value = ids[0] | |
35 | 33 … | } |
36 | 34 … | |
37 | - var search | |
38 | - var tabs = Tabs(setSelected) | |
39 | - | |
40 | - search = api.search_box(function (path, change) { | |
41 | - | |
35 … | + const tabs = Tabs(setSelected) | |
36 … | + const search = api.search_box((path, change) => { | |
42 | 37 … | if(tabs.has(path)) { |
43 | 38 … | tabs.select(path) |
44 | 39 … | return true |
45 | 40 … | } |
46 | - var el = api.screen_view(path) | |
47 | 41 … | |
48 | - if(el) { | |
49 | - if(!el.title) el.title = path | |
50 | - el.scroll = keyscroll(el.querySelector('.Scroller .\\.content')) | |
51 | - tabs.add(el, change) | |
52 | - // localStorage.openTabs = JSON.stringify(tabs.tabs) | |
53 | - return change | |
54 | - } | |
42 … | + const el = api.screen_view(path) | |
43 … | + if (!el) return | |
44 … | + | |
45 … | + if(!el.title) el.title = path | |
46 … | + el.scroll = keyscroll(el.querySelector('.Scroller .\\.content')) | |
47 … | + tabs.add(el, change) | |
48 … | +// localStorage.openTabs = JSON.stringify(tabs.tabs) | |
49 … | + return change | |
55 | 50 … | }) |
56 | 51 … | |
57 | - // TODO add a Tabs(setSelected, { append: el }) to hypertabs | |
52 … | + // TODO add options to Tabs : e.g. Tabs(setSelected, { append: el }) | |
58 | 53 … | tabs.firstChild.appendChild( |
59 | 54 … | h('div.extra', [ |
60 | 55 … | search, |
61 | 56 … | api.menu() |
@@ -78,8 +73,9 @@ | ||
78 | 73 … | if(el) tabs.add(el, false, false) |
79 | 74 … | }) |
80 | 75 … | |
81 | 76 … | tabs.select(0) |
77 … | + search.input.value = null // start with an empty field to show placeholder | |
82 | 78 … | |
83 | 79 … | //handle link clicks |
84 | 80 … | window.onclick = function (ev) { |
85 | 81 … | var link = ancestor(ev.target) |
modules_extra/search.js | ||
---|---|---|
@@ -61,8 +61,9 @@ | ||
61 | 61 … | var total = 0, matches = 0 |
62 | 62 … | |
63 | 63 … | var header = h('div.search_header', '') |
64 | 64 … | var { container, content } = api.build_scroller({ prepend: header}) |
65 … | + container.id = path // helps tabs find this tab | |
65 | 66 … | |
66 | 67 … | function matchesQuery (data) { |
67 | 68 … | total++ |
68 | 69 … | var m = _matches(data) |
Built with git-ssb-web