added support for pinning/unpinning tabs

features:
 * pin tab
 * unpin tab
 * toggle pin/unpin tab
jh-changes
Jiabo Hou 7 years ago
parent b3b017a123
commit c2d2f895a5
  1. 1
      README.md
  2. 6
      src/background/actions/operation.js
  3. 14
      src/background/tabs.js
  4. 1
      src/shared/default-settings.js
  5. 3
      src/shared/operations.js

@ -35,6 +35,7 @@ The default mappings are as follows:
- <kbd>g0</kbd>, <kbd>g$</kbd>: select first or last 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
- <kbd>p</kbd>: toggle pin/unpin current tab
### Navigation ### Navigation
- <kbd>f</kbd>: start following links in the page - <kbd>f</kbd>: start following links in the page

@ -26,6 +26,12 @@ const exec = (operation, tab) => {
return tabs.selectLastTab(); 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.TAB_PIN:
return tabs.updateTabPinned(tab, true);
case operations.TAB_UNPIN:
return tabs.updateTabPinned(tab, false);
case operations.TAB_TOGGLE_PINNED:
return tabs.updateTabPinned(tab);
case operations.ZOOM_IN: case operations.ZOOM_IN:
return zooms.zoomIn(); return zooms.zoomIn();
case operations.ZOOM_OUT: case operations.ZOOM_OUT:

@ -100,7 +100,19 @@ const reload = (current, cache) => {
); );
}; };
const updateTabPinned = (current, pinned) => {
return browser.tabs.query({ currentWindow: true, active: true })
.then(() => {
let newPinned = pinned;
if (newPinned !== true && newPinned !== false) {
newPinned = !current.pinned;
}
return browser.tabs.update(current.id, { pinned: newPinned });
});
};
export { export {
closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload,
updateTabPinned
}; };

@ -32,6 +32,7 @@ export default {
"g$": { "type": "tabs.last" }, "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 },
"p": { "type": "tabs.pin.toggle" },
"zi": { "type": "zoom.in" }, "zi": { "type": "zoom.in" },
"zo": { "type": "zoom.out" }, "zo": { "type": "zoom.out" },
"zz": { "type": "zoom.neutral" }, "zz": { "type": "zoom.neutral" },

@ -39,6 +39,9 @@ export default {
TAB_FIRST: 'tabs.first', TAB_FIRST: 'tabs.first',
TAB_LAST: 'tabs.last', TAB_LAST: 'tabs.last',
TAB_RELOAD: 'tabs.reload', TAB_RELOAD: 'tabs.reload',
TAB_PIN: 'tabs.pin',
TAB_UNPIN: 'tabs.unpin',
TAB_TOGGLE_PINNED: 'tabs.pin.toggle',
// Zooms // Zooms
ZOOM_IN: 'zoom.in', ZOOM_IN: 'zoom.in',