2015-04-06 19:01:13 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
2015-04-07 14:55:52 +00:00
|
|
|
"./helper",
|
2015-07-15 02:11:35 +00:00
|
|
|
"ui/widgets/tabs"
|
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 disabled = testHelper.disabled,
|
|
|
|
equalHeight = testHelper.equalHeight,
|
|
|
|
state = testHelper.state;
|
2012-04-19 16:53:06 +00:00
|
|
|
|
2011-04-11 17:49:22 +00:00
|
|
|
module( "tabs: options" );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2011-04-11 17:49:22 +00:00
|
|
|
test( "{ active: default }", function() {
|
2012-10-12 15:07:04 +00:00
|
|
|
expect( 6 );
|
2011-04-11 17:49:22 +00:00
|
|
|
|
|
|
|
var element = $( "#tabs1" ).tabs();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 0, "should be 0 by default" );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-04-11 17:49:22 +00:00
|
|
|
element.tabs( "destroy" );
|
|
|
|
|
2011-04-15 12:53:05 +00:00
|
|
|
location.hash = "#fragment-3";
|
2011-04-11 17:49:22 +00:00
|
|
|
element = $( "#tabs1" ).tabs();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 2, "should be 2 based on URL" );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2011-04-15 12:53:05 +00:00
|
|
|
element.tabs( "destroy" );
|
2012-10-12 15:07:04 +00:00
|
|
|
|
|
|
|
location.hash = "#custom-id";
|
|
|
|
element = $( "#tabs2" ).tabs();
|
|
|
|
equal( element.tabs( "option", "active" ), 3, "should be 3 based on URL" );
|
|
|
|
state( element, 0, 0, 0, 1, 0 );
|
|
|
|
element.tabs( "destroy" );
|
2011-05-03 11:14:33 +00:00
|
|
|
location.hash = "#";
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2011-04-11 17:49:22 +00:00
|
|
|
|
|
|
|
test( "{ active: false }", function() {
|
|
|
|
expect( 7 );
|
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2011-04-11 17:49:22 +00:00
|
|
|
active: false,
|
|
|
|
collapsible: true
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 0, 0 );
|
2012-04-23 18:25:23 +00:00
|
|
|
equal( element.find( ".ui-tabs-nav .ui-state-active" ).length, 0, "no tabs selected" );
|
2011-04-11 17:49:22 +00:00
|
|
|
strictEqual( element.tabs( "option", "active" ), false );
|
|
|
|
|
|
|
|
element.tabs( "option", "collapsible", false );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-04-11 17:49:22 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 0 );
|
|
|
|
|
|
|
|
element.tabs( "destroy" );
|
2015-08-24 12:57:25 +00:00
|
|
|
element.tabs( {
|
2011-04-11 17:49:22 +00:00
|
|
|
active: false
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-04-11 17:49:22 +00:00
|
|
|
strictEqual( element.tabs( "option", "active" ), 0 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2011-04-11 17:49:22 +00:00
|
|
|
|
|
|
|
test( "{ active: Number }", function() {
|
|
|
|
expect( 8 );
|
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2011-04-11 17:49:22 +00:00
|
|
|
active: 2
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 2 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2011-04-11 17:49:22 +00:00
|
|
|
|
|
|
|
element.tabs( "option", "active", 0 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 0 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2009-02-03 13:37:54 +00:00
|
|
|
|
2015-05-14 02:01:58 +00:00
|
|
|
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "click" );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2009-02-03 13:37:54 +00:00
|
|
|
|
2011-04-11 17:49:22 +00:00
|
|
|
element.tabs( "option", "active", 10 );
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2011-04-11 17:49:22 +00:00
|
|
|
|
2012-10-25 10:00:18 +00:00
|
|
|
test( "{ active: -Number }", function() {
|
|
|
|
expect( 8 );
|
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2012-10-25 10:00:18 +00:00
|
|
|
active: -1
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-10-25 10:00:18 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 2 );
|
|
|
|
state( element, 0, 0, 1 );
|
|
|
|
|
|
|
|
element.tabs( "option", "active", -2 );
|
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
|
|
|
state( element, 0, 1, 0 );
|
|
|
|
|
|
|
|
element.tabs( "option", "active", -10 );
|
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
|
|
|
state( element, 0, 1, 0 );
|
|
|
|
|
|
|
|
element.tabs( "option", "active", -3 );
|
|
|
|
equal( element.tabs( "option", "active" ), 0 );
|
|
|
|
state( element, 1, 0, 0 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2011-04-11 17:49:22 +00:00
|
|
|
|
2011-04-15 12:53:05 +00:00
|
|
|
test( "active - mismatched tab/panel order", function() {
|
|
|
|
expect( 3 );
|
|
|
|
|
|
|
|
location.hash = "#tabs7-2";
|
|
|
|
var element = $( "#tabs7" ).tabs();
|
2012-02-28 14:56:32 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1, "should be 1 based on URL" );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1 );
|
2011-04-15 12:53:05 +00:00
|
|
|
element.tabs( "option", "active", 0 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 1, 0 );
|
2011-05-03 11:14:33 +00:00
|
|
|
location.hash = "#";
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2011-04-15 12:53:05 +00:00
|
|
|
|
2015-01-30 16:00:44 +00:00
|
|
|
test( "collapsible", function( assert ) {
|
2014-12-03 16:28:56 +00:00
|
|
|
expect( 13 );
|
2011-04-11 17:49:22 +00:00
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2011-04-11 17:49:22 +00:00
|
|
|
active: 1,
|
|
|
|
collapsible: true
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2015-01-30 16:00:44 +00:00
|
|
|
assert.hasClasses( element, "ui-tabs-collapsible" );
|
2011-04-11 17:49:22 +00:00
|
|
|
element.tabs( "option", "active", false );
|
|
|
|
equal( element.tabs( "option", "active" ), false );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 0, 0 );
|
2011-03-29 02:28:59 +00:00
|
|
|
|
2011-04-11 17:49:22 +00:00
|
|
|
element.tabs( "option", "active", 1 );
|
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2015-05-14 02:01:58 +00:00
|
|
|
element.find( ".ui-state-active .ui-tabs-anchor" ).trigger( "click" );
|
2011-04-11 17:49:22 +00:00
|
|
|
equal( element.tabs( "option", "active" ), false );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 0, 0 );
|
2014-12-03 16:28:56 +00:00
|
|
|
|
|
|
|
element.tabs( "option", "collapsible", false );
|
2015-01-30 16:00:44 +00:00
|
|
|
assert.lacksClasses( element, "ui-tabs-collapsible" );
|
2014-12-03 16:28:56 +00:00
|
|
|
|
|
|
|
element.tabs( "option", "collapsible", true );
|
2015-01-30 16:00:44 +00:00
|
|
|
|
|
|
|
assert.hasClasses( element, "ui-tabs-collapsible" );
|
2014-12-03 16:28:56 +00:00
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
element.tabs( {
|
2014-12-03 16:28:56 +00:00
|
|
|
active: 1,
|
|
|
|
collapsible: false
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2014-12-03 16:28:56 +00:00
|
|
|
element.tabs( "option", "active", false );
|
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
|
|
|
state( element, 0, 1, 0 );
|
|
|
|
|
2015-05-14 02:01:58 +00:00
|
|
|
element.find( ".ui-state-active .ui-tabs-anchor" ).eq( 1 ).trigger( "click" );
|
2014-12-03 16:28:56 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
|
|
|
state( element, 0, 1, 0 );
|
2015-01-30 16:00:44 +00:00
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2009-02-03 13:37:54 +00:00
|
|
|
|
2015-01-30 16:00:44 +00:00
|
|
|
test( "disabled", function( assert ) {
|
2013-07-03 18:38:35 +00:00
|
|
|
expect( 23 );
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Fully enabled by default
|
2013-07-03 18:38:35 +00:00
|
|
|
var event,
|
|
|
|
element = $( "#tabs1" ).tabs();
|
2012-04-19 16:53:06 +00:00
|
|
|
disabled( element, false );
|
2011-05-09 21:10:36 +00:00
|
|
|
|
2015-01-30 16:00:44 +00:00
|
|
|
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
|
|
|
|
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
|
2013-03-14 23:08:21 +00:00
|
|
|
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
|
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Disable single tab
|
2011-05-09 21:10:36 +00:00
|
|
|
element.tabs( "option", "disabled", [ 1 ] );
|
2012-04-19 16:53:06 +00:00
|
|
|
disabled( element, [ 1 ] );
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2015-01-30 16:00:44 +00:00
|
|
|
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
|
|
|
|
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
|
2013-03-14 23:08:21 +00:00
|
|
|
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
|
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Disabled active tab
|
2011-05-09 21:10:36 +00:00
|
|
|
element.tabs( "option", "disabled", [ 0, 1 ] );
|
2012-04-19 16:53:06 +00:00
|
|
|
disabled( element, [ 0, 1 ] );
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2015-01-30 16:00:44 +00:00
|
|
|
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
|
|
|
|
assert.lacksClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
|
2013-03-14 23:08:21 +00:00
|
|
|
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
|
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Disable all tabs
|
2011-05-09 21:10:36 +00:00
|
|
|
element.tabs( "option", "disabled", [ 0, 1, 2 ] );
|
2012-04-19 16:53:06 +00:00
|
|
|
disabled( element, true );
|
2010-04-21 19:31:29 +00:00
|
|
|
|
2015-01-30 16:00:44 +00:00
|
|
|
assert.lacksClasses( element.tabs( "widget" ), "ui-state-disabled" );
|
2015-09-22 11:14:25 +00:00
|
|
|
assert.hasClasses( element.tabs( "widget" ), "ui-tabs-disabled" );
|
2013-03-14 23:08:21 +00:00
|
|
|
ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
|
|
|
|
|
2013-07-03 18:38:35 +00:00
|
|
|
event = $.Event( "click" );
|
|
|
|
element.find( ".ui-tabs-anchor" ).eq( 0 ).trigger( event );
|
|
|
|
ok( event.isDefaultPrevented(), "click is prevented for disabled tab" );
|
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Enable all tabs
|
2011-05-09 21:10:36 +00:00
|
|
|
element.tabs( "option", "disabled", [] );
|
2012-04-19 16:53:06 +00:00
|
|
|
disabled( element, false );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2009-02-03 13:37:54 +00:00
|
|
|
|
2011-05-09 21:01:11 +00:00
|
|
|
test( "{ event: null }", function() {
|
|
|
|
expect( 5 );
|
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2011-05-09 21:01:11 +00:00
|
|
|
event: null
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
|
|
|
element.tabs( "option", "active", 1 );
|
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Ensure default click handler isn't bound
|
2015-05-14 02:01:58 +00:00
|
|
|
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" );
|
2011-05-09 21:01:11 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
|
|
|
test( "{ event: custom }", function() {
|
|
|
|
expect( 11 );
|
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2011-05-09 21:01:11 +00:00
|
|
|
event: "custom1 custom2"
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 1, 0, 0 );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
2012-05-18 20:11:14 +00:00
|
|
|
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
|
2011-05-09 21:01:11 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Ensure default click handler isn't bound
|
2012-05-18 20:11:14 +00:00
|
|
|
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "click" );
|
2011-05-09 21:01:11 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
2012-05-18 20:11:14 +00:00
|
|
|
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 2 ).trigger( "custom2" );
|
2011-05-09 21:01:11 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 2 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
|
|
|
element.tabs( "option", "event", "custom3" );
|
|
|
|
|
2015-08-21 04:04:44 +00:00
|
|
|
// Ensure old event handlers are unbound
|
2012-05-18 20:11:14 +00:00
|
|
|
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom1" );
|
2011-05-09 21:01:11 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 2 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 0, 1 );
|
2011-05-09 21:01:11 +00:00
|
|
|
|
2012-05-18 20:11:14 +00:00
|
|
|
element.find( ".ui-tabs-nav .ui-tabs-anchor" ).eq( 1 ).trigger( "custom3" );
|
2011-05-09 21:01:11 +00:00
|
|
|
equal( element.tabs( "option", "active" ), 1 );
|
2012-04-19 16:53:06 +00:00
|
|
|
state( element, 0, 1, 0 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2009-02-03 13:37:54 +00:00
|
|
|
|
2012-05-28 19:11:20 +00:00
|
|
|
test( "{ heightStyle: 'auto' }", function() {
|
|
|
|
expect( 2 );
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs8" ).tabs( { heightStyle: "auto" } );
|
2012-05-28 19:11:20 +00:00
|
|
|
equalHeight( element, 45 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-05-28 19:11:20 +00:00
|
|
|
|
|
|
|
test( "{ heightStyle: 'content' }", function() {
|
|
|
|
expect( 2 );
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs8" ).tabs( { heightStyle: "content" } ),
|
|
|
|
sizes = element.find( ".ui-tabs-panel" ).map( function() {
|
2012-05-28 19:11:20 +00:00
|
|
|
return $( this ).height();
|
2015-08-24 12:57:25 +00:00
|
|
|
} ).get();
|
2012-05-28 19:11:20 +00:00
|
|
|
equal( sizes[ 0 ], 45 );
|
|
|
|
equal( sizes[ 1 ], 15 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-05-28 19:11:20 +00:00
|
|
|
|
|
|
|
test( "{ heightStyle: 'fill' }", function() {
|
2012-11-26 01:02:36 +00:00
|
|
|
expect( 4 );
|
2012-05-28 19:11:20 +00:00
|
|
|
$( "#tabs8Wrapper" ).height( 500 );
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
|
2012-05-28 19:11:20 +00:00
|
|
|
equalHeight( element, 485 );
|
2012-11-26 01:02:36 +00:00
|
|
|
element.tabs( "destroy" );
|
|
|
|
|
2015-08-24 12:57:25 +00:00
|
|
|
element = $( "#tabs8" ).css( {
|
2012-11-26 01:02:36 +00:00
|
|
|
"border": "1px solid black",
|
|
|
|
"padding": "1px 0"
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
|
|
|
element.tabs( { heightStyle: "fill" } );
|
2012-11-26 01:02:36 +00:00
|
|
|
equalHeight( element, 481 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-05-28 19:11:20 +00:00
|
|
|
|
|
|
|
test( "{ heightStyle: 'fill' } with sibling", function() {
|
|
|
|
expect( 2 );
|
|
|
|
$( "#tabs8Wrapper" ).height( 500 );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-24 12:57:25 +00:00
|
|
|
.css( {
|
2012-05-28 19:11:20 +00:00
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30
|
2015-08-24 12:57:25 +00:00
|
|
|
} )
|
2012-05-28 19:11:20 +00:00
|
|
|
.prependTo( "#tabs8Wrapper" );
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
|
2012-05-28 19:11:20 +00:00
|
|
|
equalHeight( element, 385 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-05-28 19:11:20 +00:00
|
|
|
|
|
|
|
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
|
|
|
|
expect( 2 );
|
|
|
|
$( "#tabs8Wrapper" ).height( 500 );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-24 12:57:25 +00:00
|
|
|
.css( {
|
2012-05-28 19:11:20 +00:00
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30
|
2015-08-24 12:57:25 +00:00
|
|
|
} )
|
2012-05-28 19:11:20 +00:00
|
|
|
.prependTo( "#tabs8Wrapper" );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-24 12:57:25 +00:00
|
|
|
.css( {
|
2012-05-28 19:11:20 +00:00
|
|
|
height: 50,
|
|
|
|
marginTop: 20,
|
|
|
|
marginBottom: 30,
|
|
|
|
position: "absolute"
|
2015-08-24 12:57:25 +00:00
|
|
|
} )
|
2012-05-28 19:11:20 +00:00
|
|
|
.prependTo( "#tabs8Wrapper" );
|
|
|
|
$( "<p>Lorem Ipsum</p>" )
|
2015-08-24 12:57:25 +00:00
|
|
|
.css( {
|
2012-05-28 19:11:20 +00:00
|
|
|
height: 25,
|
|
|
|
marginTop: 10,
|
|
|
|
marginBottom: 15
|
2015-08-24 12:57:25 +00:00
|
|
|
} )
|
2012-05-28 19:11:20 +00:00
|
|
|
.prependTo( "#tabs8Wrapper" );
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs8" ).tabs( { heightStyle: "fill" } );
|
2012-05-28 19:11:20 +00:00
|
|
|
equalHeight( element, 335 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-05-28 19:11:20 +00:00
|
|
|
|
2012-07-06 01:07:49 +00:00
|
|
|
test( "hide and show: false", function() {
|
|
|
|
expect( 3 );
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2012-07-06 01:07:49 +00:00
|
|
|
show: false,
|
|
|
|
hide: false
|
2015-08-24 12:57:25 +00:00
|
|
|
} ),
|
2013-03-19 15:53:35 +00:00
|
|
|
widget = element.tabs( "instance" ),
|
2012-07-06 01:07:49 +00:00
|
|
|
panels = element.find( ".ui-tabs-panel" );
|
|
|
|
widget._show = function() {
|
|
|
|
ok( false, "_show() called" );
|
|
|
|
};
|
|
|
|
widget._hide = function() {
|
|
|
|
ok( false, "_hide() called" );
|
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.tabs( "option", "active", 1 );
|
|
|
|
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
|
|
|
|
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-07-06 01:07:49 +00:00
|
|
|
|
|
|
|
asyncTest( "hide and show - animation", function() {
|
|
|
|
expect( 5 );
|
2015-08-24 12:57:25 +00:00
|
|
|
var element = $( "#tabs1" ).tabs( {
|
2012-07-06 01:07:49 +00:00
|
|
|
show: "drop",
|
|
|
|
hide: 2000
|
2015-08-24 12:57:25 +00:00
|
|
|
} ),
|
2013-03-19 15:53:35 +00:00
|
|
|
widget = element.tabs( "instance" ),
|
2012-07-06 01:07:49 +00:00
|
|
|
panels = element.find( ".ui-tabs-panel" );
|
|
|
|
widget._show = function( element, options, callback ) {
|
|
|
|
strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
|
|
|
|
equal( options, "drop", "correct options in _show()" );
|
2015-08-24 12:57:25 +00:00
|
|
|
setTimeout( function() {
|
2012-07-06 01:07:49 +00:00
|
|
|
callback();
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-07-06 01:07:49 +00:00
|
|
|
};
|
|
|
|
widget._hide = function( element, options, callback ) {
|
|
|
|
strictEqual( element[ 0 ], panels[ 0 ], "correct element in _hide()" );
|
|
|
|
equal( options, 2000, "correct options in _hide()" );
|
2015-08-24 12:57:25 +00:00
|
|
|
setTimeout( function() {
|
2012-07-06 01:07:49 +00:00
|
|
|
callback();
|
|
|
|
start();
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-07-06 01:07:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
|
|
|
|
element.tabs( "option", "active", 1 );
|
2015-08-24 12:57:25 +00:00
|
|
|
} );
|
2012-07-06 01:07:49 +00:00
|
|
|
|
2015-04-06 19:01:13 +00:00
|
|
|
} );
|