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 : 'i'
44                     
45                 },
46                 {
47                     tag : 'b',
48                     cls : 'roo-alert-title',
49                     html : this.title
50                 },
51                 {
52                     tag : 'span',
53                     cls : 'roo-alert-text',
54                     html : this.html
55                 }
56             ]
57         };
58         
59         if(this.faicon){
60             cfg.cn[0].cls = 'fa ' + this.faicon;
61         }
62         
63         if(this.weight){
64             cfg.cls += ' alert-' + this.weight;
65         }
66         
67         return cfg;
68     },
69     
70     initEvents: function() 
71     {
72         this.el.setVisibilityMode(Roo.Element.DISPLAY);
73     },
74     
75     setTitle : function(str)
76     {
77         this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
78     },
79     
80     setText : function(str)
81     {
82         this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
83     },
84     
85     setWeight : function(weight)
86     {
87         if(this.weight){
88             this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
89         }
90         
91         this.weight = weight;
92         
93         this.el.select('.alert',true).first().addClass('alert-' + this.weight);
94     },
95     
96     setIcon : function(str)
97     {
98         if(this.faicon){
99             
100         }
101         this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
102     },
103     
104     hide: function() 
105     {
106         this.el.hide();   
107     },
108     
109     show: function() 
110     {  
111         this.el.show();   
112     }
113     
114 });
115
116