Roo/bootstrap/Button.js
[roojs1] / Roo / bootstrap / Button.js
index 3b7c740..4fa7eb7 100644 (file)
@@ -48,7 +48,7 @@ Roo.bootstrap.Button = function(config){
          * @event toggle
          * After the button has been toggles
          * @param {Roo.EventObject} e
-         * @param {boolean} pressed
+         * @param {boolean} pressed (also available as button.pressed)
          */
         "toggle" : true
     });
@@ -95,9 +95,9 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
         } else {
             cfg.tag = this.tag;
         }
-        cfg.html = this.html || cfg.html;
+        cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
         
-        if (this.toggle === true) {
+        if (this.toggle == true) {
             cfg={
                 tag: 'div',
                 cls: 'slider-frame roo-button',
@@ -275,21 +275,66 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     },
     onClick : function(e)
     {
+        if (this.disabled) {
+            return;
+        }
+        
         Roo.log('button on click ');
         if(this.preventDefault){
             e.preventDefault();
         }
         if (this.pressed === true || this.pressed === false) {
             this.pressed = !this.pressed;
-            this[this.pressed ? 'addClass' : 'removeClass']('active');
-            this.fireEvent('toggle', this,e);
+            this.el[this.pressed ? 'addClass' : 'removeClass']('active');
+            this.fireEvent('toggle', this, e, this.pressed);
         }
         
         
         this.fireEvent('click', this, e);
+    },
+    
+    /**
+     * Enables this button
+     */
+    enable : function()
+    {
+        this.disabled = false;
+        this.el.removeClass('disabled');
+    },
+    
+    /**
+     * Disable this button
+     */
+    disable : function()
+    {
+        this.disabled = true;
+        this.el.addClass('disabled');
+    },
+     /**
+     * sets the active state on/off, 
+     * @param {Boolean} state (optional) Force a particular state
+     */
+    setActive : function(v) {
+        
+        this.el[v ? 'addClass' : 'removeClass']('active');
+    },
+     /**
+     * toggles the current active state 
+     */
+    toggleActive : function()
+    {
+       var active = this.el.hasClass('active');
+       this.setActive(!active);
+       
+        
+    },
+    setText : function(str)
+    {
+        
     }
     
     
+    
 });
 
  
\ No newline at end of file