2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* accordion_methods.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("accordion: methods");
|
|
|
|
|
2009-02-03 08:23:48 +00:00
|
|
|
test("init", function() {
|
2009-09-15 08:33:28 +00:00
|
|
|
$("<div></div>").appendTo('body').accordion().remove();
|
|
|
|
ok(true, '.accordion() called on element');
|
|
|
|
|
|
|
|
$([]).accordion().remove();
|
|
|
|
ok(true, '.accordion() called on empty collection');
|
|
|
|
|
|
|
|
$('<div></div>').accordion().remove();
|
|
|
|
ok(true, '.accordion() called on disconnected DOMElement - never connected');
|
|
|
|
|
|
|
|
$('<div></div>').appendTo('body').remove().accordion().remove();
|
|
|
|
ok(true, '.accordion() called on disconnected DOMElement - removed');
|
|
|
|
|
|
|
|
$('<div></div>').accordion().accordion("foo").remove();
|
|
|
|
ok(true, 'arbitrary method called after init');
|
|
|
|
|
|
|
|
var el = $('<div></div>').accordion();
|
2009-11-09 01:50:23 +00:00
|
|
|
var foo = el.accordion("option", "foo");
|
2009-09-15 08:33:28 +00:00
|
|
|
el.remove();
|
|
|
|
ok(true, 'arbitrary option getter after init');
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$('<div></div>').accordion().accordion("option", "foo", "bar").remove();
|
2009-09-15 08:33:28 +00:00
|
|
|
ok(true, 'arbitrary option setter after init');
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
2010-04-12 14:44:37 +00:00
|
|
|
var beforeHtml = $("#list1").find("div").css("font-style", "normal").end().parent().html();
|
2010-03-27 07:01:41 +00:00
|
|
|
var afterHtml = $("#list1").accordion().accordion("destroy").parent().html();
|
|
|
|
equal( afterHtml, beforeHtml );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("enable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('#list1').accordion(),
|
|
|
|
actual = expected.accordion('enable');
|
|
|
|
equals(actual, expected, 'enable is chainable');
|
2009-09-15 08:33:28 +00:00
|
|
|
state(expected, 1, 0, 0)
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("disable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('#list1').accordion(),
|
|
|
|
actual = expected.accordion('disable');
|
|
|
|
equals(actual, expected, 'disable is chainable');
|
2009-09-15 08:33:28 +00:00
|
|
|
|
|
|
|
state(expected, 1, 0, 0)
|
|
|
|
expected.accordion("activate", 1);
|
|
|
|
state(expected, 1, 0, 0)
|
|
|
|
expected.accordion("enable");
|
|
|
|
expected.accordion("activate", 1);
|
|
|
|
state(expected, 0, 1, 0)
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
test("activate", function() {
|
|
|
|
var expected = $('#list1').accordion(),
|
|
|
|
actual = expected.accordion('activate', 2);
|
|
|
|
equals(actual, expected, 'activate is chainable');
|
|
|
|
});
|
|
|
|
|
2009-02-03 08:23:48 +00:00
|
|
|
test("activate, numeric", function() {
|
|
|
|
var ac = $('#list1').accordion({ active: 1 });
|
|
|
|
state(ac, 0, 1, 0);
|
|
|
|
ac.accordion("activate", 2);
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
ac.accordion("activate", 0);
|
|
|
|
state(ac, 1, 0, 0);
|
|
|
|
ac.accordion("activate", 1);
|
|
|
|
state(ac, 0, 1, 0);
|
|
|
|
ac.accordion("activate", 2);
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("activate, boolean and numeric, collapsible:true", function() {
|
|
|
|
var ac = $('#list1').accordion({collapsible: true}).accordion("activate", 2);
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
ok("x", "----");
|
|
|
|
ac.accordion("activate", 0);
|
|
|
|
state(ac, 1, 0, 0);
|
|
|
|
ok("x", "----");
|
|
|
|
ac.accordion("activate", -1);
|
|
|
|
state(ac, 0, 0, 0);
|
|
|
|
});
|
|
|
|
|
2009-09-15 08:33:28 +00:00
|
|
|
test("activate, boolean, collapsible: false", function() {
|
2009-02-03 08:23:48 +00:00
|
|
|
var ac = $('#list1').accordion().accordion("activate", 2);
|
|
|
|
state(ac, 0, 0, 1);
|
2009-09-15 15:21:42 +00:00
|
|
|
ac.accordion("activate", false);
|
2009-02-03 08:23:48 +00:00
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("activate, string expression", function() {
|
|
|
|
var ac = $('#list1').accordion({ active: "a:last" });
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
ac.accordion("activate", ":first");
|
|
|
|
state(ac, 1, 0, 0);
|
|
|
|
ac.accordion("activate", ":eq(1)");
|
|
|
|
state(ac, 0, 1, 0);
|
|
|
|
ac.accordion("activate", ":last");
|
2009-09-15 21:19:23 +00:00
|
|
|
state(ac, 0, 0, 1);
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
2010-04-03 15:14:58 +00:00
|
|
|
|
2009-02-03 08:23:48 +00:00
|
|
|
test("activate, jQuery or DOM element", function() {
|
|
|
|
var ac = $('#list1').accordion({ active: $("#list1 a:last") });
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
ac.accordion("activate", $("#list1 a:first"));
|
|
|
|
state(ac, 1, 0, 0);
|
|
|
|
ac.accordion("activate", $("#list1 a")[1]);
|
|
|
|
state(ac, 0, 1, 0);
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
test("resize", function() {
|
2010-04-12 14:12:05 +00:00
|
|
|
var expected = $('#navigation').parent().height(300).end().accordion({
|
2010-04-03 15:21:31 +00:00
|
|
|
fillSpace: true
|
|
|
|
});
|
2009-09-15 08:33:28 +00:00
|
|
|
|
|
|
|
var sizes = [];
|
|
|
|
expected.find(".ui-accordion-content").each(function() {
|
|
|
|
sizes.push($(this).outerHeight());
|
|
|
|
});
|
2010-04-03 15:27:00 +00:00
|
|
|
same(sizes, [246, 246, 246]);
|
2009-09-15 08:33:28 +00:00
|
|
|
|
2010-04-03 15:21:31 +00:00
|
|
|
expected.parent().height(500);
|
|
|
|
expected.accordion("resize");
|
|
|
|
var sizes2 = [];
|
|
|
|
expected.find(".ui-accordion-content").each(function() {
|
|
|
|
sizes2.push($(this).outerHeight());
|
|
|
|
});
|
|
|
|
same(sizes2, [446, 446, 446]);
|
2009-04-15 02:33:28 +00:00
|
|
|
});
|
|
|
|
|
2009-02-02 14:36:08 +00:00
|
|
|
})(jQuery);
|