clean operation definitions
This commit is contained in:
parent
c2a5a41cb6
commit
4edb0331a1
4 changed files with 44 additions and 37 deletions
|
@ -6,15 +6,15 @@ import * as zooms from '../background/zooms';
|
|||
|
||||
const exec = (operation, tab) => {
|
||||
switch (operation.type) {
|
||||
case operations.TABS_CLOSE:
|
||||
case operations.TAB_CLOSE:
|
||||
return tabs.closeTab(tab.id);
|
||||
case operations.TABS_REOPEN:
|
||||
case operations.TAB_REOPEN:
|
||||
return tabs.reopenTab();
|
||||
case operations.TABS_PREV:
|
||||
case operations.TAB_PREV:
|
||||
return tabs.selectPrevTab(tab.index, operation.count);
|
||||
case operations.TABS_NEXT:
|
||||
case operations.TAB_NEXT:
|
||||
return tabs.selectNextTab(tab.index, operation.count);
|
||||
case operations.TABS_RELOAD:
|
||||
case operations.TAB_RELOAD:
|
||||
return tabs.reload(tab, operation.cache);
|
||||
case operations.ZOOM_IN:
|
||||
return zooms.zoomIn();
|
||||
|
@ -22,21 +22,21 @@ const exec = (operation, tab) => {
|
|||
return zooms.zoomOut();
|
||||
case operations.ZOOM_NEUTRAL:
|
||||
return zooms.neutral();
|
||||
case operations.COMMAND_OPEN:
|
||||
case operations.COMMAND_SHOW:
|
||||
return consoleActions.showCommand('');
|
||||
case operations.COMMAND_TABS_OPEN:
|
||||
case operations.COMMAND_SHOW_OPEN:
|
||||
if (operation.alter) {
|
||||
// alter url
|
||||
return consoleActions.showCommand('open ' + tab.url);
|
||||
}
|
||||
return consoleActions.showCommand('open ');
|
||||
case operations.COMMAND_TABS_NEW:
|
||||
case operations.COMMAND_SHOW_TABOPEN:
|
||||
if (operation.alter) {
|
||||
// alter url
|
||||
return consoleActions.showCommand('tabopen ' + tab.url);
|
||||
}
|
||||
return consoleActions.showCommand('tabopen ');
|
||||
case operations.COMMAND_BUFFER:
|
||||
case operations.COMMAND_SHOW_BUFFER:
|
||||
return consoleActions.showCommand('buffer ');
|
||||
default:
|
||||
return browser.tabs.sendMessage(tab.id, {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import operations from '../operations';
|
||||
|
||||
const defaultKeymap = {
|
||||
':': { type: operations.COMMAND_OPEN },
|
||||
'o': { type: operations.COMMAND_TABS_OPEN, alter: false },
|
||||
'O': { type: operations.COMMAND_TABS_OPEN, alter: true },
|
||||
't': { type: operations.COMMAND_TABS_NEW, alter: false },
|
||||
'T': { type: operations.COMMAND_TABS_NEW, alter: true },
|
||||
'b': { type: operations.COMMAND_BUFFER },
|
||||
':': { type: operations.COMMAND_SHOW },
|
||||
'o': { type: operations.COMMAND_SHOW_OPEN, alter: false },
|
||||
'O': { type: operations.COMMAND_SHOW_OPEN, alter: true },
|
||||
't': { type: operations.COMMAND_SHOW_TABOPEN, alter: false },
|
||||
'T': { type: operations.COMMAND_SHOW_TABOPEN, alter: true },
|
||||
'b': { type: operations.COMMAND_SHOW_BUFFER },
|
||||
'k': { type: operations.SCROLL_LINES, count: -1 },
|
||||
'j': { type: operations.SCROLL_LINES, count: 1 },
|
||||
'<C-E>': { type: operations.SCROLL_LINES, count: -1 },
|
||||
|
@ -17,14 +17,14 @@ const defaultKeymap = {
|
|||
'<C-F>': { type: operations.SCROLL_PAGES, count: 1 },
|
||||
'gg': { type: operations.SCROLL_TOP },
|
||||
'G': { type: operations.SCROLL_BOTTOM },
|
||||
'0': { type: operations.SCROLL_LEFT },
|
||||
'$': { type: operations.SCROLL_RIGHT },
|
||||
'd': { type: operations.TABS_CLOSE },
|
||||
'u': { type: operations.TABS_REOPEN },
|
||||
'h': { type: operations.TABS_PREV, count: 1 },
|
||||
'l': { type: operations.TABS_NEXT, count: 1 },
|
||||
'r': { type: operations.TABS_RELOAD, cache: false },
|
||||
'R': { type: operations.TABS_RELOAD, cache: true },
|
||||
'0': { type: operations.SCROLL_HOME },
|
||||
'$': { type: operations.SCROLL_END },
|
||||
'd': { type: operations.TAB_CLOSE },
|
||||
'u': { type: operations.TAB_REOPEN },
|
||||
'h': { type: operations.TAB_PREV, count: 1 },
|
||||
'l': { type: operations.TAB_NEXT, count: 1 },
|
||||
'r': { type: operations.TAB_RELOAD, cache: false },
|
||||
'R': { type: operations.TAB_RELOAD, cache: true },
|
||||
'zi': { type: operations.ZOOM_IN },
|
||||
'zo': { type: operations.ZOOM_OUT },
|
||||
'zz': { type: operations.ZOOM_NEUTRAL },
|
||||
|
|
|
@ -85,9 +85,9 @@ const execOperation = (operation) => {
|
|||
return scrolls.scrollTop(window);
|
||||
case operations.SCROLL_BOTTOM:
|
||||
return scrolls.scrollBottom(window);
|
||||
case operations.SCROLL_LEFT:
|
||||
case operations.SCROLL_HOME:
|
||||
return scrolls.scrollLeft(window);
|
||||
case operations.SCROLL_RIGHT:
|
||||
case operations.SCROLL_END:
|
||||
return scrolls.scrollRight(window);
|
||||
case operations.FOLLOW_START:
|
||||
return startFollows(operation.newTab);
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
export default {
|
||||
// Command
|
||||
COMMAND_OPEN: 'cmd.open',
|
||||
COMMAND_TABS_OPEN: 'cmd.tabs.open',
|
||||
COMMAND_TABS_NEW: 'cmd.tabs.new',
|
||||
COMMAND_BUFFER: 'cmd.buffer',
|
||||
COMMAND_SHOW: 'command.show',
|
||||
COMMAND_SHOW_OPEN: 'command.show.open',
|
||||
COMMAND_SHOW_TABOPEN: 'command.show.tabopen',
|
||||
COMMAND_SHOW_BUFFER: 'command.show.buffer',
|
||||
|
||||
// Scrolls
|
||||
SCROLL_LINES: 'scroll.lines',
|
||||
SCROLL_PAGES: 'scroll.pages',
|
||||
SCROLL_TOP: 'scroll.top',
|
||||
SCROLL_BOTTOM: 'scroll.bottom',
|
||||
SCROLL_LEFT: 'scroll.left',
|
||||
SCROLL_RIGHT: 'scroll.right',
|
||||
SCROLL_HOME: 'scroll.home',
|
||||
SCROLL_END: 'scroll.end',
|
||||
|
||||
// Follows
|
||||
FOLLOW_START: 'follow.start',
|
||||
|
||||
// Navigations
|
||||
NAVIGATE_HISTORY_PREV: 'navigate.history.prev',
|
||||
NAVIGATE_HISTORY_NEXT: 'navigate.history.next',
|
||||
NAVIGATE_LINK_PREV: 'navigate.link.prev',
|
||||
|
@ -19,12 +24,14 @@ export default {
|
|||
NAVIGATE_PARENT: 'navigate.parent',
|
||||
NAVIGATE_ROOT: 'navigate.root',
|
||||
|
||||
// Background
|
||||
TABS_CLOSE: 'tabs.close',
|
||||
TABS_REOPEN: 'tabs.reopen',
|
||||
TABS_PREV: 'tabs.prev',
|
||||
TABS_NEXT: 'tabs.next',
|
||||
TABS_RELOAD: 'tabs.reload',
|
||||
// Tabs
|
||||
TAB_CLOSE: 'tabs.close',
|
||||
TAB_REOPEN: 'tabs.reopen',
|
||||
TAB_PREV: 'tabs.prev',
|
||||
TAB_NEXT: 'tabs.next',
|
||||
TAB_RELOAD: 'tabs.reload',
|
||||
|
||||
// Zooms
|
||||
ZOOM_IN: 'zoom.in',
|
||||
ZOOM_OUT: 'zoom.out',
|
||||
ZOOM_NEUTRAL: 'zoom.neutral',
|
||||
|
|
Reference in a new issue