Ext.ux.TabCloseMenu = function(){
var tabs, menu, ctxItem;
this.init = function(tp){
tabs = tp;
tabs.on('contextmenu', onContextMenu);
//tabs.on('dblclick',onDblClick);
}
//右键事件
function onContextMenu(ts, item, e){
if(!menu){
menu = new Ext.menu.Menu([{
id: tabs.id + '-close',
text: '关闭',
handler : function(){
tabs.remove(ctxItem);
}
},{
id: tabs.id + '-close-others',
text: '关闭其他',
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);
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());
}
//双击事件
//function onDblClick(ts, item, e){
//if(item.closable){
// tabs.remove(item);
// }
//}
};这段代码是右键事件的,怎么实现双击事件把tab关闭,谢谢。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货