Merge "ui: Remove unused code in omnibox"
diff --git a/ui/src/assets/topbar.scss b/ui/src/assets/topbar.scss
index fc5fa45..7daa9fc 100644
--- a/ui/src/assets/topbar.scss
+++ b/ui/src/assets/topbar.scss
@@ -110,36 +110,6 @@
}
}
}
- .omnibox-results {
- @include transition(0.25s);
- @include omnibox-width();
- position: absolute;
- z-index: 1;
- max-height: 250px;
- top: calc(var(--topbar-height) + 2px);
- left: 0;
- right: 0;
- margin: auto;
- background-color: hsla(213, 0%, 95%, 0.99);
- box-shadow: 0 3px 9px #ccc;
- border-radius: 0 0 5px 5px;
- >* {
- height: 24px;
- line-height: 24px;
- padding: 0 10px;
- font-family: 'Raleway', sans-serif;
- font-size: 14px;
- vertical-align: middle;
- color: #666;
- border-bottom: 1px solid #eee;
- &:hover {
- background-color: hsl(213, 20%, 92%);
- }
- &.selected {
- background-color: hsl(213, 40%, 90%);
- }
- }
- }
.progress {
position: absolute;
bottom: 0;
diff --git a/ui/src/frontend/topbar.ts b/ui/src/frontend/topbar.ts
index a7bd25f..a5ef633 100644
--- a/ui/src/frontend/topbar.ts
+++ b/ui/src/frontend/topbar.ts
@@ -15,14 +15,11 @@
import * as m from 'mithril';
import {Actions} from '../common/actions';
-import {QueryResponse} from '../common/queries';
import {EngineConfig} from '../common/state';
import {globals} from './globals';
import {executeSearch} from './search_handler';
-const QUERY_ID = 'quicksearch';
-
const SEARCH = Symbol('search');
const COMMAND = Symbol('command');
type Mode = typeof SEARCH|typeof COMMAND;
@@ -34,21 +31,9 @@
export const DISMISSED_PANNING_HINT_KEY = 'dismissedPanningHint';
-let selResult = 0;
-let numResults = 0;
let mode: Mode = SEARCH;
let displayStepThrough = false;
-function clearOmniboxResults(e: Event) {
- globals.queryResults.delete(QUERY_ID);
- globals.dispatch(Actions.deleteQuery({queryId: QUERY_ID}));
- const txt = (e.target as HTMLInputElement);
- if (txt.value.length <= 0) {
- mode = SEARCH;
- globals.rafScheduler.scheduleFullRedraw();
- }
-}
-
function onKeyDown(e: Event) {
const event = (e as KeyboardEvent);
const key = event.key;
@@ -57,13 +42,6 @@
}
const txt = (e.target as HTMLInputElement);
- // Avoid that the global 'a', 'd', 'w', 's' handler sees these keystrokes.
- // TODO: this seems a bug in the pan_and_zoom_handler.ts.
- if (key === 'ArrowUp' || key === 'ArrowDown') {
- e.preventDefault();
- return;
- }
-
if (mode === SEARCH && txt.value === '' && key === ':') {
e.preventDefault();
mode = COMMAND;
@@ -87,17 +65,8 @@
const event = (e as KeyboardEvent);
const key = event.key;
const txt = e.target as HTMLInputElement;
- if (key === 'ArrowUp' || key === 'ArrowDown') {
- selResult += (key === 'ArrowUp') ? -1 : 1;
- selResult = Math.max(selResult, 0);
- selResult = Math.min(selResult, numResults - 1);
- e.preventDefault();
- globals.rafScheduler.scheduleFullRedraw();
- return;
- }
if (key === 'Escape') {
- globals.queryResults.delete(QUERY_ID);
globals.dispatch(Actions.deleteQuery({queryId: 'command'}));
mode = SEARCH;
txt.value = '';
@@ -114,7 +83,6 @@
class Omnibox implements m.ClassComponent {
oncreate(vnode: m.VnodeDOM) {
const txt = vnode.dom.querySelector('input') as HTMLInputElement;
- txt.addEventListener('blur', clearOmniboxResults);
txt.addEventListener('keydown', onKeyDown);
txt.addEventListener('keyup', onKeyUp);
}
@@ -136,16 +104,6 @@
}));
}
- // TODO(primiano): handle query results here.
- const results = [];
- const resp = globals.queryResults.get(QUERY_ID) as QueryResponse;
- if (resp !== undefined) {
- numResults = resp.rows ? resp.rows.length : 0;
- for (let i = 0; i < resp.rows.length; i++) {
- const clazz = (i === selResult) ? '.selected' : '';
- results.push(m(`div${clazz}`, resp.rows[i][resp.columns[0]]));
- }
- }
const commandMode = mode === COMMAND;
const state = globals.frontendLocalState;
return m(
@@ -192,8 +150,7 @@
},
m('i.material-icons.right', 'keyboard_arrow_right')),
) :
- '',
- m('.omnibox-results', results));
+ '');
}
}
@@ -221,8 +178,7 @@
loadingAnimation() {
if (this.progressBar === undefined) return;
const engine: EngineConfig = globals.state.engines['0'];
- if (globals.state.queries[QUERY_ID] !== undefined ||
- (engine !== undefined && !engine.ready) ||
+ if ((engine !== undefined && !engine.ready) ||
globals.numQueuedQueries > 0) {
this.progressBar.classList.add('progress-anim');
} else {