Roo/bootstrap/Button.js
[roojs1] / Roo / bootstrap / Button.js
index b9f0a00..925d049 100644 (file)
  * @cfg {Boolean} inverse 
  * @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 
- * @cfg {Boolean} preventDefault  default true
+ * @cfg {String} ontext text for on slidy toggle state
+ * @cfg {String} offtext text for off slidy toggle state
+ * @cfg {Boolean} preventDefault  default true (stop click event triggering the URL if it's a link.)
  * @cfg {Boolean} removeClass remove the standard class..
  * @cfg {String} target  target for a href. (_self|_blank|_parent|_top| other)
  * 
@@ -50,13 +49,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)
          */
@@ -167,7 +167,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
         }
         
         
-        if (this.active) {
+        if (this.active || this.pressed === true) {
             cfg.cls += ' active';
         }
         
@@ -307,6 +307,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
         if(this.preventDefault){
             e.preventDefault();
         }
+        
         if (this.pressed === true || this.pressed === false) {
             this.pressed = !this.pressed;
             this.el[this.pressed ? 'addClass' : 'removeClass']('active');
@@ -341,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