1 // Very simple plugin for adding a close context menu to tabs
2 Ext.ux.TabCloseMenu = function(){
3 var tabs, menu, ctxItem;
4 this.init = function(tp){
6 tabs.on('contextmenu', onContextMenu);
9 function onContextMenu(ts, item, e){
10 if(!menu){ // create context menu on first right click
11 menu = new Ext.menu.Menu([{
12 id: tabs.id + '-close',
18 id: tabs.id + '-close-others',
19 text: 'Close Other Tabs',
21 tabs.items.each(function(item){
22 if(item.closable && item != ctxItem){
30 var items = menu.items;
31 items.get(tabs.id + '-close').setDisabled(!item.closable);
32 var disableOthers = true;
33 tabs.items.each(function(){
34 if(this != item && this.closable){
35 disableOthers = false;
39 items.get(tabs.id + '-close-others').setDisabled(disableOthers);
40 menu.showAt(e.getPoint());