imported the whole jquery-ui package, refreshed with 1.10.2
[myslice.git] / third-party / jquery-ui-1.10.2 / tests / unit / tabs / tabs_test_helpers.js
1 TestHelpers.tabs = {
2         disabled: function( tabs, state ) {
3                 var expected, actual,
4                         internalState = tabs.tabs( "option", "disabled" );
5
6                 if ( internalState === false ) {
7                         internalState = [];
8                 }
9                 if ( internalState === true ) {
10                         internalState = $.map( new Array( tabs.find( ".ui-tabs-nav li" ).length ), function( _, index ) {
11                                 return index;
12                         });
13                 }
14
15                 expected = $.map( new Array( tabs.find ( ".ui-tabs-nav li" ).length ), function( _, index ) {
16                         if ( typeof state === "boolean" ) {
17                                 return state ? 1 : 0;
18                         } else {
19                                 return $.inArray( index, state ) !== -1 ? 1 : 0;
20                         }
21                 });
22
23                 actual = tabs.find( ".ui-tabs-nav li" ).map(function( index ) {
24                         var tab = $( this ),
25                                 tabIsDisabled = tab.hasClass( "ui-state-disabled" );
26
27                         if ( tabIsDisabled && $.inArray( index, internalState ) !== -1 ) {
28                                 return 1;
29                         }
30                         if ( !tabIsDisabled && $.inArray( index, internalState ) === -1 ) {
31                                 return 0;
32                         }
33                         // mixed state - invalid
34                         return -1;
35                 }).get();
36
37                 deepEqual( tabs.tabs( "option", "disabled" ), state );
38                 deepEqual( actual, expected );
39         },
40
41         equalHeight: function( tabs, height ) {
42                 tabs.find( ".ui-tabs-panel" ).each(function() {
43                         equal( $( this ).outerHeight(), height );
44                 });
45         },
46
47         state: function( tabs ) {
48                 var expected = $.makeArray( arguments ).slice( 1 ),
49                         actual = tabs.find( ".ui-tabs-nav li" ).map(function() {
50                                 var tab = $( this ),
51                                         panel = $( $.ui.tabs.prototype._sanitizeSelector(
52                                                 "#" + tab.attr( "aria-controls" ) ) ),
53                                         tabIsActive = tab.hasClass( "ui-state-active" ),
54                                         panelIsActive = panel.css( "display" ) !== "none";
55
56                                 if ( tabIsActive && panelIsActive ) {
57                                         return 1;
58                                 }
59                                 if ( !tabIsActive && !panelIsActive ) {
60                                         return 0;
61                                 }
62                                 return -1; // mixed state - invalid
63                         }).get();
64                 deepEqual( actual, expected );
65         }
66 };
67