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