Roo/bootstrap/MessageBar.js
[roojs1] / Roo / bootstrap / MessageBar.js
1 /*
2  * - LGPL
3  *
4  * element
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.MessageBar
10  * @extends Roo.bootstrap.Component
11  * Bootstrap MessageBar class
12  * @cfg {String} html contents of the MessageBar
13  * @cfg {String} weight (info | success | warning | danger) default info
14  * @cfg {Boolean} closable (true | false) default true
15  * 
16  * @constructor
17  * Create a new Element
18  * @param {Object} config The config object
19  */
20
21 Roo.bootstrap.MessageBar = function(config){
22     Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
23 };
24
25 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component,  {
26     
27     html: '',
28     weight: 'info',
29     closable: true,
30     
31     getAutoCreate : function(){
32         
33         var cfg = {
34             tag: 'div',
35             cls: 'alert alert-dismissable alert-messages alert-' + this.weight,
36             html: this.html || ''
37         }
38         
39         if(this.closable){
40             cfg.cn = {
41                 tag: 'button',
42                 cls: 'close'
43             }
44         }
45         
46         return cfg;
47     },
48     
49     onRender : function(ct, position)
50     {
51         Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
52         
53         if(!this.el){
54             var cfg = Roo.apply({},  this.getAutoCreate());
55             cfg.id = Roo.id();
56             //if(!cfg.name){
57             //    cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
58             //}
59             //if (!cfg.name.length) {
60             //    delete cfg.name;
61            // }
62             if (this.cls) {
63                 cfg.cls += ' ' + this.cls;
64             }
65             if (this.style) {
66                 cfg.style = this.style;
67             }
68             this.el = Roo.get(document.body).createChild(cfg, position);
69             
70         }
71     },
72     
73     show : function()
74     {
75         if (!this.rendered) {
76             this.render();
77         }
78     }
79    
80 });
81
82  
83
84