]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Update menubar to use menu instead of removed flyoutmenu.
authorjzaefferer <joern.zaefferer@gmail.com>
Thu, 24 Feb 2011 15:39:08 +0000 (16:39 +0100)
committerjzaefferer <joern.zaefferer@gmail.com>
Thu, 24 Feb 2011 15:39:08 +0000 (16:39 +0100)
tests/visual/menu/menubar.html
tests/visual/menu/menubar.js

index c49abb2da65055e1fdb37bf7beee246c886b70b6..a3db019c26acec83c93576b957646a59d1c2f32e 100644 (file)
@@ -10,7 +10,6 @@
        <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
        <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
        <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script>
-       <script type="text/javascript" src="flyoutmenu.js"></script>
        <script type="text/javascript" src="menubar.js"></script>
        <!--
        <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
@@ -26,7 +25,6 @@
                $(".menubar").menubar({
                        select: function(event, ui) {
                                $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
-                               ui.item.parents("ul:last").prev().focus()
                        }
                });
        });
@@ -46,6 +44,9 @@
 <body>
 
 <div class="menubar ui-widget-header">
+       <!--
+       <a href="#">About...</a>
+       -->
        <a href="#">File</a>
        <ul>
                <li><a href="#">Open...</a></li>
index a8f986349f09eafcee8da2f60db4915be400fced..8870e068ae97d224cdc8b83e39fed9e2c73d52aa 100644 (file)
@@ -5,14 +5,18 @@
  */
 (function($) {
 
+// TODO take non-menubar buttons into account
 $.widget("ui.menubar", {
        _create: function() {
                var self = this;
                var items = this.element.children("button, a");
                items.next("ul").each(function(i, elm) {
-                       $(elm).flyoutmenu({
-                               select: self.options.select
-                       }).hide().addClass("ui-menu-flyout").keydown(function(event) {
+                       $(elm).menu({
+                               select: function(event, ui) {
+                                       ui.item.parents("ul:last").hide()
+                                       self.options.select.apply(this, arguments);
+                               }
+                       }).hide().keydown(function(event) {
                                var menu = $(this);
                                if (menu.is(":hidden")) 
                                        return;
@@ -54,8 +58,8 @@ $.widget("ui.menubar", {
        },
        
        _open: function(event, menu) {
-               this.active && this.active.flyoutmenu("hide");
-               this.active = menu.flyoutmenu("show").position({
+               this.active && this.active.menu("closeAll").hide();
+               this.active = menu.show().position({
                        my: "left top",
                        at: "left bottom",
                        offset: "0 -1",
@@ -64,20 +68,20 @@ $.widget("ui.menubar", {
        },
        
        left: function(event) {
-               var prev = this.active.prevAll( ".ui-menu-flyout" ).eq( 0 );
+               var prev = this.active.prevAll( ".ui-menu" ).eq( 0 );
                if (prev.length) {
                        this._open(event, prev);
                } else {
-                       this._open(event, this.element.children(".ui-menu-flyout:last"));
+                       this._open(event, this.element.children(".ui-menu:last"));
                }
        },
        
        right: function(event) {
-               var next =  this.active.nextAll( ".ui-menu-flyout" ).eq( 0 );
+               var next =  this.active.nextAll( ".ui-menu" ).eq( 0 );
                if (next.length) {
                        this._open(event, next);
                } else {
-                       this._open(event, this.element.children(".ui-menu-flyout:first"));
+                       this._open(event, this.element.children(".ui-menu:first"));
                }
        }
 });