1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | // DATA_TEMPLATE: dom_data oTest.fnStart( "2746 - Stable sorting" ); $(document).ready( function () { $('#example').dataTable(); oTest.fnTest( "Initial sort", null, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'Firefox 1.0' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Firefox 1.5' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Firefox 2.0'; return ret; } ); oTest.fnTest( "Reserve initial sort", function () { $('#example thead th:eq(0)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Webkit' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Webkit' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'Safari 1.2' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Safari 1.3' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Safari 2.0'; return ret; } ); oTest.fnTest( "Reserve to go back to initial sort sort", function () { $('#example thead th:eq(0)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'Firefox 1.0' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Firefox 1.5' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Firefox 2.0'; return ret; } ); oTest.fnTest( "Reserve initial sort again", function () { $('#example thead th:eq(0)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Webkit' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Webkit' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'Safari 1.2' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Safari 1.3' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Safari 2.0'; return ret; } ); oTest.fnTest( "And once more back to the initial sort", function () { $('#example thead th:eq(0)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'Firefox 1.0' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Firefox 1.5' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Firefox 2.0'; return ret; } ); oTest.fnTest( "Sort on second column", function () { $('#example thead th:eq(1)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Trident' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'AOL browser (AOL desktop)' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Camino 1.0'; return ret; } ); oTest.fnTest( "Reserve sort on second column", function () { $('#example thead th:eq(1)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Webkit' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Safari 3.0' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Safari 2.0'; return ret; } ); oTest.fnTest( "And back to asc sorting on second column", function () { $('#example thead th:eq(1)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Trident' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'AOL browser (AOL desktop)' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Camino 1.0'; return ret; } ); oTest.fnTest( "Sort on third column, having now sorted on second", function () { $('#example thead th:eq(2)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Misc' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Dillo 0.8' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'NetFront 3.1'; return ret; } ); oTest.fnTest( "Reserve sort on third column", function () { $('#example thead th:eq(2)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Misc' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Trident' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'IE Mobile' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Internet Explorer 7' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'AOL browser (AOL desktop)'; return ret; } ); oTest.fnTest( "Return sorting on third column to asc", function () { $('#example thead th:eq(2)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Misc' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Dillo 0.8' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'NetFront 3.1'; return ret; } ); oTest.fnTest( "Sort on first column having sorted on second then third columns", function () { $('#example thead th:eq(0)').click(); }, function () { var ret = $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && $('#example tbody tr:eq(0) td:eq(1)').html() == 'Epiphany 2.20' && $('#example tbody tr:eq(1) td:eq(1)').html() == 'Camino 1.0' && $('#example tbody tr:eq(2) td:eq(1)').html() == 'Camino 1.5'; return ret; } ); oTest.fnComplete(); } ); |