blur as action/reducer
This commit is contained in:
parent
3c67cc0a00
commit
359fdb5288
4 changed files with 49 additions and 69 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Reference in a new issue