diff options
| author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-11-05 23:41:38 +0000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-05 23:41:38 +0000 | 
| commit | 256820f78d0450c55a32557eca13294ab9fdf80f (patch) | |
| tree | 9851c73fc77d9d5bd8e9c91f754995de2b3d56e5 | |
| parent | b3b017a123516096dd7be05695f7a71da3b808cc (diff) | |
| parent | 87b8280d4bdcaddeac1aff95d9354e1954b7c25a (diff) | |
Merge pull request #124 from JiaboHou/pin-tab
added support for pinning/unpinning tabs
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | src/background/actions/operation.js | 10 | ||||
| -rw-r--r-- | src/background/tabs.js | 14 | ||||
| -rw-r--r-- | src/shared/default-settings.js | 1 | ||||
| -rw-r--r-- | src/shared/operations.js | 3 | 
5 files changed, 28 insertions, 1 deletions
@@ -35,6 +35,7 @@ The default mappings are as follows:  - <kbd>g0</kbd>, <kbd>g$</kbd>: select first or last tab  - <kbd>r</kbd>: reload current tab  - <kbd>R</kbd>: reload current tab without cache +- <kbd>zp</kbd>: toggle pin/unpin current tab  ### Navigation  - <kbd>f</kbd>: start following links in the page diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index a5094c0..d0caf80 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -10,6 +10,9 @@ const sendConsoleShowCommand = (tab, command) => {    });  }; +// This switch statement is only gonna get longer as more +// features are added, so disable complexity check +/* eslint-disable complexity */  const exec = (operation, tab) => {    switch (operation.type) {    case operations.TAB_CLOSE: @@ -26,6 +29,12 @@ const exec = (operation, tab) => {      return tabs.selectLastTab();    case operations.TAB_RELOAD:      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.toggleTabPinned(tab);    case operations.ZOOM_IN:      return zooms.zoomIn();    case operations.ZOOM_OUT: @@ -58,5 +67,6 @@ const exec = (operation, tab) => {      return Promise.resolve();    }  }; +/* eslint-enable complexity */  export { exec }; diff --git a/src/background/tabs.js b/src/background/tabs.js index 020c826..23b3b7b 100644 --- a/src/background/tabs.js +++ b/src/background/tabs.js @@ -100,7 +100,19 @@ const reload = (current, cache) => {    );  }; +const updateTabPinned = (current, pinned) => { +  return browser.tabs.query({ currentWindow: true, active: true }) +    .then(() => { +      return browser.tabs.update(current.id, { pinned: pinned }); +    }); +}; + +const toggleTabPinned = (current) => { +  updateTabPinned(current, !current.pinned); +}; +  export {    closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, -  selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload +  selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload, +  updateTabPinned, toggleTabPinned  }; diff --git a/src/shared/default-settings.js b/src/shared/default-settings.js index 49eee37..e45bee6 100644 --- a/src/shared/default-settings.js +++ b/src/shared/default-settings.js @@ -32,6 +32,7 @@ export default {      "g$": { "type": "tabs.last" },      "r": { "type": "tabs.reload", "cache": false },      "R": { "type": "tabs.reload", "cache": true }, +    "zp": { "type": "tabs.pin.toggle" },      "zi": { "type": "zoom.in" },      "zo": { "type": "zoom.out" },      "zz": { "type": "zoom.neutral" }, diff --git a/src/shared/operations.js b/src/shared/operations.js index 1519e90..1aa4227 100644 --- a/src/shared/operations.js +++ b/src/shared/operations.js @@ -39,6 +39,9 @@ export default {    TAB_FIRST: 'tabs.first',    TAB_LAST: 'tabs.last',    TAB_RELOAD: 'tabs.reload', +  TAB_PIN: 'tabs.pin', +  TAB_UNPIN: 'tabs.unpin', +  TAB_TOGGLE_PINNED: 'tabs.pin.toggle',    // Zooms    ZOOM_IN: 'zoom.in',  | 
