aboutsummaryrefslogtreecommitdiff
path: root/src/console/console.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-10 15:49:51 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-10 16:05:13 +0900
commit359fdb528821844f3c2fda718b82ce229a64b29f (patch)
tree7ef0778eaeff3f524938d88bd9dd9e4b2f026b02 /src/console/console.js
parent3c67cc0a002aded07e88ea25acc881ff080d1ae4 (diff)
blur as action/reducer
Diffstat (limited to 'src/console/console.js')
-rw-r--r--src/console/console.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/console/console.js b/src/console/console.js
index d79e154..f83f79c 100644
--- a/src/console/console.js
+++ b/src/console/console.js
@@ -1,5 +1,6 @@
import './console.scss';
import * as backgroundActions from '../actions/background';
+import * as consoleActions from '../actions/console';
import Completion from './completion';
import consoleReducer from '../reducers/console';
@@ -9,12 +10,6 @@ var completion = null;
var completionOrigin = "";
let state = consoleReducer(undefined, {});
-const blurMessage = () => {
- return {
- type: 'vimvixen.command.blur'
- };
-};
-
const keydownMessage = (input) => {
return {
type: 'vimvixen.command.enter',
@@ -23,7 +18,7 @@ const keydownMessage = (input) => {
};
const handleBlur = () => {
- return browser.runtime.sendMessage(blurMessage());
+ return browser.runtime.sendMessage(consoleActions.hide());
};
const completeNext = () => {
@@ -57,9 +52,11 @@ const completePrev = () => {
}
const handleKeydown = (e) => {
+ let input = window.document.querySelector('#vimvixen-console-command-input');
+
switch(e.keyCode) {
case KeyboardEvent.DOM_VK_ESCAPE:
- return browser.runtime.sendMessage(blurMessage());
+ return input.blur();
case KeyboardEvent.DOM_VK_RETURN:
return browser.runtime.sendMessage(keydownMessage(e.target));
case KeyboardEvent.DOM_VK_TAB:
@@ -183,3 +180,7 @@ browser.runtime.onMessage.addListener((action) => {
state = nextState;
}
});
+
+window.addEventListener('load', () => {
+ update({}, state);
+});