| 1 |
// DATA_TEMPLATE: empty_table |
| 2 |
oTest.fnStart( "bSortClasses" ); |
| 3 |
|
| 4 |
$(document).ready( function () { |
| 5 |
/* Check the default */ |
| 6 |
$('#example').dataTable( { |
| 7 |
"bServerSide": true, |
| 8 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php" |
| 9 |
} ); |
| 10 |
|
| 11 |
oTest.fnWaitTest( |
| 12 |
"Sorting classes are applied by default", |
| 13 |
null, |
| 14 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } |
| 15 |
); |
| 16 |
|
| 17 |
oTest.fnWaitTest( |
| 18 |
"Sorting classes are applied to all required cells", |
| 19 |
null, |
| 20 |
function () { return $('#example tbody tr:eq(7) td:eq(0)').hasClass('sorting_1'); } |
| 21 |
); |
| 22 |
|
| 23 |
oTest.fnWaitTest( |
| 24 |
"Sorting classes are not applied to non-sorting columns", |
| 25 |
null, |
| 26 |
function () { return $('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_1') == false; } |
| 27 |
); |
| 28 |
|
| 29 |
oTest.fnWaitTest( |
| 30 |
"Sorting multi-column - add column 1", |
| 31 |
function () { |
| 32 |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, |
| 33 |
function () { |
| 34 |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && |
| 35 |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2'); |
| 36 |
} |
| 37 |
); |
| 38 |
|
| 39 |
oTest.fnWaitTest( |
| 40 |
"Sorting multi-column - add column 2", |
| 41 |
function () { |
| 42 |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, |
| 43 |
function () { |
| 44 |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && |
| 45 |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && |
| 46 |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3'); |
| 47 |
} |
| 48 |
); |
| 49 |
|
| 50 |
oTest.fnWaitTest( |
| 51 |
"Sorting multi-column - add column 3", |
| 52 |
function () { |
| 53 |
oDispacher.click( $('#example thead th:eq(3)')[0], { 'shift': true } ); |
| 54 |
}, |
| 55 |
function () { |
| 56 |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && |
| 57 |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && |
| 58 |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') && |
| 59 |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3'); |
| 60 |
} |
| 61 |
); |
| 62 |
|
| 63 |
oTest.fnWaitTest( |
| 64 |
"Remove sorting classes on single column sort", |
| 65 |
function () { |
| 66 |
$('#example thead th:eq(4)').click(); |
| 67 |
}, |
| 68 |
function () { |
| 69 |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && |
| 70 |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && |
| 71 |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false && |
| 72 |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3') == false; |
| 73 |
} |
| 74 |
); |
| 75 |
|
| 76 |
oTest.fnWaitTest( |
| 77 |
"Sorting class 1 was added", |
| 78 |
null, |
| 79 |
function () { return $('#example tbody tr:eq(1) td:eq(4)').hasClass('sorting_1'); } |
| 80 |
); |
| 81 |
|
| 82 |
|
| 83 |
/* Check can disable */ |
| 84 |
oTest.fnWaitTest( |
| 85 |
"Sorting classes can be disabled", |
| 86 |
function () { |
| 87 |
oSession.fnRestore(); |
| 88 |
$('#example').dataTable( { |
| 89 |
"bServerSide": true, |
| 90 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 91 |
"bSortClasses": false |
| 92 |
} ); |
| 93 |
}, |
| 94 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false; } |
| 95 |
); |
| 96 |
|
| 97 |
oTest.fnWaitTest( |
| 98 |
"Sorting classes disabled - add column 1 - no effect", |
| 99 |
function () { |
| 100 |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, |
| 101 |
function () { |
| 102 |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && |
| 103 |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false; |
| 104 |
} |
| 105 |
); |
| 106 |
|
| 107 |
oTest.fnWaitTest( |
| 108 |
"Sorting classes disabled - add column 2 - no effect", |
| 109 |
function () { |
| 110 |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, |
| 111 |
function () { |
| 112 |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && |
| 113 |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && |
| 114 |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false; |
| 115 |
} |
| 116 |
); |
| 117 |
|
| 118 |
|
| 119 |
/* Enable makes no difference */ |
| 120 |
oTest.fnWaitTest( |
| 121 |
"Sorting classes enabled override", |
| 122 |
function () { |
| 123 |
oSession.fnRestore(); |
| 124 |
$('#example').dataTable( { |
| 125 |
"bServerSide": true, |
| 126 |
"sAjaxSource": "../../../examples/server_side/scripts/server_processing.php", |
| 127 |
"bSortClasses": true |
| 128 |
} ); |
| 129 |
}, |
| 130 |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } |
| 131 |
); |
| 132 |
|
| 133 |
|
| 134 |
oTest.fnComplete(); |
| 135 |
} ); |