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
19 * @param {Object} config The config object
23 Roo.bootstrap.Button = function(config){
24 Roo.bootstrap.Button.superclass.constructor.call(this, config);
29 * When a butotn is pressed
30 * @param {Roo.EventObject} e
35 * After the button has been toggles
36 * @param {Roo.EventObject} e
37 * @param {boolean} pressed (also available as button.pressed)
43 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
70 getAutoCreate : function(){
78 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
79 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
84 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
86 if (this.toggle == true) {
89 cls: 'slider-frame roo-button',
94 'data-off-text':'OFF',
101 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
102 cfg.cls += ' '+this.weight;
111 cfg["aria-hidden"] = true;
113 cfg.html = "×";
119 if (this.theme==='default') {
120 cfg.cls = 'btn roo-button';
122 //if (this.parentType != 'Navbar') {
123 this.weight = this.weight.length ? this.weight : 'default';
125 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
127 cfg.cls += ' btn-' + this.weight;
129 } else if (this.theme==='glow') {
132 cfg.cls = 'btn-glow roo-button';
134 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
136 cfg.cls += ' ' + this.weight;
142 this.cls += ' inverse';
147 cfg.cls += ' active';
151 cfg.disabled = 'disabled';
155 Roo.log('changing to ul' );
157 this.glyphicon = 'caret';
160 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
162 //gsRoo.log(this.parentType);
163 if (this.parentType === 'Navbar' && !this.parent().bar) {
164 Roo.log('changing to li?');
173 href : this.href || '#'
176 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
177 cfg.cls += ' dropdown';
184 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
186 if (this.glyphicon) {
187 cfg.html = ' ' + cfg.html;
192 cls: 'glyphicon glyphicon-' + this.glyphicon
202 // cfg.cls='btn roo-button';
206 var value = cfg.html;
211 cls: 'glyphicon glyphicon-' + this.glyphicon,
230 cfg.cls += ' dropdown';
231 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
234 if (cfg.tag !== 'a' && this.href !== '') {
235 throw "Tag must be a to set href.";
236 } else if (this.href.length > 0) {
237 cfg.href = this.href;
240 if(this.removeClass){
245 cfg.target = this.target;
250 initEvents: function() {
251 // Roo.log('init events?');
252 // Roo.log(this.el.dom);
255 if (typeof (this.menu) != 'undefined') {
256 this.menu.parentType = this.xtype;
257 this.menu.triggerEl = this.el;
258 this.addxtype(Roo.apply({}, this.menu));
262 if (this.el.hasClass('roo-button')) {
263 this.el.on('click', this.onClick, this);
265 this.el.select('.roo-button').on('click', this.onClick, this);
268 if(this.removeClass){
269 this.el.on('click', this.onClick, this);
272 this.el.enableDisplayMode();
275 onClick : function(e)
282 Roo.log('button on click ');
283 if(this.preventDefault){
286 if (this.pressed === true || this.pressed === false) {
287 this.pressed = !this.pressed;
288 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
289 this.fireEvent('toggle', this, e, this.pressed);
293 this.fireEvent('click', this, e);
297 * Enables this button
301 this.disabled = false;
302 this.el.removeClass('disabled');
306 * Disable this button
310 this.disabled = true;
311 this.el.addClass('disabled');
314 * sets the active state on/off,
315 * @param {Boolean} state (optional) Force a particular state
317 setActive : function(v) {
319 this.el[v ? 'addClass' : 'removeClass']('active');
322 * toggles the current active state
324 toggleActive : function()
326 var active = this.el.hasClass('active');
327 this.setActive(!active);
331 setText : function(str)
333 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
337 return this.el.select('.roo-button-text',true).first().dom.innerHTML;