PDA

View Full Version : TabPanel with hide behavior



kandy
15 Oct 2009, 5:34 AM
It's code add hide behavior for tab (as in window)


Ext.override(Ext.TabPanel, {
/**
* @cfg {String} closeAction
* The action to take when the close header tool is clicked:
*
* '{@link #close}' : Default
* {@link #close remove} the tab from the DOM and {@link Ext.Component#destroy destroy}
* it and all descendant Components. The tab will not be available to be
* redisplayed via the {@link #show} method.
*
* '{@link #hide}' :
* {@link #hide} the tab by setting visibility to hidden .
* The tab will be available to be redisplayed via the {@link #show} method.
*/
closeAction: 'close' ,
// private
onBeforeShowItem : function(item){
this.unhideTabStripItem(item);
if(item != this.activeTab){
this.setActiveTab(item);
return false;
}
},
// private
onStripMouseDown : function(e){
if(e.button !== 0){
return;
}
e.preventDefault();
var t = this.findTargets(e);
if(t.close){
if (this.closeAction == 'close') {
if (t.item.fireEvent('beforeclose', t.item) !== false) {
t.item.fireEvent('close', t.item);
this.remove(t.item);
}
} else {// closeAction == 'hide'
this.hideTabStripItem(t.item);
t.item.hide();
}
return;
}
if(t.item && t.item != this.activeTab){
this.setActiveTab(t.item);
}
}
});