2015-04-07 00:28:55 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
|
|
|
"ui/tooltip"
|
|
|
|
], function( $ ) {
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
module( "tooltip: events" );
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "programmatic triggers", function() {
|
2011-05-30 22:51:29 +00:00
|
|
|
expect( 4 );
|
|
|
|
var tooltip,
|
|
|
|
element = $( "#tooltipped1" ).tooltip();
|
2011-05-28 20:20:46 +00:00
|
|
|
|
2011-05-30 22:51:29 +00:00
|
|
|
element.one( "tooltipopen", function( event, ui ) {
|
|
|
|
tooltip = ui.tooltip;
|
2011-05-28 20:20:46 +00:00
|
|
|
ok( !( "originalEvent" in event ), "open" );
|
2011-05-30 22:51:29 +00:00
|
|
|
strictEqual( ui.tooltip[0],
|
2012-05-22 15:06:44 +00:00
|
|
|
$( "#" + element.data( "ui-tooltip-id" ) )[0], "ui.tooltip" );
|
2011-05-28 20:20:46 +00:00
|
|
|
});
|
|
|
|
element.tooltip( "open" );
|
|
|
|
|
2011-05-30 22:51:29 +00:00
|
|
|
element.one( "tooltipclose", function( event, ui ) {
|
2011-05-28 20:20:46 +00:00
|
|
|
ok( !( "originalEvent" in event ), "close" );
|
2011-05-30 22:51:29 +00:00
|
|
|
strictEqual( ui.tooltip[0], tooltip[0], "ui.tooltip" );
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
2011-05-28 20:20:46 +00:00
|
|
|
element.tooltip( "close" );
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "mouse events", function() {
|
2011-05-28 20:20:46 +00:00
|
|
|
expect( 2 );
|
|
|
|
var element = $( "#tooltipped1" ).tooltip();
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipopen", function( event ) {
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( event.originalEvent.type, "mouseover" );
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
2011-05-28 20:20:46 +00:00
|
|
|
element.trigger( "mouseover" );
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipclose", function( event ) {
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( event.originalEvent.type, "mouseleave" );
|
2011-05-28 20:20:46 +00:00
|
|
|
});
|
2012-10-21 17:07:43 +00:00
|
|
|
element.trigger( "focusout" );
|
2011-05-28 20:20:46 +00:00
|
|
|
element.trigger( "mouseleave" );
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "focus events", function() {
|
2011-05-28 20:20:46 +00:00
|
|
|
expect( 2 );
|
|
|
|
var element = $( "#tooltipped1" ).tooltip();
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipopen", function( event ) {
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( event.originalEvent.type, "focusin" );
|
2011-05-28 20:20:46 +00:00
|
|
|
});
|
|
|
|
element.trigger( "focusin" );
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipclose", function( event ) {
|
2012-02-28 14:56:32 +00:00
|
|
|
deepEqual( event.originalEvent.type, "focusout" );
|
2011-05-29 23:21:31 +00:00
|
|
|
});
|
2012-10-21 17:07:43 +00:00
|
|
|
element.trigger( "mouseleave" );
|
|
|
|
element.trigger( "focusout" );
|
2011-05-29 23:21:31 +00:00
|
|
|
});
|
|
|
|
|
2015-04-07 00:28:55 +00:00
|
|
|
} );
|