1 | // DATA_TEMPLATE: empty_table |
---|
2 | oTest.fnStart( "bSort" ); |
---|
3 | |
---|
4 | $(document).ready( function () { |
---|
5 | /* Check the default */ |
---|
6 | $('#example').dataTable( { |
---|
7 | "sAjaxSource": "../../../examples/examples_support/json_source.txt" |
---|
8 | } ); |
---|
9 | |
---|
10 | oTest.fnWaitTest( |
---|
11 | "Sorting is on by default", |
---|
12 | null, |
---|
13 | function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } |
---|
14 | ); |
---|
15 | |
---|
16 | oTest.fnWaitTest( |
---|
17 | "Sorting Asc by default class applied", |
---|
18 | null, |
---|
19 | function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); } |
---|
20 | ); |
---|
21 | |
---|
22 | oTest.fnWaitTest( |
---|
23 | "Click on second column", |
---|
24 | function () { $('#example thead th:eq(1)').click(); }, |
---|
25 | function () { return $('#example tbody td:eq(1)').html() == "All others"; } |
---|
26 | ); |
---|
27 | |
---|
28 | oTest.fnWaitTest( |
---|
29 | "Sorting class removed from first column", |
---|
30 | null, |
---|
31 | function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; } |
---|
32 | ); |
---|
33 | |
---|
34 | oTest.fnWaitTest( |
---|
35 | "Sorting asc class applied to second column", |
---|
36 | null, |
---|
37 | function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); } |
---|
38 | ); |
---|
39 | |
---|
40 | oTest.fnWaitTest( |
---|
41 | "Reverse on second column", |
---|
42 | function () { $('#example thead th:eq(1)').click(); }, |
---|
43 | function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } |
---|
44 | ); |
---|
45 | |
---|
46 | oTest.fnWaitTest( |
---|
47 | "Sorting acs class removed from second column", |
---|
48 | null, |
---|
49 | function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; } |
---|
50 | ); |
---|
51 | |
---|
52 | oTest.fnWaitTest( |
---|
53 | "Sorting desc class applied to second column", |
---|
54 | null, |
---|
55 | function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); } |
---|
56 | ); |
---|
57 | |
---|
58 | /* Check can disable */ |
---|
59 | oTest.fnWaitTest( |
---|
60 | "Pagiantion can be disabled", |
---|
61 | function () { |
---|
62 | oSession.fnRestore(); |
---|
63 | $('#example').dataTable( { |
---|
64 | "sAjaxSource": "../../../examples/examples_support/json_source.txt", |
---|
65 | "bSort": false |
---|
66 | } ); |
---|
67 | }, |
---|
68 | function () { return $('#example tbody td:eq(3)').html() == "4"; } |
---|
69 | ); |
---|
70 | |
---|
71 | oTest.fnWaitTest( |
---|
72 | "Click on second column has no effect", |
---|
73 | function () { $('#example thead th:eq(1)').click(); }, |
---|
74 | function () { return $('#example tbody td:eq(3)').html() == "4"; } |
---|
75 | ); |
---|
76 | |
---|
77 | oTest.fnWaitTest( |
---|
78 | "Reverse on second column has no effect", |
---|
79 | function () { $('#example thead th:eq(1)').click(); }, |
---|
80 | function () { return $('#example tbody td:eq(3)').html() == "4"; } |
---|
81 | ); |
---|
82 | |
---|
83 | /* Enable makes no difference */ |
---|
84 | oTest.fnWaitTest( |
---|
85 | "Sorting enabled override", |
---|
86 | function () { |
---|
87 | oSession.fnRestore(); |
---|
88 | $('#example').dataTable( { |
---|
89 | "sAjaxSource": "../../../examples/examples_support/json_source.txt", |
---|
90 | "bSort": true |
---|
91 | } ); |
---|
92 | }, |
---|
93 | function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } |
---|
94 | ); |
---|
95 | |
---|
96 | |
---|
97 | |
---|
98 | oTest.fnComplete(); |
---|
99 | } ); |
---|