3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 <div id="cls-Ext.ux.TabCloseMenu"></div>/**
16 * @class Ext.ux.TabCloseMenu
18 * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs. Note that the menu respects
19 * the closable configuration on the tab. As such, commands like remove others and remove all will not
20 * remove items that are not closable.
23 * @param {Object} config The configuration options
26 Ext.ux.TabCloseMenu = Ext.extend(Object, {
27 <div id="cfg-Ext.ux.TabCloseMenu-closeTabText"></div>/**
28 * @cfg {String} closeTabText
29 * The text for closing the current tab. Defaults to <tt>'Close Tab'</tt>.
31 closeTabText: 'Close Tab',
33 <div id="cfg-Ext.ux.TabCloseMenu-closeOtherTabsText"></div>/**
34 * @cfg {String} closeOtherTabsText
35 * The text for closing all tabs except the current one. Defaults to <tt>'Close Other Tabs'</tt>.
37 closeOtherTabsText: 'Close Other Tabs',
39 <div id="cfg-Ext.ux.TabCloseMenu-showCloseAll"></div>/**
40 * @cfg {Boolean} showCloseAll
41 * Indicates whether to show the 'Close All' option. Defaults to <tt>true</tt>.
45 <div id="cfg-Ext.ux.TabCloseMenu-closeAllTabsText"></div>/**
46 * @cfg {String} closeAllTabsText
47 * <p>The text for closing all tabs. Defaults to <tt>'Close All Tabs'</tt>.
49 closeAllTabsText: 'Close All Tabs',
51 constructor : function(config){
52 Ext.apply(this, config || {});
56 init : function(tabs){
60 contextmenu: this.onContextMenu,
66 Ext.destroy(this.menu);
73 onContextMenu : function(tabs, item, e){
75 var m = this.createMenu(),
78 closeAll = m.getComponent('closeall');
80 m.getComponent('close').setDisabled(!item.closable);
81 tabs.items.each(function(){
85 disableOthers = false;
90 m.getComponent('closeothers').setDisabled(disableOthers);
92 closeAll.setDisabled(disableAll);
96 m.showAt(e.getPoint());
99 createMenu : function(){
103 text: this.closeTabText,
105 handler: this.onClose
107 if(this.showCloseAll){
111 itemId: 'closeothers',
112 text: this.closeOtherTabsText,
114 handler: this.onCloseOthers
116 if(this.showCloseAll){
119 text: this.closeAllTabsText,
121 handler: this.onCloseAll
124 this.menu = new Ext.menu.Menu({
131 onClose : function(){
132 this.tabs.remove(this.active);
135 onCloseOthers : function(){
139 onCloseAll : function(){
143 doClose : function(excludeActive){
145 this.tabs.items.each(function(item){
147 if(!excludeActive || item != this.active){
152 Ext.each(items, function(item){
153 this.tabs.remove(item);
158 Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);</pre>