]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip: Handle ESCAPE key event to close tooltip when target has focus.
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 13 Jul 2011 22:06:16 +0000 (18:06 -0400)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 13 Jul 2011 22:06:16 +0000 (18:06 -0400)
ui/jquery.ui.tooltip.js

index f19061bc3019bc6307a03115fa7ca0677e44eb81..5e32459fc497fa8ac9e54ed729a65312bff90bb0 100644 (file)
@@ -148,7 +148,14 @@ $.widget( "ui.tooltip", {
 
                this._bind( target, {
                        mouseleave: "close",
-                       blur: "close"
+                       blur: "close",
+                       keyup: function( event ) {
+                               if ( event.keyCode == $.ui.keyCode.ESCAPE ) {
+                                       var fakeEvent = $.Event(event);
+                                       fakeEvent.currentTarget = target[0];
+                                       this.close( fakeEvent, true );
+                               }
+                       }
                });
        },
 
@@ -176,7 +183,7 @@ $.widget( "ui.tooltip", {
                        delete that.tooltips[ this.id ];
                });
 
-               target.unbind( "mouseleave.tooltip blur.tooltip" );
+               target.unbind( "mouseleave.tooltip blur.tooltip keyup.tooltip" );
 
                this._trigger( "close", event, { tooltip: tooltip } );
        },