X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Roo%2Fmenu%2FMenu.js;h=8bdf51068bb5a7fd786d612a7540f4732c434ef3;hb=06efe214ed956394052cfd1c25ed069a5291aee5;hp=10c388d441ff43c12a05b6d3d744f74b2ccd9cfe;hpb=aff3356b38b982b2f6447f0b2433fe25443596c6;p=roojs1 diff --git a/Roo/menu/Menu.js b/Roo/menu/Menu.js index 10c388d441..8bdf51068b 100644 --- a/Roo/menu/Menu.js +++ b/Roo/menu/Menu.js @@ -19,7 +19,9 @@ * @param {Object} config Configuration options */ Roo.menu.Menu = function(config){ - Roo.apply(this, config); + + Roo.menu.Menu.superclass.constructor.call(this, config); + this.id = this.id || Roo.id(); this.addEvents({ /** @@ -146,10 +148,18 @@ Roo.extend(Roo.menu.Menu, Roo.util.Observable, { tag: "a", cls: "x-menu-focus", href: "#", onclick: "return false;", tabIndex:"-1" }); var ul = el.createChild({tag: "ul", cls: "x-menu-list"}); - ul.on("click", this.onClick, this); + //disabling touch- as it's causing issues .. + //ul.on(Roo.isTouch ? 'touchstart' : 'click' , this.onClick, this); + ul.on('click' , this.onClick, this); + + ul.on("mouseover", this.onMouseOver, this); ul.on("mouseout", this.onMouseOut, this); this.items.each(function(item){ + if (item.hidden) { + return; + } + var li = document.createElement("li"); li.className = "x-menu-list-item"; ul.dom.appendChild(li); @@ -195,11 +205,28 @@ Roo.extend(Roo.menu.Menu, Roo.util.Observable, { // private onClick : function(e){ - var t; - if(t = this.findTargetItem(e)){ - t.onClick(e); - this.fireEvent("click", this, t, e); + Roo.log("menu.onClick"); + var t = this.findTargetItem(e); + if(!t){ + return; + } + Roo.log(e); + if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) { + if(t == this.activeItem && t.shouldDeactivate(e)){ + this.activeItem.deactivate(); + delete this.activeItem; + return; + } + if(t.canActivate){ + this.setActiveItem(t, true); + } + return; + + } + + t.onClick(e); + this.fireEvent("click", this, t, e); }, // private @@ -362,7 +389,7 @@ var item = menu.add( var a = arguments, l = a.length, item; for(var i = 0; i < l; i++){ var el = a[i]; - if (typeof el == "object" && el.xtype) { + if ((typeof(el) == "object") && el.xtype && el.xns) { el = Roo.factory(el, Roo.menu); }