Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 5_ajax_objects / aoColumns.bSortable.js
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aoColumns.bSortable" );
3
4 $(document).ready( function () {
5         /* Check the default */
6         var oTable = $('#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         var oSettings = oTable.fnSettings();
17         
18         oTest.fnWaitTest( 
19                 "All columns are sortable by default",
20                 function () { $('#example thead th:eq(1)').click(); },
21                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; }
22         );
23         
24         oTest.fnWaitTest( 
25                 "Can disable sorting from one column",
26                 function () {
27                         oSession.fnRestore();
28                         $('#example').dataTable( {
29                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
30                                 "aoColumns": [
31                                         { "mData": "engine" },
32                                         { "mData": "browser", "bSortable": false },
33                                         { "mData": "platform" },
34                                         { "mData": "version" },
35                                         { "mData": "grade" }
36                                 ]
37                         } );
38                         $('#example thead th:eq(1)').click();
39                 },
40                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
41         );
42         
43         oTest.fnWaitTest( 
44                 "Disabled column has no sorting class",
45                 null,
46                 function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; }
47         );
48         
49         oTest.fnWaitTest( 
50                 "Other columns can still sort",
51                 function () {
52                         $('#example thead th:eq(4)').click();
53                         $('#example thead th:eq(4)').click();
54                 },
55                 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
56         );
57         
58         oTest.fnWaitTest( 
59                 "Disable sorting on multiple columns - no sorting classes",
60                 function () {
61                         oSession.fnRestore();
62                         $('#example').dataTable( {
63                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
64                                 "aoColumns": [
65                                         { "mData": "engine" },
66                                         { "mData": "browser", "bSortable": false },
67                                         { "mData": "platform" },
68                                         { "mData": "version", "bSortable": false },
69                                         { "mData": "grade" }
70                                 ]
71                         } );
72                 },
73                 function () {
74                         var bReturn = 
75                                 $('#example thead th:eq(1)').hasClass("sorting") ||
76                                 $('#example thead th:eq(3)').hasClass("sorting")
77                         return bReturn == false;
78                 }
79         );
80         
81         oTest.fnWaitTest( 
82                 "Sorting on disabled column 1 has no effect",
83                 function () {
84                         $('#example thead th:eq(1)').click();
85                 },
86                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
87         );
88         
89         oTest.fnWaitTest( 
90                 "Sorting on disabled column 2 has no effect",
91                 function () {
92                         $('#example thead th:eq(3)').click();
93                 },
94                 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
95         );
96         
97         oTest.fnWaitTest( 
98                 "Second sort on disabled column 2 has no effect",
99                 function () {
100                         $('#example thead th:eq(3)').click();
101                 },
102                 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
103         );
104         
105         oTest.fnWaitTest( 
106                 "Even with multiple disabled sorting columns other columns can still sort",
107                 function () {
108                         $('#example thead th:eq(4)').click();
109                         $('#example thead th:eq(4)').click();
110                 },
111                 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
112         );
113         
114         
115         oTest.fnComplete();
116 } );