/[projects]/misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/tabs/tabs_test_helpers.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/jquery-ui-1.10.3/tests/unit/tabs/tabs_test_helpers.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File MIME type: application/javascript
File size: 1824 byte(s)
initial import
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 };

  ViewVC Help
Powered by ViewVC 1.1.20