Roo/bootstrap/Menu.js
authorAlan Knowles <alan@roojs.com>
Thu, 17 Jun 2021 03:38:03 +0000 (11:38 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 17 Jun 2021 03:38:03 +0000 (11:38 +0800)
roojs-bootstrap.js
roojs-bootstrap-debug.js

Roo/bootstrap/Menu.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index 934534a..e5fa5cf 100644 (file)
@@ -155,21 +155,21 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
        // Roo.log("ADD event");
        // Roo.log(this.triggerEl.dom);
         if (this.triggerEl) {
-           
-           this.triggerEl.on('click', this.onTriggerClick, this);
-           
-           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) {
-                   // dropdown toggle on the 'a' in BS4?
-                   this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
-               } else {
-                   this.triggerEl.addClass('dropdown-toggle');
-               }
-           }
-       }
-       
+            
+            this.triggerEl.on('click', this.onTriggerClick, this);
+            
+            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) {
+                    // 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);
         }
@@ -373,9 +373,9 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
     hide : function(deep)
     {
         if (false === this.fireEvent("beforehide", this)) {
-           Roo.log("hide canceled");
-           return;
-       }
+            Roo.log("hide canceled");
+            return;
+        }
         this.hideMenuItems();
         if(this.el && this.isVisible()){
            
@@ -383,8 +383,11 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
                 this.activeItem.deactivate();
                 this.activeItem = null;
             }
-            this.triggerEl.removeClass('open');;
-           this.el.removeClass('show');
+            if (this.triggerEl) {
+                this.triggerEl.removeClass('open');
+            }
+            
+            this.el.removeClass('show');
             this.hidden = true;
             this.fireEvent("hide", this);
         }
@@ -429,7 +432,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
             this.hide();
         } else {
             Roo.log('show');
-            
+            
             this.show(this.triggerEl, this.align, false);
         }
         
index c769875..b945def 100644 (file)
@@ -3721,21 +3721,21 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
        // Roo.log("ADD event");
        // Roo.log(this.triggerEl.dom);
         if (this.triggerEl) {
-           
-           this.triggerEl.on('click', this.onTriggerClick, this);
-           
-           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) {
-                   // dropdown toggle on the 'a' in BS4?
-                   this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
-               } else {
-                   this.triggerEl.addClass('dropdown-toggle');
-               }
-           }
-       }
-       
+            
+            this.triggerEl.on('click', this.onTriggerClick, this);
+            
+            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) {
+                    // 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);
         }
@@ -3939,9 +3939,9 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
     hide : function(deep)
     {
         if (false === this.fireEvent("beforehide", this)) {
-           Roo.log("hide canceled");
-           return;
-       }
+            Roo.log("hide canceled");
+            return;
+        }
         this.hideMenuItems();
         if(this.el && this.isVisible()){
            
@@ -3949,8 +3949,11 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
                 this.activeItem.deactivate();
                 this.activeItem = null;
             }
-            this.triggerEl.removeClass('open');;
-           this.el.removeClass('show');
+            if (this.triggerEl) {
+                this.triggerEl.removeClass('open');
+            }
+            
+            this.el.removeClass('show');
             this.hidden = true;
             this.fireEvent("hide", this);
         }
@@ -3995,7 +3998,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component,  {
             this.hide();
         } else {
             Roo.log('show');
-            
+            
             this.show(this.triggerEl, this.align, false);
         }
         
index 65502d7..821af66 100644 (file)
@@ -163,8 +163,8 @@ Roo.log('pass click event');t.onClick(e);this.fireEvent("click",this,t,e);var A=
 var xy=this.el.getAlignToXY(el,A);if(this.el.getWidth()+xy[0]>=Roo.lib.Dom.getViewWidth()){xy=this.el.getAlignToXY(el,this.align.replace('/l/g','r'))}if(xy[0]<0){xy=this.el.getAlignToXY(el,this.align.replace('/r/g','l'))}if(this.el.getHeight()+xy[1]>=Roo.lib.Dom.getViewHeight()||xy[1]<0){var a=this.align.replace('?','').split('-');
 xy=this.el.getAlignToXY(el,a[1]+'-'+a[0]+'?')}this.showAt(xy,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;if(this.triggerEl){this.triggerEl.addClass('open');
 }this.el.addClass('show');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();Roo.log(A.nodeName.toLowerCase());if(A.nodeName.toLowerCase()==='i'){e.preventDefault();
+}},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;}if(this.triggerEl){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();Roo.log(A.nodeName.toLowerCase());if(A.nodeName.toLowerCase()==='i'){e.preventDefault();
 }},onTriggerPress:function(e){Roo.log('trigger press');var A=Roo.get(e.getTarget());if(A.findParent('.dropdown-menu')||A.findParent('.treeview-menu')){Roo.log('is treeview or dropdown?');return;}if(e.getTarget().nodeName.toLowerCase()!=='i'&&this.isLink){return;
 }if(this.isVisible()){Roo.log('hide');this.hide();}else{Roo.log('show');this.show(this.triggerEl,this.align,false);}if(this.stopEvent||e.getTarget().nodeName.toLowerCase()==='i'){e.stopEvent();}},hideMenuItems:function(){Roo.log("hide Menu Items");if(!this.el){return;
 }this.el.select('.open',true).each(function(aa){aa.removeClass('open');});},addxtypeChild:function(A,B){var C=Roo.bootstrap.Menu.superclass.addxtypeChild.call(this,A,B);this.menuitems.add(C);return C;},getEl:function(){Roo.log(this.el);return this.el;},clear:function(){this.getEl().dom.innerHTML='';