| 1 |
// DATA_TEMPLATE: dom_data |
| 2 |
oTest.fnStart( "sScrollX / Y" ); |
| 3 |
|
| 4 |
|
| 5 |
$(document).ready( function () { |
| 6 |
// Force some x scrolling |
| 7 |
$('body').css('white-space', 'nowrap'); |
| 8 |
$('#container').css('width', '400px'); |
| 9 |
|
| 10 |
var oTable = $('#example').dataTable( { |
| 11 |
"sScrollX": "100%", |
| 12 |
"sScrollY": "200px", |
| 13 |
"bPaginate": false |
| 14 |
} ); |
| 15 |
|
| 16 |
oTest.fnWaitTest( |
| 17 |
"Header follows x-scrolling", |
| 18 |
function () { $('div.dataTables_scrollBody').scrollLeft(20); }, |
| 19 |
function () { return $('div.dataTables_scrollHead').scrollLeft() == 20; } |
| 20 |
); |
| 21 |
|
| 22 |
oTest.fnWaitTest( |
| 23 |
"Footer follows x-scrolling", |
| 24 |
null, |
| 25 |
function () { return $('div.dataTables_scrollFoot').scrollLeft() == 20; } |
| 26 |
); |
| 27 |
|
| 28 |
oTest.fnWaitTest( |
| 29 |
"y-scrolling has no effect on header", |
| 30 |
function () { $('div.dataTables_scrollBody').scrollTop(20); }, |
| 31 |
function () { return $('div.dataTables_scrollHead').scrollLeft() == 20; } |
| 32 |
); |
| 33 |
|
| 34 |
oTest.fnWaitTest( |
| 35 |
"Filtering results in sets y-scroll back to 0", |
| 36 |
function () { oTable.fnFilter('1') }, |
| 37 |
function () { return $('div.dataTables_scrollBody').scrollTop() == 0; } |
| 38 |
); |
| 39 |
|
| 40 |
oTest.fnWaitTest( |
| 41 |
"Filtering has no effect on x-scroll", |
| 42 |
null, |
| 43 |
function () { return $('div.dataTables_scrollBody').scrollLeft() == 20; } |
| 44 |
); |
| 45 |
|
| 46 |
oTest.fnWaitTest( |
| 47 |
"Full x-scroll has header track all the way with it", |
| 48 |
function () { |
| 49 |
$('div.dataTables_scrollBody').scrollLeft( |
| 50 |
$('#example').width() - $('div.dataTables_scrollBody')[0].clientWidth |
| 51 |
); |
| 52 |
}, |
| 53 |
function () { return $('div.dataTables_scrollBody').scrollLeft() == $('div.dataTables_scrollHead').scrollLeft(); } |
| 54 |
); |
| 55 |
|
| 56 |
oTest.fnTest( |
| 57 |
"Footer also tracked all the way", |
| 58 |
null, |
| 59 |
function () { return $('div.dataTables_scrollBody').scrollLeft() == $('div.dataTables_scrollFoot').scrollLeft(); } |
| 60 |
); |
| 61 |
|
| 62 |
oTest.fnTest( |
| 63 |
"Don't throw an error if initialising again on id selected element", |
| 64 |
function () { |
| 65 |
$('#example').dataTable(); |
| 66 |
}, |
| 67 |
function () { return true; } |
| 68 |
); |
| 69 |
|
| 70 |
oTest.fnTest( |
| 71 |
"Don't throw an error if initialising again on tag name selected element - picking up header table as well", |
| 72 |
function () { |
| 73 |
$('table.dataTable').dataTable(); |
| 74 |
}, |
| 75 |
function () { return true; } |
| 76 |
); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
oTest.fnComplete(); |
| 81 |
} ); |