From f70946ff62abc1be60a180f305bbe8ed4d221473 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 27 Jun 2012 11:49:13 +0200 Subject: [PATCH] Menu: when clicking on file item, but next to the file input, don't trigger a click event --- source/Ox.UI/js/Menu/Menu.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/Ox.UI/js/Menu/Menu.js b/source/Ox.UI/js/Menu/Menu.js index f4c8a7be..87e71baa 100644 --- a/source/Ox.UI/js/Menu/Menu.js +++ b/source/Ox.UI/js/Menu/Menu.js @@ -169,10 +169,14 @@ Ox.Menu = function(options, self) { }); } } else { - menu.triggerEvent('click', Ox.extend({ - id: item.options('id'), - title: Ox.stripTags(item.options('title')[0]) - }, files ? {files: files} : {})); + // if item.options.files && !files, the click happened outside + // the title - as a workaround, we don't trigger a click event. + if (!item.options('file') || files) { + menu.triggerEvent('click', Ox.extend({ + id: item.options('id'), + title: Ox.stripTags(item.options('title')[0]) + }, files ? {files: files} : {})); + } } if (item.options('title').length == 2) { item.toggleTitle(); @@ -242,7 +246,10 @@ Ox.Menu = function(options, self) { } function mouseleave() { - if (self.options.selected > -1 && !that.items[self.options.selected].options('items').length) { + if ( + self.options.selected > -1 + && !that.items[self.options.selected].options('items').length + ) { selectItem(-1); } } @@ -638,7 +645,7 @@ Ox.Menu = function(options, self) { /*@ clickItem clickItem - (position, files) -> click item at position + (position, files) -> click item at position @*/ that.clickItem = function(position, files) { clickItem(position, files);