Debian Codegraph @

old-tests/tests_onhold/1_dom/html5-init-attributes.js

raw
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "HTML 5 data-* attributes as initialisation options" );
3
4
5 $(document).ready( function () {
6 // Add attributes - using DOM methods to prevent any possible jQuery overlap
7 var table = $('#example')[0];
8 table.setAttribute( 'data-page-length', 25 );
9 table.setAttribute( 'data-order', '[[ 1, "asc" ]]' );
10 table.setAttribute( 'data-scrollY', 300 );
11
12 var cols = $('#example thead th');
13 cols[3].setAttribute( 'data-orderable', 'false' );
14 cols[2].setAttribute( 'data-class-name', 'unitTest' );
15
16 var dt = $('#example').DataTable();
17
18 oTest.fnTest(
19 "Page length is 25",
20 null,
21 function () {
22 return $('#example tbody tr').length === 25;
23 }
24 );
25
26 oTest.fnTest(
27 "Ordering is by column 1 asc",
28 null,
29 function () {
30 return $('#example tbody tr:eq(0) td:eq(1)').text() === 'All others';
31 }
32 );
33
34 oTest.fnTest(
35 "Column idx 3 cannot be sorted",
36 function () {
37 return $('#example thead th:eq(3)').click();
38 },
39 function () {
40 return $('#example tbody tr:eq(0) td:eq(1)').text() === 'All others';
41 }
42 );
43
44 oTest.fnTest(
45 "Column idx 0 can be sorted",
46 function () {
47 return $('#example thead th:eq(0)').click();
48 },
49 function () {
50 return $('#example tbody tr:eq(0) td:eq(0)').text() === 'Gecko';
51 }
52 );
53
54 oTest.fnTest(
55 "Column idx 2 has as class name assigned",
56 null,
57 function () {
58 return $('#example tbody tr td.unitTest').length == 25;
59 }
60 );
61
62
63 oTest.fnComplete();
64 } );