From 86aa7df40c25bcd0fb517485ec6bcf69128691bf Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 10 Mar 2015 15:13:25 +0800 Subject: [PATCH] roojs-bootstrap.js roojs-bootstrap-debug.js --- roojs-bootstrap-debug.js | 16 +++++++++++----- roojs-bootstrap.js | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 891081576d..aabb6056b8 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -3700,12 +3700,18 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, { if(this.fireEvent('click', this, e) === false){ return; }; - - if (['tabs','pills'].indexOf(this.parent().type)!==-1) { - if (typeof(this.parent().setActiveItem) !== 'undefined') { - this.parent().setActiveItem(this); + var p = this.parent(); + if (['tabs','pills'].indexOf(p.type)!==-1) { + if (typeof(p.setActiveItem) !== 'undefined') { + p.setActiveItem(this); } - } + } + // if parent is a navbarheader.... + if (p.parentType == 'NavHeaderbar' && !this.menu) { + // remove the collapsed menu expand... + p.parent().el.select('.navbar-collapse',true).removeClass('in'); + } + }, isActive: function () { diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 2335090091..7949418917 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -90,7 +90,7 @@ this.setActiveItem(this.navItems[i-1]);},clearWasActive:function(A){Roo.each(thi //Roo/bootstrap/NavItem.js Roo.bootstrap.NavItem=function(A){Roo.bootstrap.NavItem.superclass.constructor.call(this,A);this.addEvents({"click":true,'changed':true});};Roo.extend(Roo.bootstrap.NavItem,Roo.bootstrap.Component,{href:false,html:'',badge:'',icon:false,glyphicon:false,active:false,preventDefault:false,tabId:false,tagtype:'a',disabled:false,was_active:false,getAutoCreate:function(){var A={tag:'li',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){A.cn=[{tag:this.tagtype,href:this.href||"#",html:this.html||''}];if(this.icon){A.cn[0].html=' '+A.cn[0].html+''}if(this.glyphicon){A.cn[0].html=' '+A.cn[0].html;}if(this.menu){A.cn[0].html+=" ";}if(this.badge!==''){A.cn[0].html+=' '+this.badge+'';}}return A;},initEvents:function(){if(typeof(this.menu)!='undefined'){this.menu.parentType=this.xtype;this.menu.triggerEl=this.el;this.addxtype(Roo.apply({},this.menu));} this.el.select('a',true).on('click',this.onClick,this);this.parent().register(this);},onClick:function(e){if(this.preventDefault){e.preventDefault();}if(this.disabled){return;}var tg=Roo.bootstrap.TabGroup.get(this.navId);if(tg&&tg.transition){Roo.log("waiting for the transitionend");return;} -Roo.log("fire event clicked");if(this.fireEvent('click',this,e)===false){return;};if(['tabs','pills'].indexOf(this.parent().type)!==-1){if(typeof(this.parent().setActiveItem)!=='undefined'){this.parent().setActiveItem(this);}}},isActive:function(){return this.active},setActive:function(A,B,C){if(this.active&&!A&this.navId){this.was_active=true;var nv=Roo.bootstrap.NavGroup.get(this.navId);if(nv){nv.clearWasActive(this);}} +Roo.log("fire event clicked");if(this.fireEvent('click',this,e)===false){return;};var p=this.parent();if(['tabs','pills'].indexOf(p.type)!==-1){if(typeof(p.setActiveItem)!=='undefined'){p.setActiveItem(this);}}if(p.parentType=='NavHeaderbar'&&!this.menu){p.parent().el.select('.navbar-collapse',true).removeClass('in');}},isActive:function(){return this.active},setActive:function(A,B,C){if(this.active&&!A&this.navId){this.was_active=true;var nv=Roo.bootstrap.NavGroup.get(this.navId);if(nv){nv.clearWasActive(this);}} this.active=A;if(!A){this.el.removeClass('active');}else if(!this.el.hasClass('active')){this.el.addClass('active');}if(B){this.fireEvent('changed',this,A);}if(!this.navId||!this.tabId||!A||C){return;}var tg=Roo.bootstrap.TabGroup.get(this.navId);if(!tg){return;}var D=tg.getPanelByName(this.tabId);if(!D){return;}if(false==tg.showPanel(D)){var nv=Roo.bootstrap.NavGroup.get(this.navId);if(nv){var E=nv.getWasActive();if(E){E.setActive(true,false,true);}}}},setDisabled:function(A){this.disabled=A;if(!A){this.el.removeClass('disabled');}else if(!this.el.hasClass('disabled')){this.el.addClass('disabled');}}}); //Roo/bootstrap/NavSidebarItem.js Roo.bootstrap.NavSidebarItem=function(A){Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this,A);this.addEvents({"click":true,'changed':true});};Roo.extend(Roo.bootstrap.NavSidebarItem,Roo.bootstrap.NavItem,{getAutoCreate:function(){var a={tag:'a',href:this.href||'#',cls:'',html:'',cn:[]};var A={tag:'li',cls:'',cn:[a]};var span={tag:'span',html:this.html||''};if(this.active){A.cls+=' active';}if(this.glyphicon||this.icon){var c=this.glyphicon?('glyphicon glyphicon-'+this.glyphicon):this.icon;a.cn.push({tag:'i',cls:c});} -- 2.39.2