* @extends Roo.bootstrap.Component
* Bootstrap Button class
* @cfg {String} html The button content
- * @cfg {String} weight ( primary | success | info | warning | danger | link ) default
+ * @cfg {String} weight (default | primary | success | info | warning | danger | link ) default
* @cfg {String} size ( lg | sm | xs)
* @cfg {String} tag ( a | input | submit)
* @cfg {String} href empty or href
* @cfg {String} badge text for badge
* @cfg {String} theme default
* @cfg {Boolean} inverse
- * @cfg {Boolean} toggle
+ * @cfg {Boolean} toggle is it a slidy toggle button
+ * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
* @cfg {String} ontext text for on toggle state
* @cfg {String} offtext text for off toggle state
* @cfg {Boolean} defaulton
Roo.bootstrap.Button = function(config){
Roo.bootstrap.Button.superclass.constructor.call(this, config);
+ this.weightClass = ["btn-default",
+ "btn-primary",
+ "btn-success",
+ "btn-info",
+ "btn-warning",
+ "btn-danger",
+ "btn-link"
+ ],
this.addEvents({
// raw events
/**
* @event click
* When a butotn is pressed
+ * @param {Roo.bootstrap.Button} btn
* @param {Roo.EventObject} e
*/
"click" : true,
/**
* @event toggle
* After the button has been toggles
+ * @param {Roo.bootstrap.Button} btn
* @param {Roo.EventObject} e
* @param {boolean} pressed (also available as button.pressed)
*/
}
- if (this.active) {
+ if (this.active || this.pressed === true) {
cfg.cls += ' active';
}
setActive : function(v) {
this.el[v ? 'addClass' : 'removeClass']('active');
+ this.pressed = v;
},
/**
* toggles the current active state
},
+ /**
+ * get the current active state
+ * @return {boolean} true if it's active
+ */
+ isActive : function()
+ {
+ return this.el.hasClass('active');
+ },
+ /**
+ * set the text of the first selected button
+ */
setText : function(str)
{
this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
},
+ /**
+ * get the text of the first selected button
+ */
getText : function()
{
return this.el.select('.roo-button-text',true).first().dom.innerHTML;
show: function() {
this.el.show();
+ },
+ setWeight : function(str)
+ {
+ this.el.removeClass(this.weightClass);
+ this.el.addClass('btn-' + str);
}