Open adjacent tabs and background tabs
This commit is contained in:
parent
a50c7dd0a2
commit
177940981e
10 changed files with 38 additions and 19 deletions
|
@ -1,9 +1,10 @@
|
|||
import actions from 'content/actions';
|
||||
|
||||
const enable = (newTab) => {
|
||||
const enable = (newTab, background) => {
|
||||
return {
|
||||
type: actions.FOLLOW_CONTROLLER_ENABLE,
|
||||
newTab,
|
||||
background,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ const exec = (operation) => {
|
|||
case operations.FOLLOW_START:
|
||||
return window.top.postMessage(JSON.stringify({
|
||||
type: messages.FOLLOW_START,
|
||||
newTab: operation.newTab
|
||||
newTab: operation.newTab,
|
||||
background: operation.background,
|
||||
}), '*');
|
||||
case operations.NAVIGATE_HISTORY_PREV:
|
||||
return navigates.historyPrev(window);
|
||||
|
|
|
@ -34,6 +34,7 @@ export default class Follow {
|
|||
this.win = win;
|
||||
this.store = store;
|
||||
this.newTab = false;
|
||||
this.background = false;
|
||||
this.hints = {};
|
||||
this.targets = [];
|
||||
|
||||
|
@ -68,6 +69,7 @@ export default class Follow {
|
|||
type: messages.OPEN_URL,
|
||||
url: element.href,
|
||||
newTab: true,
|
||||
background: this.background,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -79,12 +81,13 @@ export default class Follow {
|
|||
}), '*');
|
||||
}
|
||||
|
||||
createHints(keysArray, newTab) {
|
||||
createHints(keysArray, newTab, background) {
|
||||
if (keysArray.length !== this.targets.length) {
|
||||
throw new Error('illegal hint count');
|
||||
}
|
||||
|
||||
this.newTab = newTab;
|
||||
this.background = background;
|
||||
this.hints = {};
|
||||
for (let i = 0; i < keysArray.length; ++i) {
|
||||
let keys = keysArray[i];
|
||||
|
@ -150,7 +153,8 @@ export default class Follow {
|
|||
case messages.FOLLOW_REQUEST_COUNT_TARGETS:
|
||||
return this.countHints(sender, message.viewSize, message.framePosition);
|
||||
case messages.FOLLOW_CREATE_HINTS:
|
||||
return this.createHints(message.keysArray, message.newTab);
|
||||
return this.createHints(
|
||||
message.keysArray, message.newTab, message.background);
|
||||
case messages.FOLLOW_SHOW_HINTS:
|
||||
return this.showHints(message.keys);
|
||||
case messages.FOLLOW_ACTIVATE:
|
||||
|
|
|
@ -29,7 +29,7 @@ export default class FollowController {
|
|||
switch (message.type) {
|
||||
case messages.FOLLOW_START:
|
||||
return this.store.dispatch(
|
||||
followControllerActions.enable(message.newTab));
|
||||
followControllerActions.enable(message.newTab, message.background));
|
||||
case messages.FOLLOW_RESPONSE_COUNT_TARGETS:
|
||||
return this.create(message.count, sender);
|
||||
case messages.FOLLOW_KEY_PRESS:
|
||||
|
@ -126,6 +126,7 @@ export default class FollowController {
|
|||
type: messages.FOLLOW_CREATE_HINTS,
|
||||
keysArray: produced,
|
||||
newTab: this.state.newTab,
|
||||
background: this.state.background,
|
||||
}), '*');
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import actions from 'content/actions';
|
|||
const defaultState = {
|
||||
enabled: false,
|
||||
newTab: false,
|
||||
background: false,
|
||||
keys: '',
|
||||
};
|
||||
|
||||
|
@ -12,6 +13,7 @@ export default function reducer(state = defaultState, action = {}) {
|
|||
return Object.assign({}, state, {
|
||||
enabled: true,
|
||||
newTab: action.newTab,
|
||||
background: action.background,
|
||||
keys: '',
|
||||
});
|
||||
case actions.FOLLOW_CONTROLLER_DISABLE:
|
||||
|
|
Reference in a new issue