2011-05-28 17:30:00 +00:00
|
|
|
(function( $ ) {
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
module( "tooltip: methods" );
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "destroy", function() {
|
2012-10-05 16:52:02 +00:00
|
|
|
expect( 3 );
|
|
|
|
var element = $( "#tooltipped1" );
|
|
|
|
|
2011-05-28 20:20:46 +00:00
|
|
|
domEqual( "#tooltipped1", function() {
|
2012-10-05 16:52:02 +00:00
|
|
|
element.tooltip().tooltip( "destroy" );
|
2011-05-28 20:20:46 +00:00
|
|
|
});
|
2011-05-28 21:36:57 +00:00
|
|
|
|
|
|
|
// make sure that open tooltips are removed on destroy
|
2012-10-05 16:52:02 +00:00
|
|
|
domEqual( "#tooltipped1", function() {
|
|
|
|
element
|
|
|
|
.tooltip()
|
|
|
|
.tooltip( "open", $.Event( "mouseover", { target: element[0] }) )
|
|
|
|
.tooltip( "destroy" );
|
|
|
|
});
|
2011-05-28 21:36:57 +00:00
|
|
|
equal( $( ".ui-tooltip" ).length, 0 );
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
|
|
|
|
2011-05-28 20:20:46 +00:00
|
|
|
test( "open/close", function() {
|
|
|
|
expect( 3 );
|
|
|
|
$.fx.off = true;
|
2012-04-19 02:36:15 +00:00
|
|
|
var tooltip,
|
|
|
|
element = $( "#tooltipped1" ).tooltip();
|
2011-05-28 20:20:46 +00:00
|
|
|
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
|
2011-05-28 21:36:57 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
element.tooltip( "open" );
|
2012-05-22 15:06:44 +00:00
|
|
|
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
|
2011-05-28 20:20:46 +00:00
|
|
|
ok( tooltip.is( ":visible" ) );
|
2011-05-28 21:36:57 +00:00
|
|
|
|
2011-05-28 20:20:46 +00:00
|
|
|
element.tooltip( "close" );
|
|
|
|
ok( tooltip.is( ":hidden" ) );
|
|
|
|
$.fx.off = false;
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
|
|
|
|
2012-10-05 15:26:49 +00:00
|
|
|
// #8626 - Calling open() without an event
|
|
|
|
test( "open/close with tracking", function() {
|
|
|
|
expect( 3 );
|
|
|
|
$.fx.off = true;
|
|
|
|
var tooltip,
|
|
|
|
element = $( "#tooltipped1" ).tooltip({ track: true });
|
|
|
|
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
|
|
|
|
|
|
|
|
element.tooltip( "open" );
|
|
|
|
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
|
|
|
|
ok( tooltip.is( ":visible" ) );
|
|
|
|
|
|
|
|
element.tooltip( "close" );
|
|
|
|
ok( tooltip.is( ":hidden" ) );
|
|
|
|
$.fx.off = false;
|
|
|
|
});
|
|
|
|
|
2011-05-30 00:50:21 +00:00
|
|
|
test( "enable/disable", function() {
|
|
|
|
expect( 7 );
|
|
|
|
$.fx.off = true;
|
2012-04-19 02:36:15 +00:00
|
|
|
var tooltip,
|
|
|
|
element = $( "#tooltipped1" ).tooltip();
|
2011-05-30 00:50:21 +00:00
|
|
|
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
|
|
|
|
|
|
|
|
element.tooltip( "open" );
|
2012-05-22 15:06:44 +00:00
|
|
|
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
|
2011-05-30 00:50:21 +00:00
|
|
|
ok( tooltip.is( ":visible" ) );
|
|
|
|
|
|
|
|
element.tooltip( "disable" );
|
|
|
|
equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" );
|
2012-06-25 18:51:51 +00:00
|
|
|
// support: jQuery <1.6.2
|
|
|
|
// support: IE <8
|
|
|
|
// We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7)
|
2012-06-19 15:12:38 +00:00
|
|
|
ok( !tooltip.attr( "title" ), "title removed on disable" );
|
2011-05-30 00:50:21 +00:00
|
|
|
|
|
|
|
element.tooltip( "open" );
|
|
|
|
equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" );
|
|
|
|
|
|
|
|
element.tooltip( "enable" );
|
|
|
|
equal( element.attr( "title" ), "anchortitle", "title restored on enable" );
|
|
|
|
|
|
|
|
element.tooltip( "open" );
|
2012-05-22 15:06:44 +00:00
|
|
|
tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
|
2011-05-30 00:50:21 +00:00
|
|
|
ok( tooltip.is( ":visible" ) );
|
|
|
|
$.fx.off = false;
|
|
|
|
});
|
|
|
|
|
2012-08-27 00:21:24 +00:00
|
|
|
test( "widget", function() {
|
|
|
|
expect( 2 );
|
|
|
|
var element = $( "#tooltipped1" ).tooltip(),
|
|
|
|
widgetElement = element.tooltip( "widget" );
|
|
|
|
equal( widgetElement.length, 1, "one element" );
|
|
|
|
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
|
2010-07-30 12:30:43 +00:00
|
|
|
});
|
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
}( jQuery ) );
|