From 3bd7300f5f2a23b9bda8f7a4d0f4ed28696c706b Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 3 Jun 2021 15:47:51 +0800 Subject: [PATCH] sync --- Roo/bootstrap/Component.js | 5 +++++ Roo/bootstrap/Menu.js | 7 +++++-- Roo/bootstrap/menu/Separator.js | 2 +- roojs-bootstrap-debug.js | 14 +++++++++++--- roojs-bootstrap.js | 27 ++++++++++++++------------- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Roo/bootstrap/Component.js b/Roo/bootstrap/Component.js index 01b90dc3ee..efd739fe61 100644 --- a/Roo/bootstrap/Component.js +++ b/Roo/bootstrap/Component.js @@ -149,6 +149,11 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, { { return this.el; }, + getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work + { + return Roo.get(document.body); + }, + /** * Fetch the element to display the tooltip on. * @return {Roo.Element} defaults to this.el diff --git a/Roo/bootstrap/Menu.js b/Roo/bootstrap/Menu.js index b65aaf681b..47bc16929a 100644 --- a/Roo/bootstrap/Menu.js +++ b/Roo/bootstrap/Menu.js @@ -108,6 +108,9 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { isLink : false, + container_method : 'getDocumentBody', + + getChildContainer : function() { return this.el; }, @@ -145,10 +148,10 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); - if (this.triggerEl.hasClass('nav-item')) { + 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 { + } else if (!this.triggerEl.hasClass('no-dropdown-toggle')) { this.triggerEl.addClass('dropdown-toggle'); } if (Roo.isTouch) { diff --git a/Roo/bootstrap/menu/Separator.js b/Roo/bootstrap/menu/Separator.js index 648c5246a2..60c508a2f7 100644 --- a/Roo/bootstrap/menu/Separator.js +++ b/Roo/bootstrap/menu/Separator.js @@ -26,7 +26,7 @@ Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, { getAutoCreate : function(){ var cfg = { tag : 'li', - cls: 'divider' + cls: 'dropdown-divider divider' }; return cfg; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 6e93436948..1ad425edaf 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -362,6 +362,11 @@ Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, { { return this.el; }, + getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work + { + return Roo.get(document.body); + }, + /** * Fetch the element to display the tooltip on. * @return {Roo.Element} defaults to this.el @@ -3666,6 +3671,9 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { isLink : false, + container_method : 'getDocumentBody', + + getChildContainer : function() { return this.el; }, @@ -3703,10 +3711,10 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); - if (this.triggerEl.hasClass('nav-item')) { + 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 { + } else if (!this.triggerEl.hasClass('no-dropdown-toggle')) { this.triggerEl.addClass('dropdown-toggle'); } if (Roo.isTouch) { @@ -28954,7 +28962,7 @@ Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, { getAutoCreate : function(){ var cfg = { tag : 'li', - cls: 'divider' + cls: 'dropdown-divider divider' }; return cfg; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index f4388fcd93..5f9432b3e2 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -14,11 +14,12 @@ Roo.bootstrap=Roo.bootstrap||{};Roo.bootstrap.Component=function(A){Roo.bootstra ,xattr:false,parentId:false,can_build_overlaid:true,container_method:false,dataId:false,name:false,parent:function(){return Roo.ComponentMgr.get(this.parentId)},onRender:function(ct,A){Roo.bootstrap.Component.superclass.onRender.call(this,ct,A);if(this.el){if(this.el.attr('xtype')){this.el.attr('xtypex',this.el.attr('xtype')); this.el.dom.removeAttribute('xtype');this.initEvents();}return;}var B=Roo.apply({},this.getAutoCreate());B.id=this.id||Roo.id();if(this.xattr&&typeof(this.xattr)=='object'){for(var i in this.xattr){B[i]=this.xattr[i];}}if(this.dataId){B.dataId=this.dataId; }if(this.cls){B.cls=(typeof(B.cls)=='undefined')?this.cls:B.cls+' '+this.cls;}if(this.style){B.style=this.style;}if(this.name){B.name=this.name;}this.el=ct.createChild(B,A);if(this.tooltip){this.tooltipEl().attr('tooltip',this.tooltip);}if(this.tabIndex!==undefined){this.el.dom.setAttribute('tabIndex',this.tabIndex); -}this.initEvents();},getChildContainer:function(){return this.el;},tooltipEl:function(){return this.el;},addxtype:function(A,B){var cn=this;cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;B=(typeof(B)=='undefined')?'getChildContainer':B;if(typeof(cn.container_method)=='string'){B=cn.container_method; -}var C=(typeof(A['flexy:foreach'])!='undefined');var D=(typeof(A['flexy:if'])!='undefined');var E=Roo.XComponent.build_from_html;var F=(A.xtype=='Body');var G=(Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body');var H=Roo.get(this[B](false));if((C||D||this.can_build_overlaid==false)&&E){return false; -}if(!C||!E||F||!G){if(!D||typeof(A.name)=='undefined'||!E||F||!G){return this.addxtypeChild(A,B,F);}var I=H?H.child('>*[name='+A.name+']'):false;if(I){return this.addxtypeChild(Roo.apply({},A),B);}Roo.log('skipping render');return cn;}var J=false;if(!E){return false; -}while(true){var I=H?H.child('>*[xtype]'):false;if(!I){break;}if(I&&I.attr('xtype').split('.').pop()!=cn.xtype){break;}J=this.addxtypeChild(Roo.apply({},A),B);}return J;},addxtypeChild:function(A,B,C){Roo.debug&&Roo.log('addxtypeChild:'+B);var cn=this;B=(typeof(B)=='undefined')?'getChildContainer':B; -var D=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefined');skip_children=false;if(!C){if(!this[B](true)){A.items=[];return A;}cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;var E=Roo.XComponent.build_from_html;if(E&&Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body'){var F=Roo.get(this[B](false)); +}this.initEvents();},getChildContainer:function(){return this.el;},getDocumentBody:function(){return Roo.get(document.body);},tooltipEl:function(){return this.el;},addxtype:function(A,B){var cn=this;cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id; +B=(typeof(B)=='undefined')?'getChildContainer':B;if(typeof(cn.container_method)=='string'){B=cn.container_method;}var C=(typeof(A['flexy:foreach'])!='undefined');var D=(typeof(A['flexy:if'])!='undefined');var E=Roo.XComponent.build_from_html;var F=(A.xtype=='Body'); +var G=(Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body');var H=Roo.get(this[B](false));if((C||D||this.can_build_overlaid==false)&&E){return false;}if(!C||!E||F||!G){if(!D||typeof(A.name)=='undefined'||!E||F||!G){return this.addxtypeChild(A,B,F); +}var I=H?H.child('>*[name='+A.name+']'):false;if(I){return this.addxtypeChild(Roo.apply({},A),B);}Roo.log('skipping render');return cn;}var J=false;if(!E){return false;}while(true){var I=H?H.child('>*[xtype]'):false;if(!I){break;}if(I&&I.attr('xtype').split('.').pop()!=cn.xtype){break; +}J=this.addxtypeChild(Roo.apply({},A),B);}return J;},addxtypeChild:function(A,B,C){Roo.debug&&Roo.log('addxtypeChild:'+B);var cn=this;B=(typeof(B)=='undefined')?'getChildContainer':B;var D=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefined'); +skip_children=false;if(!C){if(!this[B](true)){A.items=[];return A;}cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;var E=Roo.XComponent.build_from_html;if(E&&Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body'){var F=Roo.get(this[B](false)); var G=F?F.child('>*[xtype]'):false;if(G){}if(G&&G.attr('xtype').split('.').pop()==cn.xtype){cn.el=G;}else{Roo.debug&&Roo.log("MISSING "+cn.xtype+" on child of "+(this.el?this.el.attr('xbuilderid'):'no parent'));Roo.debug&&Roo.log(F);Roo.debug&&Roo.log(G); Roo.debug&&Roo.log(cn);}}if(E&&D&&!cn.el&&cn.can_build_overlaid){Roo.debug&&Roo.log('skipping render');Roo.debug&&Roo.log(A);if(!cn.el){Roo.debug&&Roo.log('skipping all children');skip_children=true;}}else{cn.render&&cn.render(this[B](true));}}var H=[];if(!A.items||!A.items.length){cn.items=H; return cn;}var I=A.items;delete A.items;if(!skip_children){for(var i=0;i=Roo.lib.Dom.getViewWidth()){xy[0]=xy[0]-this.el.getWidth()+this.triggerEl.getWidth(); +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); +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); +},showAt:function(xy,A,_e){this.parentMenu=A;if(!this.el){this.render();}if(_e!==false){this.fireEvent("beforeshow",this);}this.hideMenuItems();this.hidden=false;this.triggerEl.addClass('open');this.el.addClass('show');if(this.el.getWidth()+xy[0]>=Roo.lib.Dom.getViewWidth()){xy[0]=xy[0]-this.el.getWidth()+this.triggerEl.getWidth(); }if(this.el.getHeight()+xy[1]>=Roo.lib.Dom.getViewHeight()){xy[1]=xy[1]-this.el.getHeight()-this.triggerEl.getHeight();}if(this.el.getStyle('top')!='auto'&&this.el.getStyle('top').slice(-1)!="%"){this.el.setXY(xy);}this.focus();this.fireEvent("show",this); },focus:function(){return;if(!this.hidden){this.doFocus.defer(50,this);}},doFocus:function(){if(!this.hidden){this.focusEl.focus();}},hide:function(A){if(false===this.fireEvent("beforehide",this)){Roo.log("hide canceled");return;}this.hideMenuItems();if(this.el&&this.isVisible()){if(this.activeItem){this.activeItem.deactivate(); this.activeItem=null;}this.triggerEl.removeClass('open');;this.el.removeClass('show');this.hidden=true;this.fireEvent("hide",this);}if(A===true&&this.parentMenu){this.parentMenu.hide(true);}},onTriggerClick:function(e){Roo.log('trigger click');var A=e.getTarget(); @@ -1217,7 +1218,7 @@ if(this.pos=='left'){B.cls=(typeof(B.cls)=='undefined')?'pull-left':(B.cls+' pul },onClick:function(e){if(this.preventDefault){e.preventDefault();}this.fireEvent("click",this,e);},onMouseOver:function(e){if(this.submenu&&this.pos=='left'){this.el.select('ul.dropdown-menu',true).first().setLeft(this.el.select('ul.dropdown-menu',true).first().getWidth()*-1); }this.fireEvent("mouseover",this,e);},onMouseOut:function(e){this.fireEvent("mouseout",this,e);}}); // Roo/bootstrap/menu/Separator.js -Roo.bootstrap.menu=Roo.bootstrap.menu||{};Roo.bootstrap.menu.Separator=function(A){Roo.bootstrap.menu.Separator.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.menu.Separator,Roo.bootstrap.Component,{getAutoCreate:function(){var A={tag:'li',cls:'divider'} +Roo.bootstrap.menu=Roo.bootstrap.menu||{};Roo.bootstrap.menu.Separator=function(A){Roo.bootstrap.menu.Separator.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.menu.Separator,Roo.bootstrap.Component,{getAutoCreate:function(){var A={tag:'li',cls:'dropdown-divider divider'} ;return A;}}); // Roo/bootstrap/Tooltip.js Roo.bootstrap.Tooltip=function(A){Roo.bootstrap.Tooltip.superclass.constructor.call(this,A);this.alignment=Roo.bootstrap.Tooltip.alignment;if(typeof(A)!='undefined'&&typeof(A.alignment)!='undefined'){this.alignment=A.alignment;}};Roo.apply(Roo.bootstrap.Tooltip,{currentEl:false,currentTip:false,currentRegion:false,init:function(){Roo.get(document).on('mouseover',this.enter,this); -- 2.39.2