2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 // Very simple plugin for adding a close context menu to tabs
\r
12 Ext.ux.TabCloseMenu = function(){
\r
13 var tabs, menu, ctxItem;
\r
14 this.init = function(tp){
\r
16 tabs.on('contextmenu', onContextMenu);
\r
19 function onContextMenu(ts, item, e){
\r
20 if(!menu){ // create context menu on first right click
\r
21 menu = new Ext.menu.Menu([{
\r
22 id: tabs.id + '-close',
\r
24 handler : function(){
\r
25 tabs.remove(ctxItem);
\r
28 id: tabs.id + '-close-others',
\r
29 text: 'Close Other Tabs',
\r
30 handler : function(){
\r
31 tabs.items.each(function(item){
\r
32 if(item.closable && item != ctxItem){
\r
40 var items = menu.items;
\r
41 items.get(tabs.id + '-close').setDisabled(!item.closable);
\r
42 var disableOthers = true;
\r
43 tabs.items.each(function(){
\r
44 if(this != item && this.closable){
\r
45 disableOthers = false;
\r
49 items.get(tabs.id + '-close-others').setDisabled(disableOthers);
\r
50 menu.showAt(e.getPoint());
\r