annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/fnDrawCallback.js @ 9:7300ed4c1481 draft default tip

Uploaded
author saskia-hiltemann
date Mon, 04 Sep 2017 10:49:00 -0400
parents ac5f9272033b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 // DATA_TEMPLATE: empty_table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 oTest.fnStart( "fnDrawCallback" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 /* Fairly boring function compared to the others! */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 /* Check the default */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 "bDeferRender": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 var oSettings = oTable.fnSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 var mPass, bInit;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 "Default should be null",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 function () { return oSettings.fnDrawCallback == null; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 "One argument passed",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 mPass = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 bInit = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 "fnDrawCallback": function ( ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 mPass = arguments.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 "fnInitComplete": function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 bInit = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 function () { return mPass == 1 && bInit; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 "That one argument is the settings object",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 bInit = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 "fnDrawCallback": function ( oSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 mPass = oSettings;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 "fnInitComplete": function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 bInit = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 function () { return oTable.fnSettings() == mPass && bInit; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 /* The draw callback is called once for the init and then when the data is added */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 "fnRowCallback called once on first draw",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 mPass = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 bInit = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 "fnDrawCallback": function ( ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 mPass++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 "fnInitComplete": function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 bInit = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 function () { return mPass == 2 && bInit; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 "fnRowCallback called once on each draw there after as well",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 $('#example_next').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 $('#example_next').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 $('#example_next').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 function () { return mPass == 5; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101 oTest.fnComplete();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 } );