Roo/bootstrap/MenuItem.js
authorAlan Knowles <alan@roojs.com>
Fri, 25 Nov 2016 02:53:30 +0000 (10:53 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 25 Nov 2016 02:53:30 +0000 (10:53 +0800)
roojs-bootstrap.js
roojs-bootstrap-debug.js

Roo/bootstrap/MenuItem.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index b2a1cb3..9b3b502 100644 (file)
@@ -58,7 +58,7 @@ Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
         var ctag = {
             tag: 'span',
             html: 'Link'
-        }
+        };
         
         var anc = {
             tag : 'a',
index cc58cde..4661fb0 100644 (file)
@@ -2239,6 +2239,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
  * @cfg {Boolean} preventDefault do not trigger A href on clicks.
  * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
  * @cfg {Boolean} active  used on sidebars to highlight active itesm
+ * @cfg {String} fa favicon to show on left of menu item.
  * 
  * 
  * @constructor
@@ -2267,6 +2268,8 @@ Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
     html : false,
     preventDefault: true,
     isContainer : false,
+    active : false,
+    fa: false,
     
     getAutoCreate : function(){
         
@@ -2276,17 +2279,31 @@ Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
                 cls: 'dropdown-menu-item'
             };
         }
+        var ctag = {
+            tag: 'span',
+            html: 'Link'
+        };
+        
+        var anc = {
+            tag : 'a',
+            href : '#',
+            cn : [  ]
+        };
+        
+        if (this.fa !== false) {
+            anc.cn.push({
+                tag : 'i',
+                cls : 'fa fa-' + this.fa
+            });
+        }
+        
+        anc.cn.push(ctag);
+        
         
         var cfg= {
             tag: 'li',
             cls: 'dropdown-menu-item',
-            cn: [
-                    {
-                        tag : 'a',
-                        href : '#',
-                        html : 'Link'
-                    }
-                ]
+            cn: [ anc ]
         };
         if (this.parent().type == 'treeview') {
             cfg.cls = 'treeview-menu';
@@ -2297,8 +2314,8 @@ Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component,  {
         
         
         
-        cfg.cn[0].href = this.href || cfg.cn[0].href ;
-        cfg.cn[0].html = this.html || cfg.cn[0].html ;
+        anc.href = this.href || cfg.cn[0].href ;
+        ctag.html = this.html || cfg.cn[0].html ;
         return cfg;
     },
     
index 3be5085..ce22944 100644 (file)
@@ -88,9 +88,10 @@ this.activeItem=null;}this.triggerEl.removeClass('open');;this.hidden=true;this.
 }if(this.isVisible()){Roo.log('hide');this.hide();}else{Roo.log('show');this.show(this.triggerEl,false,false);}e.stopEvent();},hideMenuItems:function(){Roo.log("hide Menu Items");if(!this.el){return;}this.el.select('.open',true).each(function(aa){aa.removeClass('open');
 });},addxtypeChild:function(A,B){var C=Roo.bootstrap.Menu.superclass.addxtypeChild.call(this,A,B);this.menuitems.add(C);return C;},getEl:function(){Roo.log(this.el);return this.el;}});
 // Roo/bootstrap/MenuItem.js
-Roo.bootstrap.MenuItem=function(A){Roo.bootstrap.MenuItem.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.MenuItem,Roo.bootstrap.Component,{href:false,html:false,preventDefault:true,isContainer:false,getAutoCreate:function(){if(this.isContainer){return {tag:'li',cls:'dropdown-menu-item'}
-;}var A={tag:'li',cls:'dropdown-menu-item',cn:[{tag:'a',href:'#',html:'Link'}]};if(this.parent().type=='treeview'){A.cls='treeview-menu';}if(this.active){A.cls+=' active';}A.cn[0].href=this.href||A.cn[0].href;A.cn[0].html=this.html||A.cn[0].html;return A;
-},initEvents:function(){if(this.parent().type=='treeview'){this.el.select('a').on('click',this.onClick,this);}},onClick:function(e){Roo.log('item on click ');this.fireEvent('click',this,e);},getEl:function(){return this.el;}});
+Roo.bootstrap.MenuItem=function(A){Roo.bootstrap.MenuItem.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.MenuItem,Roo.bootstrap.Component,{href:false,html:false,preventDefault:true,isContainer:false,active:false,fa:false,getAutoCreate:function(){if(this.isContainer){return {tag:'li',cls:'dropdown-menu-item'}
+;}var A={tag:'span',html:'Link'};var B={tag:'a',href:'#',cn:[]};if(this.fa!==false){B.cn.push({tag:'i',cls:'fa fa-'+this.fa});}B.cn.push(A);var C={tag:'li',cls:'dropdown-menu-item',cn:[B]};if(this.parent().type=='treeview'){C.cls='treeview-menu';}if(this.active){C.cls+=' active';
+}B.href=this.href||C.cn[0].href;A.html=this.html||C.cn[0].html;return C;},initEvents:function(){if(this.parent().type=='treeview'){this.el.select('a').on('click',this.onClick,this);}},onClick:function(e){Roo.log('item on click ');this.fireEvent('click',this,e);
+},getEl:function(){return this.el;}});
 // Roo/bootstrap/MenuSeparator.js
 Roo.bootstrap.MenuSeparator=function(A){Roo.bootstrap.MenuSeparator.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.MenuSeparator,Roo.bootstrap.Component,{getAutoCreate:function(){var A={cls:'divider',tag:'li'};return A;}});
 // Roo/bootstrap/Modal.js