From 50cc126e08056b4f5191f603c01f0e9951692696 Mon Sep 17 00:00:00 2001 From: Daniel Campoverde Date: Sun, 5 Nov 2017 18:04:46 -0500 Subject: Dummy selectPrevSelTab implementation --- src/background/actions/operation.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/background/actions/operation.js') diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index 1e4990c..cfee868 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -27,6 +27,8 @@ const exec = (operation, tab) => { return tabs.selectFirstTab(); case operations.TAB_LAST: return tabs.selectLastTab(); + case operations.TAB_PREV_SEL: + return tabs.selectPrevSelTab(); case operations.TAB_RELOAD: return tabs.reload(tab, operation.cache); case operations.TAB_PIN: -- cgit v1.2.3 From e7dcd7f500f9c139835313a573f861a10aa49d18 Mon Sep 17 00:00:00 2001 From: Cornelius Matějka Date: Wed, 22 Nov 2017 19:22:30 +0100 Subject: Pinned tabs are not closeable by 'd' Added binding 'DD' to force tab close which also closes pinned tabs --- src/background/actions/operation.js | 2 ++ src/background/tabs.js | 15 ++++++++++++--- src/shared/operations.js | 1 + src/shared/settings/default.js | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/background/actions/operation.js') diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index cfee868..1188ea2 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -17,6 +17,8 @@ const exec = (operation, tab) => { switch (operation.type) { case operations.TAB_CLOSE: return tabs.closeTab(tab.id); + case operations.TAB_CLOSE_FORCE: + return tabs.closeTabForce(tab.id); case operations.TAB_REOPEN: return tabs.reopenTab(); case operations.TAB_PREV: diff --git a/src/background/tabs.js b/src/background/tabs.js index d50d8e5..e02932a 100644 --- a/src/background/tabs.js +++ b/src/background/tabs.js @@ -9,6 +9,14 @@ browser.tabs.onActivated.addListener((activeInfo) => { }); const closeTab = (id) => { + return browser.tabs.get(id).then((tab) => { + if(!tab.pinned) { + return browser.tabs.remove(id); + } + }) +}; + +const closeTabForce = (id) => { return browser.tabs.remove(id); }; @@ -130,7 +138,8 @@ const duplicate = (id) => { }; export { - closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, - selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, selectPrevSelTab, - reload, updateTabPinned, toggleTabPinned, duplicate + closeTab, closeTabForce, reopenTab, selectAt, selectByKeyword, + getCompletions, selectPrevTab, selectNextTab, selectFirstTab, + selectLastTab, selectPrevSelTab, reload, updateTabPinned, + toggleTabPinned, duplicate }; diff --git a/src/shared/operations.js b/src/shared/operations.js index 19466df..4172f8b 100644 --- a/src/shared/operations.js +++ b/src/shared/operations.js @@ -33,6 +33,7 @@ export default { // Tabs TAB_CLOSE: 'tabs.close', + TAB_CLOSE_FORCE: 'tabs.close.force', TAB_REOPEN: 'tabs.reopen', TAB_PREV: 'tabs.prev', TAB_NEXT: 'tabs.next', diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js index e81df2b..826e3f6 100644 --- a/src/shared/settings/default.js +++ b/src/shared/settings/default.js @@ -23,6 +23,7 @@ export default { "G": { "type": "scroll.bottom" }, "$": { "type": "scroll.end" }, "d": { "type": "tabs.close" }, + "DD": { "type": "tabs.close.force" }, "u": { "type": "tabs.reopen" }, "K": { "type": "tabs.prev", "count": 1 }, "J": { "type": "tabs.next", "count": 1 }, -- cgit v1.2.3 From 90b83d7b7b99598834466c97e9c74c82cbd25cf3 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 4 Mar 2018 18:32:24 +0900 Subject: hide console on and --- src/background/actions/operation.js | 4 ++++ src/content/actions/setting.js | 9 ++++++++- src/shared/messages.js | 1 + src/shared/operations.js | 3 +++ test/background/reducers/setting.test.js | 1 - test/content/actions/setting.test.js | 2 ++ 6 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/background/actions/operation.js') diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index 1188ea2..56eb168 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -73,6 +73,10 @@ const exec = (operation, tab) => { return browser.tabs.sendMessage(tab.id, { type: messages.CONSOLE_SHOW_FIND }); + case operations.CANCEL: + return browser.tabs.sendMessage(tab.id, { + type: messages.CONSOLE_HIDE, + }); default: return Promise.resolve(); } diff --git a/src/content/actions/setting.js b/src/content/actions/setting.js index 0238c71..4c1e385 100644 --- a/src/content/actions/setting.js +++ b/src/content/actions/setting.js @@ -1,10 +1,17 @@ import actions from 'content/actions'; import * as keyUtils from 'shared/utils/keys'; +import operations from 'shared/operations'; + +const reservedKeymaps = { + '': { type: operations.CANCEL }, + '': { type: operations.CANCEL }, +}; const set = (value) => { let entries = []; if (value.keymaps) { - entries = Object.entries(value.keymaps).map((entry) => { + let keymaps = Object.assign({}, value.keymaps, reservedKeymaps); + entries = Object.entries(keymaps).map((entry) => { return [ keyUtils.fromMapKeys(entry[0]), entry[1], diff --git a/src/shared/messages.js b/src/shared/messages.js index de00a3f..b7a1a7e 100644 --- a/src/shared/messages.js +++ b/src/shared/messages.js @@ -32,6 +32,7 @@ export default { CONSOLE_SHOW_ERROR: 'console.show.error', CONSOLE_SHOW_INFO: 'console.show.info', CONSOLE_SHOW_FIND: 'console.show.find', + CONSOLE_HIDE: 'console.hide', FOLLOW_START: 'follow.start', FOLLOW_REQUEST_COUNT_TARGETS: 'follow.request.count.targets', diff --git a/src/shared/operations.js b/src/shared/operations.js index 008e9eb..a2f980f 100644 --- a/src/shared/operations.js +++ b/src/shared/operations.js @@ -1,4 +1,7 @@ export default { + // Hide console, or cancel some user actions + CANCEL: 'cancel', + // Addons ADDON_ENABLE: 'addon.enable', ADDON_DISABLE: 'addon.disable', diff --git a/test/background/reducers/setting.test.js b/test/background/reducers/setting.test.js index 2ef98cb..8df5abe 100644 --- a/test/background/reducers/setting.test.js +++ b/test/background/reducers/setting.test.js @@ -30,7 +30,6 @@ describe("setting reducer", () => { }; state = settingReducer(state, action); - console.log(state); expect(state.value.properties).to.have.property('smoothscroll', true); expect(state.value.properties).to.have.property('encoding', 'utf-8'); }); diff --git a/test/content/actions/setting.test.js b/test/content/actions/setting.test.js index 1248edf..3112b2d 100644 --- a/test/content/actions/setting.test.js +++ b/test/content/actions/setting.test.js @@ -23,6 +23,8 @@ describe("setting actions", () => { let map = new Map(keymaps); expect(map).to.have.deep.all.keys( [ + [{ key: 'Esc', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }], + [{ key: '[', shiftKey: false, ctrlKey: true, altKey: false, metaKey: false }], [{ key: 'd', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }, { key: 'd', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }], [{ key: 'z', shiftKey: false, ctrlKey: false, altKey: false, metaKey: false }, -- cgit v1.2.3