3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js"><div id="cls-Ext.ux.TabCloseMenu"></div>/**
\r
9 * @class Ext.ux.TabCloseMenu
\r
11 * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs.
\r
13 * @ptype tabclosemenu
\r
15 Ext.ux.TabCloseMenu = function(){
\r
16 var tabs, menu, ctxItem;
\r
17 this.init = function(tp){
\r
19 tabs.on('contextmenu', onContextMenu);
\r
22 function onContextMenu(ts, item, e){
\r
23 if(!menu){ // create context menu on first right click
\r
24 menu = new Ext.menu.Menu({
\r
26 id: tabs.id + '-close',
\r
28 handler : function(){
\r
29 tabs.remove(ctxItem);
\r
32 id: tabs.id + '-close-others',
\r
33 text: 'Close Other Tabs',
\r
34 handler : function(){
\r
35 tabs.items.each(function(item){
\r
36 if(item.closable && item != ctxItem){
\r
44 var items = menu.items;
\r
45 items.get(tabs.id + '-close').setDisabled(!item.closable);
\r
46 var disableOthers = true;
\r
47 tabs.items.each(function(){
\r
48 if(this != item && this.closable){
\r
49 disableOthers = false;
\r
53 items.get(tabs.id + '-close-others').setDisabled(disableOthers);
\r
55 menu.showAt(e.getPoint());
\r
59 Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);
\r