1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "asStripeClasses" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
/* Check the default */ |
6 |
$('#example').dataTable( { |
7 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
8 |
"aoColumns": [ |
9 |
{ "mData": "engine" }, |
10 |
{ "mData": "browser" }, |
11 |
{ "mData": "platform" }, |
12 |
{ "mData": "version" }, |
13 |
{ "mData": "grade" } |
14 |
] |
15 |
} ); |
16 |
|
17 |
oTest.fnWaitTest( |
18 |
"Default row striping is applied", |
19 |
null, |
20 |
function () { |
21 |
return $('#example tbody tr:eq(0)').hasClass('odd') && |
22 |
$('#example tbody tr:eq(1)').hasClass('even') && |
23 |
$('#example tbody tr:eq(2)').hasClass('odd') && |
24 |
$('#example tbody tr:eq(3)').hasClass('even'); |
25 |
} |
26 |
); |
27 |
|
28 |
oTest.fnWaitTest( |
29 |
"Row striping on the second page", |
30 |
function () { $('#example_next').click(); }, |
31 |
function () { |
32 |
return $('#example tbody tr:eq(0)').hasClass('odd') && |
33 |
$('#example tbody tr:eq(1)').hasClass('even') && |
34 |
$('#example tbody tr:eq(2)').hasClass('odd') && |
35 |
$('#example tbody tr:eq(3)').hasClass('even'); |
36 |
} |
37 |
); |
38 |
|
39 |
/* No striping */ |
40 |
oTest.fnWaitTest( |
41 |
"No row striping", |
42 |
function () { |
43 |
oSession.fnRestore(); |
44 |
$('#example').dataTable( { |
45 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
46 |
"aoColumnDefs": [ |
47 |
{ "mData": "engine", "aTargets": [0] }, |
48 |
{ "mData": "browser", "aTargets": [1] }, |
49 |
{ "mData": "platform", "aTargets": [2] }, |
50 |
{ "mData": "version", "aTargets": [3] }, |
51 |
{ "mData": "grade", "aTargets": [4] } |
52 |
], |
53 |
"asStripeClasses": [] |
54 |
} ); |
55 |
}, |
56 |
function () { |
57 |
if ( typeof $('#example tbody tr:eq(1)')[0] == 'undefined' ) |
58 |
{ |
59 |
/* Use the 'wait for' to allow this to become true */ |
60 |
return false; |
61 |
} |
62 |
return $('#example tbody tr:eq(0)')[0].className == "" && |
63 |
$('#example tbody tr:eq(1)')[0].className == "" && |
64 |
$('#example tbody tr:eq(2)')[0].className == "" && |
65 |
$('#example tbody tr:eq(3)')[0].className == ""; |
66 |
} |
67 |
); |
68 |
|
69 |
/* Custom striping */ |
70 |
oTest.fnWaitTest( |
71 |
"Custom striping [2]", |
72 |
function () { |
73 |
oSession.fnRestore(); |
74 |
$('#example').dataTable( { |
75 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
76 |
"aoColumnDefs": [ |
77 |
{ "mData": "engine", "aTargets": [0] }, |
78 |
{ "mData": "browser", "aTargets": [1] }, |
79 |
{ "mData": "platform", "aTargets": [2] }, |
80 |
{ "mData": "version", "aTargets": [3] }, |
81 |
{ "mData": "grade", "aTargets": [4] } |
82 |
], |
83 |
"asStripeClasses": [ 'test1', 'test2' ] |
84 |
} ); |
85 |
}, |
86 |
function () { |
87 |
return $('#example tbody tr:eq(0)').hasClass('test1') && |
88 |
$('#example tbody tr:eq(1)').hasClass('test2') && |
89 |
$('#example tbody tr:eq(2)').hasClass('test1') && |
90 |
$('#example tbody tr:eq(3)').hasClass('test2'); |
91 |
} |
92 |
); |
93 |
|
94 |
|
95 |
/* long array of striping */ |
96 |
oTest.fnWaitTest( |
97 |
"Custom striping [4]", |
98 |
function () { |
99 |
oSession.fnRestore(); |
100 |
$('#example').dataTable( { |
101 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
102 |
"aoColumnDefs": [ |
103 |
{ "mData": "engine", "aTargets": [0] }, |
104 |
{ "mData": "browser", "aTargets": [1] }, |
105 |
{ "mData": "platform", "aTargets": [2] }, |
106 |
{ "mData": "version", "aTargets": [3] }, |
107 |
{ "mData": "grade", "aTargets": [4] } |
108 |
], |
109 |
"asStripeClasses": [ 'test1', 'test2', 'test3', 'test4' ] |
110 |
} ); |
111 |
}, |
112 |
function () { |
113 |
return $('#example tbody tr:eq(0)').hasClass('test1') && |
114 |
$('#example tbody tr:eq(1)').hasClass('test2') && |
115 |
$('#example tbody tr:eq(2)').hasClass('test3') && |
116 |
$('#example tbody tr:eq(3)').hasClass('test4'); |
117 |
} |
118 |
); |
119 |
|
120 |
oTest.fnWaitTest( |
121 |
"Custom striping is restarted on second page [2]", |
122 |
function () { $('#example_next').click(); }, |
123 |
function () { |
124 |
return $('#example tbody tr:eq(0)').hasClass('test1') && |
125 |
$('#example tbody tr:eq(1)').hasClass('test2') && |
126 |
$('#example tbody tr:eq(2)').hasClass('test3') && |
127 |
$('#example tbody tr:eq(3)').hasClass('test4'); |
128 |
} |
129 |
); |
130 |
|
131 |
|
132 |
oTest.fnComplete(); |
133 |
} ); |