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