Roo/bootstrap/Button.js
[roojs1] / Roo / bootstrap / Button.js
index 5d84d97..b9f0a00 100644 (file)
@@ -10,7 +10,7 @@
  * @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
@@ -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 
 
 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
         /**
@@ -266,7 +275,7 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
        // Roo.log('init events?');
 //        Roo.log(this.el.dom);
         // add the menu...
-        Roo.log('button????');
+        
         if (typeof (this.menu) != 'undefined') {
             this.menu.parentType = this.xtype;
             this.menu.triggerEl = this.el;
@@ -343,10 +352,24 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
        
         
     },
+     /**
+     * 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;
@@ -359,6 +382,11 @@ Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component,  {
     show: function() {
        
         this.el.show();   
+    },
+    setWeight : function(str)
+    {
+       this.el.removeClass(this.weightClass);
+        this.el.addClass('btn-' + str);        
     }