X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2Fbootstrap%2FMenu.js;h=e5fa5cf2d764ef05e43f7f1fa03d9a686ae69cd8;hb=242e8cb7d4eb31741bfb8d282303ac36f54dd00e;hp=b0f64f4ae9fcb131e1e9b397843ef0ed23e45ba7;hpb=8946284bad10596673ce59afe8ef1ea49ba0b790;p=roojs1 diff --git a/Roo/bootstrap/Menu.js b/Roo/bootstrap/Menu.js index b0f64f4ae9..e5fa5cf2d7 100644 --- a/Roo/bootstrap/Menu.js +++ b/Roo/bootstrap/Menu.js @@ -154,19 +154,22 @@ 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); } @@ -328,7 +331,10 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { //this.el.show(); this.hideMenuItems(); this.hidden = false; - this.triggerEl.addClass('open'); + if (this.triggerEl) { + this.triggerEl.addClass('open'); + } + this.el.addClass('show'); @@ -367,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()){ @@ -377,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); } @@ -423,7 +432,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { this.hide(); } else { Roo.log('show'); - + this.show(this.triggerEl, this.align, false); }