Merge pull request #113 from alx741/tabs

Add Tabs first/last selectors
jh-changes
Shin'ya Ueoka 7 years ago committed by GitHub
commit b3b017a123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      README.md
  2. 4
      src/background/actions/operation.js
  3. 16
      src/background/tabs.js
  4. 2
      src/shared/default-settings.js
  5. 2
      src/shared/operations.js

@ -32,6 +32,7 @@ The default mappings are as follows:
- <kbd>d</kbd>: delete current tab - <kbd>d</kbd>: delete current tab
- <kbd>u</kbd>: reopen close tab - <kbd>u</kbd>: reopen close tab
- <kbd>K</kbd>, <kbd>J</kbd>: select prev or next tab - <kbd>K</kbd>, <kbd>J</kbd>: select prev or next tab
- <kbd>g0</kbd>, <kbd>g$</kbd>: select first or last tab
- <kbd>r</kbd>: reload current tab - <kbd>r</kbd>: reload current tab
- <kbd>R</kbd>: reload current tab without cache - <kbd>R</kbd>: reload current tab without cache

@ -20,6 +20,10 @@ const exec = (operation, tab) => {
return tabs.selectPrevTab(tab.index, operation.count); return tabs.selectPrevTab(tab.index, operation.count);
case operations.TAB_NEXT: case operations.TAB_NEXT:
return tabs.selectNextTab(tab.index, operation.count); return tabs.selectNextTab(tab.index, operation.count);
case operations.TAB_FIRST:
return tabs.selectFirstTab();
case operations.TAB_LAST:
return tabs.selectLastTab();
case operations.TAB_RELOAD: case operations.TAB_RELOAD:
return tabs.reload(tab, operation.cache); return tabs.reload(tab, operation.cache);
case operations.ZOOM_IN: case operations.ZOOM_IN:

@ -79,6 +79,20 @@ const selectNextTab = (current, count) => {
}); });
}; };
const selectFirstTab = () => {
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
let id = tabs[0].id;
return browser.tabs.update(id, { active: true });
});
};
const selectLastTab = () => {
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
let id = tabs[tabs.length - 1].id;
return browser.tabs.update(id, { active: true });
});
};
const reload = (current, cache) => { const reload = (current, cache) => {
return browser.tabs.reload( return browser.tabs.reload(
current.id, current.id,
@ -88,5 +102,5 @@ const reload = (current, cache) => {
export { export {
closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
selectPrevTab, selectNextTab, reload selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload
}; };

@ -28,6 +28,8 @@ export default {
"u": { "type": "tabs.reopen" }, "u": { "type": "tabs.reopen" },
"K": { "type": "tabs.prev", "count": 1 }, "K": { "type": "tabs.prev", "count": 1 },
"J": { "type": "tabs.next", "count": 1 }, "J": { "type": "tabs.next", "count": 1 },
"g0": { "type": "tabs.first" },
"g$": { "type": "tabs.last" },
"r": { "type": "tabs.reload", "cache": false }, "r": { "type": "tabs.reload", "cache": false },
"R": { "type": "tabs.reload", "cache": true }, "R": { "type": "tabs.reload", "cache": true },
"zi": { "type": "zoom.in" }, "zi": { "type": "zoom.in" },

@ -36,6 +36,8 @@ export default {
TAB_REOPEN: 'tabs.reopen', TAB_REOPEN: 'tabs.reopen',
TAB_PREV: 'tabs.prev', TAB_PREV: 'tabs.prev',
TAB_NEXT: 'tabs.next', TAB_NEXT: 'tabs.next',
TAB_FIRST: 'tabs.first',
TAB_LAST: 'tabs.last',
TAB_RELOAD: 'tabs.reload', TAB_RELOAD: 'tabs.reload',
// Zooms // Zooms