diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/background/actions/tab.js | 18 | ||||
-rw-r--r-- | src/background/components/background.js | 6 | ||||
-rw-r--r-- | src/background/index.js | 10 | ||||
-rw-r--r-- | src/content/actions/follow-controller.js | 3 | ||||
-rw-r--r-- | src/content/actions/operation.js | 3 | ||||
-rw-r--r-- | src/content/components/common/follow.js | 8 | ||||
-rw-r--r-- | src/content/components/top-content/follow-controller.js | 3 | ||||
-rw-r--r-- | src/content/reducers/follow-controller.js | 2 | ||||
-rw-r--r-- | src/shared/settings/default.js | 6 | ||||
-rw-r--r-- | src/shared/settings/properties.js | 2 | ||||
-rw-r--r-- | src/shared/versions/index.js | 39 | ||||
-rw-r--r-- | src/shared/versions/release-notes.js | 8 | ||||
-rw-r--r-- | src/shared/versions/storage.js | 11 |
13 files changed, 107 insertions, 12 deletions
diff --git a/src/background/actions/tab.js b/src/background/actions/tab.js index 40da55d..3c642fd 100644 --- a/src/background/actions/tab.js +++ b/src/background/actions/tab.js @@ -1,9 +1,21 @@ -const openNewTab = (url, openerTabId) => { - return browser.tabs.create({ url, openerTabId }); +const openNewTab = (url, openerTabId, background = false, adjacent = false) => { + if (adjacent) { + return browser.tabs.query({ + active: true, currentWindow: true + }).then((tabs) => { + return browser.tabs.create({ + url, + openerTabId, + active: !background, + index: tabs[0].index + 1 + }); + }); + } + return browser.tabs.create({ url, active: !background }); }; const openToTab = (url, tab) => { return browser.tabs.update(tab.id, { url: url }); }; -export { openToTab, openNewTab }; +export { openNewTab, openToTab }; diff --git a/src/background/components/background.js b/src/background/components/background.js index fdec8ec..fae3fbb 100644 --- a/src/background/components/background.js +++ b/src/background/components/background.js @@ -33,8 +33,10 @@ export default class BackgroundComponent { sender); case messages.OPEN_URL: if (message.newTab) { - return this.store.dispatch( - tabActions.openNewTab(message.url, sender.tab.id), sender); + let action = tabActions.openNewTab( + message.url, sender.tab.id, message.background, + settings.value.properties.adjacenttab); + return this.store.dispatch(action, sender); } return this.store.dispatch( tabActions.openToTab(message.url, sender.tab), sender); diff --git a/src/background/index.js b/src/background/index.js index 3ef712f..ff27796 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -3,6 +3,7 @@ import messages from 'shared/messages'; import BackgroundComponent from 'background/components/background'; import reducers from 'background/reducers'; import { createStore } from 'shared/store'; +import * as versions from 'shared/versions'; const store = createStore(reducers, (e, sender) => { console.error('Vim-Vixen:', e); @@ -17,3 +18,12 @@ const store = createStore(reducers, (e, sender) => { const backgroundComponent = new BackgroundComponent(store); store.dispatch(settingActions.load()); + +versions.checkUpdated().then((updated) => { + if (!updated) { + return; + } + return versions.notify(); +}).then(() => { + return versions.commit(); +}); diff --git a/src/content/actions/follow-controller.js b/src/content/actions/follow-controller.js index 3fd4dce..006b248 100644 --- a/src/content/actions/follow-controller.js +++ b/src/content/actions/follow-controller.js @@ -1,9 +1,10 @@ import actions from 'content/actions'; -const enable = (newTab) => { +const enable = (newTab, background) => { return { type: actions.FOLLOW_CONTROLLER_ENABLE, newTab, + background, }; }; diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js index 71b2470..9171766 100644 --- a/src/content/actions/operation.js +++ b/src/content/actions/operation.js @@ -44,7 +44,8 @@ const exec = (operation, repeat, settings) => { 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); diff --git a/src/content/components/common/follow.js b/src/content/components/common/follow.js index a8682c5..2a55ea3 100644 --- a/src/content/components/common/follow.js +++ b/src/content/components/common/follow.js @@ -50,6 +50,7 @@ export default class Follow { this.win = win; this.store = store; this.newTab = false; + this.background = false; this.hints = {}; this.targets = []; @@ -85,6 +86,7 @@ export default class Follow { type: messages.OPEN_URL, url: element.href, newTab: true, + background: this.background, }); } @@ -96,12 +98,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]; @@ -167,7 +170,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: diff --git a/src/content/components/top-content/follow-controller.js b/src/content/components/top-content/follow-controller.js index 1b5586b..7f36604 100644 --- a/src/content/components/top-content/follow-controller.js +++ b/src/content/components/top-content/follow-controller.js @@ -28,7 +28,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: @@ -129,6 +129,7 @@ export default class FollowController { type: messages.FOLLOW_CREATE_HINTS, keysArray: produced, newTab: this.state.newTab, + background: this.state.background, }), '*'); } diff --git a/src/content/reducers/follow-controller.js b/src/content/reducers/follow-controller.js index 2afb232..78fd848 100644 --- a/src/content/reducers/follow-controller.js +++ b/src/content/reducers/follow-controller.js @@ -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: diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js index f82db5a..9e1c202 100644 --- a/src/shared/settings/default.js +++ b/src/shared/settings/default.js @@ -27,6 +27,8 @@ export default { "u": { "type": "tabs.reopen" }, "K": { "type": "tabs.prev", "count": 1 }, "J": { "type": "tabs.next", "count": 1 }, + "gT": { "type": "tabs.prev", "count": 1 }, + "gt": { "type": "tabs.next", "count": 1 }, "g0": { "type": "tabs.first" }, "g$": { "type": "tabs.last" }, "<C-6>": { "type": "tabs.prevsel" }, @@ -37,8 +39,8 @@ export default { "zi": { "type": "zoom.in" }, "zo": { "type": "zoom.out" }, "zz": { "type": "zoom.neutral" }, - "f": { "type": "follow.start", "newTab": false }, - "F": { "type": "follow.start", "newTab": true }, + "f": { "type": "follow.start", "newTab": false, "background": false }, + "F": { "type": "follow.start", "newTab": true, "background": false }, "H": { "type": "navigate.history.prev" }, "L": { "type": "navigate.history.next" }, "[[": { "type": "navigate.link.prev" }, diff --git a/src/shared/settings/properties.js b/src/shared/settings/properties.js index 37dc881..4bda8d6 100644 --- a/src/shared/settings/properties.js +++ b/src/shared/settings/properties.js @@ -5,12 +5,14 @@ const types = { hintchars: 'string', smoothscroll: 'boolean', + adjacenttab: 'boolean', }; // describe default values of a property const defaults = { hintchars: 'abcdefghijklmnopqrstuvwxyz', smoothscroll: false, + adjacenttab: true, }; export { types, defaults }; diff --git a/src/shared/versions/index.js b/src/shared/versions/index.js new file mode 100644 index 0000000..ee9f3b5 --- /dev/null +++ b/src/shared/versions/index.js @@ -0,0 +1,39 @@ +import * as storage from './storage'; +import * as releaseNotes from './release-notes'; +import manifest from '../../../manifest.json'; + +const NOTIFICATION_ID = 'vimvixen-update'; + +const notificationClickListener = (id) => { + if (id !== NOTIFICATION_ID) { + return; + } + + browser.tabs.create({ url: releaseNotes.url(manifest.version) }); + browser.notifications.onClicked.removeListener(notificationClickListener); +}; + +const checkUpdated = () => { + return storage.load().then((prev) => { + if (!prev) { + return true; + } + return manifest.version !== prev; + }); +}; + +const notify = () => { + browser.notifications.onClicked.addListener(notificationClickListener); + return browser.notifications.create(NOTIFICATION_ID, { + 'type': 'basic', + 'iconUrl': browser.extension.getURL('resources/icon_48x48.png'), + 'title': 'Vim Vixen ' + manifest.version + ' has been installed', + 'message': 'Click here to see release notes', + }); +}; + +const commit = () => { + storage.save(manifest.version); +}; + +export { checkUpdated, notify, commit }; diff --git a/src/shared/versions/release-notes.js b/src/shared/versions/release-notes.js new file mode 100644 index 0000000..6ef2335 --- /dev/null +++ b/src/shared/versions/release-notes.js @@ -0,0 +1,8 @@ +const url = (version) => { + if (version) { + return 'https://github.com/ueokande/vim-vixen/releases/tag/' + version; + } + return 'https://github.com/ueokande/vim-vixen/releases/'; +}; + +export { url }; diff --git a/src/shared/versions/storage.js b/src/shared/versions/storage.js new file mode 100644 index 0000000..37603c8 --- /dev/null +++ b/src/shared/versions/storage.js @@ -0,0 +1,11 @@ +const load = () => { + return browser.storage.local.get('version').then(({ version }) => { + return version; + }); +}; + +const save = (version) => { + return browser.storage.local.set({ version }); +}; + +export { load, save }; |