From 50c57c8e8f83719c66c64a18f16f89cc1b79a466 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 3 Jun 2021 15:51:52 +0800 Subject: [PATCH] sync --- docs/json/roodata.json | 9 +++++++++ docs/src/Roo_bootstrap_Menu.js.html | 18 +++++++++++------- docs/symbols/Roo.bootstrap.Menu.json | 10 ++++++++++ roojs-bootstrap-debug.js | 18 +++++++++++------- roojs-bootstrap.js | 6 +++--- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/docs/json/roodata.json b/docs/json/roodata.json index 8cbf85cb45..730bc22a02 100644 --- a/docs/json/roodata.json +++ b/docs/json/roodata.json @@ -37979,6 +37979,15 @@ ], "memberOf" : "Roo.Component" }, + { + "name" : "hideTrigger", + "type" : "bool", + "desc" : [ + "(true", + "false)" + ], + "memberOf" : "" + }, { "name" : "isLink", "type" : "bool", diff --git a/docs/src/Roo_bootstrap_Menu.js.html b/docs/src/Roo_bootstrap_Menu.js.html index c9b1a64393..211a7c98b8 100644 --- a/docs/src/Roo_bootstrap_Menu.js.html +++ b/docs/src/Roo_bootstrap_Menu.js.html @@ -13,6 +13,7 @@ * @cfg {bool} hidden if the menu should be hidden when rendered. * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true) * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false) + * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger. * * @constructor * Create a new Menu @@ -108,7 +109,9 @@ isLink : false, - container_method : 'getDocumentBody', + container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works. + + hideTrigger : false, getChildContainer : function() { @@ -147,12 +150,13 @@ this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); - - if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { - // dropdown toggle on the 'a' in BS4? - this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); - } else if (!this.triggerEl.hasClass('no-dropdown-toggle')) { - this.triggerEl.addClass('dropdown-toggle'); + if (!this.hideTrigger) { + if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { + // dropdown toggle on the 'a' in BS4? + this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); + } else { + this.triggerEl.addClass('dropdown-toggle'); + } } if (Roo.isTouch) { this.el.on('touchstart' , this.onTouch, this); diff --git a/docs/symbols/Roo.bootstrap.Menu.json b/docs/symbols/Roo.bootstrap.Menu.json index 3f60e6d759..e02819f45b 100644 --- a/docs/symbols/Roo.bootstrap.Menu.json +++ b/docs/symbols/Roo.bootstrap.Menu.json @@ -134,6 +134,16 @@ "memberOf" : "Roo.Component", "values" : [] }, + { + "name" : "hideTrigger", + "type" : "bool", + "desc" : "default false - hide the carret for trigger.", + "memberOf" : "Roo.bootstrap.Menu", + "values" : [ + "(true", + "false)" + ] + }, { "name" : "registerMenu", "type" : "Boolean", diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 1ad425edaf..6bb9cd0c09 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -3576,6 +3576,7 @@ Roo.bootstrap.MenuMgr = function(){ * @cfg {bool} hidden if the menu should be hidden when rendered. * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true) * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false) + * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger. * * @constructor * Create a new Menu @@ -3671,7 +3672,9 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { isLink : false, - container_method : 'getDocumentBody', + container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works. + + hideTrigger : false, getChildContainer : function() { @@ -3710,12 +3713,13 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); - - if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { - // dropdown toggle on the 'a' in BS4? - this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); - } else if (!this.triggerEl.hasClass('no-dropdown-toggle')) { - this.triggerEl.addClass('dropdown-toggle'); + if (!this.hideTrigger) { + if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { + // dropdown toggle on the 'a' in BS4? + this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); + } else { + this.triggerEl.addClass('dropdown-toggle'); + } } if (Roo.isTouch) { this.el.on('touchstart' , this.onTouch, this); diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 5f9432b3e2..25fe19734e 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -152,10 +152,10 @@ F.un("show",onShow);var g=F.group;if(g&&F.events["checkchange"]){C[g].remove(F); if(g){C[g].remove(F);F.un("beforecheckchange",onBeforeCheck);}}};}(); // Roo/bootstrap/Menu.js Roo.bootstrap.Menu=function(A){Roo.bootstrap.Menu.superclass.constructor.call(this,A);if(this.registerMenu&&this.type!='treeview'){Roo.bootstrap.MenuMgr.register(this);}this.addEvents({beforeshow:true,beforehide:true,show:true,hide:true,click:true,mouseover:true,mouseout:true,itemclick:true} -);this.menuitems=new Roo.util.MixedCollection(false,function(o){return o.el.id;});};Roo.extend(Roo.bootstrap.Menu,Roo.bootstrap.Component,{triggerEl:false,type:false,registerMenu:true,menuItems:false,hidden:true,parentMenu:false,stopEvent:true,isLink:false,container_method:'getDocumentBody',getChildContainer:function(){return this.el; +);this.menuitems=new Roo.util.MixedCollection(false,function(o){return o.el.id;});};Roo.extend(Roo.bootstrap.Menu,Roo.bootstrap.Component,{triggerEl:false,type:false,registerMenu:true,menuItems:false,hidden:true,parentMenu:false,stopEvent:true,isLink:false,container_method:'getDocumentBody',hideTrigger:false,getChildContainer:function(){return this.el; },getAutoCreate:function(){var A={tag:'ul',cls:'dropdown-menu',style:'z-index:1000'};if(this.type==='submenu'){A.cls='submenu active';}if(this.type==='treeview'){A.cls='treeview-menu';}return A;},initEvents:function(){this.triggerEl.on('click',this.onTriggerClick,this); -this.triggerEl.on(Roo.isTouch?'touchstart':'mouseup',this.onTriggerPress,this);if(this.triggerEl.hasClass('nav-item')&&this.triggerEl.select('.nav-link',true).length){this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');}else if(!this.triggerEl.hasClass('no-dropdown-toggle')){this.triggerEl.addClass('dropdown-toggle'); -}if(Roo.isTouch){this.el.on('touchstart',this.onTouch,this);}this.el.on('click',this.onClick,this);this.el.on("mouseover",this.onMouseOver,this);this.el.on("mouseout",this.onMouseOut,this);},findTargetItem:function(e){var t=e.getTarget(".dropdown-menu-item",this.el,true); +this.triggerEl.on(Roo.isTouch?'touchstart':'mouseup',this.onTriggerPress,this);if(!this.hideTrigger){if(this.triggerEl.hasClass('nav-item')&&this.triggerEl.select('.nav-link',true).length){this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); +}else{this.triggerEl.addClass('dropdown-toggle');}}if(Roo.isTouch){this.el.on('touchstart',this.onTouch,this);}this.el.on('click',this.onClick,this);this.el.on("mouseover",this.onMouseOver,this);this.el.on("mouseout",this.onMouseOut,this);},findTargetItem:function(e){var t=e.getTarget(".dropdown-menu-item",this.el,true); if(!t){return false;}if(t&&t.id){return this.menuitems.get(t.id);}return false;},onTouch:function(e){Roo.log("menu.onTouch");this.onClick(e);},onClick:function(e){Roo.log("menu.onClick");var t=this.findTargetItem(e);if(!t||t.isContainer){return;}Roo.log(e); Roo.log('pass click event');t.onClick(e);this.fireEvent("click",this,t,e);var A=this;if(!t.href.length||t.href=='#'){(function(){A.hide();}).defer(100);}},onMouseOver:function(e){var t=this.findTargetItem(e);this.fireEvent("mouseover",this,e,t);},isVisible:function(){return !this.hidden; },onMouseOut:function(e){var t=this.findTargetItem(e);this.fireEvent("mouseout",this,e,t);},show:function(el,A,B){if(false===this.fireEvent("beforeshow",this)){Roo.log("show canceled");return;}this.parentMenu=B;if(!this.el){this.render();}this.showAt(this.el.getAlignToXY(el,A||this.defaultAlign),B,false); -- 2.39.2