X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c45dbdae360cfbcbdc998b45e172cc30915add84..237d2ad60dd6b6778603ad274e2f6a168aada259:/app/assets/javascripts/menu.js diff --git a/app/assets/javascripts/menu.js b/app/assets/javascripts/menu.js index 5e2d9d97a..a01fc39cc 100644 --- a/app/assets/javascripts/menu.js +++ b/app/assets/javascripts/menu.js @@ -23,25 +23,27 @@ function openMenu(anchor, menu, align) { * Setup a menu, triggered by hovering over an anchor for a given time. */ function createMenu(anchorid, menuid, align) { - var $anchor = $("#" + anchorid), - $arrow = $("#" + anchorid + ' .arrow'), - $menu = $("#" + menuid), - $page = $(':not(#' + menuid + ', #' + anchorid + ')'); + var $anchor = $("#" + anchorid); + var $arrow = $("#" + anchorid + " .menuicon"); + var $menu = $("#" + menuid); + var $page = $(":not(#" + menuid + ", #" + anchorid + ")"); function hide() { $menu.hide(); - $page.unbind('click', hide); + $page.off("click", hide); } $arrow.click(function(e) { + if ($anchor.is(":not(.disabled)")) { e.stopPropagation(); e.preventDefault(); - if ($menu.is(':visible')) { - $menu.hide(); - $page.unbind('click', hide); + if ($menu.is(":visible")) { + $menu.hide(); + $page.off("click", hide); } else { - openMenu($anchor, $menu.show(), 'left'); - $page.bind('click', hide); + openMenu($anchor, $menu.show(), align); + $page.on("click", hide); } + } }); }