aboutsummaryrefslogtreecommitdiff
path: root/src/console/components
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-11-09 21:05:02 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-11-11 16:16:01 +0900
commite021504356016dc4cdb89356cae542c31486fe6a (patch)
tree9aca1822091301cff833632011e37d2a9f87fd1b /src/console/components
parent956dd937d33d167440d9d637f67ebff5d72353e5 (diff)
first find implementation
Diffstat (limited to 'src/console/components')
-rw-r--r--src/console/components/console.js40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/console/components/console.js b/src/console/components/console.js
index 605feb2..e83a1c9 100644
--- a/src/console/components/console.js
+++ b/src/console/components/console.js
@@ -25,23 +25,18 @@ export default class ConsoleComponent {
}
onBlur() {
- return browser.runtime.sendMessage({
- type: messages.CONSOLE_BLURRED,
- });
+ let state = this.store.getState();
+ if (state.mode === 'command') {
+ this.hideCommand();
+ }
}
onKeyDown(e) {
- let doc = this.wrapper.ownerDocument;
- let input = doc.querySelector('#vimvixen-console-command-input');
-
switch (e.keyCode) {
case KeyboardEvent.DOM_VK_ESCAPE:
- return input.blur();
+ return this.hideCommand();
case KeyboardEvent.DOM_VK_RETURN:
- return browser.runtime.sendMessage({
- type: messages.CONSOLE_ENTERED,
- text: e.target.value
- }).then(this.onBlur);
+ return this.onEntered(e.target.value);
case KeyboardEvent.DOM_VK_TAB:
if (e.shiftKey) {
this.store.dispatch(consoleActions.completionPrev());
@@ -54,6 +49,22 @@ export default class ConsoleComponent {
}
}
+ onEntered(value) {
+ let state = this.store.getState();
+ if (state.mode === 'command') {
+ browser.runtime.sendMessage({
+ type: messages.CONSOLE_ENTER_COMMAND,
+ text: value,
+ }).then(this.hideCommand);
+ } else if (state.mode === 'find') {
+ this.hideCommand();
+ window.top.postMessage(JSON.stringify({
+ type: messages.CONSOLE_ENTER_FIND,
+ text: value,
+ }), '*');
+ }
+ }
+
onInput(e) {
this.store.dispatch(consoleActions.setConsoleText(e.target.value));
@@ -78,6 +89,13 @@ export default class ConsoleComponent {
}
}
+ hideCommand() {
+ this.store.dispatch(consoleActions.hideCommand());
+ window.top.postMessage(JSON.stringify({
+ type: messages.CONSOLE_UNFOCUS,
+ }), '*');
+ }
+
update() {
let state = this.store.getState();