From: jzaefferer Date: Wed, 23 Feb 2011 11:12:29 +0000 (+0100) Subject: Menu: Introducing position option into flyout menu X-Git-Tag: 1.9m5~293 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ddfd5e632cf4a1517c1f28d89c2b9c00429e8ab2;p=jquery-ui.git Menu: Introducing position option into flyout menu --- diff --git a/tests/visual/menu/flyoutmenu.html b/tests/visual/menu/flyoutmenu.html index 8240689df..55e7053e5 100644 --- a/tests/visual/menu/flyoutmenu.html +++ b/tests/visual/menu/flyoutmenu.html @@ -28,7 +28,6 @@ // TODO required to prevent the click handler below from handling this event event.stopPropagation(); menu.flyoutmenu("show") - //.attr("tabIndex", 0) .focus() .css({ top: 0, @@ -45,17 +44,28 @@ }); menu.flyoutmenu({ - //input: button, + /* top-alignment + position: function(item) { + return { + my: "left top", + at: "right top", + of: item.parent() + } + }, + */ select: function(event, ui) { $("#log").append("
Selected " + ui.item.children("a").text() + "
"); button.focus(); } }).hide(); + + // equal height + //menu.find("ul").height(menu.height()); }); diff --git a/tests/visual/menu/flyoutmenu.js b/tests/visual/menu/flyoutmenu.js index 665426796..bffecea7f 100644 --- a/tests/visual/menu/flyoutmenu.js +++ b/tests/visual/menu/flyoutmenu.js @@ -6,6 +6,14 @@ (function($) { $.widget("ui.flyoutmenu", { + + options: { + position: { + my: "left top", + at: "right top" + } + }, + _create: function() { var self = this; this.active = this.element; @@ -90,14 +98,18 @@ $.widget("ui.flyoutmenu", { // TODO restrict to widget //only one menu can have items open at a time. $(document).find(".ui-menu-flyout").not(submenu.parents()).hide(); + + var position = $.extend({}, { + of: this.activeItem + }, $.type(this.options.position) == "function" + ? this.options.position(this.activeItem) + : this.options.position + ); + submenu.show().css({ top: 0, left: 0 - }).position({ - my: "left top", - at: "right top", - of: this.activeItem - }); + }).position(position); }, _select: function(event) { event.stopPropagation();