2011-11-25 10:32:44 +00:00
|
|
|
(function ($) {
|
2011-10-19 17:47:02 +00:00
|
|
|
|
2012-02-26 00:24:52 +00:00
|
|
|
module("selectmenu: options");
|
2012-01-13 18:49:42 +00:00
|
|
|
|
|
|
|
test("appendTo another element", function () {
|
2012-12-15 01:24:10 +00:00
|
|
|
expect( 8 );
|
|
|
|
|
|
|
|
var detached = $( "<div>" ),
|
|
|
|
element = $("#speed").selectmenu();
|
|
|
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], document.body, "defaults to body" );
|
|
|
|
element.selectmenu( "destroy" );
|
|
|
|
|
|
|
|
element.selectmenu({
|
|
|
|
appendTo: ".sm-wrap"
|
|
|
|
});
|
|
|
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap1" )[0], "first found element" );
|
|
|
|
equal( $( "#sm-wrap2 .ui-selectmenu" ).length, 0, "only appends to one element" );
|
|
|
|
element.selectmenu( "destroy" );
|
|
|
|
|
|
|
|
$( "#sm-wrap2" ).addClass( "ui-front" );
|
|
|
|
element.selectmenu();
|
|
|
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap2" )[0], "null, inside .ui-front" );
|
|
|
|
element.selectmenu( "destroy" );
|
|
|
|
$( "#sm-wrap2" ).removeClass( "ui-front" );
|
|
|
|
|
|
|
|
element.selectmenu().selectmenu( "option", "appendTo", "#sm-wrap1" );
|
|
|
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap1" )[0], "modified after init" );
|
|
|
|
element.selectmenu( "destroy" );
|
|
|
|
|
|
|
|
element.selectmenu({
|
|
|
|
appendTo: detached
|
|
|
|
});
|
|
|
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached jQuery object" );
|
|
|
|
element.selectmenu( "destroy" );
|
2012-05-16 18:43:42 +00:00
|
|
|
|
2012-12-15 01:24:10 +00:00
|
|
|
element.selectmenu({
|
|
|
|
appendTo: detached[0]
|
|
|
|
});
|
|
|
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element" );
|
|
|
|
element.selectmenu( "destroy" );
|
2012-05-16 18:43:42 +00:00
|
|
|
|
2012-12-15 01:24:10 +00:00
|
|
|
element.selectmenu().selectmenu( "option", "appendTo", detached );
|
|
|
|
equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element via option()" );
|
|
|
|
element.selectmenu( "destroy" );
|
2012-01-13 18:49:42 +00:00
|
|
|
});
|
|
|
|
|
2012-01-13 19:46:47 +00:00
|
|
|
|
2012-12-19 23:12:35 +00:00
|
|
|
test("CSS styles", function () {
|
2012-02-26 00:24:52 +00:00
|
|
|
expect(2);
|
|
|
|
|
|
|
|
var element = $("#speed").selectmenu(),
|
|
|
|
button = element.selectmenu("widget"),
|
|
|
|
menu = element.selectmenu("menuWidget");
|
2012-02-21 17:08:14 +00:00
|
|
|
|
2012-02-26 00:24:52 +00:00
|
|
|
element.selectmenu("open");
|
|
|
|
ok( button.hasClass("ui-corner-top") && !button.hasClass("ui-corner-all") && button.find("span.ui-icon").hasClass("ui-icon-triangle-1-s"), "button styles dropdown");
|
|
|
|
ok( menu.hasClass("ui-corner-bottom") && !menu.hasClass("ui-corner-all"), "menu styles dropdown");
|
|
|
|
});
|
|
|
|
|
2011-11-25 10:32:44 +00:00
|
|
|
})(jQuery);
|