Roo/bootstrap/Button.js
[roojs1] / Roo / bootstrap / Button.js
index 17695db..6dcdf58 100644 (file)
@@ -20,7 +20,8 @@
  * @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 
@@ -49,13 +50,14 @@ Roo.bootstrap.Button = function(config){
         /**
          * @event click
          * When a butotn is pressed
-         * @param {Roo.bootstrap.Button} this
+         * @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)
          */
@@ -166,7 +168,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
         }
         
         
-        if (this.active) {
+        if (this.active || this.pressed === true) {
             cfg.cls += ' active';
         }
         
@@ -340,6 +342,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     setActive : function(v) {
         
         this.el[v ? 'addClass' : 'removeClass']('active');
+        this.pressed = v;
     },
      /**
      * toggles the current active state 
@@ -359,11 +362,16 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     {
         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;
@@ -379,7 +387,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     },
     setWeight : function(str)
     {
-         this.el.removeClass(this.weightClass);
+       this.el.removeClass(this.weightClass);
         this.el.addClass('btn-' + str);        
     }