3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * @class Ext.ux.TabCloseMenu
10 * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs. Note that the menu respects
11 * the closable configuration on the tab. As such, commands like remove others and remove all will not
12 * remove items that are not closable.
15 * @param {Object} config The configuration options
18 Ext.ux.TabCloseMenu = Ext.extend(Object, {
20 * @cfg {String} closeTabText
21 * The text for closing the current tab. Defaults to <tt>'Close Tab'</tt>.
23 closeTabText: 'Close Tab',
26 * @cfg {String} closeOtherTabsText
27 * The text for closing all tabs except the current one. Defaults to <tt>'Close Other Tabs'</tt>.
29 closeOtherTabsText: 'Close Other Tabs',
32 * @cfg {Boolean} showCloseAll
33 * Indicates whether to show the 'Close All' option. Defaults to <tt>true</tt>.
38 * @cfg {String} closeAllTabsText
39 * <p>The text for closing all tabs. Defaults to <tt>'Close All Tabs'</tt>.
41 closeAllTabsText: 'Close All Tabs',
43 constructor : function(config){
44 Ext.apply(this, config || {});
48 init : function(tabs){
52 contextmenu: this.onContextMenu,
58 Ext.destroy(this.menu);
65 onContextMenu : function(tabs, item, e){
67 var m = this.createMenu(),
70 closeAll = m.getComponent('closeall');
72 m.getComponent('close').setDisabled(!item.closable);
73 tabs.items.each(function(){
77 disableOthers = false;
82 m.getComponent('closeothers').setDisabled(disableOthers);
84 closeAll.setDisabled(disableAll);
88 m.showAt(e.getPoint());
91 createMenu : function(){
95 text: this.closeTabText,
99 if(this.showCloseAll){
103 itemId: 'closeothers',
104 text: this.closeOtherTabsText,
106 handler: this.onCloseOthers
108 if(this.showCloseAll){
111 text: this.closeAllTabsText,
113 handler: this.onCloseAll
116 this.menu = new Ext.menu.Menu({
123 onClose : function(){
124 this.tabs.remove(this.active);
127 onCloseOthers : function(){
131 onCloseAll : function(){
135 doClose : function(excludeActive){
137 this.tabs.items.each(function(item){
139 if(!excludeActive || item != this.active){
144 Ext.each(items, function(item){
145 this.tabs.remove(item);
150 Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);