Merge branch 'some-features'

jh-changes
Shin'ya Ueoka 7 years ago
commit 6213f55e22
  1. 1
      .eslintrc
  2. 13
      src/background/index.js
  3. 7
      src/background/key-queue.js
  4. 9
      src/background/tabs.js
  5. 38
      src/background/zooms.js
  6. 8
      src/content/histories.js
  7. 9
      src/content/index.js
  8. 16
      src/shared/actions.js

@ -22,7 +22,6 @@
"multiline-ternary": "off",
"max-statements": ["error", 15],
"no-console": "off",
"no-magic-numbers": ["error", { "ignore": [0, 1, 2] }],
"no-param-reassign": "off",
"no-ternary": "off",
"object-curly-spacing": [

@ -1,6 +1,7 @@
import * as actions from '../shared/actions';
import * as tabs from './tabs';
import * as commands from './commands';
import * as zooms from './zooms';
import KeyQueue from './key-queue';
const queue = new KeyQueue();
@ -38,6 +39,18 @@ const doBackgroundAction = (sender, action) => {
case actions.TABS_NEXT:
tabs.selectNextTab(sender.tab.index, actions[1] || 1);
break;
case actions.TABS_RELOAD:
tabs.reload(sender.tab, actions[1] || false);
break;
case actions.ZOOM_IN:
zooms.zoomIn();
break;
case actions.ZOOM_OUT:
zooms.zoomOut();
break;
case actions.ZOOM_NEUTRAL:
zooms.neutral();
break;
}
}

@ -13,8 +13,15 @@ const DEFAULT_KEYMAP = [
{ keys: [{ code: KeyboardEvent.DOM_VK_U }], action: [ actions.TABS_REOPEN]},
{ keys: [{ code: KeyboardEvent.DOM_VK_H }], action: [ actions.TABS_PREV, 1 ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_L }], action: [ actions.TABS_NEXT, 1 ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_R }], action: [ actions.TABS_RELOAD, false ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_R, shift: true }], action: [ actions.TABS_RELOAD, true ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_Z }, { code: KeyboardEvent.DOM_VK_I }], action: [ actions.ZOOM_IN ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_Z }, { code: KeyboardEvent.DOM_VK_O }], action: [ actions.ZOOM_OUT ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_Z }, { code: KeyboardEvent.DOM_VK_Z }], action: [ actions.ZOOM_NEUTRAL]},
{ keys: [{ code: KeyboardEvent.DOM_VK_F }], action: [ actions.FOLLOW_START, false ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_F, shift: true }], action: [ actions.FOLLOW_START, true ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_H, shift: true }], action: [ actions.HISTORY_PREV ]},
{ keys: [{ code: KeyboardEvent.DOM_VK_L, shift: true }], action: [ actions.HISTORY_NEXT ]},
]
export default class KeyQueue {

@ -40,4 +40,11 @@ const selectNextTab = (current, count) => {
});
};
export { closeTab, reopenTab, selectNextTab, selectPrevTab };
const reload = (current, cache) => {
browser.tabs.reload(
current.id,
{ bypassCache: cache }
);
};
export { closeTab, reopenTab, selectNextTab, selectPrevTab, reload };

@ -0,0 +1,38 @@
// For chromium
// const ZOOM_SETTINGS = [
// 0.25, 0.33, 0.50, 0.66, 0.75, 0.80, 0.90, 1.00,
// 1.10, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00, 4.00, 5.00
// ];
const ZOOM_SETTINGS = [
0.33, 0.50, 0.66, 0.75, 0.80, 0.90, 1.00,
1.10, 1.25, 1.50, 1.75, 2.00, 2.50, 3.00
];
const zoomIn = (tabId = undefined) => {
browser.tabs.getZoom(tabId).then((factor) => {
for (let f of ZOOM_SETTINGS) {
if (f > factor) {
browser.tabs.setZoom(tabId, f);
break;
}
}
});
};
const zoomOut = (tabId = undefined) => {
browser.tabs.getZoom(tabId).then((factor) => {
for (let f of [].concat(ZOOM_SETTINGS).reverse()) {
if (f < factor) {
browser.tabs.setZoom(tabId, f);
break;
}
}
});
};
const neutral = (tabId = undefined) => {
browser.tabs.setZoom(tabId, 1);
};
export { zoomIn, zoomOut, neutral };

@ -0,0 +1,8 @@
const prev = (win) => {
win.history.back()
};
const next = (win) => {
win.history.forward()
};
export { prev, next };

@ -1,7 +1,8 @@
import * as scrolls from './scrolls';
import * as histories from './histories';
import * as actions from '../shared/actions';
import FooterLine from './footer-line';
import Follow from './follow';
import * as actions from '../shared/actions';
var footer = null;
@ -56,6 +57,12 @@ const invokeEvent = (action) => {
case actions.FOLLOW_START:
new Follow(window.document, action[1] || false);
break;
case actions.HISTORY_PREV:
histories.prev(window);
break;
case actions.HISTORY_NEXT:
histories.next(window);
break;
}
}

@ -4,17 +4,27 @@ export const TABS_CLOSE = 'tabs.close';
export const TABS_REOPEN = 'tabs.reopen';
export const TABS_PREV = 'tabs.prev';
export const TABS_NEXT = 'tabs.next';
export const TABS_RELOAD = 'tabs.reload';
export const SCROLL_UP = 'scroll.up';
export const SCROLL_DOWN = 'scroll.down';
export const SCROLL_TOP = 'scroll.top';
export const SCROLL_BOTTOM = 'scroll.bottom';
export const FOLLOW_START = 'follow.start';
export const HISTORY_PREV = 'history.prev';
export const HISTORY_NEXT = 'history.next';
export const ZOOM_IN = 'zoom.in';
export const ZOOM_OUT = 'zoom.out';
export const ZOOM_NEUTRAL = 'zoom.neutral';
const BACKGROUND_ACTION_SET = new Set([
TABS_CLOSE,
TABS_REOPEN,
TABS_PREV,
TABS_NEXT
TABS_NEXT,
TABS_RELOAD,
ZOOM_IN,
ZOOM_OUT,
ZOOM_NEUTRAL
]);
const CONTENT_ACTION_SET = new Set([
@ -24,7 +34,9 @@ const CONTENT_ACTION_SET = new Set([
SCROLL_DOWN,
SCROLL_TOP,
SCROLL_BOTTOM,
FOLLOW_START
FOLLOW_START,
HISTORY_PREV,
HISTORY_NEXT
]);
export const isBackgroundAction = (action) => {