Don't say anything, directly on the code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<link rel= "stylesheet" type= text/css "href=". /resources/css/ext-all.css "/>
<script type= "Text/javascript" src= ". /adapter/ext/ext-base.js "></script>
<script type= "Text/javascript" src= ". /ext-all.js "></script>
<style type= "Text/css" >
*{font-size:12px;line-height:130%;}
. list {list-style:square;width:500px;padding-left:16px;}
. List li{padding:2px;font-size:8pt;}
Pre {
font-size:11px;
}
. x-tab-panel-body. x-panel-body {
padding:10px;
}
/* Default loading indicator for AJAX calls * *
. loading-indicator {
font-size:8pt;
Background-image:url ('.. /resources/images/default/grid/loading.gif ');
Background-repeat:no-repeat;
Background-position:left;
padding-left:20px;
}
. new-tab {
Background-image:url (.. /examples/feed-viewer/images/new_tab.gif)!important;
}
. tabs {
Background-image:url (.. /examples/desktop/images/tabs.gif)!important;
}
</style>
<title>tabs demo</title>
<body>
<script type= "Text/javascript" >
Ext.onready (function () {
var tabs = new Ext.tabpanel ({
RenderTo:Ext.getBody (),
Resizetabs:true,//Turn on tab resizing
mintabwidth:115,
tabwidth:135,
Enabletabscroll:true,
width:600,
height:150,
Defaults: {autoscroll:true},
Plugins:new Ext.ux.TabCloseMenu (),
Tbar: [{text: ' new tab ', Iconcls: ' New-tab ', Handler:addtab}]
});
Tab Generation Code
var index = 0;
while (Index < 2) {
AddTab ();
}
function addtab (tab) {
if (Tabs.items.length > 9) {
Ext.MessageBox.alert ("Hint", "can only create 10 new tab!");
Tabs.tbar.setVisible (FALSE);
return false;
}
Tabs.add ({
Title: ' New Tab ' + (++index),
Iconcls: ' Tabs ',
HTML: ' Tab body ' + (index),
Closable:true
). Show ();
}
});
Right-click pop-up menu
Ext.ux.TabCloseMenu = function () {
var tabs, menu, Ctxitem;
This.init = function (TP) {
tabs = TP;
Tabs.on (' ContextMenu ', oncontextmenu);
}
function OnContextMenu (TS, item, e) {
if (!menu) {//Create context menu on the right click
menu = new Ext.menu.Menu ([{
Id:tabs.id + '-close ',
Text: ' Close current ',
Handler:function () {tabs.remove (ctxitem);}
}, {
Id:tabs.id + '-close-others ',
Text: ' Close other ',
Handler:function () {
Tabs.items.each (function (item) {
if (item.closable && item!= ctxitem) {
Tabs.remove (item);
}
});
}
}]);
}
Ctxitem = Item;
var items = Menu.Items;
Items.get (tabs.id + '-close '). setdisabled (!item.closable);
When only one is left, disable the shutdown.
if (tabs.items.length = = 1) {
Items.get (tabs.id + '-close '). Setdisabled (True);
// }
var disableothers = true;
Tabs.items.each (function () {
if (this!= item && this.closable) {
Disableothers = false;
return false;
}
});
Items.get (tabs.id + '-close-others '). setdisabled (Disableothers);
Menu.showat (E.getpoint ());
}
};
</script>
</body>
The effect chart is as follows: