2015-04-03 19:24:09 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
2015-04-07 14:55:52 +00:00
|
|
|
"./helper",
|
2015-04-03 19:24:09 +00:00
|
|
|
"ui/accordion"
|
2015-04-07 14:30:07 +00:00
|
|
|
], function( $, testHelper ) {
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
var equalHeight = testHelper.equalHeight,
|
|
|
|
setupTeardown = testHelper.setupTeardown,
|
|
|
|
state = testHelper.state;
|
2012-04-19 15:37:33 +00:00
|
|
|
|
|
|
|
module( "accordion: options", setupTeardown() );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ active: default }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 2 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion();
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 0 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2012-10-17 15:35:27 +00:00
|
|
|
test( "{ active: null }", function() {
|
|
|
|
expect( 2 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
|
|
|
active: null
|
|
|
|
});
|
|
|
|
equal( element.accordion( "option", "active" ), 0 );
|
|
|
|
state( element, 1, 0, 0 );
|
|
|
|
});
|
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ active: false }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 7 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion({
|
2009-02-03 08:23:48 +00:00
|
|
|
active: false,
|
|
|
|
collapsible: true
|
|
|
|
});
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 0, 0 );
|
2012-04-23 18:25:23 +00:00
|
|
|
equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" );
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), false );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "collapsible", false );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 0 );
|
2011-02-03 14:54:11 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "destroy" );
|
|
|
|
element.accordion({
|
2011-02-03 14:54:11 +00:00
|
|
|
active: false
|
|
|
|
});
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-04-15 15:29:26 +00:00
|
|
|
strictEqual( element.accordion( "option", "active" ), 0 );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ active: Number }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 8 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion({
|
2011-01-25 00:20:09 +00:00
|
|
|
active: 2
|
2009-08-11 00:45:01 +00:00
|
|
|
});
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 2 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2009-08-11 00:45:01 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 0 );
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 0 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2009-08-11 00:45:01 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).click();
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2009-08-11 00:45:01 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 10 );
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2012-10-24 15:11:47 +00:00
|
|
|
test( "{ active: -Number }", function() {
|
|
|
|
expect( 8 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
|
|
|
active: -1
|
2011-01-25 00:20:09 +00:00
|
|
|
});
|
2012-10-24 15:11:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 2 );
|
|
|
|
state( element, 0, 0, 1 );
|
|
|
|
|
|
|
|
element.accordion( "option", "active", -2 );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( element, 0, 1, 0 );
|
|
|
|
|
|
|
|
element.accordion( "option", "active", -10 );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
|
|
|
state( element, 0, 1, 0 );
|
|
|
|
|
|
|
|
element.accordion( "option", "active", -3 );
|
|
|
|
equal( element.accordion( "option", "active" ), 0 );
|
|
|
|
state( element, 1, 0, 0 );
|
|
|
|
});
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2012-03-27 22:05:51 +00:00
|
|
|
test( "{ animate: false }", function() {
|
|
|
|
expect( 3 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
|
|
|
animate: false
|
|
|
|
}),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
2012-03-27 22:05:51 +00:00
|
|
|
animate = $.fn.animate;
|
|
|
|
$.fn.animate = function() {
|
|
|
|
ok( false, ".animate() called" );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.accordion( "option", "active", 1 );
|
|
|
|
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
|
|
|
$.fn.animate = animate;
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( "{ animate: Number }", function() {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
|
|
|
animate: 100
|
|
|
|
}),
|
2012-04-19 14:50:09 +00:00
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
2012-03-27 22:05:51 +00:00
|
|
|
animate = $.fn.animate;
|
|
|
|
// called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
|
|
|
equal( options.duration, 100, "correct duration" );
|
|
|
|
equal( options.easing, undefined, "default easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.accordion( "option", "active", 1 );
|
|
|
|
panels.promise().done(function() {
|
|
|
|
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
|
|
|
$.fn.animate = animate;
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( "{ animate: String }", function() {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
2012-04-19 14:50:09 +00:00
|
|
|
animate: "linear"
|
|
|
|
}),
|
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2012-03-27 22:05:51 +00:00
|
|
|
// called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
|
|
|
equal( options.duration, undefined, "default duration" );
|
|
|
|
equal( options.easing, "linear", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.accordion( "option", "active", 1 );
|
|
|
|
panels.promise().done(function() {
|
|
|
|
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
|
|
|
$.fn.animate = animate;
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( "{ animate: {} }", function() {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
2012-04-19 14:50:09 +00:00
|
|
|
animate: {}
|
|
|
|
}),
|
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2012-03-27 22:05:51 +00:00
|
|
|
// called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
|
|
|
equal( options.duration, undefined, "default duration" );
|
|
|
|
equal( options.easing, undefined, "default easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.accordion( "option", "active", 1 );
|
|
|
|
panels.promise().done(function() {
|
|
|
|
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
|
|
|
$.fn.animate = animate;
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( "{ animate: { duration, easing } }", function() {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
2012-04-19 14:50:09 +00:00
|
|
|
animate: { duration: 100, easing: "linear" }
|
|
|
|
}),
|
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2012-03-27 22:05:51 +00:00
|
|
|
// called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
|
|
|
equal( options.duration, 100, "correct duration" );
|
|
|
|
equal( options.easing, "linear", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.accordion( "option", "active", 1 );
|
|
|
|
panels.promise().done(function() {
|
|
|
|
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
|
|
|
$.fn.animate = animate;
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( "{ animate: { duration, easing } }, animate down", function() {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
2012-04-19 14:50:09 +00:00
|
|
|
active: 1,
|
|
|
|
animate: { duration: 100, easing: "linear" }
|
|
|
|
}),
|
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2012-03-27 22:05:51 +00:00
|
|
|
// called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
|
|
|
equal( options.duration, 100, "correct duration" );
|
|
|
|
equal( options.easing, "linear", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.accordion( "option", "active", 0 );
|
|
|
|
panels.promise().done(function() {
|
|
|
|
ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
|
|
|
|
$.fn.animate = animate;
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#list1" ).accordion({
|
2012-04-19 14:50:09 +00:00
|
|
|
active: 1,
|
|
|
|
animate: {
|
|
|
|
duration: 100,
|
|
|
|
easing: "linear",
|
|
|
|
down: {
|
|
|
|
easing: "swing"
|
|
|
|
}
|
2012-03-27 22:05:51 +00:00
|
|
|
}
|
2012-04-19 14:50:09 +00:00
|
|
|
}),
|
|
|
|
panels = element.find( ".ui-accordion-content" ),
|
|
|
|
animate = $.fn.animate;
|
2012-03-27 22:05:51 +00:00
|
|
|
// called twice (both panels)
|
2012-10-01 20:52:54 +00:00
|
|
|
$.fn.animate = function( props, options ) {
|
|
|
|
equal( options.duration, 100, "correct duration" );
|
|
|
|
equal( options.easing, "swing", "correct easing" );
|
2012-03-27 22:05:51 +00:00
|
|
|
animate.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.accordion( "option", "active", 0 );
|
|
|
|
panels.promise().done(function() {
|
|
|
|
ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
|
|
|
|
$.fn.animate = animate;
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
});
|
2010-12-15 04:48:36 +00:00
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ collapsible: false }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 4 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion({
|
2011-01-25 00:20:09 +00:00
|
|
|
active: 1
|
2010-12-15 04:48:36 +00:00
|
|
|
});
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", false );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).click();
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ collapsible: true }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 6 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion({
|
2009-08-11 00:57:50 +00:00
|
|
|
active: 1,
|
|
|
|
collapsible: true
|
|
|
|
});
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", false );
|
|
|
|
equal( element.accordion( "option", "active" ), false );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 0, 0 );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).click();
|
2011-06-13 14:54:47 +00:00
|
|
|
equal( element.accordion( "option", "active" ), false );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 0, 0 );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2011-02-21 15:07:42 +00:00
|
|
|
test( "{ event: null }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 5 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion({
|
2011-02-21 15:07:42 +00:00
|
|
|
event: null
|
|
|
|
});
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 1 );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
|
|
|
// ensure default click handler isn't bound
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 2 ).click();
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "{ event: custom }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 11 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion({
|
2011-02-21 15:07:42 +00:00
|
|
|
event: "custom1 custom2"
|
|
|
|
});
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
|
|
|
// ensure default click handler isn't bound
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
|
|
|
|
equal( element.accordion( "option", "active" ), 2 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "event", "custom3" );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
|
|
|
// ensure old event handlers are unbound
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
|
2012-03-07 18:17:09 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" );
|
2011-04-15 15:29:26 +00:00
|
|
|
equal( element.accordion( "option", "active" ), 2 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2011-02-21 15:07:42 +00:00
|
|
|
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
|
|
|
|
equal( element.accordion( "option", "active" ), 1 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-02-21 15:07:42 +00:00
|
|
|
});
|
2011-01-25 00:20:09 +00:00
|
|
|
|
|
|
|
test( "{ header: default }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 2 );
|
2011-01-25 00:20:09 +00:00
|
|
|
// default: > li > :first-child,> :not(li):even
|
|
|
|
// > :not(li):even
|
2012-04-19 15:37:33 +00:00
|
|
|
state( $( "#list1" ).accordion(), 1, 0, 0);
|
2011-01-25 00:20:09 +00:00
|
|
|
// > li > :first-child
|
2012-04-19 15:37:33 +00:00
|
|
|
state( $( "#navigation" ).accordion(), 1, 0, 0);
|
2010-12-15 04:48:36 +00:00
|
|
|
});
|
|
|
|
|
2015-01-30 14:53:26 +00:00
|
|
|
test( "{ header: custom }", function( assert ) {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 6 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#navigationWrapper" ).accordion({
|
2011-02-03 15:11:00 +00:00
|
|
|
header: "h2"
|
|
|
|
});
|
2011-04-15 15:29:26 +00:00
|
|
|
element.find( "h2" ).each(function() {
|
2015-01-30 14:53:26 +00:00
|
|
|
assert.hasClasses( this, "ui-accordion-header" );
|
2011-02-03 15:11:00 +00:00
|
|
|
});
|
2011-04-15 15:29:26 +00:00
|
|
|
equal( element.find( ".ui-accordion-header" ).length, 3 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "active", 2 );
|
2012-04-19 15:37:33 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2011-02-03 15:11:00 +00:00
|
|
|
});
|
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ heightStyle: 'auto' }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 3 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#navigation" ).accordion({ heightStyle: "auto" });
|
2012-05-28 16:41:57 +00:00
|
|
|
equalHeight( element, 105 );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ heightStyle: 'content' }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 3 );
|
2012-04-19 14:50:09 +00:00
|
|
|
var element = $( "#navigation" ).accordion({ heightStyle: "content" }),
|
|
|
|
sizes = element.find( ".ui-accordion-content" ).map(function() {
|
|
|
|
return $( this ).height();
|
|
|
|
}).get();
|
2012-05-28 17:42:47 +00:00
|
|
|
equal( sizes[ 0 ], 75 );
|
|
|
|
equal( sizes[ 1 ], 105 );
|
|
|
|
equal( sizes[ 2 ], 45 );
|
2009-05-11 11:43:48 +00:00
|
|
|
});
|
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ heightStyle: 'fill' }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 3 );
|
2011-01-25 00:20:09 +00:00
|
|
|
$( "#navigationWrapper" ).height( 500 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
|
2012-05-28 16:41:57 +00:00
|
|
|
equalHeight( element, 455 );
|
2011-01-25 01:35:58 +00:00
|
|
|
});
|
2011-01-25 00:20:09 +00:00
|
|
|
|
2011-01-25 01:35:58 +00:00
|
|
|
test( "{ heightStyle: 'fill' } with sibling", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 3 );
|
2011-01-25 01:35:58 +00:00
|
|
|
$( "#navigationWrapper" ).height( 500 );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
|
|
|
.css({
|
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30
|
|
|
|
})
|
|
|
|
.prependTo( "#navigationWrapper" );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
|
2012-05-28 16:41:57 +00:00
|
|
|
equalHeight( element , 355 );
|
2011-01-25 01:35:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 3 );
|
2011-01-25 01:35:58 +00:00
|
|
|
$( "#navigationWrapper" ).height( 500 );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
|
|
|
.css({
|
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30
|
|
|
|
})
|
|
|
|
.prependTo( "#navigationWrapper" );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
|
|
|
.css({
|
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30,
|
|
|
|
position: "absolute"
|
|
|
|
})
|
|
|
|
.prependTo( "#navigationWrapper" );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
|
|
|
.css({
|
|
|
|
height: 25,
|
|
|
|
marginTop: 10,
|
|
|
|
marginBottom: 15
|
|
|
|
})
|
|
|
|
.prependTo( "#navigationWrapper" );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
|
2012-05-28 16:41:57 +00:00
|
|
|
equalHeight( element, 305 );
|
2011-01-11 20:38:47 +00:00
|
|
|
});
|
|
|
|
|
2011-01-25 00:20:09 +00:00
|
|
|
test( "{ icons: false }", function() {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 8 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" );
|
2011-01-25 00:20:09 +00:00
|
|
|
function icons( on ) {
|
2011-06-13 14:54:47 +00:00
|
|
|
deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 );
|
2012-01-31 18:11:20 +00:00
|
|
|
deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 );
|
2011-01-25 00:20:09 +00:00
|
|
|
}
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion();
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( true );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "destroy" ).accordion({
|
2011-01-25 00:20:09 +00:00
|
|
|
icons: false
|
2009-07-03 21:05:22 +00:00
|
|
|
});
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( false );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( true );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "icons", false );
|
2011-01-25 00:20:09 +00:00
|
|
|
icons( false );
|
2009-02-03 08:23:48 +00:00
|
|
|
});
|
|
|
|
|
2015-01-30 14:53:26 +00:00
|
|
|
test( "{ icons: hash }", function( assert ) {
|
2011-06-13 18:51:13 +00:00
|
|
|
expect( 3 );
|
2011-04-15 15:29:26 +00:00
|
|
|
var element = $( "#list1" ).accordion({
|
2011-01-25 00:20:09 +00:00
|
|
|
icons: { activeHeader: "a1", header: "h1" }
|
2009-07-03 21:05:22 +00:00
|
|
|
});
|
2015-01-30 14:53:26 +00:00
|
|
|
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1" );
|
2011-04-15 15:29:26 +00:00
|
|
|
element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
|
2015-01-30 14:53:26 +00:00
|
|
|
assert.lacksClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a1");
|
|
|
|
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" );
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
2015-04-03 19:24:09 +00:00
|
|
|
} );
|