From: Alan Knowles Date: Wed, 5 Dec 2018 07:56:23 +0000 (+0800) Subject: roojs-bootstrap.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=74635ad8eb9b44610bb2c0edc7bc963a3a811150 roojs-bootstrap.js roojs-bootstrap-debug.js --- diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 5f023177fa..fd415b77e2 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -4615,6 +4615,8 @@ Roo.apply(Roo.bootstrap.NavGroup, { * @extends Roo.bootstrap.Component * Bootstrap Navbar.NavItem class * @cfg {String} href link to + * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none + * @cfg {String} html content of button * @cfg {String} badge text inside badge * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge @@ -4680,6 +4682,8 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, { disabled : false, animateRef : false, was_active : false, + button_weight : '', + button_outline : false, navLink: false, @@ -4688,7 +4692,6 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, { var cfg = { tag: this.tag, cls: 'nav-item' - }; if (this.active) { @@ -4697,6 +4700,27 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, { if (this.disabled) { cfg.cls += ' disabled'; } + + // BS4 only? + if (this.button_weight.length) { + cfg.tag = this.href ? 'a' : 'button'; + cfg.html = this.html || ''; + cfg.cls += ' btn' + (this.btn_outline ? '-outline' : '') + this.button_weight; + if (this.href) { + cfg.href = this.href; + } + if (this.fa) { + cfg.html = ' ' + this.html + ''; + } + + // menu .. should add dropdown-menu class - so no need for carat.. + + if (this.badge !== '') { + + cfg.html += ' ' + this.badge + ''; + } + return cfg; + } if (this.href || this.html || this.glyphicon || this.icon || this.fa) { cfg.cn = [ @@ -4710,10 +4734,10 @@ Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, { cfg.cn[0].cls = 'nav-link'; } if (this.icon) { - cfg.cn[0].html = ' ' + cfg.cn[0].html + '' + cfg.cn[0].html = ' ' + cfg.cn[0].html + ''; } if (this.fa) { - cfg.cn[0].html = ' ' + cfg.cn[0].html + '' + cfg.cn[0].html = ' ' + cfg.cn[0].html + ''; } if(this.glyphicon) { cfg.cn[0].html = ' ' + cfg.cn[0].html; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index d937a240c0..7b4acaa9c5 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -186,9 +186,10 @@ return false;}return true;});return B;},setActiveNext:function(){var i=this.inde }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,navLink: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'; -}if(this.icon){A.cn[0].html=' '+A.cn[0].html+''}if(this.fa){A.cn[0].html=' '+A.cn[0].html+''}if(this.glyphicon){A.cn[0].html=' '+A.cn[0].html; +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,button_weight:'',button_outline:false,navLink: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.button_weight.length){A.tag=this.href?'a':'button';A.html=this.html||'';A.cls+=' btn'+(this.btn_outline?'-outline':'')+this.button_weight; +if(this.href){A.href=this.href;}if(this.fa){A.html=' '+this.html+'';}if(this.badge!==''){A.html+=' '+this.badge+'';}return A;}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';}if(this.icon){A.cn[0].html=' '+A.cn[0].html+'';}if(this.fa){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;},onRender:function(ct,A){if(Roo.bootstrap.version==4&&ct.dom.type!='ul'){this.tag='div'; }var B=Roo.bootstrap.NavItem.superclass.onRender.call(this,ct,A);this.navLink=this.el.select('.nav-link',true).first();return B;},initEvents:function(){if(typeof(this.menu)!='undefined'){this.menu.parentType=this.xtype;this.menu.triggerEl=this.el;this.menu=this.addxtype(Roo.apply({} ,this.menu));}this.el.select('a',true).on('click',this.onClick,this);if(this.tagtype=='span'){this.el.select('span',true).on('click',this.onClick,this);}this.parent().register(this);},onClick:function(e){if(e.getTarget('.dropdown-menu-item')){return;}if(this.preventDefault||this.href=='#'){Roo.log("NavItem - prevent Default?");