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
19 * @param {Object} config The config object
23 Roo.bootstrap.Alert = function(config){
24 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
28 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
35 getAutoCreate : function(){
43 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
44 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
49 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
51 if (this.toggle == true) {
54 cls: 'slider-frame roo-button',
59 'data-off-text':'OFF',
66 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
67 cfg.cls += ' '+this.weight;
76 cfg["aria-hidden"] = true;
84 if (this.theme==='default') {
85 cfg.cls = 'btn roo-button';
87 //if (this.parentType != 'Navbar') {
88 this.weight = this.weight.length ? this.weight : 'default';
90 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
92 cfg.cls += ' btn-' + this.weight;
94 } else if (this.theme==='glow') {
97 cfg.cls = 'btn-glow roo-button';
99 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
101 cfg.cls += ' ' + this.weight;
107 this.cls += ' inverse';
112 cfg.cls += ' active';
116 cfg.disabled = 'disabled';
120 Roo.log('changing to ul' );
122 this.glyphicon = 'caret';
125 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
127 //gsRoo.log(this.parentType);
128 if (this.parentType === 'Navbar' && !this.parent().bar) {
129 Roo.log('changing to li?');
138 href : this.href || '#'
141 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
142 cfg.cls += ' dropdown';
149 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
151 if (this.glyphicon) {
152 cfg.html = ' ' + cfg.html;
157 cls: 'glyphicon glyphicon-' + this.glyphicon
167 // cfg.cls='btn roo-button';
171 var value = cfg.html;
176 cls: 'glyphicon glyphicon-' + this.glyphicon,
195 cfg.cls += ' dropdown';
196 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
199 if (cfg.tag !== 'a' && this.href !== '') {
200 throw "Tag must be a to set href.";
201 } else if (this.href.length > 0) {
202 cfg.href = this.href;
205 if(this.removeClass){
210 cfg.target = this.target;
215 initEvents: function() {
216 // Roo.log('init events?');
217 // Roo.log(this.el.dom);
220 if (typeof (this.menu) != 'undefined') {
221 this.menu.parentType = this.xtype;
222 this.menu.triggerEl = this.el;
223 this.addxtype(Roo.apply({}, this.menu));
227 if (this.el.hasClass('roo-button')) {
228 this.el.on('click', this.onClick, this);
230 this.el.select('.roo-button').on('click', this.onClick, this);
233 if(this.removeClass){
234 this.el.on('click', this.onClick, this);
237 this.el.enableDisplayMode();
240 onClick : function(e)
247 Roo.log('button on click ');
248 if(this.preventDefault){
251 if (this.pressed === true || this.pressed === false) {
252 this.pressed = !this.pressed;
253 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
254 this.fireEvent('toggle', this, e, this.pressed);
258 this.fireEvent('click', this, e);
262 * Enables this button
266 this.disabled = false;
267 this.el.removeClass('disabled');
271 * Disable this button
275 this.disabled = true;
276 this.el.addClass('disabled');
279 * sets the active state on/off,
280 * @param {Boolean} state (optional) Force a particular state
282 setActive : function(v) {
284 this.el[v ? 'addClass' : 'removeClass']('active');
287 * toggles the current active state
289 toggleActive : function()
291 var active = this.el.hasClass('active');
292 this.setActive(!active);
296 setText : function(str)
298 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
302 return this.el.select('.roo-button-text',true).first().dom.innerHTML;