@@ -73,6 +73,8 @@ $.widget( "ui.tooltip", {
73
73
74
74
// IDs of generated tooltips, needed for destroy
75
75
this . tooltips = { } ;
76
+ // IDs of parent tooltips where we removed the title attribute
77
+ this . parents = { } ;
76
78
} ,
77
79
78
80
_setOption : function ( key , value ) {
@@ -126,10 +128,11 @@ $.widget( "ui.tooltip", {
126
128
} ,
127
129
128
130
open : function ( event ) {
129
- var target = $ ( event ? event . target : this . element )
130
- // we need closest here due to mouseover bubbling,
131
- // but always pointing at the same event target
132
- . closest ( this . options . items ) ;
131
+ var that = this ,
132
+ target = $ ( event ? event . target : this . element )
133
+ // we need closest here due to mouseover bubbling,
134
+ // but always pointing at the same event target
135
+ . closest ( this . options . items ) ;
133
136
134
137
// No element to show a tooltip for
135
138
if ( ! target . length ) {
@@ -154,6 +157,26 @@ $.widget( "ui.tooltip", {
154
157
155
158
target . data ( "tooltip-open" , true ) ;
156
159
160
+ // kill parent tooltips, custom or native, for hover
161
+ if ( event && event . type === "mouseover" ) {
162
+ target . parents ( ) . each ( function ( ) {
163
+ var blurEvent ;
164
+ if ( $ ( this ) . data ( "tooltip-open" ) ) {
165
+ blurEvent = $ . Event ( "blur" ) ;
166
+ blurEvent . target = blurEvent . currentTarget = this ;
167
+ that . close ( blurEvent , true ) ;
168
+ }
169
+ if ( this . title ) {
170
+ $ ( this ) . uniqueId ( ) ;
171
+ that . parents [ this . id ] = {
172
+ element : this ,
173
+ title : this . title
174
+ } ;
175
+ this . title = "" ;
176
+ }
177
+ } ) ;
178
+ }
179
+
157
180
this . _updateContent ( target , event ) ;
158
181
} ,
159
182
@@ -289,6 +312,13 @@ $.widget( "ui.tooltip", {
289
312
this . _off ( target , "mouseleave focusout keyup" ) ;
290
313
this . _off ( this . document , "mousemove" ) ;
291
314
315
+ if ( event && event . type === "mouseleave" ) {
316
+ $ . each ( this . parents , function ( id , parent ) {
317
+ parent . element . title = parent . title ;
318
+ delete that . parents [ id ] ;
319
+ } ) ;
320
+ }
321
+
292
322
this . closing = true ;
293
323
this . _trigger ( "close" , event , { tooltip : tooltip } ) ;
294
324
this . closing = false ;
0 commit comments