Roo/bootstrap/Alert.js
[roojs1] / Roo / bootstrap / Alert.js
1 /*
2  * - LGPL
3  *
4  * Alert
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.Alert
10  * @extends Roo.bootstrap.Component
11  * Bootstrap Alert class
12  * @cfg {String} title The title of alert
13  * @cfg {String} html The content of alert
14  * @cfg {String} weight (  success | info | warning | danger )
15  * @cfg {String} faicon font-awesomeicon
16  * 
17  * @constructor
18  * Create a new alert
19  * @param {Object} config The config object
20  */
21
22
23 Roo.bootstrap.Alert = function(config){
24     Roo.bootstrap.Alert.superclass.constructor.call(this, config);
25     
26 };
27
28 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component,  {
29     
30     title: '',
31     html: '',
32     weight: '',
33     faicon: false,
34     
35     getAutoCreate : function()
36     {
37         
38         var cfg = {
39             tag : 'div',
40             cls : 'alert',
41             cn : [
42                 {
43                     tag : 'b',
44                     cls : 'roo-alert-title',
45                     html : this.title
46                 },
47                 {
48                     tag : 'span',
49                     cls : 'roo-alert-text',
50                     html : this.html
51                 }
52             ]
53         };
54         
55         if(this.faicon){
56             cfg.cn.unshift({
57                 tag : 'i',
58                 cls : 'fa ' + this.faicon
59             });
60         }
61         
62         return cfg;
63     },
64     
65     initEvents: function() 
66     {
67         this.el.setVisibilityMode(Roo.Element.DISPLAY);
68     },
69     
70     setTitle : function(str)
71     {
72         this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
73     },
74     
75     setText : function(str)
76     {
77         this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
78     },
79     
80     hide: function() 
81     {
82         this.el.hide();   
83     },
84     
85     show: function() 
86     {  
87         this.el.show();   
88     }
89     
90 });
91
92