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 ) default info
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, {
55 getAutoCreate : function(){
63 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
64 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
69 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
71 if (this.toggle == true) {
74 cls: 'slider-frame roo-button',
79 'data-off-text':'OFF',
86 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
87 cfg.cls += ' '+this.weight;
96 cfg["aria-hidden"] = true;
104 if (this.theme==='default') {
105 cfg.cls = 'btn roo-button';
107 //if (this.parentType != 'Navbar') {
108 this.weight = this.weight.length ? this.weight : 'default';
110 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
112 cfg.cls += ' btn-' + this.weight;
114 } else if (this.theme==='glow') {
117 cfg.cls = 'btn-glow roo-button';
119 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
121 cfg.cls += ' ' + this.weight;
127 this.cls += ' inverse';
132 cfg.cls += ' active';
136 cfg.disabled = 'disabled';
140 Roo.log('changing to ul' );
142 this.glyphicon = 'caret';
145 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
147 //gsRoo.log(this.parentType);
148 if (this.parentType === 'Navbar' && !this.parent().bar) {
149 Roo.log('changing to li?');
158 href : this.href || '#'
161 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
162 cfg.cls += ' dropdown';
169 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
171 if (this.glyphicon) {
172 cfg.html = ' ' + cfg.html;
177 cls: 'glyphicon glyphicon-' + this.glyphicon
187 // cfg.cls='btn roo-button';
191 var value = cfg.html;
196 cls: 'glyphicon glyphicon-' + this.glyphicon,
215 cfg.cls += ' dropdown';
216 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
219 if (cfg.tag !== 'a' && this.href !== '') {
220 throw "Tag must be a to set href.";
221 } else if (this.href.length > 0) {
222 cfg.href = this.href;
225 if(this.removeClass){
230 cfg.target = this.target;
235 initEvents: function() {
236 // Roo.log('init events?');
237 // Roo.log(this.el.dom);
240 if (typeof (this.menu) != 'undefined') {
241 this.menu.parentType = this.xtype;
242 this.menu.triggerEl = this.el;
243 this.addxtype(Roo.apply({}, this.menu));
247 if (this.el.hasClass('roo-button')) {
248 this.el.on('click', this.onClick, this);
250 this.el.select('.roo-button').on('click', this.onClick, this);
253 if(this.removeClass){
254 this.el.on('click', this.onClick, this);
257 this.el.enableDisplayMode();
260 onClick : function(e)
267 Roo.log('button on click ');
268 if(this.preventDefault){
271 if (this.pressed === true || this.pressed === false) {
272 this.pressed = !this.pressed;
273 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
274 this.fireEvent('toggle', this, e, this.pressed);
278 this.fireEvent('click', this, e);
282 * Enables this button
286 this.disabled = false;
287 this.el.removeClass('disabled');
291 * Disable this button
295 this.disabled = true;
296 this.el.addClass('disabled');
299 * sets the active state on/off,
300 * @param {Boolean} state (optional) Force a particular state
302 setActive : function(v) {
304 this.el[v ? 'addClass' : 'removeClass']('active');
307 * toggles the current active state
309 toggleActive : function()
311 var active = this.el.hasClass('active');
312 this.setActive(!active);
316 setText : function(str)
318 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
322 return this.el.select('.roo-button-text',true).first().dom.innerHTML;