Partial Fix #5654 - roojspacker - get it working as a doc tool...
[roojs1] / Roo / bootstrap / NavSidebarItem.js
index 8263b24..893b962 100644 (file)
  * @extends Roo.bootstrap.NavItem
  * Bootstrap Navbar.NavSidebarItem class
  * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
- * {bool} open is the menu open
+ * {Boolean} open is the menu open
+ * {Boolean} buttonView use button as the tigger el rather that a (default false)
+ * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
+ * {String} buttonSize (sm|md|lg)the extra classes for the button
+ * {Boolean} showArrow show arrow next to the text (default true)
  * @constructor
  * Create a new Navbar Button
  * @param {Object} config The config object
@@ -47,6 +51,14 @@ Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
     
     open: false,
     
+    buttonView : false,
+    
+    buttonWeight : 'default',
+    
+    buttonSize : 'md',
+    
+    showArrow : true,
+    
     getAutoCreate : function(){
         
         
@@ -57,16 +69,22 @@ Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
                 html : '',
                 cn : []
         };
+        
+        if(this.buttonView){
+            a = {
+                tag: 'button',
+                href : this.href || '#',
+                cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
+                html : this.html,
+                cn : []
+            };
+        }
+        
         var cfg = {
             tag: 'li',
             cls: '',
             cn: [ a ]
         };
-        var span = {
-            tag: 'span',
-            html : this.html || ''
-        };
-        
         
         if (this.active) {
             cfg.cls += ' active';
@@ -83,25 +101,31 @@ Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
             var c = this.glyphicon  ? ('glyphicon glyphicon-'+this.glyphicon)  : this.icon;
             a.cn.push({ tag : 'i', cls : c }) ;
         }
-        // html..
-        a.cn.push(span);
-        // then badge..
-        if (this.badge !== '') {
+        
+        if(!this.buttonView){
+            var span = {
+                tag: 'span',
+                html : this.html || ''
+            };
+
+            a.cn.push(span);
             
+        }
+        
+        if (this.badge !== '') {
             a.cn.push({ tag: 'span',  cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge }); 
         }
-        // fi
+        
         if (this.menu) {
-            a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
-            a.cls += 'dropdown-toggle treeview' ;
             
+            if(this.showArrow){
+                a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
+            }
+            
+            a.cls += ' dropdown-toggle treeview' ;
         }
         
-        
-        
         return cfg;
-         
-          
     },
     
     initEvents : function()
@@ -113,10 +137,8 @@ Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
         }
         
         this.el.on('click', this.onClick, this);
-       
-    
+        
         if(this.badge !== ''){
             this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
         }
         
@@ -133,7 +155,7 @@ Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem,  {
             e.preventDefault();
         }
         
-        this.fireEvent('click', this);
+        this.fireEvent('click', this, e);
     },
     
     disable : function()