2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* accordion_options.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("accordion: options");
|
|
|
|
|
2009-02-03 08:23:48 +00:00
|
|
|
test("{ active: first child }, default", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
var ac = $("#list1").accordion();
|
|
|
|
equals( ac.accordion('option', 'active'), 0);
|
|
|
|
state(ac, 1, 0, 0)
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("{ active: Selector }", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
var ac = $("#list1").accordion({
|
2010-12-06 05:56:19 +00:00
|
|
|
active: "h3:last"
|
2009-09-15 08:33:28 +00:00
|
|
|
});
|
|
|
|
state(ac, 0, 0, 1);
|
2010-12-06 05:56:19 +00:00
|
|
|
ac.accordion('option', 'active', "h3:eq(1)");
|
2009-09-15 08:33:28 +00:00
|
|
|
state(ac, 0, 1, 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("{ active: Element }", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
var ac = $("#list1").accordion({
|
2010-12-06 05:56:19 +00:00
|
|
|
active: $("#list1 h3:last")[0]
|
2009-09-15 08:33:28 +00:00
|
|
|
});
|
|
|
|
state(ac, 0, 0, 1);
|
2010-12-06 05:56:19 +00:00
|
|
|
ac.accordion('option', 'active', $("#list1 h3:eq(1)")[0]);
|
2009-09-15 08:33:28 +00:00
|
|
|
state(ac, 0, 1, 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("{ active: jQuery Object }", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
var ac = $("#list1").accordion({
|
2010-12-06 05:56:19 +00:00
|
|
|
active: $("#list1 h3:last")
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
2009-09-15 08:33:28 +00:00
|
|
|
state(ac, 0, 0, 1);
|
2010-12-06 05:56:19 +00:00
|
|
|
ac.accordion('option', 'active', $("#list1 h3:eq(1)"));
|
2009-09-15 08:33:28 +00:00
|
|
|
state(ac, 0, 1, 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("{ active: false }", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
var ac = $("#list1").accordion({
|
2009-02-03 08:23:48 +00:00
|
|
|
active: false,
|
|
|
|
collapsible: true
|
|
|
|
});
|
2009-09-15 08:33:28 +00:00
|
|
|
state(ac, 0, 0, 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
equals( $("#list1 .ui-accordion-header.ui-state-active").size(), 0, "no headers selected" );
|
2009-08-11 00:57:50 +00:00
|
|
|
equals( $("#list1").accordion('option', 'active'), false);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("{ active: Number }", function() {
|
2009-08-11 00:45:01 +00:00
|
|
|
expect(4);
|
|
|
|
$("#list1").accordion({
|
|
|
|
active: 0
|
|
|
|
});
|
|
|
|
equals( $("#list1").accordion('option', 'active'), 0);
|
|
|
|
|
|
|
|
$("#list1").accordion('option', 'active', 1);
|
|
|
|
equals( $("#list1").accordion('option', 'active'), 1);
|
|
|
|
|
|
|
|
$('.ui-accordion-header:eq(2)', '#list1').click();
|
|
|
|
equals( $("#list1").accordion('option', 'active'), 2);
|
|
|
|
|
2011-01-12 01:53:31 +00:00
|
|
|
$("#list1").accordion('option', 'active', 0);
|
2009-08-11 00:45:01 +00:00
|
|
|
equals( $("#list1").accordion('option', 'active'), 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("{ autoHeight: true }, default", function() {
|
2010-04-13 08:13:13 +00:00
|
|
|
equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2010-12-15 04:48:36 +00:00
|
|
|
test("{ heightStyle: 'auto' }, default", function() {
|
|
|
|
equalHeights($('#navigation').accordion({ heightStyle: 'auto' }), 95, 130);
|
|
|
|
});
|
|
|
|
|
2009-02-03 08:23:48 +00:00
|
|
|
test("{ autoHeight: false }", function() {
|
2010-04-13 08:13:13 +00:00
|
|
|
var accordion = $('#navigation').accordion({ autoHeight: false });
|
|
|
|
var sizes = [];
|
|
|
|
accordion.find(".ui-accordion-content").each(function() {
|
2010-04-13 08:36:04 +00:00
|
|
|
sizes.push($(this).height());
|
2010-04-13 08:13:13 +00:00
|
|
|
});
|
2010-04-13 08:36:04 +00:00
|
|
|
ok( sizes[0] >= 70 && sizes[0] <= 90, "was " + sizes[0] );
|
|
|
|
ok( sizes[1] >= 98 && sizes[1] <= 126, "was " + sizes[1] );
|
2010-04-13 08:54:54 +00:00
|
|
|
ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2010-12-15 04:48:36 +00:00
|
|
|
test("{ heightStyle: 'content' }", function() {
|
|
|
|
var accordion = $('#navigation').accordion({ heightStyle: 'content' });
|
|
|
|
var sizes = [];
|
|
|
|
accordion.find(".ui-accordion-content").each(function() {
|
|
|
|
sizes.push($(this).height());
|
|
|
|
});
|
|
|
|
ok( sizes[0] >= 70 && sizes[0] <= 90, "was " + sizes[0] );
|
|
|
|
ok( sizes[1] >= 98 && sizes[1] <= 126, "was " + sizes[1] );
|
|
|
|
ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
|
|
|
|
});
|
2009-02-03 08:23:48 +00:00
|
|
|
test("{ collapsible: false }, default", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
var ac = $("#list1").accordion();
|
2011-01-12 01:53:31 +00:00
|
|
|
ac.accordion("option", "active", false);
|
2009-09-15 08:33:28 +00:00
|
|
|
state(ac, 1, 0, 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("{ collapsible: true }", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
var ac = $("#list1").accordion({
|
2009-08-11 00:57:50 +00:00
|
|
|
active: 1,
|
|
|
|
collapsible: true
|
|
|
|
});
|
2009-09-15 08:33:28 +00:00
|
|
|
var header = $('#list1 .ui-accordion-header:eq(1)').click();
|
2009-08-11 00:57:50 +00:00
|
|
|
equals( $("#list1").accordion('option', 'active'), false);
|
2009-09-15 08:33:28 +00:00
|
|
|
state(ac, 0, 0, 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2010-04-13 08:13:13 +00:00
|
|
|
// fillSpace: false == autoHeight: true, covered above
|
2009-02-03 08:23:48 +00:00
|
|
|
test("{ fillSpace: true }", function() {
|
2009-08-11 18:58:03 +00:00
|
|
|
$("#navigationWrapper").height(500);
|
2010-04-13 08:13:13 +00:00
|
|
|
equalHeights($('#navigation').accordion({ fillSpace: true }), 446, 458);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2010-12-15 04:48:36 +00:00
|
|
|
test("{ heightStyle: 'fill' }", function() {
|
|
|
|
$("#navigationWrapper").height(500);
|
|
|
|
equalHeights($('#navigation').accordion({ heightStyle: 'fill' }), 446, 458);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("{ fillSpace: true } with sibling", function() {
|
|
|
|
$("#navigationWrapper").height(500);
|
|
|
|
var sibling = $("<p>Lorem Ipsum</p>");
|
|
|
|
$("#navigationWrapper").prepend( sibling.height(100) );
|
|
|
|
//sibling.outerHeight(true) == 126
|
|
|
|
equalHeights($('#navigation').accordion({ fillSpace: true}), 320, 332);
|
|
|
|
});
|
|
|
|
|
2010-12-18 02:38:29 +00:00
|
|
|
test("{ fillSpace: true } with multiple siblings", function() {
|
|
|
|
$("#navigationWrapper").height(500);
|
|
|
|
var sibling = $("<p>Lorem Ipsum</p>");
|
2010-12-19 21:26:03 +00:00
|
|
|
$("#navigationWrapper")
|
|
|
|
.prepend( sibling.clone().height(100) )
|
|
|
|
.prepend( sibling.clone().height(100).css( "position", "absolute" ) )
|
|
|
|
.prepend( sibling.clone().height(50) );
|
2010-12-18 02:38:29 +00:00
|
|
|
//sibling.outerHeight(true) == 126
|
|
|
|
equalHeights($('#navigation').accordion({ fillSpace: true}), 244, 256);
|
|
|
|
});
|
|
|
|
|
2009-02-03 08:23:48 +00:00
|
|
|
test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
state($("#list1").accordion(), 1, 0, 0);
|
|
|
|
state($("#navigation").accordion(), 1, 0, 0);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2009-05-11 11:43:48 +00:00
|
|
|
test("{ icons: false }", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
var list = $("#list1");
|
2009-05-11 11:43:48 +00:00
|
|
|
function icons(on) {
|
2010-01-07 03:19:50 +00:00
|
|
|
same($("span.ui-icon", list).length, on ? 3 : 0);
|
|
|
|
same( list.hasClass("ui-accordion-icons"), on );
|
2009-05-11 11:43:48 +00:00
|
|
|
}
|
2010-01-07 03:19:50 +00:00
|
|
|
list.accordion();
|
2009-05-11 11:43:48 +00:00
|
|
|
icons(true);
|
2010-01-07 03:19:50 +00:00
|
|
|
list.accordion("destroy").accordion({
|
2009-05-11 11:43:48 +00:00
|
|
|
icons: false
|
|
|
|
});
|
|
|
|
icons(false);
|
2010-01-07 03:19:50 +00:00
|
|
|
list.accordion("option", "icons", $.ui.accordion.prototype.options.icons);
|
2009-05-11 11:43:48 +00:00
|
|
|
icons(true);
|
2010-01-07 03:19:50 +00:00
|
|
|
list.accordion("option", "icons", false);
|
2009-05-11 11:43:48 +00:00
|
|
|
icons(false);
|
|
|
|
});
|
|
|
|
|
2011-01-11 20:38:47 +00:00
|
|
|
test("{ icons: { activeHeader : 'test' } }", function() {
|
|
|
|
var list = $("#list1");
|
|
|
|
list.accordion( { icons: { "activeHeader": "test" } } );
|
|
|
|
equals( $( "#list1 span.test" ).length, 1);
|
|
|
|
list.accordion("option", "icons", { "activeHeader": "news" } );
|
|
|
|
equals( $( "#list1 span.test" ).length, 0);
|
|
|
|
equals( $( "#list1 span.news" ).length, 1);
|
|
|
|
});
|
|
|
|
|
2009-07-03 21:05:22 +00:00
|
|
|
test("{ navigation: true, navigationFilter: header }", function() {
|
|
|
|
$("#navigation").accordion({
|
|
|
|
navigation: true,
|
|
|
|
navigationFilter: function() {
|
|
|
|
return /\?p=1\.1\.3$/.test(this.href);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2009-07-03 21:05:22 +00:00
|
|
|
test("{ navigation: true, navigationFilter: content }", function() {
|
|
|
|
$("#navigation").accordion({
|
|
|
|
navigation: true,
|
|
|
|
navigationFilter: function() {
|
|
|
|
return /\?p=1\.1\.3\.2$/.test(this.href);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
2011-01-11 20:38:47 +00:00
|
|
|
test("change headerSelected option after creation", function() {
|
|
|
|
var list = $("#list1");
|
|
|
|
list.accordion( { icons: { "activeHeader": "test" } } );
|
|
|
|
equals( $( "#list1 span.test" ).length, 1);
|
|
|
|
list.accordion( "option", "icons", { "headerSelected": "deprecated" } );
|
|
|
|
equals( $( "#list1 span.deprecated" ).length, 1);
|
|
|
|
});
|
|
|
|
|
2009-02-02 14:36:08 +00:00
|
|
|
})(jQuery);
|