2011-05-28 17:30:00 +00:00
|
|
|
(function( $ ) {
|
2010-10-26 12:26:53 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
module( "tooltip: options" );
|
2010-10-26 15:07:22 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "items", function() {
|
|
|
|
var event = $.Event( "mouseenter" );
|
|
|
|
event.target = $( "[data-tooltip]" )[ 0 ];
|
|
|
|
var element = $( "#qunit-fixture" ).tooltip({
|
2011-02-11 15:01:23 +00:00
|
|
|
items: "[data-tooltip]",
|
|
|
|
content: function() {
|
2011-05-28 17:30:00 +00:00
|
|
|
return $( this ).attr( "data-tooltip" );
|
2011-02-11 15:01:23 +00:00
|
|
|
}
|
2011-05-28 17:30:00 +00:00
|
|
|
}).tooltip( "open", event );
|
|
|
|
same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "text" );
|
|
|
|
element.tooltip( "destroy" );
|
2010-10-26 15:07:22 +00:00
|
|
|
});
|
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "content: default", function() {
|
|
|
|
var element = $( "#tooltipped1" ).tooltip().tooltip("open");
|
|
|
|
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
|
2010-10-26 12:26:53 +00:00
|
|
|
});
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "content: return string", function() {
|
|
|
|
var element = $( "#tooltipped1" ).tooltip({
|
2010-10-26 12:26:53 +00:00
|
|
|
content: function() {
|
|
|
|
return "customstring";
|
|
|
|
}
|
2011-05-28 17:30:00 +00:00
|
|
|
}).tooltip( "open" );
|
|
|
|
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
2010-10-26 12:26:53 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
test( "content: return jQuery", function() {
|
|
|
|
var element = $( "#tooltipped1" ).tooltip({
|
2010-10-26 13:36:43 +00:00
|
|
|
content: function() {
|
2011-05-28 17:30:00 +00:00
|
|
|
return $( "<div>" ).html( "cu<b>s</b>tomstring" );
|
2010-10-26 13:36:43 +00:00
|
|
|
}
|
2011-05-28 17:30:00 +00:00
|
|
|
}).tooltip( "open" );
|
|
|
|
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
|
2010-10-26 13:36:43 +00:00
|
|
|
});
|
|
|
|
|
2011-05-02 19:04:56 +00:00
|
|
|
/*
|
|
|
|
TODO broken, probably related to async content
|
2010-10-26 12:26:53 +00:00
|
|
|
test("content: callback string", function() {
|
|
|
|
stop();
|
|
|
|
$("#tooltipped1").tooltip({
|
|
|
|
content: function(response) {
|
|
|
|
response("customstring2");
|
|
|
|
setTimeout(function() {
|
2011-05-02 19:04:56 +00:00
|
|
|
//console.log($("#tooltipped1").attr("aria-describedby"))
|
|
|
|
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring2" );
|
2010-10-26 12:26:53 +00:00
|
|
|
start();
|
|
|
|
}, 100)
|
|
|
|
}
|
|
|
|
}).tooltip("open");
|
|
|
|
|
2010-04-15 07:45:35 +00:00
|
|
|
});
|
2011-05-02 19:04:56 +00:00
|
|
|
*/
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2011-05-28 17:30:00 +00:00
|
|
|
}( jQuery ) );
|