2 * @class Roo.bootstrap.Alert
3 * @extends Roo.bootstrap.Component
4 * Bootstrap Alert class - shows an alert area box
6 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
7 Enter a valid email address
10 * @cfg {String} title The title of alert
11 * @cfg {String} html The content of alert
12 * @cfg {String} weight (success|info|warning|danger) Weight of the message
13 * @cfg {String} fa font-awesomeicon
14 * @cfg {Number} seconds default:-1 Number of seconds until it disapears (-1 means never.)
15 * @cfg {Boolean} close true to show a x closer
20 * @param {Object} config The config object
24 Roo.bootstrap.Alert = function(config){
25 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
29 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
39 getAutoCreate : function()
51 style : this.close ? '' : 'display:none'
55 cls : 'roo-alert-icon'
60 cls : 'roo-alert-title',
65 cls : 'roo-alert-text',
72 cfg.cn[0].cls += ' fa ' + this.faicon;
75 cfg.cn[0].cls += ' fa ' + this.fa;
79 cfg.cls += ' alert-' + this.weight;
85 initEvents: function()
87 this.el.setVisibilityMode(Roo.Element.DISPLAY);
88 this.titleEl = this.el.select('.roo-alert-title',true).first();
89 this.iconEl = this.el.select('.roo-alert-icon',true).first();
90 this.htmlEl = this.el.select('.roo-alert-text',true).first();
91 if (this.seconds > 0) {
92 this.hide.defer(this.seconds, this);
96 * Set the Title Message HTML
97 * @param {String} html
99 setTitle : function(str)
101 this.titleEl.dom.innerHTML = str;
105 * Set the Body Message HTML
106 * @param {String} html
108 setHtml : function(str)
110 this.htmlEl.dom.innerHTML = str;
113 * Set the Weight of the alert
114 * @param {String} (success|info|warning|danger) weight
117 setWeight : function(weight)
120 this.el.removeClass('alert-' + this.weight);
123 this.weight = weight;
125 this.el.addClass('alert-' + this.weight);
128 * Set the Icon of the alert
129 * @param {String} see fontawsome names (name without the 'fa-' bit)
131 setIcon : function(icon)
134 this.alertEl.removeClass(['fa', 'fa-' + this.faicon]);
139 this.alertEl.addClass(['fa', 'fa-' + this.faicon]);