Permalink
Browse files

Tooltip: Fix re-enabling of delegated tooltips

Fixes #14950
Closes gh-1699
  • Loading branch information...
scottgonzalez committed Apr 20, 2016
1 parent 3585b7a commit 010f5f9d13b7d6f1c13482825547ee95d3033e40
Showing with 29 additions and 9 deletions.
  1. +14 −0 tests/unit/tooltip/methods.js
  2. +15 −9 ui/widgets/tooltip.js
@@ -94,6 +94,20 @@ QUnit.test( "enable/disable", function( assert ) {
$.fx.off = false;
} );
QUnit.test( "enable/disable delegated", function( assert ) {
assert.expect( 1 );
var element = $( "#qunit-fixture" ).tooltip();
var tooltipped = $( "#tooltipped1" );
element.tooltip( "disable" );
element.tooltip( "enable" );
tooltipped.trigger( "mouseover" );
assert.equal( $( ".ui-tooltip" ).length, 1, "open" );
element.tooltip( "destroy" );
} );
QUnit.test( "widget", function( assert ) {
assert.expect( 2 );
var element = $( "#tooltipped1" ).tooltip(),
View
@@ -114,6 +114,8 @@ $.widget( "ui.tooltip", {
} )
.appendTo( this.document[ 0 ].body );
this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
this.disabledTitles = $( [] );
},
_setOption: function( key, value ) {
@@ -143,25 +145,29 @@ $.widget( "ui.tooltip", {
} );
// Remove title attributes to prevent native tooltips
this.element.find( this.options.items ).addBack().each( function() {
var element = $( this );
if ( element.is( "[title]" ) ) {
element
.data( "ui-tooltip-title", element.attr( "title" ) )
.removeAttr( "title" );
}
} );
this.disabledTitles = this.disabledTitles.add(
this.element.find( this.options.items ).addBack()
.filter( function() {
var element = $( this );
if ( element.is( "[title]" ) ) {
return element
.data( "ui-tooltip-title", element.attr( "title" ) )
.removeAttr( "title" );
}
} )
);
},
_enable: function() {
// restore title attributes
this.element.find( this.options.items ).addBack().each( function() {
this.disabledTitles.each( function() {
var element = $( this );
if ( element.data( "ui-tooltip-title" ) ) {
element.attr( "title", element.data( "ui-tooltip-title" ) );
}
} );
this.disabledTitles = $( [] );
},
open: function( event ) {

0 comments on commit 010f5f9

Please sign in to comment.