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: false,
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         if(this.weight){
63             cfg.cls += ' alert-' + this.weight;
64         }
65         
66         return cfg;
67     },
68     
69     initEvents: function() 
70     {
71         this.el.setVisibilityMode(Roo.Element.DISPLAY);
72     },
73     
74     setTitle : function(str)
75     {
76         this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
77     },
78     
79     setText : function(str)
80     {
81         this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
82     },
83     
84     setText : function(str)
85     {
86         this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
87     },
88     
89     hide: function() 
90     {
91         this.el.hide();   
92     },
93     
94     show: function() 
95     {  
96         this.el.show();   
97     }
98     
99 });
100
101