1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "sPaginationType" ); |
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 |
"Check two button paging is the default", |
20 |
null, |
21 |
function () { return oSettings.sPaginationType == "two_button"; } |
22 |
); |
23 |
|
24 |
oTest.fnWaitTest( |
25 |
"Check class is applied", |
26 |
null, |
27 |
function () { return $('#example_paginate').hasClass('paging_two_button'); } |
28 |
); |
29 |
|
30 |
oTest.fnWaitTest( |
31 |
"Two A elements are in the wrapper", |
32 |
null, |
33 |
function () { return $('#example_paginate a').length == 2; } |
34 |
); |
35 |
|
36 |
oTest.fnWaitTest( |
37 |
"We have the previous button", |
38 |
null, |
39 |
function () { return document.getElementById('example_previous'); } |
40 |
); |
41 |
|
42 |
oTest.fnWaitTest( |
43 |
"We have the next button", |
44 |
null, |
45 |
function () { return document.getElementById('example_next'); } |
46 |
); |
47 |
|
48 |
oTest.fnWaitTest( |
49 |
"Previous button is disabled", |
50 |
null, |
51 |
function () { return $('#example_previous').hasClass('paginate_disabled_previous'); } |
52 |
); |
53 |
|
54 |
oTest.fnWaitTest( |
55 |
"Next button is enabled", |
56 |
null, |
57 |
function () { return $('#example_next').hasClass('paginate_enabled_next'); } |
58 |
); |
59 |
|
60 |
/* Don't test paging - that's done by the zero config test script. */ |
61 |
|
62 |
|
63 |
/* Two buttons paging */ |
64 |
var bComplete = false; |
65 |
oTest.fnWaitTest( |
66 |
"Can enabled full numbers paging", |
67 |
function () { |
68 |
oSession.fnRestore(); |
69 |
oTable = $('#example').dataTable( { |
70 |
"sAjaxSource": "../../../examples/ajax/sources/objects.txt", |
71 |
"aoColumnDefs": [ |
72 |
{ "mData": "engine", "aTargets": [0] }, |
73 |
{ "mData": "browser", "aTargets": [1] }, |
74 |
{ "mData": "platform", "aTargets": [2] }, |
75 |
{ "mData": "version", "aTargets": [3] }, |
76 |
{ "mData": "grade", "aTargets": [4] } |
77 |
], |
78 |
"sPaginationType": "full_numbers", |
79 |
"fnInitComplete": function () { |
80 |
bComplete = true; |
81 |
} |
82 |
} ); |
83 |
oSettings = oTable.fnSettings(); |
84 |
}, |
85 |
function () { |
86 |
if ( bComplete ) |
87 |
return oSettings.sPaginationType == "full_numbers"; |
88 |
else |
89 |
return false; |
90 |
} |
91 |
); |
92 |
|
93 |
oTest.fnWaitTest( |
94 |
"Check full numbers class is applied", |
95 |
null, |
96 |
function () { return $('#example_paginate').hasClass('paging_full_numbers'); } |
97 |
); |
98 |
|
99 |
|
100 |
var nFirst, nPrevious, nNext, nLast; |
101 |
oTest.fnWaitTest( |
102 |
"Jump to last page", |
103 |
function () { |
104 |
nFirst = $('div.dataTables_paginate a.first'); |
105 |
nPrevious = $('div.dataTables_paginate a.previous'); |
106 |
nNext = $('div.dataTables_paginate a.next'); |
107 |
nLast = $('div.dataTables_paginate a.last'); |
108 |
nLast.click(); |
109 |
}, |
110 |
function () { |
111 |
return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; |
112 |
} |
113 |
); |
114 |
|
115 |
oTest.fnWaitTest( |
116 |
"Go to two pages previous", |
117 |
function () { |
118 |
nPrevious.click(); |
119 |
nPrevious.click(); |
120 |
}, |
121 |
function () { |
122 |
return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries"; |
123 |
} |
124 |
); |
125 |
|
126 |
oTest.fnWaitTest( |
127 |
"Next (second last) page", |
128 |
function () { |
129 |
nNext.click(); |
130 |
}, |
131 |
function () { |
132 |
return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries"; |
133 |
} |
134 |
); |
135 |
|
136 |
oTest.fnWaitTest( |
137 |
"Jump to first page", |
138 |
function () { |
139 |
nFirst.click(); |
140 |
}, |
141 |
function () { |
142 |
return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; |
143 |
} |
144 |
); |
145 |
|
146 |
|
147 |
oTest.fnComplete(); |
148 |
} ); |