From: Scott González Date: Sat, 28 May 2011 21:55:45 +0000 (-0400) Subject: Tooltip: Fixed tooltipClass option and added test. X-Git-Tag: 1.9m6~111^2~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=215599309660733221d51830d12f2ed117961b36;p=jquery-ui.git Tooltip: Fixed tooltipClass option and added test. --- diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index bbbab72ff..04bb4c6a4 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -2,25 +2,6 @@ module( "tooltip: options" ); -test( "items", function() { - expect( 2 ); - var element = $( "#qunit-fixture" ).tooltip({ - items: "#fixture-span" - }); - - var event = $.Event( "mouseenter" ); - event.target = $( "#fixture-span" )[ 0 ]; - element.tooltip( "open", event ); - same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" ); - - // make sure default [title] doesn't get used - event.target = $( "#tooltipped1" )[ 0 ]; - element.tooltip( "open", event ); - same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined ); - - element.tooltip( "destroy" ); -}); - test( "content: default", function() { var element = $( "#tooltipped1" ).tooltip().tooltip( "open" ); same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" ); @@ -62,4 +43,31 @@ asyncTest( "content: sync + async callback", function() { }).tooltip( "open" ); }); +test( "items", function() { + expect( 2 ); + var element = $( "#qunit-fixture" ).tooltip({ + items: "#fixture-span" + }); + + var event = $.Event( "mouseenter" ); + event.target = $( "#fixture-span" )[ 0 ]; + element.tooltip( "open", event ); + same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" ); + + // make sure default [title] doesn't get used + event.target = $( "#tooltipped1" )[ 0 ]; + element.tooltip( "open", event ); + same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined ); + + element.tooltip( "destroy" ); +}); + +test( "tooltipClass", function() { + expect( 1 ) + var element = $( "#tooltipped1" ).tooltip({ + tooltipClass: "custom" + }).tooltip( "open" ); + ok( $( "#" + element.attr( "aria-describedby" ) ).hasClass( "custom" ) ); +}); + }( jQuery ) ); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 343c1d055..a6d3b1dd3 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -142,7 +142,7 @@ $.widget( "ui.tooltip", { id: id, role: "tooltip" }) - .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content" + + .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " + ( this.options.tooltipClass || "" ) ); $( "
" ) .addClass( "ui-tooltip-content" )