Roo.bootstrap.MessageBar = function(config){
Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
};
Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
html: '',
weight: 'info',
closable: false,
fixed: false,
beforeClass: 'bootstrap-sticky-wrap',
getAutoCreate : function(){
var cfg = {
tag: 'div',
cls: 'alert alert-dismissable alert-' + this.weight,
cn: [
{
tag: 'span',
cls: 'message',
html: this.html || ''
}
]
};
if(this.fixed){
cfg.cls += ' alert-messages-fixed';
}
if(this.closable){
cfg.cn.push({
tag: 'button',
cls: 'close',
html: 'x'
});
}
return cfg;
},
onRender : function(ct, position)
{
Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
if(!this.el){
var cfg = Roo.apply({}, this.getAutoCreate());
cfg.id = Roo.id();
if (this.cls) {
cfg.cls += ' ' + this.cls;
}
if (this.style) {
cfg.style = this.style;
}
this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
this.el.setVisibilityMode(Roo.Element.DISPLAY);
}
this.el.select('>button.close').on('click', this.hide, this);
},
show : function()
{
if (!this.rendered) {
this.render();
}
this.el.show();
this.fireEvent('show', this);
},
hide : function()
{
if (!this.rendered) {
this.render();
}
this.el.hide();
this.fireEvent('hide', this);
},
update : function()
{
this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
}
});