From: Alan Knowles Date: Tue, 4 Dec 2018 08:22:41 +0000 (+0800) Subject: Roo/bootstrap/NavGroup.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=d2b58ed655b77ac37d5deb3a70acb5492dce546a Roo/bootstrap/NavGroup.js roojs-bootstrap.js roojs-bootstrap-debug.js --- diff --git a/Roo/bootstrap/NavGroup.js b/Roo/bootstrap/NavGroup.js index 15e239e7f7..8ff00bce13 100644 --- a/Roo/bootstrap/NavGroup.js +++ b/Roo/bootstrap/NavGroup.js @@ -58,11 +58,11 @@ Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, { cls: 'nav' }; if (Roo.bootstrap.version == 4) { - if (this.type == 'pills') { - cfg.cls = ' nav-pills'; + if (['nav','pills'].indexOf(this.type) != -1) { + cfg.cls = ' nav-' + this.type; } } else { - if (['tabs','pills'].indexOf(this.type)!==-1) { + if (['tabs','pills'].indexOf(this.type) != -1) { cfg.cls += ' nav-' + this.type } else { if (this.type !== 'nav') { diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index e622442519..2d1e471acb 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -4365,11 +4365,11 @@ Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, { cls: 'nav' }; if (Roo.bootstrap.version == 4) { - if (this.type == 'pills') { - cfg.cls = ' nav-pills'; + if (['nav','pills'].indexOf(this.type) != -1) { + cfg.cls = ' nav-' + this.type; } } else { - if (['tabs','pills'].indexOf(this.type)!==-1) { + if (['tabs','pills'].indexOf(this.type) != -1) { cfg.cls += ' nav-' + this.type } else { if (this.type !== 'nav') { diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 20b131f1be..bec72adfe0 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -175,15 +175,15 @@ if(this.autohide){var A=0;var ft=this.el;Roo.get(document).on('scroll',function( Roo.bootstrap.NavSidebar=function(A){Roo.bootstrap.NavSidebar.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.NavSidebar,Roo.bootstrap.Navbar,{sidebar:true,getAutoCreate:function(){return {tag:'div',cls:'sidebar sidebar-nav'};}}); // Roo/bootstrap/NavGroup.js Roo.bootstrap.NavGroup=function(A){Roo.bootstrap.NavGroup.superclass.constructor.call(this,A);this.navItems=[];Roo.bootstrap.NavGroup.register(this);this.addEvents({'changed':true});};Roo.extend(Roo.bootstrap.NavGroup,Roo.bootstrap.Component,{align:'',inverse:false,form:false,type:'nav',navId:'',navItems:false,getAutoCreate:function(){var A=Roo.apply({} -,Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));A={tag:'ul',cls:'nav'};if(Roo.bootstrap.version==4){if(this.type=='pills'){A.cls=' nav-pills';}}else{if(['tabs','pills'].indexOf(this.type)!==-1){A.cls+=' nav-'+this.type}else{if(this.type!=='nav'){Roo.log('nav type must be nav/tabs/pills')} -A.cls+=' navbar-nav'}}if(this.parent()&&this.parent().sidebar){A={tag:'ul',cls:'dashboard-menu sidebar-menu'};return A;}if(this.form===true){A={tag:'form',cls:'navbar-form form-inline'};if(this.align==='right'){A.cls+=' navbar-right ml-md-auto';}else{A.cls+=' navbar-left'; -}}if(this.align==='right'){A.cls+=' navbar-right ml-md-auto';}else{A.cls+=' mr-auto';}if(this.inverse){A.cls+=' navbar-inverse';}return A;},setActiveItem:function(A){var B=false;Roo.each(this.navItems,function(v){if(v==A){return;}if(v.isActive()){v.setActive(false,true); -B=v;}});A.setActive(true,true);this.fireEvent('changed',this,A,B);},getActive:function(){var A=false;Roo.each(this.navItems,function(v){if(v.isActive()){A=v;}});return A;},indexOfNav:function(){var A=false;Roo.each(this.navItems,function(v,i){if(v.isActive()){A=i; -}});return A;},addItem:function(A){if(this.form&&Roo.bootstrap.version==4){A.tag='div';}var cn=new Roo.bootstrap.NavItem(A);this.register(cn);cn.parentId=this.id;cn.onRender(this.el,null);return cn;},register:function(A){this.navItems.push(A);A.navId=this.navId; -},clearAll:function(){this.navItems=[];this.el.dom.innerHTML='';},getNavItem:function(A){var B=false;Roo.each(this.navItems,function(e){if(e.tabId==A){B=e;return false;}return true;});return B;},setActiveNext:function(){var i=this.indexOfNav(this.getActive()); -if(i>this.navItems.length){return;}this.setActiveItem(this.navItems[i+1]);},setActivePrev:function(){var i=this.indexOfNav(this.getActive());if(i<1){return;}this.setActiveItem(this.navItems[i-1]);},clearWasActive:function(A){Roo.each(this.navItems,function(e){if(e.tabId!=A.tabId&&e.was_active){e.was_active=false; -return false;}return true;});},getWasActive:function(){var r=false;Roo.each(this.navItems,function(e){if(e.was_active){r=e;return false;}return true;});return r;}});Roo.apply(Roo.bootstrap.NavGroup,{groups:{},register:function(A){this.groups[A.navId]=A;},get:function(A){if(typeof(this.groups[A])=='undefined'){return false; -}return this.groups[A];}}); +,Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));A={tag:'ul',cls:'nav'};if(Roo.bootstrap.version==4){if(['nav','pills'].indexOf(this.type)!=-1){A.cls=' nav-'+this.type;}}else{if(['tabs','pills'].indexOf(this.type)!=-1){A.cls+=' nav-'+this.type} +else{if(this.type!=='nav'){Roo.log('nav type must be nav/tabs/pills')}A.cls+=' navbar-nav'}}if(this.parent()&&this.parent().sidebar){A={tag:'ul',cls:'dashboard-menu sidebar-menu'};return A;}if(this.form===true){A={tag:'form',cls:'navbar-form form-inline'} +;if(this.align==='right'){A.cls+=' navbar-right ml-md-auto';}else{A.cls+=' navbar-left';}}if(this.align==='right'){A.cls+=' navbar-right ml-md-auto';}else{A.cls+=' mr-auto';}if(this.inverse){A.cls+=' navbar-inverse';}return A;},setActiveItem:function(A){var B=false; +Roo.each(this.navItems,function(v){if(v==A){return;}if(v.isActive()){v.setActive(false,true);B=v;}});A.setActive(true,true);this.fireEvent('changed',this,A,B);},getActive:function(){var A=false;Roo.each(this.navItems,function(v){if(v.isActive()){A=v;}});return A; +},indexOfNav:function(){var A=false;Roo.each(this.navItems,function(v,i){if(v.isActive()){A=i;}});return A;},addItem:function(A){if(this.form&&Roo.bootstrap.version==4){A.tag='div';}var cn=new Roo.bootstrap.NavItem(A);this.register(cn);cn.parentId=this.id; +cn.onRender(this.el,null);return cn;},register:function(A){this.navItems.push(A);A.navId=this.navId;},clearAll:function(){this.navItems=[];this.el.dom.innerHTML='';},getNavItem:function(A){var B=false;Roo.each(this.navItems,function(e){if(e.tabId==A){B=e; +return false;}return true;});return B;},setActiveNext:function(){var i=this.indexOfNav(this.getActive());if(i>this.navItems.length){return;}this.setActiveItem(this.navItems[i+1]);},setActivePrev:function(){var i=this.indexOfNav(this.getActive());if(i<1){return; +}this.setActiveItem(this.navItems[i-1]);},clearWasActive:function(A){Roo.each(this.navItems,function(e){if(e.tabId!=A.tabId&&e.was_active){e.was_active=false;return false;}return true;});},getWasActive:function(){var r=false;Roo.each(this.navItems,function(e){if(e.was_active){r=e; +return false;}return true;});return r;}});Roo.apply(Roo.bootstrap.NavGroup,{groups:{},register:function(A){this.groups[A.navId]=A;},get:function(A){if(typeof(this.groups[A])=='undefined'){return false;}return this.groups[A];}}); // Roo/bootstrap/NavItem.js Roo.bootstrap.NavItem=function(A){Roo.bootstrap.NavItem.superclass.constructor.call(this,A);this.addEvents({"click":true,'changed':true,'scrollto':true});};Roo.extend(Roo.bootstrap.NavItem,Roo.bootstrap.Component,{href:false,html:'',badge:'',icon:false,fa:false,glyphicon:false,active:false,preventDefault:false,tabId:false,tagtype:'a',tag:'li',disabled:false,animateRef:false,was_active:false,getAutoCreate:function(){var A={tag:this.tag,cls:'nav-item'} ;if(this.active){A.cls=typeof(A.cls)=='undefined'?'active':A.cls+' active';}if(this.disabled){A.cls+=' disabled';}if(this.href||this.html||this.glyphicon||this.icon||this.fa){A.cn=[{tag:this.tagtype,href:this.href||"#",html:this.html||''}];if(this.tagtype=='a'){A.cn[0].cls='nav-link';