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