context menu on tab and "close all except for this tab"

This commit is contained in:
zadam
2019-05-07 21:34:01 +02:00
parent aef0e552a0
commit 4ea27e604f
3 changed files with 30 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import NoteFull from "../entities/note_full.js";
import bundleService from "./bundle.js";
import utils from "./utils.js";
import importDialog from "../dialogs/import.js";
import contextMenuService from "./context_menu.js";
const chromeTabsEl = document.querySelector('.chrome-tabs');
const chromeTabs = new ChromeTabs();
@@ -263,6 +264,23 @@ chromeTabsEl.addEventListener('tabRemove', ({ detail }) => {
console.log(`Removed tab ${tabId}`);
});
$(chromeTabsEl).on('contextmenu', '.chrome-tab', e => {
const tab = $(e.target).closest(".chrome-tab");
contextMenuService.initContextMenu(e, {
getContextMenuItems: () => {
return [
{title: "Close all tabs except for this", cmd: "removeAllTabsExceptForThis", uiIcon: "empty"}
];
},
selectContextMenuItem: (e, cmd) => {
if (cmd === 'removeAllTabsExceptForThis') {
chromeTabs.removeAllTabsExceptForThis(tab[0]);
}
}
});
});
if (utils.isElectron()) {
utils.bindShortcut('ctrl+w', () => {
if (noteContexts.length === 1) {