Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 2x 2x 2x 2x 1x 1x 1x | import {browser, Menus, Tabs} from 'webextension-polyfill-ts';
import {MENU_ITEM_ID} from './util';
import {Listeners} from './listeners';
import Tab = Tabs.Tab;
import OnClickData = Menus.OnClickData;
export class Lifecycle {
init(onclick: (info: OnClickData, target: Tab) => void): void {
browser.menus.create(
{
id: MENU_ITEM_ID,
type: 'normal',
contexts: ['tab'],
title: browser.i18n.getMessage('labelCloseTabsToLeft'),
onclick: onclick,
},
this.onCreated,
);
}
onCreated(): void {
browser.menus.onShown.addListener(Listeners.updateEnabledState);
browser.menus.onHidden.addListener(Listeners.resetMenuInstanceState);
}
}
|