support zi/zo commands
This commit is contained in:
parent
1afbde6e19
commit
1f15d22643
5 changed files with 48 additions and 2 deletions
|
@ -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,12 @@ const doBackgroundAction = (sender, action) => {
|
|||
case actions.TABS_NEXT:
|
||||
tabs.selectNextTab(sender.tab.index, actions[1] || 1);
|
||||
break;
|
||||
case actions.ZOOM_IN:
|
||||
zooms.zoomIn();
|
||||
break;
|
||||
case actions.ZOOM_OUT:
|
||||
zooms.zoomOut();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ 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_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_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 ]},
|
||||
|
|
34
src/background/zooms.js
Normal file
34
src/background/zooms.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
// 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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export { zoomIn, zoomOut };
|
|
@ -11,12 +11,16 @@ 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';
|
||||
|
||||
const BACKGROUND_ACTION_SET = new Set([
|
||||
TABS_CLOSE,
|
||||
TABS_REOPEN,
|
||||
TABS_PREV,
|
||||
TABS_NEXT
|
||||
TABS_NEXT,
|
||||
ZOOM_IN,
|
||||
ZOOM_OUT
|
||||
]);
|
||||
|
||||
const CONTENT_ACTION_SET = new Set([
|
||||
|
|
Reference in a new issue