3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
7 // Very simple plugin for adding a close context menu to tabs
\r
8 Ext.ux.TabCloseMenu = function(){
\r
9 var tabs, menu, ctxItem;
\r
10 this.init = function(tp){
\r
12 tabs.on('contextmenu', onContextMenu);
\r
15 function onContextMenu(ts, item, e){
\r
16 if(!menu){ // create context menu on first right click
\r
17 menu = new Ext.menu.Menu([{
\r
18 id: tabs.id + '-close',
\r
20 handler : function(){
\r
21 tabs.remove(ctxItem);
\r
24 id: tabs.id + '-close-others',
\r
25 text: 'Close Other Tabs',
\r
26 handler : function(){
\r
27 tabs.items.each(function(item){
\r
28 if(item.closable && item != ctxItem){
\r
36 var items = menu.items;
\r
37 items.get(tabs.id + '-close').setDisabled(!item.closable);
\r
38 var disableOthers = true;
\r
39 tabs.items.each(function(){
\r
40 if(this != item && this.closable){
\r
41 disableOthers = false;
\r
45 items.get(tabs.id + '-close-others').setDisabled(disableOthers);
\r
46 menu.showAt(e.getPoint());
\r