]> source.dussan.org Git - jquery-ui.git/commitdiff
Menubar: Handle ESCAPE to close and refactor document-click code to also use _bind
authorjzaefferer <joern.zaefferer@gmail.com>
Thu, 17 Mar 2011 11:00:37 +0000 (12:00 +0100)
committerjzaefferer <joern.zaefferer@gmail.com>
Thu, 17 Mar 2011 11:00:37 +0000 (12:00 +0100)
tests/visual/menu/menubar.js

index 63fc34e8445a2f15a7bad6a6599b5c5c73ca5cb0..323f6f6816a6bdc3f06c996ad3603969f54750c7 100644 (file)
@@ -75,8 +75,17 @@ $.widget("ui.menubar", {
                        };                      
                        
                });
-               $(document).click(function(event) {
-                       !$(event.target).closest(".ui-menubar").length && self._close();
+               self._bind(document, {
+                       click: function(event) {
+                               !$(event.target).closest(".ui-menubar").length && self._close();
+                       }
+               })
+               self._bind({
+                       keyup: function(event) {
+                               if (event.keyCode == $.ui.keyCode.ESCAPE) {
+                                       self._close();
+                               }
+                       }
                });
        },