var giTotalTestCount = 0; | |
var giActiveModule = 0; | |
var giModuleTests; | |
var giStartTime; | |
var giTest; | |
var gbStop = false; | |
var gtoTest; | |
function fnTestStart ( sTestInfo ) | |
{ | |
gaoTest[ giActiveModule ].iTests++; | |
document.getElementById('test_info').innerHTML += | |
(giActiveModule+1)+'.'+(giModuleTests+1)+'. '+sTestInfo+'... '; | |
document.getElementById('test_number').innerHTML = giTotalTestCount+1; | |
giModuleTests++; | |
giTotalTestCount++; | |
/* Set a timer to catch stalled script */ | |
gtoTest = setTimeout( function () { | |
fnMessage( '<span class="error">WARNING - test script stalled. Likely a JS error</span>' ); | |
gbStop = true; | |
}, 3000 ); | |
} | |
function fnTestResult ( bResult ) | |
{ | |
clearTimeout( gtoTest ); | |
if ( bResult ) | |
{ | |
fnMessage( 'Passed' ); | |
} | |
else | |
{ | |
fnMessage( '<span class="error">FAILED</span>' ); | |
gbStop = true; | |
fnEnd( false ); | |
} | |
} | |
function fnUnitStart( iTest ) | |
{ | |
if ( !gbStop ) | |
{ | |
giModuleTests = 0; | |
window.parent.test_arena.location.href = | |
(iTest==0?"":"../")+'templates/'+gaoTest[iTest].sTemplate+'.php?scripts='+gaoTest[iTest].sTest; | |
giTest = iTest; | |
} | |
} | |
function fnStartMessage( sMessage ) | |
{ | |
fnMessage( '<br><b>'+gaoTest[giTest].sGroup+' - '+sMessage+'</b>' ); | |
} | |
function fnMessage( sMessage ) | |
{ | |
var nInfo = document.getElementById('test_info'); | |
nInfo.innerHTML += sMessage+'<br>'; | |
nInfo.scrollTop = nInfo.scrollHeight; | |
} | |
function fnUnitComplete() | |
{ | |
if ( giActiveModule < gaoTest.length - 1 ) | |
{ | |
fnUnitStart( ++giActiveModule ); | |
} | |
else | |
{ | |
fnEnd( true ); | |
} | |
} | |
function fnEnd( bSuccess ) | |
{ | |
var iEndTime = new Date().getTime(); | |
var sTime = '<br>This test run took '+parseInt((iEndTime-giStartTime)/1000, 10)+ | |
' second(s) to complete.'; | |
if ( bSuccess ) | |
{ | |
$('#test_running').html( 'Tests complete. '+giTotalTestCount+' tests were run.'+sTime ); | |
} | |
else | |
{ | |
$('#test_running').html( 'Unit tests failed at test '+giTotalTestCount+'.'+sTime ); | |
} | |
} | |
$(document).ready( function () { | |
giStartTime = new Date().getTime(); | |
fnUnitStart( giActiveModule ); | |
} ); |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>DataTables unit test controller</title> | |
<style type="text/css" media="screen"> | |
#controller { | |
font: 12px/1.45em "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; | |
margin: 0; | |
padding: 0 0 0 0.5em; | |
color: #333; | |
background-color: #fff; | |
} | |
#test_info { | |
position: absolute; | |
top: 0; | |
right: 0; | |
width: 50%; | |
height: 100%; | |
font-size: 11px; | |
overflow: auto; | |
} | |
.error { | |
color: red; | |
} | |
#controller h1 { | |
color: #4E6CA3; | |
font-size: 18px; | |
} | |
</style> | |
<script type="text/javascript" language="javascript" src="../js/jquery.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
var gaoTest = [ | |
<?php | |
function fnReadDir( &$aReturn, $path ) | |
{ | |
$rDir = opendir( $path ); | |
while ( ($file = readdir($rDir)) !== false ) | |
{ | |
if ( $file == "." || $file == ".." || $file == ".DS_Store" ) | |
{ | |
continue; | |
} | |
else if ( is_dir( $path.'/'.$file ) ) | |
{ | |
fnReadDir( $aReturn, $path.'/'.$file ); | |
} | |
else | |
{ | |
array_push( $aReturn, $path.'/'.$file ); | |
} | |
} | |
closedir($rDir); | |
} | |
/* Get the tests dynamically from the 'tests' directory, and their templates */ | |
$aFiles = array(); | |
fnReadDir( &$aFiles, "tests" ); | |
for ( $i=0 ; $i<count($aFiles) ; $i++ ) | |
{ | |
$sTemplate; | |
$fp = fopen( $aFiles[$i], "r" ); | |
fscanf( $fp, "// DATA_TEMPLATE: %s", &$sTemplate ); | |
fclose( $fp ); | |
$aPath = split('/', $aFiles[$i]); | |
echo '{ '. | |
'"sTemplate": "'.$sTemplate.'", '. | |
'"sTest": "'.$aFiles[$i].'", '. | |
'"sGroup": "'.$aPath[1].'"},'."\n"; | |
} | |
?> | |
null ]; | |
gaoTest.pop(); /* No interest in the null */ | |
</script> | |
<script type="text/javascript" language="javascript" src="controller.js"></script> | |
</head> | |
<body id="controller"> | |
<h1>DataTables unit testing</h1> | |
<div id="test_running">Running test: <span id="test_number"></span></div> | |
<div id="test_info"> | |
<b>Test information:</b><br> | |
</div> | |
</body> | |
</html> |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> | |
<html> | |
<frameset rows="20%,80%"> | |
<frame name="controller" id="controller" src="controller.php"> | |
<frame name="test_arena" id="test_arena"> | |
</frameset> | |
</html> |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico" /> | |
<title>DataTables example</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(document).ready(function() { | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var iStart = new Date().getTime(); | |
//console.profile(); | |
//for ( var i=0, iLen=1000 ; i<iLen ; i++ ) | |
//{ | |
// oSettings._iDisplayLength = 100; | |
// oTable.oApi._fnCalculateEnd( oSettings ); | |
// oTable.oApi._fnDraw( oSettings ); | |
// | |
// oSettings._iDisplayLength = 10; | |
// oTable.oApi._fnCalculateEnd( oSettings ); | |
// oTable.oApi._fnDraw( oSettings ); | |
//} | |
//console.profileEnd(); | |
var iEnd = new Date().getTime(); | |
document.getElementById('output').innerHTML = "Test took "+(iEnd-iStart)+"mS"; | |
} ); | |
</script> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> performance test - draw | |
</div> | |
<div id="output"></div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeX"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 4.0</td> | |
<td>Win 95+</td> | |
<td class="center">4</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.0</td> | |
<td>Win 95+</td> | |
<td class="center">5</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.5</td> | |
<td>Win 95+</td> | |
<td class="center">5.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 6</td> | |
<td>Win 98+</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet Explorer 7</td> | |
<td>Win XP SP2+</td> | |
<td class="center">7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>AOL browser (AOL desktop)</td> | |
<td>Win XP</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.5</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 2.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 3.0</td> | |
<td>Win 2k+ / OSX.3+</td> | |
<td class="center">1.9</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.0</td> | |
<td>OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.5</td> | |
<td>OSX.3+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape 7.2</td> | |
<td>Win 95+ / Mac OS 8.6-9.2</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Browser 8</td> | |
<td>Win 98SE+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Navigator 9</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.1</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.2</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.2</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.3</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.4</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.4</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.5</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.6</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.7</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.8</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Seamonkey 1.1</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Epiphany 2.20</td> | |
<td>Gnome</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.2</td> | |
<td>OSX.3</td> | |
<td class="center">125.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.3</td> | |
<td>OSX.3</td> | |
<td class="center">312.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 2.0</td> | |
<td>OSX.4+</td> | |
<td class="center">419.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 3.0</td> | |
<td>OSX.4+</td> | |
<td class="center">522.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>OmniWeb 5.5</td> | |
<td>OSX.4+</td> | |
<td class="center">420</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>iPod Touch / iPhone</td> | |
<td>iPod</td> | |
<td class="center">420.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>S60</td> | |
<td>S60</td> | |
<td class="center">413</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.0</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.0</td> | |
<td>Win 95+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.2</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.5</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera for Wii</td> | |
<td>Wii</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nokia N800</td> | |
<td>N800</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nintendo DS browser</td> | |
<td>Nintendo DS</td> | |
<td class="center">8.5</td> | |
<td class="center">C/A<sup>1</sup></td> | |
</tr> | |
<tr class="gradeC"> | |
<td>KHTML</td> | |
<td>Konqureror 3.1</td> | |
<td>KDE 3.1</td> | |
<td class="center">3.1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.3</td> | |
<td>KDE 3.3</td> | |
<td class="center">3.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.5</td> | |
<td>KDE 3.5</td> | |
<td class="center">3.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Tasman</td> | |
<td>Internet Explorer 4.5</td> | |
<td>Mac OS 8-9</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.1</td> | |
<td>Mac OS 7.6-9</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.2</td> | |
<td>Mac OS 8-X</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.1</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.4</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Dillo 0.8</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Links</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Lynx</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>IE Mobile</td> | |
<td>Windows Mobile 6</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>PSP browser</td> | |
<td>PSP</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeU"> | |
<td>Other browsers</td> | |
<td>All others</td> | |
<td>-</td> | |
<td class="center">-</td> | |
<td class="center">U</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
<div id="footer" style="text-align:center;"> | |
<span style="font-size:10px;"> | |
DataTables © Allan Jardine 2008-2009. | |
</span> | |
</div> | |
</div> | |
</body> | |
</html> |
<?php | |
/* MySQL connection */ | |
include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" ); /* ;-) */ | |
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or | |
die( 'Could not open connection to server' ); | |
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or | |
die( 'Could not select database '. $gaSql['db'] ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico" /> | |
<title>DataTables example</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(document).ready(function() { | |
var iStart = new Date().getTime(); | |
if ( typeof console != 'undefined' ) { | |
console.profile(); | |
} | |
for ( var i=0 ; i<1 ; i++ ) | |
{ | |
var oTable = $('#example').dataTable({"bDestroy": true}); | |
} | |
if ( typeof console != 'undefined' ) { | |
console.profileEnd(); | |
} | |
var iEnd = new Date().getTime(); | |
document.getElementById('output').innerHTML = "Test took "+(iEnd-iStart)+"mS"; | |
} ); | |
</script> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> performance test - draw | |
</div> | |
<div id="output"></div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>id</th> | |
<th>name</th> | |
<th>phone</th> | |
<th>email</th> | |
<th>city</th> | |
<th>zip</th> | |
<th>state</th> | |
<th>country</th> | |
<th>zip2</th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php | |
$sQuery = " | |
SELECT * | |
FROM testData | |
LIMIT 2000 | |
"; | |
$rResult = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error()); | |
while ( $aRow = mysql_fetch_array( $rResult ) ) | |
{ | |
echo '<tr>'; | |
echo '<td><a href="1">'.$aRow['id'].'</a></td>'; | |
echo '<td>'.$aRow['name'].'</td>'; | |
echo '<td>'.$aRow['phone'].'</td>'; | |
echo '<td>'.$aRow['email'].'</td>'; | |
echo '<td>'.$aRow['city'].'</td>'; | |
echo '<td>'.$aRow['zip'].'</td>'; | |
echo '<td>'.$aRow['state'].'</td>'; | |
echo '<td>'.$aRow['country'].'</td>'; | |
echo '<td>'.$aRow['zip2'].'</td>'; | |
echo '</tr>'; | |
} | |
?> | |
</tbody> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
<div id="footer" style="text-align:center;"> | |
<span style="font-size:10px;"> | |
DataTables © Allan Jardine 2008-2009. | |
</span> | |
</div> | |
</div> | |
</body> | |
</html> |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico" /> | |
<title>DataTables example</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(document).ready(function() { | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var iStart = new Date().getTime(); | |
//for ( var i=0, iLen=100 ; i<iLen ; i++ ) | |
//{ | |
console.profile( ); | |
oTable.fnPageChange( "next" ); | |
oTable.fnPageChange( "previous" ); | |
console.profileEnd( ); | |
//} | |
var iEnd = new Date().getTime(); | |
document.getElementById('output').innerHTML = "Test took "+(iEnd-iStart)+"mS"; | |
} ); | |
</script> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> performance test - draw | |
</div> | |
<div id="output"></div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeX"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 4.0</td> | |
<td>Win 95+</td> | |
<td class="center">4</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.0</td> | |
<td>Win 95+</td> | |
<td class="center">5</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.5</td> | |
<td>Win 95+</td> | |
<td class="center">5.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 6</td> | |
<td>Win 98+</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet Explorer 7</td> | |
<td>Win XP SP2+</td> | |
<td class="center">7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>AOL browser (AOL desktop)</td> | |
<td>Win XP</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.5</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 2.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 3.0</td> | |
<td>Win 2k+ / OSX.3+</td> | |
<td class="center">1.9</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.0</td> | |
<td>OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.5</td> | |
<td>OSX.3+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape 7.2</td> | |
<td>Win 95+ / Mac OS 8.6-9.2</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Browser 8</td> | |
<td>Win 98SE+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Navigator 9</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.1</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.2</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.2</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.3</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.4</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.4</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.5</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.6</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.7</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.8</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Seamonkey 1.1</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Epiphany 2.20</td> | |
<td>Gnome</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.2</td> | |
<td>OSX.3</td> | |
<td class="center">125.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.3</td> | |
<td>OSX.3</td> | |
<td class="center">312.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 2.0</td> | |
<td>OSX.4+</td> | |
<td class="center">419.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 3.0</td> | |
<td>OSX.4+</td> | |
<td class="center">522.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>OmniWeb 5.5</td> | |
<td>OSX.4+</td> | |
<td class="center">420</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>iPod Touch / iPhone</td> | |
<td>iPod</td> | |
<td class="center">420.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>S60</td> | |
<td>S60</td> | |
<td class="center">413</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.0</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.0</td> | |
<td>Win 95+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.2</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.5</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera for Wii</td> | |
<td>Wii</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nokia N800</td> | |
<td>N800</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nintendo DS browser</td> | |
<td>Nintendo DS</td> | |
<td class="center">8.5</td> | |
<td class="center">C/A<sup>1</sup></td> | |
</tr> | |
<tr class="gradeC"> | |
<td>KHTML</td> | |
<td>Konqureror 3.1</td> | |
<td>KDE 3.1</td> | |
<td class="center">3.1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.3</td> | |
<td>KDE 3.3</td> | |
<td class="center">3.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.5</td> | |
<td>KDE 3.5</td> | |
<td class="center">3.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Tasman</td> | |
<td>Internet Explorer 4.5</td> | |
<td>Mac OS 8-9</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.1</td> | |
<td>Mac OS 7.6-9</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.2</td> | |
<td>Mac OS 8-X</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.1</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.4</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Dillo 0.8</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Links</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Lynx</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>IE Mobile</td> | |
<td>Windows Mobile 6</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>PSP browser</td> | |
<td>PSP</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeU"> | |
<td>Other browsers</td> | |
<td>All others</td> | |
<td>-</td> | |
<td class="center">-</td> | |
<td class="center">U</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
<div id="footer" style="text-align:center;"> | |
<span style="font-size:10px;"> | |
DataTables © Allan Jardine 2008-2009. | |
</span> | |
</div> | |
</div> | |
</body> | |
</html> |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico" /> | |
<title>DataTables example</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(document).ready(function() { | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var iStart = new Date().getTime(); | |
for ( var i=0, iLen=100 ; i<iLen ; i++ ) | |
{ | |
console.profile( ); | |
oTable.fnSort( [[1, 'asc']] ); | |
oTable.fnSort( [[0, 'asc']] ); | |
console.profileEnd( ); | |
} | |
var iEnd = new Date().getTime(); | |
document.getElementById('output').innerHTML = "Test took "+(iEnd-iStart)+"mS"; | |
} ); | |
</script> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> performance test - draw | |
</div> | |
<div id="output"></div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeX"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 4.0</td> | |
<td>Win 95+</td> | |
<td class="center">4</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.0</td> | |
<td>Win 95+</td> | |
<td class="center">5</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.5</td> | |
<td>Win 95+</td> | |
<td class="center">5.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 6</td> | |
<td>Win 98+</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet Explorer 7</td> | |
<td>Win XP SP2+</td> | |
<td class="center">7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>AOL browser (AOL desktop)</td> | |
<td>Win XP</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.5</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 2.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 3.0</td> | |
<td>Win 2k+ / OSX.3+</td> | |
<td class="center">1.9</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.0</td> | |
<td>OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.5</td> | |
<td>OSX.3+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape 7.2</td> | |
<td>Win 95+ / Mac OS 8.6-9.2</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Browser 8</td> | |
<td>Win 98SE+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Navigator 9</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.1</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.2</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.2</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.3</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.4</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.4</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.5</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.6</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.7</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.8</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Seamonkey 1.1</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Epiphany 2.20</td> | |
<td>Gnome</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.2</td> | |
<td>OSX.3</td> | |
<td class="center">125.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.3</td> | |
<td>OSX.3</td> | |
<td class="center">312.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 2.0</td> | |
<td>OSX.4+</td> | |
<td class="center">419.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 3.0</td> | |
<td>OSX.4+</td> | |
<td class="center">522.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>OmniWeb 5.5</td> | |
<td>OSX.4+</td> | |
<td class="center">420</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>iPod Touch / iPhone</td> | |
<td>iPod</td> | |
<td class="center">420.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>S60</td> | |
<td>S60</td> | |
<td class="center">413</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.0</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.0</td> | |
<td>Win 95+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.2</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.5</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera for Wii</td> | |
<td>Wii</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nokia N800</td> | |
<td>N800</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nintendo DS browser</td> | |
<td>Nintendo DS</td> | |
<td class="center">8.5</td> | |
<td class="center">C/A<sup>1</sup></td> | |
</tr> | |
<tr class="gradeC"> | |
<td>KHTML</td> | |
<td>Konqureror 3.1</td> | |
<td>KDE 3.1</td> | |
<td class="center">3.1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.3</td> | |
<td>KDE 3.3</td> | |
<td class="center">3.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.5</td> | |
<td>KDE 3.5</td> | |
<td class="center">3.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Tasman</td> | |
<td>Internet Explorer 4.5</td> | |
<td>Mac OS 8-9</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.1</td> | |
<td>Mac OS 7.6-9</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.2</td> | |
<td>Mac OS 8-X</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.1</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.4</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Dillo 0.8</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Links</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Lynx</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>IE Mobile</td> | |
<td>Windows Mobile 6</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>PSP browser</td> | |
<td>PSP</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeU"> | |
<td>Other browsers</td> | |
<td>All others</td> | |
<td>-</td> | |
<td class="center">-</td> | |
<td class="center">U</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
<div id="footer" style="text-align:center;"> | |
<span style="font-size:10px;"> | |
DataTables © Allan Jardine 2008-2009. | |
</span> | |
</div> | |
</div> | |
</body> | |
</html> |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" /> | |
<title>DataTables unit testing</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" language="javascript" src="../unit_test.js"></script> | |
<?php | |
$aScripts = split( ":", $_GET['scripts'] ); | |
for ( $i=0 ; $i<count($aScripts) ; $i++ ) | |
{ | |
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n"; | |
} | |
?> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> unit test template for reading DOM data | |
</div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th rowspan="2" class="bl bt">Rendering engine</th> | |
<th colspan="3" class="bl br bt">Browser details</th> | |
<th class="br bt">CSS grade</th> | |
</tr> | |
<tr> | |
<th class="bl">Browser</th> | |
<th>Platform(s)</th> | |
<th class="br">Engine version</th> | |
<th class="br bt">CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeX"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 4.0</td> | |
<td>Win 95+</td> | |
<td class="center">4</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.0</td> | |
<td>Win 95+</td> | |
<td class="center">5</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.5</td> | |
<td>Win 95+</td> | |
<td class="center">5.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 6</td> | |
<td>Win 98+</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet Explorer 7</td> | |
<td>Win XP SP2+</td> | |
<td class="center">7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>AOL browser (AOL desktop)</td> | |
<td>Win XP</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.5</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 2.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 3.0</td> | |
<td>Win 2k+ / OSX.3+</td> | |
<td class="center">1.9</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.0</td> | |
<td>OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.5</td> | |
<td>OSX.3+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape 7.2</td> | |
<td>Win 95+ / Mac OS 8.6-9.2</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Browser 8</td> | |
<td>Win 98SE+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Navigator 9</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.1</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.2</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.2</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.3</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.4</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.4</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.5</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.6</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.7</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.8</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Seamonkey 1.1</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Epiphany 2.20</td> | |
<td>Gnome</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.2</td> | |
<td>OSX.3</td> | |
<td class="center">125.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.3</td> | |
<td>OSX.3</td> | |
<td class="center">312.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 2.0</td> | |
<td>OSX.4+</td> | |
<td class="center">419.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 3.0</td> | |
<td>OSX.4+</td> | |
<td class="center">522.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>OmniWeb 5.5</td> | |
<td>OSX.4+</td> | |
<td class="center">420</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>iPod Touch / iPhone</td> | |
<td>iPod</td> | |
<td class="center">420.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>S60</td> | |
<td>S60</td> | |
<td class="center">413</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.0</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.0</td> | |
<td>Win 95+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.2</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.5</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera for Wii</td> | |
<td>Wii</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nokia N800</td> | |
<td>N800</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nintendo DS browser</td> | |
<td>Nintendo DS</td> | |
<td class="center">8.5</td> | |
<td class="center">C/A<sup>1</sup></td> | |
</tr> | |
<tr class="gradeC"> | |
<td>KHTML</td> | |
<td>Konqureror 3.1</td> | |
<td>KDE 3.1</td> | |
<td class="center">3.1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.3</td> | |
<td>KDE 3.3</td> | |
<td class="center">3.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.5</td> | |
<td>KDE 3.5</td> | |
<td class="center">3.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Tasman</td> | |
<td>Internet Explorer 4.5</td> | |
<td>Mac OS 8-9</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.1</td> | |
<td>Mac OS 7.6-9</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.2</td> | |
<td>Mac OS 8-X</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.1</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.4</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Dillo 0.8</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Links</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Lynx</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>IE Mobile</td> | |
<td>Windows Mobile 6</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>PSP browser</td> | |
<td>PSP</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeU"> | |
<td>Other browsers</td> | |
<td>All others</td> | |
<td>-</td> | |
<td class="center">-</td> | |
<td class="center">U</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
</div> | |
</body> | |
</html> |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" /> | |
<title>DataTables unit testing</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" language="javascript" src="../unit_test.js"></script> | |
<?php | |
$aScripts = split( ":", $_GET['scripts'] ); | |
for ( $i=0 ; $i<count($aScripts) ; $i++ ) | |
{ | |
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n"; | |
} | |
?> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> unit test template for reading DOM data | |
</div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeX"> | |
<td>Trident</td> | |
<td>testsearchstring <br>html & entity</td> | |
<td>Win 95+</td> | |
<td class="center">4</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.0</td> | |
<td>Win 95+</td> | |
<td class="center">5</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.5</td> | |
<td>Win 95+</td> | |
<td class="center">5.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 6</td> | |
<td>Win 98+</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet Explorer 7</td> | |
<td>Win XP SP2+</td> | |
<td class="center">7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>AOL browser (AOL desktop)</td> | |
<td>Win XP</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.5</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 2.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 3.0</td> | |
<td>Win 2k+ / OSX.3+</td> | |
<td class="center">1.9</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.0</td> | |
<td>OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.5</td> | |
<td>OSX.3+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape 7.2</td> | |
<td>Win 95+ / Mac OS 8.6-9.2</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Browser 8</td> | |
<td>Win 98SE+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Navigator 9</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.1</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.2</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.2</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.3</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.4</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.4</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.5</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.6</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.7</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.8</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Seamonkey 1.1</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Epiphany 2.20</td> | |
<td>Gnome</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.2</td> | |
<td>OSX.3</td> | |
<td class="center">125.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.3</td> | |
<td>OSX.3</td> | |
<td class="center">312.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 2.0</td> | |
<td>OSX.4+</td> | |
<td class="center">419.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 3.0</td> | |
<td>OSX.4+</td> | |
<td class="center">522.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>OmniWeb 5.5</td> | |
<td>OSX.4+</td> | |
<td class="center">420</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>iPod Touch / iPhone</td> | |
<td>iPod</td> | |
<td class="center">420.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>S60</td> | |
<td>S60</td> | |
<td class="center">413</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.0</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.0</td> | |
<td>Win 95+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.2</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.5</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera for Wii</td> | |
<td>Wii</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nokia N800</td> | |
<td>N800</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nintendo DS browser</td> | |
<td>Nintendo DS</td> | |
<td class="center">8.5</td> | |
<td class="center">C/A<sup>1</sup></td> | |
</tr> | |
<tr class="gradeC"> | |
<td>KHTML</td> | |
<td>Konqureror 3.1</td> | |
<td>KDE 3.1</td> | |
<td class="center">3.1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.3</td> | |
<td>KDE 3.3</td> | |
<td class="center">3.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.5</td> | |
<td>KDE 3.5</td> | |
<td class="center">3.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Tasman</td> | |
<td>Internet Explorer 4.5</td> | |
<td>Mac OS 8-9</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.1</td> | |
<td>Mac OS 7.6-9</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.2</td> | |
<td>Mac OS 8-X</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.1</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.4</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Dillo 0.8</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Links</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Lynx</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>IE Mobile</td> | |
<td>Windows Mobile 6</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>PSP browser</td> | |
<td>PSP</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeU"> | |
<td>Other browsers</td> | |
<td>All others</td> | |
<td>-</td> | |
<td class="center">-</td> | |
<td class="center">U</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
</div> | |
</body> | |
</html> |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" /> | |
<title>DataTables unit testing</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" language="javascript" src="../unit_test.js"></script> | |
<?php | |
$aScripts = split( ":", $_GET['scripts'] ); | |
for ( $i=0 ; $i<count($aScripts) ; $i++ ) | |
{ | |
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n"; | |
} | |
?> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> unit test template for reading DOM data | |
</div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeX"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 4.0</td> | |
<td>Win 95+</td> | |
<td class="center">4</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.0</td> | |
<td>Win 95+</td> | |
<td class="center">5</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.5</td> | |
<td>Win 95+</td> | |
<td class="center">5.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 6</td> | |
<td>Win 98+</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet Explorer 7</td> | |
<td>Win XP SP2+</td> | |
<td class="center">7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>AOL browser (AOL desktop)</td> | |
<td>Win XP</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.5</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 2.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 3.0</td> | |
<td>Win 2k+ / OSX.3+</td> | |
<td class="center">1.9</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.0</td> | |
<td>OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.5</td> | |
<td>OSX.3+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape 7.2</td> | |
<td>Win 95+ / Mac OS 8.6-9.2</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Browser 8</td> | |
<td>Win 98SE+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Navigator 9</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.1</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.2</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.2</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.3</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.4</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.4</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.5</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.6</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">1.6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.7</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.8</td> | |
<td>Win 98+ / OSX.1+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Seamonkey 1.1</td> | |
<td>Win 98+ / OSX.2+</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Epiphany 2.20</td> | |
<td>Gnome</td> | |
<td class="center">1.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.2</td> | |
<td>OSX.3</td> | |
<td class="center">125.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 1.3</td> | |
<td>OSX.3</td> | |
<td class="center">312.8</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 2.0</td> | |
<td>OSX.4+</td> | |
<td class="center">419.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>Safari 3.0</td> | |
<td>OSX.4+</td> | |
<td class="center">522.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>OmniWeb 5.5</td> | |
<td>OSX.4+</td> | |
<td class="center">420</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>iPod Touch / iPhone</td> | |
<td>iPod</td> | |
<td class="center">420.1</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Webkit</td> | |
<td>S60</td> | |
<td>S60</td> | |
<td class="center">413</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 7.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.0</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 8.5</td> | |
<td>Win 95+ / OSX.2+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.0</td> | |
<td>Win 95+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.2</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera 9.5</td> | |
<td>Win 88+ / OSX.3+</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Opera for Wii</td> | |
<td>Wii</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nokia N800</td> | |
<td>N800</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Presto</td> | |
<td>Nintendo DS browser</td> | |
<td>Nintendo DS</td> | |
<td class="center">8.5</td> | |
<td class="center">C/A<sup>1</sup></td> | |
</tr> | |
<tr class="gradeC"> | |
<td>KHTML</td> | |
<td>Konqureror 3.1</td> | |
<td>KDE 3.1</td> | |
<td class="center">3.1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.3</td> | |
<td>KDE 3.3</td> | |
<td class="center">3.3</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>KHTML</td> | |
<td>Konqureror 3.5</td> | |
<td>KDE 3.5</td> | |
<td class="center">3.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Tasman</td> | |
<td>Internet Explorer 4.5</td> | |
<td>Mac OS 8-9</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.1</td> | |
<td>Mac OS 7.6-9</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Tasman</td> | |
<td>Internet Explorer 5.2</td> | |
<td>Mac OS 8-X</td> | |
<td class="center">1</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.1</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Misc</td> | |
<td>NetFront 3.4</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Dillo 0.8</td> | |
<td>Embedded devices</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Links</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeX"> | |
<td>Misc</td> | |
<td>Lynx</td> | |
<td>Text only</td> | |
<td class="center">-</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>IE Mobile</td> | |
<td>Windows Mobile 6</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Misc</td> | |
<td>PSP browser</td> | |
<td>PSP</td> | |
<td class="center">-</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeU"> | |
<td>Other browsers</td> | |
<td>All others</td> | |
<td>-</td> | |
<td class="center">-</td> | |
<td class="center">U</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
</div> | |
</body> | |
</html> |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" /> | |
<title>DataTables unit testing</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" language="javascript" src="../unit_test.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(document).ready( function () { | |
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' ); | |
} ); | |
</script> | |
<?php | |
$aScripts = split( ":", $_GET['scripts'] ); | |
for ( $i=0 ; $i<count($aScripts) ; $i++ ) | |
{ | |
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n"; | |
} | |
?> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> dynamic table template | |
</div> | |
<h1>Live example</h1> | |
<div id="demo"></div> | |
<div class="spacer"></div> | |
</div> | |
</body> | |
</html> |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" /> | |
<title>DataTables unit testing</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" language="javascript" src="../unit_test.js"></script> | |
<?php | |
$aScripts = split( ":", $_GET['scripts'] ); | |
for ( $i=0 ; $i<count($aScripts) ; $i++ ) | |
{ | |
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n"; | |
} | |
?> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> empty table template | |
</div> | |
<h1>Live example</h1> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
</tbody> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
</div> | |
</body> | |
</html> |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" /> | |
<title>DataTables unit testing</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" language="javascript" src="../unit_test.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
/* Make the data source available for testing */ | |
var gaaData = [ | |
['Trident','Internet Explorer 4.0','Win 95+','4','X'], | |
['Trident','Internet Explorer 5.0','Win 95+','5','C'], | |
['Trident','Internet Explorer 5.5','Win 95+','5.5','A'], | |
['Trident','Internet Explorer 6','Win 98+','6','A'], | |
['Trident','Internet Explorer 7','Win XP SP2+','7','A'], | |
['Trident','AOL browser (AOL desktop)','Win XP','6','A'], | |
['Gecko','Firefox 1.0','Win 98+ / OSX.2+','1.7','A'], | |
['Gecko','Firefox 1.5','Win 98+ / OSX.2+','1.8','A'], | |
['Gecko','Firefox 2.0','Win 98+ / OSX.2+','1.8','A'], | |
['Gecko','Firefox 3.0','Win 2k+ / OSX.3+','1.9','A'], | |
['Gecko','Camino 1.0','OSX.2+','1.8','A'], | |
['Gecko','Camino 1.5','OSX.3+','1.8','A'], | |
['Gecko','Netscape 7.2','Win 95+ / Mac OS 8.6-9.2','1.7','A'], | |
['Gecko','Netscape Browser 8','Win 98SE+','1.7','A'], | |
['Gecko','Netscape Navigator 9','Win 98+ / OSX.2+','1.8','A'], | |
['Gecko','Mozilla 1.0','Win 95+ / OSX.1+',1,'A'], | |
['Gecko','Mozilla 1.1','Win 95+ / OSX.1+',1.1,'A'], | |
['Gecko','Mozilla 1.2','Win 95+ / OSX.1+',1.2,'A'], | |
['Gecko','Mozilla 1.3','Win 95+ / OSX.1+',1.3,'A'], | |
['Gecko','Mozilla 1.4','Win 95+ / OSX.1+',1.4,'A'], | |
['Gecko','Mozilla 1.5','Win 95+ / OSX.1+',1.5,'A'], | |
['Gecko','Mozilla 1.6','Win 95+ / OSX.1+',1.6,'A'], | |
['Gecko','Mozilla 1.7','Win 98+ / OSX.1+',1.7,'A'], | |
['Gecko','Mozilla 1.8','Win 98+ / OSX.1+',1.8,'A'], | |
['Gecko','Seamonkey 1.1','Win 98+ / OSX.2+','1.8','A'], | |
['Gecko','Epiphany 2.20','Gnome','1.8','A'], | |
['Webkit','Safari 1.2','OSX.3','125.5','A'], | |
['Webkit','Safari 1.3','OSX.3','312.8','A'], | |
['Webkit','Safari 2.0','OSX.4+','419.3','A'], | |
['Webkit','Safari 3.0','OSX.4+','522.1','A'], | |
['Webkit','OmniWeb 5.5','OSX.4+','420','A'], | |
['Webkit','iPod Touch / iPhone','iPod','420.1','A'], | |
['Webkit','S60','S60','413','A'], | |
['Presto','Opera 7.0','Win 95+ / OSX.1+','-','A'], | |
['Presto','Opera 7.5','Win 95+ / OSX.2+','-','A'], | |
['Presto','Opera 8.0','Win 95+ / OSX.2+','-','A'], | |
['Presto','Opera 8.5','Win 95+ / OSX.2+','-','A'], | |
['Presto','Opera 9.0','Win 95+ / OSX.3+','-','A'], | |
['Presto','Opera 9.2','Win 88+ / OSX.3+','-','A'], | |
['Presto','Opera 9.5','Win 88+ / OSX.3+','-','A'], | |
['Presto','Opera for Wii','Wii','-','A'], | |
['Presto','Nokia N800','N800','-','A'], | |
['Presto','Nintendo DS browser','Nintendo DS','8.5','C/A<sup>1</sup>'], | |
['KHTML','Konqureror 3.1','KDE 3.1','3.1','C'], | |
['KHTML','Konqureror 3.3','KDE 3.3','3.3','A'], | |
['KHTML','Konqureror 3.5','KDE 3.5','3.5','A'], | |
['Tasman','Internet Explorer 4.5','Mac OS 8-9','-','X'], | |
['Tasman','Internet Explorer 5.1','Mac OS 7.6-9','1','C'], | |
['Tasman','Internet Explorer 5.2','Mac OS 8-X','1','C'], | |
['Misc','NetFront 3.1','Embedded devices','-','C'], | |
['Misc','NetFront 3.4','Embedded devices','-','A'], | |
['Misc','Dillo 0.8','Embedded devices','-','X'], | |
['Misc','Links','Text only','-','X'], | |
['Misc','Lynx','Text only','-','X'], | |
['Misc','IE Mobile','Windows Mobile 6','-','C'], | |
['Misc','PSP browser','PSP','-','C'], | |
['Other browsers','All others','-','-','U'] | |
]; | |
</script> | |
<?php | |
$aScripts = split( ":", $_GET['scripts'] ); | |
for ( $i=0 ; $i<count($aScripts) ; $i++ ) | |
{ | |
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n"; | |
} | |
?> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> unit test template for reading DOM data | |
</div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
</div> | |
</body> | |
</html> |
<?php | |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); | |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); | |
header( 'Cache-Control: post-check=0, pre-check=0', false ); | |
header( 'Pragma: no-cache' ); | |
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico" /> | |
<title>DataTables unit testing</title> | |
<style type="text/css" title="currentStyle"> | |
@import "../../css/demo_page.css"; | |
@import "../../css/demo_table.css"; | |
</style> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.js"></script> | |
<script type="text/javascript" language="javascript" src="../../js/jquery.dataTables.js"></script> | |
<script type="text/javascript" language="javascript" src="../unit_test.js"></script> | |
<?php | |
$aScripts = split( ":", $_GET['scripts'] ); | |
for ( $i=0 ; $i<count($aScripts) ; $i++ ) | |
{ | |
echo '<script type="text/javascript" language="javascript" src="../'.$aScripts[$i].'?rand='.rand().'"></script>'."\n"; | |
} | |
?> | |
</head> | |
<body id="dt_example"> | |
<div id="container"> | |
<div class="full_width big"> | |
<i>DataTables</i> unit test template for two tables | |
</div> | |
<div id="demo"> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example1"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeX"> | |
<td>Trident</td> | |
<td>testsearchstring <br>html & entity</td> | |
<td>Win 95+</td> | |
<td class="center">4</td> | |
<td class="center">X</td> | |
</tr> | |
<tr class="gradeC"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.0</td> | |
<td>Win 95+</td> | |
<td class="center">5</td> | |
<td class="center">C</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 5.5</td> | |
<td>Win 95+</td> | |
<td class="center">5.5</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet | |
Explorer 6</td> | |
<td>Win 98+</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>Internet Explorer 7</td> | |
<td>Win XP SP2+</td> | |
<td class="center">7</td> | |
<td class="center">A</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Trident</td> | |
<td>AOL browser (AOL desktop)</td> | |
<td>Win XP</td> | |
<td class="center">6</td> | |
<td class="center">A</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
<th>Engine version</th> | |
<th>CSS grade</th> | |
</tr> | |
</tfoot> | |
</table> | |
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example2"> | |
<thead> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 1.5</td> | |
<td>Win 98+ / OSX.2+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 2.0</td> | |
<td>Win 98+ / OSX.2+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Firefox 3.0</td> | |
<td>Win 2k+ / OSX.3+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.0</td> | |
<td>OSX.2+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Camino 1.5</td> | |
<td>OSX.3+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape 7.2</td> | |
<td>Win 95+ / Mac OS 8.6-9.2</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Browser 8</td> | |
<td>Win 98SE+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Netscape Navigator 9</td> | |
<td>Win 98+ / OSX.2+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.0</td> | |
<td>Win 95+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.1</td> | |
<td>Win 95+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.2</td> | |
<td>Win 95+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.3</td> | |
<td>Win 95+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.4</td> | |
<td>Win 95+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.5</td> | |
<td>Win 95+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.6</td> | |
<td>Win 95+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.7</td> | |
<td>Win 98+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Mozilla 1.8</td> | |
<td>Win 98+ / OSX.1+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Seamonkey 1.1</td> | |
<td>Win 98+ / OSX.2+</td> | |
</tr> | |
<tr class="gradeA"> | |
<td>Gecko</td> | |
<td>Epiphany 2.20</td> | |
<td>Gnome</td> | |
</tr> | |
</tbody> | |
<tfoot> | |
<tr> | |
<th>Rendering engine</th> | |
<th>Browser</th> | |
<th>Platform(s)</th> | |
</tr> | |
</tfoot> | |
</table> | |
</div> | |
<div class="spacer"></div> | |
</div> | |
</body> | |
</html> |
// DATA_TEMPLATE: -complex_header | |
oTest.fnStart( "Complex header" ); | |
$(document).ready( function () { | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Sorting on colspan has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnTest( | |
"Sorting on non-unique TH and first TH has no effect", | |
function () { $('#example thead th:eq(2)').click(); }, | |
function () { return $('#example tbody tr td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnTest( | |
"Sorting on non-unique TH and second TH will sort", | |
function () { $('#example thead th:eq(6)').click(); }, | |
function () { return $('#example tbody tr td:eq(4)').html() == "A"; } | |
); | |
oTest.fnTest( | |
"Sorting on non-unique TH and second TH will sort - reserve", | |
function () { $('#example thead th:eq(6)').click(); }, | |
function () { return $('#example tbody tr td:eq(4)').html() == "X"; } | |
); | |
oTest.fnTest( | |
"Sorting on unique TH will sort", | |
function () { $('#example thead th:eq(5)').click(); }, | |
function () { return $('#example tbody tr td:eq(3)').html() == "-"; } | |
); | |
oTest.fnTest( | |
"Sorting on unique TH will sort - reserve", | |
function () { $('#example thead th:eq(5)').click(); }, | |
function () { return $('#example tbody tr td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnTest( | |
"Sorting on unique rowspan TH will sort", | |
function () { $('#example thead th:eq(0)').click(); }, | |
function () { return $('#example tbody tr td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "iDraw - check that iDraw increments for each draw" ); | |
$(document).ready( function () { | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"After first draw, iDraw is 1", | |
null, | |
function () { return oSettings.iDraw == 1; } | |
); | |
oTest.fnTest( | |
"After second draw, iDraw is 2", | |
function () { oTable.fnDraw() }, | |
function () { return oSettings.iDraw == 2; } | |
); | |
oTest.fnTest( | |
"After sort", | |
function () { oTable.fnSort([[1,'asc']]) }, | |
function () { return oSettings.iDraw == 3; } | |
); | |
oTest.fnTest( | |
"After filter", | |
function () { oTable.fnFilter('gecko') }, | |
function () { return oSettings.iDraw == 4; } | |
); | |
oTest.fnTest( | |
"After another filter", | |
function () { oTable.fnFilter('gec') }, | |
function () { return oSettings.iDraw == 5; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: 2512 | |
oTest.fnStart( "Check filtering with BR and HTML entity" ); | |
$(document).ready( function () { | |
$('#example').dataTable(); | |
/* Basic checks */ | |
oTest.fnTest( | |
"Check filtering", | |
function () { $('#example').dataTable().fnFilter('testsearchstring'); }, | |
function () { return $('#example tbody tr').length == 1; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "User given with is left when no scrolling" ); | |
$(document).ready( function () { | |
$('#example')[0].style.width = "80%"; | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Check user width is left", | |
null, | |
function () { return $('#example').width() == 640; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dymanic_table | |
oTest.fnStart( "2530 - Check width's when dealing with empty strings" ); | |
$(document).ready( function () { | |
$('#example').dataTable( { | |
"aaData": [ | |
['','Internet Explorer 4.0','Win 95+','4','X'], | |
['','Internet Explorer 5.0','Win 95+','5','C'] | |
], | |
"aoColumns": [ | |
{ "sTitle": "", "sWidth": "40px" }, | |
{ "sTitle": "Browser" }, | |
{ "sTitle": "Platform" }, | |
{ "sTitle": "Version", "sClass": "center" }, | |
{ "sTitle": "Grade", "sClass": "center" } | |
] | |
} ); | |
/* Basic checks */ | |
oTest.fnTest( | |
"Check calculated widths", | |
null, | |
function () { return $('#example tbody tr td:eq(0)').width() < 100; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "Destroy with hidden columns" ); | |
$(document).ready( function () { | |
$('#example').dataTable( { | |
"aoColumnDefs": [ | |
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] }, | |
{ "bVisible": false, "aTargets": [ 3 ] } | |
] | |
} ); | |
$('#example').dataTable().fnDestroy(); | |
oTest.fnTest( | |
"Check that the number of columns in table is correct", | |
null, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnTest( | |
"And with scrolling", | |
function () { | |
$('#example').dataTable( { | |
"sScrollY": 200, | |
"aoColumnDefs": [ | |
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] }, | |
{ "bVisible": false, "aTargets": [ 3 ] } | |
] | |
} ); | |
$('#example').dataTable().fnDestroy(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "2600 - Display rewind when changing length" ); | |
$(document).ready( function () { | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Info correct on init", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Page 2", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 11 to 20 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Page 3", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 21 to 30 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Page 4", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 31 to 40 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Page 5", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 41 to 50 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Rewind", | |
function () { $('#example_length select').val('100'); $('#example_length select').change(); }, | |
function () { return $('#example_info').html() == "Showing 1 to 57 of 57 entries"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "2608 - State saving escaping filters" ); | |
$(document).ready( function () { | |
$('#example').dataTable( { | |
"bStateSave": true | |
} ); | |
oTest.fnTest( | |
"Set the filter", | |
function () { | |
$('#example_filter input').val( '\\s*CVM\\s*$' ); | |
$('#example_filter input').keyup(); | |
}, | |
function () { return $('#example_filter input').val() == '\\s*CVM\\s*$'; } | |
); | |
oTest.fnTest( | |
"Destroy the table and remake it - checking the filter was saved", | |
function () { | |
$('#example').dataTable( { | |
"bStateSave": true, | |
"bDestroy": true | |
} ); | |
}, | |
function () { return $('#example_filter input').val() == '\\s*CVM\\s*$'; } | |
); | |
oTest.fnTest( | |
"Do it again without state saving and make sure filter is empty", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true | |
} ); | |
}, | |
function () { return $('#example_filter input').val() == ''; } | |
); | |
oTest.fnTest( | |
"Clean up", | |
function () { | |
$('#example').dataTable( { | |
"bStateSave": true, | |
"bDestroy": true | |
} ); | |
$('#example_filter input').val( '' ); | |
$('#example_filter input').keyup(); | |
}, | |
function () { return $('#example_filter input').val() == ''; } | |
); | |
oTest.fnCookieDestroy( $('#example').dataTable() ); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "2635 - Hiding column and state saving" ); | |
$(document).ready( function () { | |
$('#example').dataTable( { | |
"bStateSave": true | |
} ); | |
oTest.fnTest( | |
"Set the hidden column", | |
function () { | |
$('#example').dataTable().fnSetColumnVis( 2, false ); | |
}, | |
function () { return $('#example thead th').length == 4; } | |
); | |
oTest.fnTest( | |
"Destroy the table and remake it - checking one column was removed", | |
function () { | |
$('#example').dataTable( { | |
"bStateSave": true, | |
"bDestroy": true | |
} ); | |
}, | |
function () { return $('#example thead th').length == 4; } | |
); | |
oTest.fnTest( | |
"Do it again without state saving and make sure we are back to 5 columns", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true | |
} ); | |
}, | |
function () { return $('#example thead th').length == 5; } | |
); | |
oTest.fnCookieDestroy( $('#example').dataTable() ); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "2746 - Stable sorting" ); | |
$(document).ready( function () { | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Initial sort", | |
null, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'Firefox 1.0' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Firefox 1.5' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Firefox 2.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Reserve initial sort", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Webkit' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Webkit' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'Safari 1.2' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Safari 1.3' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Safari 2.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Reserve to go back to initial sort sort", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'Firefox 1.0' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Firefox 1.5' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Firefox 2.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Reserve initial sort again", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Webkit' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Webkit' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'Safari 1.2' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Safari 1.3' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Safari 2.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"And once more back to the initial sort", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'Firefox 1.0' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Firefox 1.5' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Firefox 2.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Sort on second column", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Trident' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'AOL browser (AOL desktop)' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Camino 1.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Reserve sort on second column", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Webkit' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Safari 3.0' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Safari 2.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"And back to asc sorting on second column", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Trident' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'AOL browser (AOL desktop)' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Camino 1.0'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Sort on third column, having now sorted on second", | |
function () { | |
$('#example thead th:eq(2)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Misc' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Dillo 0.8' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'NetFront 3.1'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Reserve sort on third column", | |
function () { | |
$('#example thead th:eq(2)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Misc' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Trident' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'IE Mobile' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Internet Explorer 7' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'AOL browser (AOL desktop)'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Return sorting on third column to asc", | |
function () { | |
$('#example thead th:eq(2)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Other browsers' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Misc' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'All others' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Dillo 0.8' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'NetFront 3.1'; | |
return ret; | |
} | |
); | |
oTest.fnTest( | |
"Sort on first column having sorted on second then third columns", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { | |
var ret = | |
$('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(1) td:eq(0)').html() == 'Gecko' && | |
$('#example tbody tr:eq(0) td:eq(1)').html() == 'Epiphany 2.20' && | |
$('#example tbody tr:eq(1) td:eq(1)').html() == 'Camino 1.0' && | |
$('#example tbody tr:eq(2) td:eq(1)').html() == 'Camino 1.5'; | |
return ret; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: two_tables | |
oTest.fnStart( "Initialise two tables" ); | |
$(document).ready( function () { | |
$('table.display').dataTable(); | |
oTest.fnTest( | |
"Check that initialisation was okay", | |
null, | |
function () { return true; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "2840 - Restore table width on fnDestory" ); | |
$(document).ready( function () { | |
document.cookie = ""; | |
$('#example').dataTable( { | |
"sScrollX": "100%", | |
"sScrollXInner": "110%" | |
} ); | |
$('#example').dataTable().fnDestroy(); | |
oTest.fnTest( | |
"Width after destroy", | |
null, | |
function () { return $('#example').width() == "800"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "2914 - State saving with an empty array" ); | |
$(document).ready( function () { | |
document.cookie = ""; | |
$('#example').dataTable( { | |
"bStateSave": true, | |
"aaSorting": [] | |
} ); | |
oTest.fnTest( | |
"No sort", | |
null, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Next page", | |
function () { | |
$('#example').dataTable().fnPageChange( 'next' ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnTest( | |
"Destroy the table and remake it - checking we are still on the next page", | |
function () { | |
$('#example').dataTable( { | |
"bStateSave": true, | |
"aaSorting": [], | |
"bDestroy": true | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnCookieDestroy( $('#example').dataTable() ); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "Sanity checks for DataTables with DOM data" ); | |
oTest.fnTest( | |
"jQuery.dataTable function", | |
null, | |
function () { return typeof jQuery().dataTable == "function"; } | |
); | |
oTest.fnTest( | |
"jQuery.dataTableSettings storage array", | |
null, | |
function () { return typeof jQuery().dataTableSettings == "object"; } | |
); | |
oTest.fnTest( | |
"jQuery.dataTableExt plugin object", | |
null, | |
function () { return typeof jQuery().dataTableExt == "object"; } | |
); | |
$(document).ready( function () { | |
$('#example').dataTable(); | |
/* Basic checks */ | |
oTest.fnTest( | |
"Length changing div exists", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnTest( | |
"Filtering div exists", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnTest( | |
"Information div exists", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnTest( | |
"Pagination div exists", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnTest( | |
"Processing div is off by default", | |
null, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnTest( | |
"10 rows shown on the first page", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Initial sort occured", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
/* Need to use the WaitTest for sorting due to the setTimeout datatables uses */ | |
oTest.fnTest( | |
"Sorting (first click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting (second click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Sorting (third click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting (first click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnTest( | |
"Sorting (second click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column (first click)", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { var b = | |
$('#example tbody td:eq(0)').html() == "Gecko" && | |
$('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column - sorting second column only", | |
function () { | |
$('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
/* Basic paging */ | |
oTest.fnTest( | |
"Paging to second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; } | |
); | |
oTest.fnTest( | |
"Paging to first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Attempting to page back beyond the first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
/* Changing length */ | |
oTest.fnTest( | |
"Changing table length to 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnTest( | |
"Changing table length to 50 records", | |
function () { $("select[name=example_length]").val('50').change(); }, | |
function () { return $('#example tbody tr').length == 50; } | |
); | |
oTest.fnTest( | |
"Changing table length to 100 records", | |
function () { $("select[name=example_length]").val('100').change(); }, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnTest( | |
"Changing table length to 10 records", | |
function () { $("select[name=example_length]").val('10').change(); }, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
/* | |
* Information element | |
*/ | |
oTest.fnTest( | |
"Information on zero config", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on third page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information back on first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 25 records - second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 100 records - first page", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('100').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information back to 10 records", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('10').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' back to first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page - second time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter increased to 'Win 98'", | |
function () { $('#example_filter input').val("Win 98").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter decreased to 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page - third time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter removed", | |
function () { $('#example_filter input').val("").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* | |
* Filtering | |
*/ | |
oTest.fnTest( | |
"Filter 'W' - rows", | |
function () { | |
/* Reset the table such that the old sorting doesn't mess things up */ | |
oSession.fnRestore(); | |
$('#example').dataTable(); | |
$('#example_filter input').val("W").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"Filter 'W' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Wi'", | |
function () { $('#example_filter input').val("Wi").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1 info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1 reverse", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - maintaing reverse sorting col 1", | |
function () { $('#example_filter input').val("Win XP").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - sorting col 3", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - sorting col 3 - reversed", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting col 3 - reversed info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'nothinghere'", | |
function () { $('#example_filter input').val("nothinghere").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == | |
"No matching records found"; } | |
); | |
oTest.fnTest( | |
"Filter 'nothinghere' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter back to blank and 1st column sorting", | |
function () { | |
$('#example_filter input').val("").keyup(); | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Prefixing a filter entry", | |
function () { | |
$('#example_filter input').val("Win").keyup(); | |
$('#example_filter input').val("GeckoWin").keyup(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Prefixing a filter entry with space", | |
function () { | |
$('#example_filter input').val("Gecko Win").keyup(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aaSorting" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default sorting is single column", | |
null, | |
function () { | |
return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object'; | |
} | |
); | |
oTest.fnTest( | |
"Default sorting is first column asc", | |
null, | |
function () { | |
return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 && | |
oSettings.aaSorting[0][1] == 'asc'; | |
} | |
); | |
oTest.fnTest( | |
"Sorting is applied", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single string column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single string column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single int column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single int column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','asc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','desc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','desc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','asc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','asc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1.9"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','desc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "125.5"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','desc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (3 column) - string asc / int asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSorting": [['0','asc'], ['3','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aaSortingFixed" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"No fixed sorting by default", | |
null, | |
function () { | |
return oSettings.aaSortingFixed == null; | |
} | |
); | |
oTest.fnTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSortingFixed": [['0','asc']] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaSortingFixed": [['3','asc']] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "PSP browser"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.bSeachable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Columns are searchable by default", | |
function () { oTable.fnFilter("Camino"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html().match(/Camino/); } | |
); | |
oTest.fnTest( | |
"Disabling sorting on a column removes it from the global filter", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "bSearchable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("Camino"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Disabled on one column has no effect on other columns", | |
function () { oTable.fnFilter("Webkit"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Webkit"; } | |
); | |
oTest.fnTest( | |
"Disable filtering on multiple columns", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
{ "bSearchable": false }, | |
{ "bSearchable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("Webkit"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Filter on second disabled column", | |
function () { oTable.fnFilter("Camino"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.bSortable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"All columns are sortable by default", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Can disable sorting from one column", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } | |
); | |
oTest.fnTest( | |
"Disabled column has no sorting class", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; } | |
); | |
oTest.fnTest( | |
"Other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } | |
); | |
oTest.fnTest( | |
"Disable sorting on multiple columns - no sorting classes", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
{ "bSortable": false }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(1)').hasClass("sorting") || | |
$('#example thead th:eq(3)').hasClass("sorting") | |
return bReturn == false; | |
} | |
); | |
oTest.fnTest( | |
"Sorting on disabled column 1 has no effect", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } | |
); | |
oTest.fnTest( | |
"Second sort on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } | |
); | |
oTest.fnTest( | |
"Even with multiple disabled sorting columns other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.bUseRendered" ); | |
/* bUseRendered is used to alter sorting data, if false then the original data is used for | |
* sorting rather than the rendered data | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa"; | |
} else | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default for bUseRendered is true - rendered data is used for sorting", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; } | |
); | |
oTest.fnTest( | |
"When bUseRendered is false, original data is used for sorting", | |
function () { | |
mTmp = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ | |
"bUseRendered": false, | |
"fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
null, | |
null, | |
null | |
] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnTest( | |
"bUseRendered set to false on one columns and true (default) on two others", | |
function () { | |
mTmp = 0; | |
var mTmp2 = 0; | |
var mTmp3 = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
{ | |
"fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa1"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
{ | |
"bUseRendered": false, | |
"fnRender": function (a) { | |
if ( mTmp2 == 0 ) { | |
mTmp2++; | |
return "aaa2"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
{ | |
"fnRender": function (a) { | |
if ( mTmp3 == 0 ) { | |
mTmp3++; | |
return "zzz3"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 2nd column sorting", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 3rd column sorting", | |
function () { | |
$('#example thead th:eq(2)').click(); | |
$('#example thead th:eq(2)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 4th column sorting", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 5th column sorting", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.bVisible" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"All columns are visible by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnTest( | |
"Can hide one column and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 4; } | |
); | |
oTest.fnTest( | |
"Can hide one column and it removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 4; } | |
); | |
oTest.fnTest( | |
"Can hide one column and it removes tfoot th column from DOM", | |
null, | |
function () { return $('#example tfoot tr:eq(0) th').length == 4; } | |
); | |
oTest.fnTest( | |
"The correct thead column has been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Platform(s)" && | |
jqNodes[2].innerHTML == "Engine version" && | |
jqNodes[3].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"The correct tbody column has been hidden", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); | |
}, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "Gnome" && | |
jqNodes[2].innerHTML == "1.8" && | |
jqNodes[3].innerHTML == "A"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Can hide multiple columns and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
{ "bVisible": false }, | |
null, | |
{ "bVisible": false } | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 2; } | |
); | |
oTest.fnTest( | |
"Multiple hide - removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 2; } | |
); | |
oTest.fnTest( | |
"Multiple hide - removes tfoot th column from DOM", | |
null, | |
function () { return $('#example tfoot tr:eq(0) th').length == 2; } | |
); | |
oTest.fnTest( | |
"Multiple hide - the correct thead columns have been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Engine version" | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Multiple hide - the correct tbody columns have been hidden", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); | |
}, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "1" | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.fnRender" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
mTmp++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Single column - fnRender is called once for each row", | |
null, | |
function () { return mTmp == 57; } | |
); | |
oTest.fnTest( | |
"Confirm that fnRender passes one argument (an object) with three parameters", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( arguments.length != 1 || typeof a.iDataRow=='undefined' || | |
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"fnRender iDataColumn is row number", | |
function () { | |
var iCount = 0; | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( iCount != a.iDataRow ) | |
{ | |
mTmp = false; | |
} | |
iCount++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"fnRender iDataColumn is the column", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.iDataColumn != 1 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"fnRender aData is data array of correct size", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.aData.length != 5 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest'; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; } | |
); | |
oTest.fnTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest1'; | |
} }, | |
{ "fnRender": function (a) { | |
return 'unittest2'; | |
} }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' && | |
$('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2'; | |
return bReturn; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.iDataSort" ); | |
$(document).ready( function () { | |
/* Should know that sorting already works by default from other tests, so we can jump | |
* right in here | |
*/ | |
var oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "iDataSort": 4 }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Sorting on first column is uneffected", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } | |
); | |
oTest.fnTest( | |
"Sorting on second column is the order of the fifth", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnTest( | |
"Reserve sorting on second column uses fifth column as well", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } | |
); | |
oTest.fnTest( | |
"Sorting on 5th column retains it's own sorting", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnTest( | |
"Use 2nd col for sorting 5th col and via-versa - no effect on first col sorting", | |
function () { | |
mTmp = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "iDataSort": 4 }, | |
null, | |
null, | |
{ "iDataSort": 1 } | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } | |
); | |
oTest.fnTest( | |
"2nd col sorting uses fifth col", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnTest( | |
"2nd col sorting uses fifth col - reversed", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } | |
); | |
oTest.fnTest( | |
"5th col sorting uses 2nd col", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnTest( | |
"5th col sorting uses 2nd col - reversed", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1'; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.sClass" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"By default the test class hasn't been applied to the column (sanity!)", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
null, | |
{ "sClass": 'unittest' }, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - third row", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - last row", | |
null, | |
function () { return $('#example tbody tr:eq(9) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to other columns - 1st", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to other columns - 5th", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - seventh row - second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody tr:eq(6) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to header", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to footer", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Class defined for multiple columns - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
{ "sClass": 'unittest2' }, | |
null, | |
null, | |
{ "sClass": 'unittest1' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest2') && | |
$('#example tbody tr:eq(8) td:eq(3)').hasClass('unittest1'); | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 1", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').hasClass('unittest1') == false; } | |
); | |
oTest.fnTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 2", | |
null, | |
function () { return $('#example tbody tr:eq(6) td:eq(4)').hasClass('unittest2') == false; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.sName" ); | |
/* This has no effect at all in DOM methods - so we just check that it has applied the name */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sName": 'unit test' }, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Names are stored in the columns object", | |
null, | |
function () { return oSettings.aoColumns[3].sName =="unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.sTitle" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Column names are read from the DOM by default", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Browser" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Can set a single column title - and others are read from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Can set multiple column titles", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test 1' }, | |
null, | |
null, | |
{ "sTitle": 'unit test 2' } | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test 1" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "unit test 2"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoColumns.sWidth" ); | |
/* NOTE - we need to disable the auto width for the majority of these test in order to preform | |
* these tests as the auto width will convert the width to a px value. We can do 'non-exact' tests | |
* with auto width enabled however to ensure it scales columns as required | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
{ "sWidth": '40%' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"With auto width disabled the width for one column is appled", | |
null, | |
function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; } | |
); | |
oTest.fnTest( | |
"With auto width disabled the width for one column is appled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
null, | |
{ "sWidth": '20%' }, | |
{ "sWidth": '30%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(2)')[0].style.width == "20%" && | |
$('#example thead th:eq(3)')[0].style.width == "30%"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"With auto width, it will make the smallest column the largest with percentage width given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sWidth": '40%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "aoSearchCols" ); | |
/* We could be here forever testing this one, so we test a limited subset on a couple of colums */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default should be to have a empty colums array", | |
null, | |
function () { | |
var bReturn = | |
oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex && | |
oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex && | |
oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex && | |
oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex && | |
oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Search on a single column - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Search on two columns - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1.5" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; } | |
); | |
oTest.fnTest( | |
"Search on single column - escape regex false", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
null, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Search on two columns - escape regex false on first, true on second", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
{ "sSearch": "3.3", "bEscapeRegex": true }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; } | |
); | |
oTest.fnTest( | |
"Search on two columns (no records) - escape regex false on first, true on second", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
{ "sSearch": "Allan", "bEscapeRegex": true }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "asStripClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Default row striping is applied", | |
null, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
oTest.fnTest( | |
"Row striping does not effect current classes", | |
null, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('gradeA') && | |
$('#example tbody tr:eq(1)').hasClass('gradeA') && | |
$('#example tbody tr:eq(2)').hasClass('gradeA') && | |
$('#example tbody tr:eq(3)').hasClass('gradeA'); | |
} | |
); | |
oTest.fnTest( | |
"Row striping on the second page", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
/* No striping */ | |
oTest.fnTest( | |
"No row striping", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"asStripClasses": [] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)')[0].className == "gradeA" && | |
$('#example tbody tr:eq(1)')[0].className == "gradeA" && | |
$('#example tbody tr:eq(2)')[0].className == "gradeA" && | |
$('#example tbody tr:eq(3)')[0].className == "gradeA"; | |
} | |
); | |
/* Custom striping */ | |
oTest.fnTest( | |
"Custom striping [2]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"asStripClasses": [ 'test1', 'test2' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test1') && | |
$('#example tbody tr:eq(3)').hasClass('test2'); | |
} | |
); | |
/* long array of striping */ | |
oTest.fnTest( | |
"Custom striping [4]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"asStripClasses": [ 'test1', 'test2', 'test3', 'test4' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnTest( | |
"Custom striping is restarted on second page [2]", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bAutoWidth" ); | |
/* It's actually a little tricky to test this. We can't test absolute numbers because | |
* different browsers and different platforms will render the width of the columns slightly | |
* differently. However, we certainly can test the principle of what should happen (column | |
* width doesn't change over pages) | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Auto width is enabled by default", | |
null, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnTest( | |
"First column has a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style').match(/width/i); } | |
); | |
/* | |
This would seem like a better test - but there appear to be difficulties with tables | |
which are bigger (calculated) than there is actually room for. I suspect this is actually | |
a bug in datatables | |
oTest.fnTest( | |
"Check column widths on first page match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
console.log( a0, b0, a1, b1, a2, b2, a3, b3 ); | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnTest( | |
"Check column widths on second page match thid page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
*/ | |
/* Check can disable */ | |
oTest.fnTest( | |
"Auto width can be disabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bAutoWidth": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth == false; } | |
); | |
oTest.fnTest( | |
"First column does not have a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style') == null; } | |
); | |
/* | |
oTest.fnTest( | |
"Check column widths on first page do not match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return false; | |
else | |
return true; | |
} | |
); | |
*/ | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Auto width enabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bAutoWidth": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bFilter" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Filtering div exists by default", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Fltering can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bFilter": false | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Filtering enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bFilter": true | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bInfiniteScroll" ); | |
$(document).ready( function () { | |
var oTable = $('#example').dataTable( { | |
"bScrollInfinite": true, | |
"sScrollY": "200px" | |
} ); | |
oTest.fnTest( | |
"10 rows by default", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Info", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Get nodes", | |
null, | |
function () { return $('#example tbody>tr').length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Scroll on 20px adds 10 rows", | |
function () { $('div.dataTables_scrollBody').scrollTop(20); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Info after 20px scroll", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Get nodes after 20px scroll", | |
null, | |
function () { return $('#example tbody>tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Scroll on 10px more results in the same number of rows", | |
function () { $('div.dataTables_scrollBody').scrollTop(30); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Info after 10 more px scroll", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Scroll to 240px adds another 10 rows", | |
function () { $('div.dataTables_scrollBody').scrollTop(240); }, | |
function () { return $('#example tbody tr').length == 30; } | |
); | |
oTest.fnTest( | |
"Info after 240px scroll", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 30 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Get nodes after 240px scroll", | |
null, | |
function () { return $('#example tbody>tr').length == 30; } | |
); | |
oTest.fnTest( | |
"Filtering will drop back to 10 rows", | |
function () { | |
$('div.dataTables_scrollBody').scrollTop(0); | |
oTable.fnFilter('gec') | |
}, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Info after filtering", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 10 of 20 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Get nodes after filtering", | |
null, | |
function () { return $('#example tbody>tr').length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Scroll after filtering adds 10", | |
function () { $('div.dataTables_scrollBody').scrollTop(20); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Get nodes after filtering", | |
null, | |
function () { return $('#example tbody>tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Sorting will drop back to 10 rows", | |
function () { oTable.fnSort([[1,'asc']]) }, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Scroll after sorting adds 10", | |
function () { $('div.dataTables_scrollBody').scrollTop(20); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Get nodes after scrolling", | |
null, | |
function () { return $('#example tbody>tr').length == 20; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Info div exists by default", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Info can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bInfo": false | |
} ); | |
}, | |
function () { return document.getElementById('example_info') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Info enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bInfo": true | |
} ); | |
}, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bJQueryUI" ); | |
$(document).ready( function () { | |
$('#example').dataTable( { | |
"bJQueryUI": true | |
} ); | |
oTest.fnTest( | |
"Header elements are fully wrapped by DIVs", | |
null, | |
function () { | |
var test = true; | |
$('#example thead th').each( function () { | |
if ( this.childNodes > 1 ) { | |
test = false; | |
} | |
} ); | |
return test; | |
} | |
); | |
oTest.fnTest( | |
"One div for each header element", | |
null, | |
function () { | |
return $('#example thead th div').length == 5; | |
} | |
); | |
oTest.fnTest( | |
"One span for each header element, nested as child of div", | |
null, | |
function () { | |
return $('#example thead th div>span').length == 5; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bLengthChange" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Length div exists by default", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnTest( | |
"Four default options", | |
null, | |
function () { return $("select[name=example_length] option").length == 4; } | |
); | |
oTest.fnTest( | |
"Default options", | |
null, | |
function () { | |
var opts = $("select[name='example_length'] option"); | |
return opts[0].getAttribute('value') == 10 && opts[1].getAttribute('value') == 25 && | |
opts[2].getAttribute('value') == 50 && opts[3].getAttribute('value') == 100; | |
} | |
); | |
oTest.fnTest( | |
"Info takes length into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Change length can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bLengthChange": false | |
} ); | |
}, | |
function () { return document.getElementById('example_length') == null; } | |
); | |
oTest.fnTest( | |
"Information takes length disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Length change enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bLengthChange": true | |
} ); | |
}, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bPaginate" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Pagiantion div exists by default", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnTest( | |
"Information div takes paging into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bPaginate": false | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') == null; } | |
); | |
oTest.fnTest( | |
"Information div takes paging disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 57 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Pagiantion enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bPaginate": true | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bProcessing" ); | |
/* It's actually a bit hard to set this one due to the fact that it will only be shown | |
* when DataTables is doing some kind of processing. The server-side processing is a bit | |
* better to test this than here - so we just the interal functions to enable it and check | |
* that it is available | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Processing is off by default", | |
null, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnTest( | |
"Processing div cannot be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnTest( | |
"Processing div cannot be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Processing can be enabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bProcessing": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == true; } | |
); | |
oTest.fnTest( | |
"Processing div is in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing'); } | |
); | |
oTest.fnTest( | |
"Processing div is hidden by default", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
oTest.fnTest( | |
"Processing div can be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "visible"; } | |
); | |
oTest.fnTest( | |
"Processing div can be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Processing disabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bProcessing": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bServerSide" ); | |
/* Not interested in server-side processing here other than to check that it is off */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Server side is off by default", | |
null, | |
function () { return oSettings.oFeatures.bServerSide == false; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bSort" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Sorting is on by default", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"Sorting Asc by default class applied", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); } | |
); | |
oTest.fnTest( | |
"Click on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting class removed from first column", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnTest( | |
"Sorting asc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); } | |
); | |
oTest.fnTest( | |
"Reverse on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Sorting acs class removed from second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnTest( | |
"Sorting desc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bSort": false | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Disabled classes applied", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass('sorting_disabled'); } | |
); | |
oTest.fnTest( | |
"Click on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Reverse on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Sorting enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bSort": true | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "bSortClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Sorting classes are applied by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnTest( | |
"Sorting classes are applied to all required cells", | |
null, | |
function () { return $('#example tbody tr:eq(7) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnTest( | |
"Sorting classes are not applied to non-sorting columns", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column - add column 1", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2'); | |
} | |
); | |
oTest.fnTest( | |
"Sorting multi-column - add column 2", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnTest( | |
"Sorting multi-column - add column 3", | |
function () { | |
oDispacher.click( $('#example thead th:eq(3)')[0], { 'shift': true } ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnTest( | |
"Remove sorting classes on single column sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3') == false; | |
} | |
); | |
oTest.fnTest( | |
"Sorting class 1 was added", | |
null, | |
function () { return $('#example tbody tr:eq(1) td:eq(4)').hasClass('sorting_1'); } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Sorting classes can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bSortClasses": false | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnTest( | |
"Sorting classes disabled - add column 1 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false; | |
} | |
); | |
oTest.fnTest( | |
"Sorting classes disabled - add column 2 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false; | |
} | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Sorting classes enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bSortClasses": true | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "Cookie callback" ); | |
$(document).ready( function () { | |
var mPass; | |
/* Note that in order to be fully effective here for saving state, there would need to be a | |
* stringify function to serialise the data array | |
*/ | |
oTest.fnTest( | |
"null by default", | |
function () { | |
$('#example').dataTable(); | |
}, | |
function () { return $('#example').dataTable().fnSettings().fnCookieCallback == null; } | |
); | |
oTest.fnTest( | |
"Number of arguments", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"bStateSave": true, | |
"fnCookieCallback": function (sName, oData, sExpires, sPath) { | |
mPass = arguments.length; | |
return sName + "=; expires=" + sExpires +"; path=" + sPath; | |
} | |
} ); | |
}, | |
function () { return mPass == 4; } | |
); | |
oTest.fnTest( | |
"Name", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"bStateSave": true, | |
"fnCookieCallback": function (sName, oData, sExpires, sPath) { | |
mPass = sName=="SpryMedia_DataTables_example_dom_data.php"; | |
return sName + "=; expires=" + sExpires +"; path=" + sPath; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"bStateSave": true, | |
"fnCookieCallback": function (sName, oData, sExpires, sPath) { | |
mPass = typeof oData.iStart != 'undefined'; | |
return sName + "=; expires=" + sExpires +"; path=" + sPath; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Expires", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"bStateSave": true, | |
"fnCookieCallback": function (sName, oData, sExpires, sPath) { | |
mPass = typeof sExpires == 'string'; | |
return sName + "=; expires=" + sExpires +"; path=" + sPath; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Path", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"bStateSave": true, | |
"fnCookieCallback": function (sName, oData, sExpires, sPath) { | |
mPass = sPath.match(/media\/unit_testing\/templates/); | |
return sName + "=; expires=" + sExpires +"; path=" + sPath; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnCookieDestroy( $('#example').dataTable() ); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "fnDeleteRow" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Check that the default data is sane", | |
null, | |
function () { return oSettings.asDataSearch.join(' ').match(/4.0/g).length == 3; } | |
); | |
oTest.fnTest( | |
"Remove the first data row, and check that hte search data has been updated", | |
function () { oTable.fnDeleteRow( 0 ); }, | |
function () { return oSettings.asDataSearch.join(' ').match(/4.0/g).length == 2; } | |
); | |
oTest.fnTest( | |
"Check that the info element has been updated", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 10 of 56 entries"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "fnDrawCallback" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnDrawCallback == null; } | |
); | |
oTest.fnTest( | |
"One argument passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"fnDrawCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"fnDrawCallback": function ( oSettings ) { | |
mPass = oSettings; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"fnDrawCallback": function ( ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once on each draw there after as well", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass == 4; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "fnFooterCallback" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnFooterCallback == null; } | |
); | |
oTest.fnTest( | |
"Five arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 5; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once per draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called on paging (i.e. another draw)", | |
function () { $('#example_next').click(); }, | |
function () { return mPass == 2; } | |
); | |
oTest.fnTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
nFoot.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records"; | |
} | |
} ); | |
}, | |
function () { return $('#example tfoot th:eq(0)').html() == "Displaying 10 records"; } | |
); | |
oTest.fnTest( | |
"Data array has length matching original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aasData.length != 57 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data array's column lengths match original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
for ( var i=0, iLen=aasData.length ; i<iLen ; i++ ) | |
{ | |
if ( aasData[i].length != 5 ) | |
{ | |
mPass = false; | |
} | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart != 0 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart == 10 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd != 10 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd == 20 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is full data when not filtered", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 57 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is 9 when filtering on 'Mozilla'", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
oTable = $('#example').dataTable( { | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 9 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
oTable.fnFilter( "Mozilla" ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "fnHeaderCallback" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnHeaderCallback == null; } | |
); | |
oTest.fnTest( | |
"Five arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 5; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once per draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called on paging (i.e. another draw)", | |
function () { $('#example_next').click(); }, | |
function () { return mPass == 2; } | |
); | |
oTest.fnTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records"; | |
} | |
} ); | |
}, | |
function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; } | |
); | |
oTest.fnTest( | |
"Data array has length matching original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aasData.length != 57 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data array's column lengths match original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
for ( var i=0, iLen=aasData.length ; i<iLen ; i++ ) | |
{ | |
if ( aasData[i].length != 5 ) | |
{ | |
mPass = false; | |
} | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart != 0 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart == 10 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd != 10 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd == 20 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is full data when not filtered", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 57 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is 9 when filtering on 'Mozilla'", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
oTable = $('#example').dataTable( { | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 9 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
oTable.fnFilter( "Mozilla" ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "fnInfoCallback checks" ); | |
$(document).ready( function () { | |
var mPass; | |
$('#example').dataTable(); | |
/* Basic checks */ | |
oTest.fnTest( | |
"null by default", | |
null, | |
function () { return $('#example').dataTable().fnSettings().oLanguage.fnInfoCallback == null; } | |
); | |
oTest.fnTest( | |
"Agrument length", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"fnInfoCallback": function( oS, iStart, iEnd, iMax, iTotal, sPre ) { | |
mPass = arguments.length; | |
return sPre; | |
} | |
} ); | |
}, | |
function () { return mPass == 6; } | |
); | |
oTest.fnTest( | |
"Settings first", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"fnInfoCallback": function( oS, iStart, iEnd, iMax, iTotal, sPre ) { | |
mPass = (oS == $('#example').dataTable().fnSettings()) ? true : false; | |
return sPre; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Start arg", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"fnInfoCallback": function( oS, iStart, iEnd, iMax, iTotal, sPre ) { | |
return iStart; | |
} | |
} ); | |
}, | |
function () { return $('#example_info').html() == "1"; } | |
); | |
oTest.fnTest( | |
"End arg", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"fnInfoCallback": function( oS, iStart, iEnd, iMax, iTotal, sPre ) { | |
return iEnd; | |
} | |
} ); | |
}, | |
function () { return $('#example_info').html() == "10"; } | |
); | |
oTest.fnTest( | |
"Max arg", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"fnInfoCallback": function( oS, iStart, iEnd, iMax, iTotal, sPre ) { | |
return iMax; | |
} | |
} ); | |
}, | |
function () { return $('#example_info').html() == "57"; } | |
); | |
oTest.fnTest( | |
"Max arg - filter", | |
function () { | |
$('#example').dataTable().fnFilter("1.0"); | |
}, | |
function () { return $('#example_info').html() == "57"; } | |
); | |
oTest.fnTest( | |
"Total arg", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"fnInfoCallback": function( oS, iStart, iEnd, iMax, iTotal, sPre ) { | |
return iTotal; | |
} | |
} ); | |
}, | |
function () { return $('#example_info').html() == "57"; } | |
); | |
oTest.fnTest( | |
"Total arg - filter", | |
function () { | |
$('#example').dataTable().fnFilter("1.0"); | |
}, | |
function () { return $('#example_info').html() == "3"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "fnInitComplete" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnInitComplete == null; } | |
); | |
oTest.fnTest( | |
"One argument passed (for DOM!)", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"fnInitComplete": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"fnInitComplete": function ( oSettings ) { | |
mPass = oSettings; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass; } | |
); | |
oTest.fnTest( | |
"fnInitComplete called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"fnInitComplete": function ( ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnInitComplete never called there after", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"10 rows in the table on complete", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"fnInitComplete": function ( ) { | |
mPass = $('#example tbody tr').length; | |
} | |
} ); | |
}, | |
function () { return mPass == 10; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "fnRowCallback" ); | |
/* Note - fnRowCallback MUST return the first arguments (modified or not) */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnRowCallback == null; } | |
); | |
oTest.fnTest( | |
"Four arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"fnRowCallback": function ( nTr ) { | |
mPass = arguments.length; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 4; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once for each drawn row", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
mPass++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 10; } | |
); | |
oTest.fnTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
$(nTr).addClass('unit_test'); | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1)').hasClass('unit_test'); } | |
); | |
oTest.fnTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( asData.length != 5 ) | |
mPass = false; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
var iCount = 0; | |
$('#example').dataTable( { | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( iCount != iDrawIndex ) | |
mPass = false; | |
iCount++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "iDisplayLength" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable(); | |
oTest.fnTest( | |
"Default length is ten", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Select menu shows 10", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnTest( | |
"Set initial length to 25", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"iDisplayLength": 25 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 25; } | |
); | |
oTest.fnTest( | |
"Set initial length to 100", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"iDisplayLength": 100 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 100; } | |
); | |
oTest.fnTest( | |
"Set initial length to 23 (unknown select menu length)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"iDisplayLength": 23 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 23; } | |
); | |
oTest.fnTest( | |
"Select menu shows 10 (since 23 is unknow)", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.oPaginate" ); | |
/* Note that the paging language information only has relevence in full numbers */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { "sPaginationType": "full_numbers" } ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"oLanguage.oPaginate defaults", | |
null, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "First" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Previous" && | |
oSettings.oLanguage.oPaginate.sNext == "Next" && | |
oSettings.oLanguage.oPaginate.sLast == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate defaults are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "First" && | |
$('#example_paginate .previous').html() == "Previous" && | |
$('#example_paginate .next').html() == "Next" && | |
$('#example_paginate .last').html() == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sPaginationType": "full_numbers", | |
"oLanguage": { | |
"oPaginate": { | |
"sFirst": "unit1", | |
"sPrevious": "test2", | |
"sNext": "unit3", | |
"sLast": "test4" | |
} | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "unit1" && | |
oSettings.oLanguage.oPaginate.sPrevious == "test2" && | |
oSettings.oLanguage.oPaginate.sNext == "unit3" && | |
oSettings.oLanguage.oPaginate.sLast == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate definitions are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "unit1" && | |
$('#example_paginate .previous').html() == "test2" && | |
$('#example_paginate .next').html() == "unit3" && | |
$('#example_paginate .last').html() == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Info language is 'Showing _START_ to _END_ of _TOTAL_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sInfo == "Showing _START_ to _END_ of _TOTAL_ entries"; } | |
); | |
oTest.fnTest( | |
"Info language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - without any macros", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sInfo": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfo == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macro _START_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oLanguage": { | |
"sInfo": "unit _START_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macro _END_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 10 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macro _TOTAL_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 57 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macros _START_ and _END_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macros _START_, _END_ and _TOTAL_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 57 test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sInfoEmpty" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Info empty language is 'Showing 0 to 0 of 0 entries' by default", | |
function () { oTable.fnFilter("nothinghere"); }, | |
function () { return oSettings.oLanguage.sInfoEmpty == "Showing 0 to 0 of 0 entries"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"Showing 0 to 0 of 0 entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Info empty language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sInfoEmpty": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return oSettings.oLanguage.sInfoEmpty == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit test"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Macro's not replaced", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sInfoEmpty": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit _START_ _END_ _TOTAL_ test"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sInfoPostFix" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Info post fix language is '' (blank) by default", | |
null, | |
function () { return oSettings.oLanguage.sInfoPostFix == ""; } | |
); | |
oTest.fnTest( | |
"Width no post fix, the basic info shows", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Info post fix language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfoPostFix == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit test"; } | |
); | |
oTest.fnTest( | |
"Macros have no effect in the post fix", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sInfoPostFix": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit _START_ _END_ _TOTAL_ test"; } | |
); | |
oTest.fnTest( | |
"Post fix is applied after fintering info", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 0 to 0 of 0 entries unit (filtered from 57 total entries) test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sLengthMenu" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Menu language is 'Show _MENU_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sLengthMenu == "Show _MENU_ entries"; } | |
); | |
oTest.fnTest( | |
"_MENU_ macro is replaced by select menu in DOM", | |
null, | |
function () { return $('select', oSettings.aanFeatures.l[0]).length == 1 } | |
); | |
oTest.fnTest( | |
"Default is put into DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "Show " && | |
anChildren[2].nodeValue == " entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Menu length language can be defined - no _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sLengthMenu": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sLengthMenu == "unit test"; } | |
); | |
oTest.fnTest( | |
"Menu length language definition is in the DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
return anChildren[0].nodeValue == "unit test"; | |
} | |
); | |
oTest.fnTest( | |
"Menu length language can be defined - with _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sLengthMenu": "unit _MENU_ test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "unit " && | |
anChildren[2].nodeValue == " test"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Only the _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sLengthMenu": "_MENU_" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren.length == 1 && | |
$('select', oSettings.aanFeatures.l[0]).length == 1; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sProcessing" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bProcessing": true | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Processing language is 'Processing...' by default", | |
null, | |
function () { return oSettings.oLanguage.sProcessing == "Processing..."; } | |
); | |
oTest.fnTest( | |
"Processing language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "Processing..."; } | |
); | |
oTest.fnTest( | |
"Processing language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bProcessing": true, | |
"oLanguage": { | |
"sProcessing": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sProcessing == "unit test"; } | |
); | |
oTest.fnTest( | |
"Processing language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sSearch" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Search language is 'Search:' by default", | |
null, | |
function () { return oSettings.oLanguage.sSearch == "Search:"; } | |
); | |
oTest.fnTest( | |
"Search language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "Search: "; } | |
); | |
oTest.fnTest( | |
"Search language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sSearch": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sSearch == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "unit test "; } | |
); | |
oTest.fnTest( | |
"Blank search has a no (separator) inserted", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sSearch": "" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return document.getElementById('example_filter').childNodes.length == 1; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sUrl" ); | |
/* Note that we only test the internal storage of language information pulled form a file here | |
* as the other language tests will check it goes into the DOM correctly | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"sUrl is blank by default", | |
null, | |
function () { return oSettings.oLanguage.sUrl == ""; } | |
); | |
oTest.fnWaitTest( | |
"Loading of German file loads language information", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sUrl": "../../../examples/examples_support/de_DE.txt" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.sProcessing == "Bitte warten..." && | |
oSettings.oLanguage.sLengthMenu == "_MENU_ Einträge anzeigen" && | |
oSettings.oLanguage.sZeroRecords == "Keine Einträge vorhanden." && | |
oSettings.oLanguage.sInfo == "_START_ bis _END_ von _TOTAL_ Einträgen" && | |
oSettings.oLanguage.sInfoEmpty == "0 bis 0 von 0 Einträgen" && | |
oSettings.oLanguage.sInfoFiltered == "(gefiltert von _MAX_ Einträgen)" && | |
oSettings.oLanguage.sInfoPostFix == "" && | |
oSettings.oLanguage.sSearch == "Suchen" && | |
oSettings.oLanguage.oPaginate.sFirst == "Erster" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Zurück" && | |
oSettings.oLanguage.oPaginate.sNext == "Nächster" && | |
oSettings.oLanguage.oPaginate.sLast == "Letzter"; | |
return bReturn; | |
} | |
); | |
/* One DOM check just to ensure that they go into the DOM */ | |
oTest.fnTest( | |
"Loaded language goes into the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "1 bis 10 von 57 Einträgen"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oLanguage.sZeroRecords" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Zero records language is 'No matching records found' by default", | |
null, | |
function () { return oSettings.oLanguage.sZeroRecords == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere'); }, | |
function () { return $('#example tbody tr td')[0].innerHTML == "No matching records found" } | |
); | |
oTest.fnTest( | |
"Zero records language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oLanguage": { | |
"sZeroRecords": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sZeroRecords == "unit test"; } | |
); | |
oTest.fnTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere2'); }, | |
function () { return $('#example tbody tr td')[0].innerHTML == "unit test" } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "oSearch" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default values should be blank", | |
null, | |
function () { | |
var bReturn = oSettings.oPreviousSearch.sSearch == "" && | |
!oSettings.oPreviousSearch.bRegex; | |
return bReturn; | |
} | |
); | |
/* This test might be considered iffy since the full object isn't given, but it's reasonable to | |
* expect DataTables to cope with this. It should just assumine regex false | |
*/ | |
oTest.fnTest( | |
"Search term only in object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"oSearch": { | |
"sSearch": "Mozilla" | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"New search will kill old one", | |
function () { | |
oTable.fnFilter("Opera"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } | |
); | |
oTest.fnTest( | |
"Search plain text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oSearch": { | |
"sSearch": "DS", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; } | |
); | |
oTest.fnTest( | |
"Search plain text term and escape regex false", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oSearch": { | |
"sSearch": "Opera", | |
"bRegex": true | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } | |
); | |
oTest.fnTest( | |
"Search regex text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oSearch": { | |
"sSearch": "1.*", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Search regex text term and escape regex false", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"oSearch": { | |
"sSearch": "1.*", | |
"bRegex": true | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "sAjaxSource" ); | |
/* Not interested in ajax source here other than to check it's default */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Server side is off by default", | |
null, | |
function () { return oSettings.sAjaxSource == null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "sDom" ); | |
/* This is going to be brutal on the browser! There is a lot that can be tested here... */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default DOM varaible", | |
null, | |
function () { return oSettings.sDom == "lfrtip"; } | |
); | |
oTest.fnTest( | |
"Default DOM in document", | |
null, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check example 1 in code propagates", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sDom": '<"wrapper"flipt>' | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.sDom == '<"wrapper"flipt>'; } | |
); | |
oTest.fnTest( | |
"Check example 1 in DOM", | |
null, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var nCustomWrapper = $('div.wrapper')[0]; | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrapper && | |
nNodes[2] == nFilter && | |
nNodes[3] == nLength && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging && | |
nNodes[6] == nTable; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check example 2 in DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sDom": '<lf<t>ip>' | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
var nCustomWrappers = [] | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
/* Only the two custom divs don't have class names */ | |
if ( !jqNodes[i].getAttribute('class') ) | |
{ | |
nCustomWrappers.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrappers[0] && | |
nNodes[2] == nLength && | |
nNodes[3] == nFilter && | |
nNodes[4] == nCustomWrappers[1] && | |
nNodes[5] == nTable && | |
nNodes[6] == nInfo && | |
nNodes[7] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check no length element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sDom": 'frtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
null == nLength && | |
nNodes[1] == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check no filter element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sDom": 'lrtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
null == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
/* Note we don't test for no table as this is not supported (and it would be fairly daft! */ | |
oTest.fnTest( | |
"Check no info element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sDom": 'lfrtp' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
null == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check no paging element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sDom": 'lfrti' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
null == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Element with an id", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sDom": '<"#test"lf>rti' | |
} ); | |
}, | |
function () { | |
return $('#test').length == 1; | |
} | |
); | |
oTest.fnTest( | |
"Element with an id and a class", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sDom": '<"#test.classTest"lf>rti' | |
} ); | |
}, | |
function () { | |
return ($('#test').length == 1 && $('#test')[0].className == "classTest"); | |
} | |
); | |
oTest.fnTest( | |
"Element with just a class", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sDom": '<"classTest"lf>rti' | |
} ); | |
}, | |
function () { | |
return ($('div.classTest').length == 1 ); | |
} | |
); | |
oTest.fnTest( | |
"Two elements with an id", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sDom": '<"#test1"lf>rti<"#test2"lf>' | |
} ); | |
}, | |
function () { | |
return ($('#test1').length == 1 && $('#test2').length == 1); | |
} | |
); | |
oTest.fnTest( | |
"Two elements with an id and one with a class", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sDom": '<"#test1"lf>rti<"#test2.classTest"lf>' | |
} ); | |
}, | |
function () { | |
return ($('#test1').length == 1 && $('#test2').length == 1 && $('div.classTest').length == 1); | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: dom_data | |
oTest.fnStart( "sPaginationType" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable(); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Check two button paging is the default", | |
null, | |
function () { return oSettings.sPaginationType == "two_button"; } | |
); | |
oTest.fnTest( | |
"Check class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_two_button'); } | |
); | |
oTest.fnTest( | |
"Two div elements are in the wrapper", | |
null, | |
function () { return $('#example_paginate div').length == 2; } | |
); | |
oTest.fnTest( | |
"We have the previous button", | |
null, | |
function () { return document.getElementById('example_previous'); } | |
); | |
oTest.fnTest( | |
"We have the next button", | |
null, | |
function () { return document.getElementById('example_next'); } | |
); | |
oTest.fnTest( | |
"Previous button is disabled", | |
null, | |
function () { return $('#example_previous').hasClass('paginate_disabled_previous'); } | |
); | |
oTest.fnTest( | |
"Next button is enabled", | |
null, | |
function () { return $('#example_next').hasClass('paginate_enabled_next'); } | |
); | |
/* Don't test paging - that's done by the zero config test script. */ | |
/* Two buttons paging */ | |
oTest.fnTest( | |
"Can enabled full numbers paging", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sPaginationType": "full_numbers" | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.sPaginationType == "full_numbers"; } | |
); | |
oTest.fnTest( | |
"Check full numbers class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_full_numbers'); } | |
); | |
var nFirst, nPrevious, nNext, nLast; | |
oTest.fnTest( | |
"Jump to last page", | |
function () { | |
nFirst = $('div.dataTables_paginate span.first'); | |
nPrevious = $('div.dataTables_paginate span.previous'); | |
nNext = $('div.dataTables_paginate span.next'); | |
nLast = $('div.dataTables_paginate span.last'); | |
nLast.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; | |
} | |
); | |
oTest.fnTest( | |
"Go to two pages previous", | |
function () { | |
nPrevious.click(); | |
nPrevious.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries"; | |
} | |
); | |
oTest.fnTest( | |
"Next (second last) page", | |
function () { | |
nNext.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries"; | |
} | |
); | |
oTest.fnTest( | |
"Jump to first page", | |
function () { | |
nFirst.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "Sanity checks for DataTables with data from JS" ); | |
oTest.fnTest( | |
"jQuery.dataTable function", | |
null, | |
function () { return typeof jQuery().dataTable == "function"; } | |
); | |
oTest.fnTest( | |
"jQuery.dataTableSettings storage array", | |
null, | |
function () { return typeof jQuery().dataTableSettings == "object"; } | |
); | |
oTest.fnTest( | |
"jQuery.dataTableExt plugin object", | |
null, | |
function () { return typeof jQuery().dataTableExt == "object"; } | |
); | |
$(document).ready( function () { | |
var oInit = { | |
"aaData": gaaData | |
}; | |
$('#example').dataTable( oInit ); | |
/* Basic checks */ | |
oTest.fnTest( | |
"Length changing div exists", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnTest( | |
"Filtering div exists", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnTest( | |
"Information div exists", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnTest( | |
"Pagination div exists", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnTest( | |
"Processing div is off by default", | |
null, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnTest( | |
"10 rows shown on the first page", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Initial sort occured", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
/* Need to use the WaitTest for sorting due to the setTimeout datatables uses */ | |
oTest.fnTest( | |
"Sorting (first click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting (second click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Sorting (third click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting (first click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnTest( | |
"Sorting (second click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column (first click)", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { var b = | |
$('#example tbody td:eq(0)').html() == "Gecko" && | |
$('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column - sorting second column only", | |
function () { | |
$('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
/* Basic paging */ | |
oTest.fnTest( | |
"Paging to second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; } | |
); | |
oTest.fnTest( | |
"Paging to first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Attempting to page back beyond the first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
/* Changing length */ | |
oTest.fnTest( | |
"Changing table length to 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnTest( | |
"Changing table length to 50 records", | |
function () { $("select[name=example_length]").val('50').change(); }, | |
function () { return $('#example tbody tr').length == 50; } | |
); | |
oTest.fnTest( | |
"Changing table length to 100 records", | |
function () { $("select[name=example_length]").val('100').change(); }, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnTest( | |
"Changing table length to 10 records", | |
function () { $("select[name=example_length]").val('10').change(); }, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
/* | |
* Information element | |
*/ | |
oTest.fnTest( | |
"Information on zero config", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on third page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information back on first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 25 records - second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 100 records - first page", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('100').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information back to 10 records", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('10').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' back to first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page - second time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter increased to 'Win 98'", | |
function () { $('#example_filter input').val("Win 98").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter decreased to 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page - third time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter removed", | |
function () { $('#example_filter input').val("").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* | |
* Filtering | |
*/ | |
oTest.fnTest( | |
"Filter 'W' - rows", | |
function () { | |
/* Reset the table such that the old sorting doesn't mess things up */ | |
oSession.fnRestore(); | |
$('#example').dataTable( oInit ); | |
$('#example_filter input').val("W").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"Filter 'W' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Wi'", | |
function () { $('#example_filter input').val("Wi").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1 info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1 reverse", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - maintaing reverse sorting col 1", | |
function () { $('#example_filter input').val("Win XP").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - sorting col 3", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - sorting col 3 - reversed", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting col 3 - reversed info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'nothinghere'", | |
function () { $('#example_filter input').val("nothinghere").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == | |
"No matching records found"; } | |
); | |
oTest.fnTest( | |
"Filter 'nothinghere' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter back to blank and 1st column sorting", | |
function () { | |
$('#example_filter input').val("").keyup(); | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Prefixing a filter entry", | |
function () { | |
$('#example_filter input').val("Win").keyup(); | |
$('#example_filter input').val("GeckoWin").keyup(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Prefixing a filter entry with space", | |
function () { | |
$('#example_filter input').val("Gecko Win").keyup(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aaSorting" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default sorting is single column", | |
null, | |
function () { | |
return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object'; | |
} | |
); | |
oTest.fnTest( | |
"Default sorting is first column asc", | |
null, | |
function () { | |
return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 && | |
oSettings.aaSorting[0][1] == 'asc'; | |
} | |
); | |
oTest.fnTest( | |
"Sorting is applied", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single string column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single string column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single int column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnTest( | |
"Custom sorting on single int column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','asc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','desc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','desc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','asc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string asc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','asc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1.9"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','desc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "125.5"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (2 column) - string desc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','desc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnTest( | |
"Multi-column sorting (3 column) - string asc / int asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSorting": [['0','asc'], ['3','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aaSortingFixed" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"No fixed sorting by default", | |
null, | |
function () { | |
return oSettings.aaSortingFixed == null; | |
} | |
); | |
oTest.fnTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSortingFixed": [['0','asc']] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aaSortingFixed": [['3','asc']] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "PSP browser"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.bSeachable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Columns are searchable by default", | |
function () { oTable.fnFilter("Camino"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html().match(/Camino/); } | |
); | |
oTest.fnTest( | |
"Disabling sorting on a column removes it from the global filter", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "bSearchable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("Camino"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Disabled on one column has no effect on other columns", | |
function () { oTable.fnFilter("Webkit"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Webkit"; } | |
); | |
oTest.fnTest( | |
"Disable filtering on multiple columns", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
{ "bSearchable": false }, | |
{ "bSearchable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("Webkit"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Filter on second disabled column", | |
function () { oTable.fnFilter("Camino"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.bSortable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"All columns are sortable by default", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Can disable sorting from one column", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } | |
); | |
oTest.fnTest( | |
"Disabled column has no sorting class", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; } | |
); | |
oTest.fnTest( | |
"Other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } | |
); | |
oTest.fnTest( | |
"Disable sorting on multiple columns - no sorting classes", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
{ "bSortable": false }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(1)').hasClass("sorting") || | |
$('#example thead th:eq(3)').hasClass("sorting") | |
return bReturn == false; | |
} | |
); | |
oTest.fnTest( | |
"Sorting on disabled column 1 has no effect", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } | |
); | |
oTest.fnTest( | |
"Second sort on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } | |
); | |
oTest.fnTest( | |
"Even with multiple disabled sorting columns other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.bUseRendered" ); | |
/* bUseRendered is used to alter sorting data, if false then the original data is used for | |
* sorting rather than the rendered data | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa"; | |
} else | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default for bUseRendered is true - rendered data is used for sorting", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; } | |
); | |
oTest.fnTest( | |
"When bUseRendered is false, original data is used for sorting", | |
function () { | |
mTmp = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ | |
"bUseRendered": false, | |
"fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
null, | |
null, | |
null | |
] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnTest( | |
"bUseRendered set to false on one columns and true (default) on two others", | |
function () { | |
mTmp = 0; | |
var mTmp2 = 0; | |
var mTmp3 = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
{ | |
"fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa1"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
{ | |
"bUseRendered": false, | |
"fnRender": function (a) { | |
if ( mTmp2 == 0 ) { | |
mTmp2++; | |
return "aaa2"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
{ | |
"fnRender": function (a) { | |
if ( mTmp3 == 0 ) { | |
mTmp3++; | |
return "zzz3"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 2nd column sorting", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 3rd column sorting", | |
function () { | |
$('#example thead th:eq(2)').click(); | |
$('#example thead th:eq(2)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 4th column sorting", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; } | |
); | |
oTest.fnTest( | |
"Multi-column rendering - 5th column sorting", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.bVisible" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"All columns are visible by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnTest( | |
"Can hide one column and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 4; } | |
); | |
oTest.fnTest( | |
"Can hide one column and it removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 4; } | |
); | |
oTest.fnTest( | |
"Can hide one column and it removes tfoot th column from DOM", | |
null, | |
function () { return $('#example tfoot tr:eq(0) th').length == 4; } | |
); | |
oTest.fnTest( | |
"The correct tbody column has been hidden", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); | |
}, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "Gnome" && | |
jqNodes[2].innerHTML == "1.8" && | |
jqNodes[3].innerHTML == "A"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Can hide multiple columns and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
{ "bVisible": false }, | |
null, | |
{ "bVisible": false } | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 2; } | |
); | |
oTest.fnTest( | |
"Multiple hide - removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 2; } | |
); | |
oTest.fnTest( | |
"Multiple hide - removes tfoot th column from DOM", | |
null, | |
function () { return $('#example tfoot tr:eq(0) th').length == 2; } | |
); | |
oTest.fnTest( | |
"Multiple hide - the correct tbody columns have been hidden", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); | |
}, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "1" | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.fnRender" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
mTmp++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Single column - fnRender is called once for each row", | |
null, | |
function () { return mTmp == 57; } | |
); | |
oTest.fnTest( | |
"Confirm that fnRender passes one argument (an object) with three parameters", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( arguments.length != 1 || typeof a.iDataRow=='undefined' || | |
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"fnRender iDataColumn is row number", | |
function () { | |
var iCount = 0; | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( iCount != a.iDataRow ) | |
{ | |
mTmp = false; | |
} | |
iCount++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"fnRender iDataColumn is the column", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.iDataColumn != 1 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"fnRender aData is data array of correct size", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.aData.length != 5 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest'; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; } | |
); | |
oTest.fnTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest1'; | |
} }, | |
{ "fnRender": function (a) { | |
return 'unittest2'; | |
} }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' && | |
$('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2'; | |
return bReturn; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.iDataSort" ); | |
$(document).ready( function () { | |
/* Should know that sorting already works by default from other tests, so we can jump | |
* right in here | |
*/ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "iDataSort": 4 }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Sorting on first column is uneffected", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } | |
); | |
oTest.fnTest( | |
"Sorting on second column is the order of the fifth", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnTest( | |
"Reserve sorting on second column uses fifth column as well", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } | |
); | |
oTest.fnTest( | |
"Sorting on 5th column retains it's own sorting", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnTest( | |
"Use 2nd col for sorting 5th col and via-versa - no effect on first col sorting", | |
function () { | |
mTmp = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "iDataSort": 4 }, | |
null, | |
null, | |
{ "iDataSort": 1 } | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } | |
); | |
oTest.fnTest( | |
"2nd col sorting uses fifth col", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnTest( | |
"2nd col sorting uses fifth col - reversed", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } | |
); | |
oTest.fnTest( | |
"5th col sorting uses 2nd col", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnTest( | |
"5th col sorting uses 2nd col - reversed", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1'; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.sClass" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"By default the test class hasn't been applied to the column (sanity!)", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
null, | |
{ "sClass": 'unittest' }, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - third row", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - last row", | |
null, | |
function () { return $('#example tbody tr:eq(9) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to other columns - 1st", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to other columns - 5th", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - seventh row - second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody tr:eq(6) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to header", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Add a class to a single column - has not applied to footer", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnTest( | |
"Class defined for multiple columns - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
{ "sClass": 'unittest2' }, | |
null, | |
null, | |
{ "sClass": 'unittest1' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest2') && | |
$('#example tbody tr:eq(8) td:eq(3)').hasClass('unittest1'); | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 1", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').hasClass('unittest1') == false; } | |
); | |
oTest.fnTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 2", | |
null, | |
function () { return $('#example tbody tr:eq(6) td:eq(4)').hasClass('unittest2') == false; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.sName" ); | |
/* This has no effect at all in DOM methods - so we just check that it has applied the name */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sName": 'unit test' }, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Names are stored in the columns object", | |
null, | |
function () { return oSettings.aoColumns[3].sName =="unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.sTitle" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"If not given, then the columns titles are empty", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Browser" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Can set a single column title - and others are read from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Can set multiple column titles", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test 1' }, | |
null, | |
null, | |
{ "sTitle": 'unit test 2' } | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test 1" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "unit test 2"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoColumns.sWidth" ); | |
/* NOTE - we need to disable the auto width for the majority of these test in order to preform | |
* these tests as the auto width will convert the width to a px value. We can do 'non-exact' tests | |
* with auto width enabled however to ensure it scales columns as required | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
{ "sWidth": '40%' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"With auto width disabled the width for one column is appled", | |
null, | |
function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; } | |
); | |
oTest.fnTest( | |
"With auto width disabled the width for one column is appled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
null, | |
{ "sWidth": '20%' }, | |
{ "sWidth": '30%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(2)')[0].style.width == "20%" && | |
$('#example thead th:eq(3)')[0].style.width == "30%"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"With auto width, it will make the smallest column the largest with percentage width given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sWidth": '40%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "aoSearchCols" ); | |
/* We could be here forever testing this one, so we test a limited subset on a couple of colums */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default should be to have a empty colums array", | |
null, | |
function () { | |
var bReturn = | |
oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex && | |
oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex && | |
oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex && | |
oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex && | |
oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Search on a single column - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Search on two columns - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1.5" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; } | |
); | |
oTest.fnTest( | |
"Search on single column - escape regex false", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
null, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Search on two columns - escape regex false on first, true on second", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
{ "sSearch": "3.3", "bEscapeRegex": true }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; } | |
); | |
oTest.fnTest( | |
"Search on two columns (no records) - escape regex false on first, true on second", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
{ "sSearch": "Allan", "bEscapeRegex": true }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "asStripClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Default row striping is applied", | |
null, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
oTest.fnTest( | |
"Row striping on the second page", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
/* No striping */ | |
oTest.fnTest( | |
"No row striping", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"asStripClasses": [] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)')[0].className == "" && | |
$('#example tbody tr:eq(1)')[0].className == "" && | |
$('#example tbody tr:eq(2)')[0].className == "" && | |
$('#example tbody tr:eq(3)')[0].className == ""; | |
} | |
); | |
/* Custom striping */ | |
oTest.fnTest( | |
"Custom striping [2]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"asStripClasses": [ 'test1', 'test2' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test1') && | |
$('#example tbody tr:eq(3)').hasClass('test2'); | |
} | |
); | |
/* long array of striping */ | |
oTest.fnTest( | |
"Custom striping [4]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"asStripClasses": [ 'test1', 'test2', 'test3', 'test4' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnTest( | |
"Custom striping is restarted on second page [2]", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bAutoWidth" ); | |
/* It's actually a little tricky to test this. We can't test absolute numbers because | |
* different browsers and different platforms will render the width of the columns slightly | |
* differently. However, we certainly can test the principle of what should happen (column | |
* width doesn't change over pages) | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Auto width is enabled by default", | |
null, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnTest( | |
"First column has a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style').match(/width/i); } | |
); | |
/* | |
This would seem like a better test - but there appear to be difficulties with tables | |
which are bigger (calculated) than there is actually room for. I suspect this is actually | |
a bug in datatables | |
oTest.fnTest( | |
"Check column widths on first page match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
console.log( a0, b0, a1, b1, a2, b2, a3, b3 ); | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnTest( | |
"Check column widths on second page match thid page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
*/ | |
/* Check can disable */ | |
oTest.fnTest( | |
"Auto width can be disabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bAutoWidth": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth == false; } | |
); | |
oTest.fnTest( | |
"First column does not have a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style') == null; } | |
); | |
/* | |
oTest.fnTest( | |
"Check column widths on first page do not match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return false; | |
else | |
return true; | |
} | |
); | |
*/ | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Auto width enabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bAutoWidth": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bFilter" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Filtering div exists by default", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Fltering can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bFilter": false | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Filtering enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bFilter": true | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Info div exists by default", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Info can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bInfo": false | |
} ); | |
}, | |
function () { return document.getElementById('example_info') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Info enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bInfo": true | |
} ); | |
}, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bLengthChange" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Length div exists by default", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnTest( | |
"Four default options", | |
null, | |
function () { return $("select[name=example_length] option").length == 4; } | |
); | |
oTest.fnTest( | |
"Default options", | |
null, | |
function () { | |
var opts = $("select[name='example_length'] option"); | |
return opts[0].getAttribute('value') == 10 && opts[1].getAttribute('value') == 25 && | |
opts[2].getAttribute('value') == 50 && opts[3].getAttribute('value') == 100; | |
} | |
); | |
oTest.fnTest( | |
"Info takes length into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Change length can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bLengthChange": false | |
} ); | |
}, | |
function () { return document.getElementById('example_length') == null; } | |
); | |
oTest.fnTest( | |
"Information takes length disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Length change enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bLengthChange": true | |
} ); | |
}, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bPaginate" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Pagiantion div exists by default", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnTest( | |
"Information div takes paging into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bPaginate": false | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') == null; } | |
); | |
oTest.fnTest( | |
"Information div takes paging disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 57 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Pagiantion enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bPaginate": true | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bProcessing" ); | |
/* It's actually a bit hard to set this one due to the fact that it will only be shown | |
* when DataTables is doing some kind of processing. The server-side processing is a bit | |
* better to test this than here - so we just the interal functions to enable it and check | |
* that it is available | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Processing is off by default", | |
null, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnTest( | |
"Processing div cannot be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnTest( | |
"Processing div cannot be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Processing can be enabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bProcessing": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == true; } | |
); | |
oTest.fnTest( | |
"Processing div is in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing'); } | |
); | |
oTest.fnTest( | |
"Processing div is hidden by default", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
oTest.fnTest( | |
"Processing div can be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "visible"; } | |
); | |
oTest.fnTest( | |
"Processing div can be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Processing disabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bProcessing": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bServerSide" ); | |
/* Not interested in server-side processing here other than to check that it is off */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Server side is off by default", | |
null, | |
function () { return oSettings.oFeatures.bServerSide == false; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bSort" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Sorting is on by default", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"Sorting Asc by default class applied", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); } | |
); | |
oTest.fnTest( | |
"Click on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting class removed from first column", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnTest( | |
"Sorting asc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); } | |
); | |
oTest.fnTest( | |
"Reverse on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Sorting acs class removed from second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnTest( | |
"Sorting desc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bSort": false | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Click on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Reverse on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Sorting enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bSort": true | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "bSortClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Sorting classes are applied by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnTest( | |
"Sorting classes are applied to all required cells", | |
null, | |
function () { return $('#example tbody tr:eq(7) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnTest( | |
"Sorting classes are not applied to non-sorting columns", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column - add column 1", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2'); | |
} | |
); | |
oTest.fnTest( | |
"Sorting multi-column - add column 2", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnTest( | |
"Sorting multi-column - add column 3", | |
function () { | |
oDispacher.click( $('#example thead th:eq(3)')[0], { 'shift': true } ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnTest( | |
"Remove sorting classes on single column sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3') == false; | |
} | |
); | |
oTest.fnTest( | |
"Sorting class 1 was added", | |
null, | |
function () { return $('#example tbody tr:eq(1) td:eq(4)').hasClass('sorting_1'); } | |
); | |
/* Check can disable */ | |
oTest.fnTest( | |
"Sorting classes can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bSortClasses": false | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnTest( | |
"Sorting classes disabled - add column 1 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false; | |
} | |
); | |
oTest.fnTest( | |
"Sorting classes disabled - add column 2 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false; | |
} | |
); | |
/* Enable makes no difference */ | |
oTest.fnTest( | |
"Sorting classes enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"bSortClasses": true | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "fnDrawCallback" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnDrawCallback == null; } | |
); | |
oTest.fnTest( | |
"One argument passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnDrawCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"fnDrawCallback": function ( oSettings ) { | |
mPass = oSettings; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnDrawCallback": function ( ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once on each draw there after as well", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass == 4; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "fnFooterCallback" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnFooterCallback == null; } | |
); | |
oTest.fnTest( | |
"Five arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 5; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once per draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called on paging (i.e. another draw)", | |
function () { $('#example_next').click(); }, | |
function () { return mPass == 2; } | |
); | |
oTest.fnTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
nFoot.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records"; | |
} | |
} ); | |
}, | |
function () { return $('#example tfoot th:eq(0)').html() == "Displaying 10 records"; } | |
); | |
oTest.fnTest( | |
"Data array has length matching original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aasData.length != 57 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data array's column lengths match original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
for ( var i=0, iLen=aasData.length ; i<iLen ; i++ ) | |
{ | |
if ( aasData[i].length != 5 ) | |
{ | |
mPass = false; | |
} | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart != 0 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart == 10 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd != 10 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd == 20 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is full data when not filtered", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 57 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is 9 when filtering on 'Mozilla'", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 9 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
oTable.fnFilter( "Mozilla" ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "fnHeaderCallback" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnHeaderCallback == null; } | |
); | |
oTest.fnTest( | |
"Five arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 5; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once per draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called on paging (i.e. another draw)", | |
function () { $('#example_next').click(); }, | |
function () { return mPass == 2; } | |
); | |
oTest.fnTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records"; | |
} | |
} ); | |
}, | |
function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; } | |
); | |
oTest.fnTest( | |
"Data array has length matching original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aasData.length != 57 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data array's column lengths match original data", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
for ( var i=0, iLen=aasData.length ; i<iLen ; i++ ) | |
{ | |
if ( aasData[i].length != 5 ) | |
{ | |
mPass = false; | |
} | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart != 0 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iStart correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart == 10 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd != 10 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"iEnd correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd == 20 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
$('#example_next').click(); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is full data when not filtered", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 57 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"aiDisplay length is 9 when filtering on 'Mozilla'", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 9 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
oTable.fnFilter( "Mozilla" ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "fnInitComplete" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnInitComplete == null; } | |
); | |
oTest.fnTest( | |
"One argument passed (for DOM!)", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnInitComplete": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"fnInitComplete": function ( oSettings ) { | |
mPass = oSettings; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass; } | |
); | |
oTest.fnTest( | |
"fnInitComplete called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnInitComplete": function ( ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnTest( | |
"fnInitComplete never called there after", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "fnRowCallback" ); | |
/* Note - fnRowCallback MUST return the first arguments (modified or not) */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnRowCallback == null; } | |
); | |
oTest.fnTest( | |
"Four arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnRowCallback": function ( nTr ) { | |
mPass = arguments.length; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 4; } | |
); | |
oTest.fnTest( | |
"fnRowCallback called once for each drawn row", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
mPass++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 10; } | |
); | |
oTest.fnTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
$(nTr).addClass('unit_test'); | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1)').hasClass('unit_test'); } | |
); | |
oTest.fnTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( asData.length != 5 ) | |
mPass = false; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
var iCount = 0; | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( iCount != iDrawIndex ) | |
mPass = false; | |
iCount++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "iDisplayLength" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
oTest.fnTest( | |
"Default length is ten", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Select menu shows 10", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnTest( | |
"Set initial length to 25", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"iDisplayLength": 25 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 25; } | |
); | |
oTest.fnTest( | |
"Set initial length to 100", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"iDisplayLength": 100 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 100; } | |
); | |
oTest.fnTest( | |
"Set initial length to 23 (unknown select menu length)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"iDisplayLength": 23 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 23; } | |
); | |
oTest.fnTest( | |
"Select menu shows 10 (since 23 is unknow)", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.oPaginate" ); | |
/* Note that the paging language information only has relevence in full numbers */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"sPaginationType": "full_numbers" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"oLanguage.oPaginate defaults", | |
null, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "First" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Previous" && | |
oSettings.oLanguage.oPaginate.sNext == "Next" && | |
oSettings.oLanguage.oPaginate.sLast == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate defaults are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "First" && | |
$('#example_paginate .previous').html() == "Previous" && | |
$('#example_paginate .next').html() == "Next" && | |
$('#example_paginate .last').html() == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"sPaginationType": "full_numbers", | |
"oLanguage": { | |
"oPaginate": { | |
"sFirst": "unit1", | |
"sPrevious": "test2", | |
"sNext": "unit3", | |
"sLast": "test4" | |
} | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "unit1" && | |
oSettings.oLanguage.oPaginate.sPrevious == "test2" && | |
oSettings.oLanguage.oPaginate.sNext == "unit3" && | |
oSettings.oLanguage.oPaginate.sLast == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate definitions are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "unit1" && | |
$('#example_paginate .previous').html() == "test2" && | |
$('#example_paginate .next').html() == "unit3" && | |
$('#example_paginate .last').html() == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Info language is 'Showing _START_ to _END_ of _TOTAL_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sInfo == "Showing _START_ to _END_ of _TOTAL_ entries"; } | |
); | |
oTest.fnTest( | |
"Info language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - without any macros", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfo": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfo == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macro _START_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfo": "unit _START_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macro _END_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 10 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macro _TOTAL_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 57 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macros _START_ and _END_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 test"; } | |
); | |
oTest.fnTest( | |
"Info language can be defined - with macros _START_, _END_ and _TOTAL_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 57 test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sInfoEmpty" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Info empty language is 'Showing 0 to 0 of 0 entries' by default", | |
function () { oTable.fnFilter("nothinghere"); }, | |
function () { return oSettings.oLanguage.sInfoEmpty == "Showing 0 to 0 of 0 entries"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"Showing 0 to 0 of 0 entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Info empty language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfoEmpty": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return oSettings.oLanguage.sInfoEmpty == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit test"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Macro's not replaced", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfoEmpty": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit _START_ _END_ _TOTAL_ test"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sInfoPostFix" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Info post fix language is '' (blank) by default", | |
null, | |
function () { return oSettings.oLanguage.sInfoPostFix == ""; } | |
); | |
oTest.fnTest( | |
"Width no post fix, the basic info shows", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Info post fix language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfoPostFix == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit test"; } | |
); | |
oTest.fnTest( | |
"Macros have no effect in the post fix", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfoPostFix": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit _START_ _END_ _TOTAL_ test"; } | |
); | |
oTest.fnTest( | |
"Post fix is applied after fintering info", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 0 to 0 of 0 entries unit (filtered from 57 total entries) test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sLengthMenu" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Menu language is 'Show _MENU_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sLengthMenu == "Show _MENU_ entries"; } | |
); | |
oTest.fnTest( | |
"_MENU_ macro is replaced by select menu in DOM", | |
null, | |
function () { return $('select', oSettings.aanFeatures.l[0]).length == 1 } | |
); | |
oTest.fnTest( | |
"Default is put into DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "Show " && | |
anChildren[2].nodeValue == " entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Menu length language can be defined - no _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sLengthMenu": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sLengthMenu == "unit test"; } | |
); | |
oTest.fnTest( | |
"Menu length language definition is in the DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
return anChildren[0].nodeValue == "unit test"; | |
} | |
); | |
oTest.fnTest( | |
"Menu length language can be defined - with _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sLengthMenu": "unit _MENU_ test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "unit " && | |
anChildren[2].nodeValue == " test"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Only the _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sLengthMenu": "_MENU_" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren.length == 1 && | |
$('select', oSettings.aanFeatures.l[0]).length == 1; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sProcessing" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bProcessing": true | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Processing language is 'Processing...' by default", | |
null, | |
function () { return oSettings.oLanguage.sProcessing == "Processing..."; } | |
); | |
oTest.fnTest( | |
"Processing language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "Processing..."; } | |
); | |
oTest.fnTest( | |
"Processing language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"bProcessing": true, | |
"oLanguage": { | |
"sProcessing": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sProcessing == "unit test"; } | |
); | |
oTest.fnTest( | |
"Processing language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sSearch" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Search language is 'Search:' by default", | |
null, | |
function () { return oSettings.oLanguage.sSearch == "Search:"; } | |
); | |
oTest.fnTest( | |
"Search language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "Search: "; } | |
); | |
oTest.fnTest( | |
"Search language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sSearch": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sSearch == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "unit test "; } | |
); | |
oTest.fnTest( | |
"Blank search has a no (separator) inserted", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sSearch": "" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return document.getElementById('example_filter').childNodes.length == 1; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sUrl" ); | |
/* Note that we only test the internal storage of language information pulled form a file here | |
* as the other language tests will check it goes into the DOM correctly | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"sUrl is blank by default", | |
null, | |
function () { return oSettings.oLanguage.sUrl == ""; } | |
); | |
oTest.fnWaitTest( | |
"Loading of German file loads language information", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sUrl": "../../../examples/examples_support/de_DE.txt" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.sProcessing == "Bitte warten..." && | |
oSettings.oLanguage.sLengthMenu == "_MENU_ Einträge anzeigen" && | |
oSettings.oLanguage.sZeroRecords == "Keine Einträge vorhanden." && | |
oSettings.oLanguage.sInfo == "_START_ bis _END_ von _TOTAL_ Einträgen" && | |
oSettings.oLanguage.sInfoEmpty == "0 bis 0 von 0 Einträgen" && | |
oSettings.oLanguage.sInfoFiltered == "(gefiltert von _MAX_ Einträgen)" && | |
oSettings.oLanguage.sInfoPostFix == "" && | |
oSettings.oLanguage.sSearch == "Suchen" && | |
oSettings.oLanguage.oPaginate.sFirst == "Erster" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Zurück" && | |
oSettings.oLanguage.oPaginate.sNext == "Nächster" && | |
oSettings.oLanguage.oPaginate.sLast == "Letzter"; | |
return bReturn; | |
} | |
); | |
/* One DOM check just to ensure that they go into the DOM */ | |
oTest.fnTest( | |
"Loaded language goes into the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "1 bis 10 von 57 Einträgen"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oLanguage.sZeroRecords" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Zero records language is 'No matching records found' by default", | |
null, | |
function () { return oSettings.oLanguage.sZeroRecords == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere'); }, | |
function () { return $('#example tbody tr td')[0].innerHTML == "No matching records found" } | |
); | |
oTest.fnTest( | |
"Zero records language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oLanguage": { | |
"sZeroRecords": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sZeroRecords == "unit test"; } | |
); | |
oTest.fnTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere2'); }, | |
function () { return $('#example tbody tr td')[0].innerHTML == "unit test" } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "oSearch" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default values should be blank", | |
null, | |
function () { | |
var bReturn = oSettings.oPreviousSearch.sSearch == "" && | |
!oSettings.oPreviousSearch.bRegex; | |
return bReturn; | |
} | |
); | |
/* This test might be considered iffy since the full object isn't given, but it's reasonable to | |
* expect DataTables to cope with this. It should just assumine regex false | |
*/ | |
oTest.fnTest( | |
"Search term only in object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"oSearch": { | |
"sSearch": "Mozilla" | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"New search will kill old one", | |
function () { | |
oTable.fnFilter("Opera"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } | |
); | |
oTest.fnTest( | |
"Search plain text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oSearch": { | |
"sSearch": "DS", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; } | |
); | |
oTest.fnTest( | |
"Search plain text term and escape regex false", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oSearch": { | |
"sSearch": "Opera", | |
"bRegex": true | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } | |
); | |
oTest.fnTest( | |
"Search regex text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oSearch": { | |
"sSearch": "1.*", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnTest( | |
"Search regex text term and escape regex false", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"oSearch": { | |
"sSearch": "1.*", | |
"bRegex": true | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "sAjaxSource" ); | |
/* Not interested in ajax source here other than to check it's default */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Server side is off by default", | |
null, | |
function () { return oSettings.sAjaxSource == null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "sDom" ); | |
/* This is going to be brutal on the browser! There is a lot that can be tested here... */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Default DOM varaible", | |
null, | |
function () { return oSettings.sDom == "lfrtip"; } | |
); | |
oTest.fnTest( | |
"Default DOM in document", | |
null, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check example 1 in code propagates", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"sDom": '<"wrapper"flipt>' | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.sDom == '<"wrapper"flipt>'; } | |
); | |
oTest.fnTest( | |
"Check example 1 in DOM", | |
null, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var nCustomWrapper = $('div.wrapper')[0]; | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrapper && | |
nNodes[2] == nFilter && | |
nNodes[3] == nLength && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging && | |
nNodes[6] == nTable; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check example 2 in DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"sDom": '<lf<t>ip>' | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
var nCustomWrappers = [] | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
/* Only the two custom divs don't have class names */ | |
if ( !jqNodes[i].getAttribute('class') ) | |
{ | |
nCustomWrappers.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrappers[0] && | |
nNodes[2] == nLength && | |
nNodes[3] == nFilter && | |
nNodes[4] == nCustomWrappers[1] && | |
nNodes[5] == nTable && | |
nNodes[6] == nInfo && | |
nNodes[7] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check no length element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"sDom": 'frtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
null == nLength && | |
nNodes[1] == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check no filter element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"sDom": 'lrtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
null == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
/* Note we don't test for no table as this is not supported (and it would be fairly daft! */ | |
oTest.fnTest( | |
"Check no info element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"sDom": 'lfrtp' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
null == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"Check no paging element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"aaData": gaaData, | |
"sDom": 'lfrti' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
null == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: js_data | |
oTest.fnStart( "sPaginationType" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"aaData": gaaData | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"Check two button paging is the default", | |
null, | |
function () { return oSettings.sPaginationType == "two_button"; } | |
); | |
oTest.fnTest( | |
"Check class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_two_button'); } | |
); | |
oTest.fnTest( | |
"Two div elements are in the wrapper", | |
null, | |
function () { return $('#example_paginate div').length == 2; } | |
); | |
oTest.fnTest( | |
"We have the previous button", | |
null, | |
function () { return document.getElementById('example_previous'); } | |
); | |
oTest.fnTest( | |
"We have the next button", | |
null, | |
function () { return document.getElementById('example_next'); } | |
); | |
oTest.fnTest( | |
"Previous button is disabled", | |
null, | |
function () { return $('#example_previous').hasClass('paginate_disabled_previous'); } | |
); | |
oTest.fnTest( | |
"Next button is enabled", | |
null, | |
function () { return $('#example_next').hasClass('paginate_enabled_next'); } | |
); | |
/* Don't test paging - that's done by the zero config test script. */ | |
/* Two buttons paging */ | |
oTest.fnTest( | |
"Can enabled full numbers paging", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"aaData": gaaData, | |
"sPaginationType": "full_numbers" | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.sPaginationType == "full_numbers"; } | |
); | |
oTest.fnTest( | |
"Check full numbers class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_full_numbers'); } | |
); | |
var nFirst, nPrevious, nNext, nLast; | |
oTest.fnTest( | |
"Jump to last page", | |
function () { | |
nFirst = $('div.dataTables_paginate span.first'); | |
nPrevious = $('div.dataTables_paginate span.previous'); | |
nNext = $('div.dataTables_paginate span.next'); | |
nLast = $('div.dataTables_paginate span.last'); | |
nLast.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; | |
} | |
); | |
oTest.fnTest( | |
"Go to two pages previous", | |
function () { | |
nPrevious.click(); | |
nPrevious.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries"; | |
} | |
); | |
oTest.fnTest( | |
"Next (second last) page", | |
function () { | |
nNext.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries"; | |
} | |
); | |
oTest.fnTest( | |
"Jump to first page", | |
function () { | |
nFirst.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "Sanity checks for DataTables with data from JS" ); | |
oTest.fnTest( | |
"jQuery.dataTable function", | |
null, | |
function () { return typeof jQuery().dataTable == "function"; } | |
); | |
oTest.fnTest( | |
"jQuery.dataTableSettings storage array", | |
null, | |
function () { return typeof jQuery().dataTableSettings == "object"; } | |
); | |
oTest.fnTest( | |
"jQuery.dataTableExt plugin object", | |
null, | |
function () { return typeof jQuery().dataTableExt == "object"; } | |
); | |
$(document).ready( function () { | |
var oInit = { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
}; | |
$('#example').dataTable( oInit ); | |
/* Basic checks */ | |
oTest.fnWaitTest( | |
"Length changing div exists", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnTest( | |
"Filtering div exists", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnTest( | |
"Information div exists", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnTest( | |
"Pagination div exists", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnTest( | |
"Processing div is off by default", | |
null, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnWaitTest( | |
"10 rows shown on the first page", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Initial sort occured", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
/* Need to use the WaitTest for sorting due to the setTimeout datatables uses */ | |
oTest.fnTest( | |
"Sorting (first click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting (second click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Sorting (third click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Sorting (first click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnTest( | |
"Sorting (second click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column (first click)", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { var b = | |
$('#example tbody td:eq(0)').html() == "Gecko" && | |
$('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; } | |
); | |
oTest.fnTest( | |
"Sorting multi-column - sorting second column only", | |
function () { | |
$('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
/* Basic paging */ | |
oTest.fnTest( | |
"Paging to second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; } | |
); | |
oTest.fnTest( | |
"Paging to first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnTest( | |
"Attempting to page back beyond the first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
/* Changing length */ | |
oTest.fnTest( | |
"Changing table length to 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnTest( | |
"Changing table length to 50 records", | |
function () { $("select[name=example_length]").val('50').change(); }, | |
function () { return $('#example tbody tr').length == 50; } | |
); | |
oTest.fnTest( | |
"Changing table length to 100 records", | |
function () { $("select[name=example_length]").val('100').change(); }, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnTest( | |
"Changing table length to 10 records", | |
function () { $("select[name=example_length]").val('10').change(); }, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
/* | |
* Information element | |
*/ | |
oTest.fnTest( | |
"Information on zero config", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on third page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information on last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information back on first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 25 records - second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with 100 records - first page", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('100').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information back to 10 records", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('10').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' back to first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page - second time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter increased to 'Win 98'", | |
function () { $('#example_filter input').val("Win 98").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter decreased to 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter 'Win' second page - third time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Information with filter removed", | |
function () { $('#example_filter input').val("").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* | |
* Filtering | |
*/ | |
oTest.fnWaitTest( | |
"Filter 'W' - rows", | |
function () { | |
/* Reset the table such that the old sorting doesn't mess things up */ | |
oSession.fnRestore(); | |
$('#example').dataTable( oInit ); | |
$('#example_filter input').val("W").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnTest( | |
"Filter 'W' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Wi'", | |
function () { $('#example_filter input').val("Wi").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1 info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting column 1 reverse", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - maintaing reverse sorting col 1", | |
function () { $('#example_filter input').val("Win XP").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - sorting col 3", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win XP' - sorting col 3 - reversed", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; } | |
); | |
oTest.fnTest( | |
"Filter 'Win' - sorting col 3 - reversed info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter 'nothinghere'", | |
function () { $('#example_filter input').val("nothinghere").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == | |
"No matching records found"; } | |
); | |
oTest.fnTest( | |
"Filter 'nothinghere' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Filter back to blank and 1st column sorting", | |
function () { | |
$('#example_filter input').val("").keyup(); | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Prefixing a filter entry", | |
function () { | |
$('#example_filter input').val("Win").keyup(); | |
$('#example_filter input').val("GeckoWin").keyup(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Prefixing a filter entry with space", | |
function () { | |
$('#example_filter input').val("Gecko Win").keyup(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aaSorting" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default sorting is single column", | |
null, | |
function () { | |
return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object'; | |
} | |
); | |
oTest.fnWaitTest( | |
"Default sorting is first column asc", | |
null, | |
function () { | |
return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 && | |
oSettings.aaSorting[0][1] == 'asc'; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting is applied", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single string column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single string column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single int column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single int column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','asc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','desc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','desc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','asc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','asc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1.9"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','desc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "125.5"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','desc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (3 column) - string asc / int asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSorting": [['0','asc'], ['3','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aaSortingFixed" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"No fixed sorting by default", | |
null, | |
function () { | |
return oSettings.aaSortingFixed == null; | |
} | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSortingFixed": [['0','asc']], | |
"fnInitComplete": function () { | |
$('#example thead th:eq(1)').click(); | |
} | |
} ); | |
// | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aaSortingFixed": [['3','asc']] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "PSP browser"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bSeachable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Columns are searchable by default", | |
function () { oTable.fnFilter("Camino"); }, | |
function () { | |
if ( $('#example tbody tr:eq(0) td:eq(1)')[0] ) | |
return $('#example tbody tr:eq(0) td:eq(1)').html().match(/Camino/); | |
else | |
return null; | |
} | |
); | |
oTest.fnWaitTest( | |
"Disabling sorting on a column removes it from the global filter", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "bSearchable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("Camino"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnWaitTest( | |
"Disabled on one column has no effect on other columns", | |
function () { oTable.fnFilter("Webkit"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Webkit"; } | |
); | |
oTest.fnWaitTest( | |
"Disable filtering on multiple columns", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
{ "bSearchable": false }, | |
{ "bSearchable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("Webkit"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnWaitTest( | |
"Filter on second disabled column", | |
function () { oTable.fnFilter("Camino"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bSortable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"All columns are sortable by default", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Can disable sorting from one column", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Disabled column has no sorting class", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; } | |
); | |
oTest.fnWaitTest( | |
"Other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } | |
); | |
oTest.fnWaitTest( | |
"Disable sorting on multiple columns - no sorting classes", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
{ "bSortable": false }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(1)').hasClass("sorting") || | |
$('#example thead th:eq(3)').hasClass("sorting") | |
return bReturn == false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting on disabled column 1 has no effect", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } | |
); | |
oTest.fnWaitTest( | |
"Second sort on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; } | |
); | |
oTest.fnWaitTest( | |
"Even with multiple disabled sorting columns other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bUseRendered" ); | |
/* bUseRendered is used to alter sorting data, if false then the original data is used for | |
* sorting rather than the rendered data | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa"; | |
} else | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default for bUseRendered is true - rendered data is used for sorting", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; } | |
); | |
oTest.fnWaitTest( | |
"When bUseRendered is false, original data is used for sorting", | |
function () { | |
mTmp = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ | |
"bUseRendered": false, | |
"fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
null, | |
null, | |
null | |
] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnWaitTest( | |
"bUseRendered set to false on one columns and true (default) on two others", | |
function () { | |
mTmp = 0; | |
var mTmp2 = 0; | |
var mTmp3 = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
{ | |
"fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa1"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
{ | |
"bUseRendered": false, | |
"fnRender": function (a) { | |
if ( mTmp2 == 0 ) { | |
mTmp2++; | |
return "aaa2"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
{ | |
"fnRender": function (a) { | |
if ( mTmp3 == 0 ) { | |
mTmp3++; | |
return "zzz3"; | |
} else { | |
return a.aData[a.iDataColumn]; | |
} | |
} | |
}, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column rendering - 2nd column sorting", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column rendering - 3rd column sorting", | |
function () { | |
$('#example thead th:eq(2)').click(); | |
$('#example thead th:eq(2)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column rendering - 4th column sorting", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column rendering - 5th column sorting", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bVisible" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"All columns are visible by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnWaitTest( | |
"Can hide one column and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 4; } | |
); | |
oTest.fnWaitTest( | |
"Can hide one column and it removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 4; } | |
); | |
oTest.fnWaitTest( | |
"The correct thead column has been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Platform(s)" && | |
jqNodes[2].innerHTML == "Engine version" && | |
jqNodes[3].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"The correct tbody column has been hidden", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); | |
}, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "Gnome" && | |
jqNodes[2].innerHTML == "1.8" && | |
jqNodes[3].innerHTML == "A"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Can hide multiple columns and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
{ "bVisible": false }, | |
null, | |
{ "bVisible": false } | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 2; } | |
); | |
oTest.fnWaitTest( | |
"Multiple hide - removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 2; } | |
); | |
oTest.fnWaitTest( | |
"Multiple hide - the correct thead columns have been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Engine version" | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Multiple hide - the correct tbody columns have been hidden", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); | |
}, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "1" | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.fnRender" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
mTmp++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Single column - fnRender is called once for each row", | |
null, | |
function () { return mTmp == 57; } | |
); | |
oTest.fnWaitTest( | |
"Confirm that fnRender passes one argument (an object) with three parameters", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( arguments.length != 1 || typeof a.iDataRow=='undefined' || | |
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"fnRender iDataColumn is row number", | |
function () { | |
var iCount = 0; | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( iCount != a.iDataRow ) | |
{ | |
mTmp = false; | |
} | |
iCount++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"fnRender iDataColumn is the column", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.iDataColumn != 1 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"fnRender aData is data array of correct size", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.aData.length != 5 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest'; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; } | |
); | |
oTest.fnWaitTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest1'; | |
} }, | |
{ "fnRender": function (a) { | |
return 'unittest2'; | |
} }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' && | |
$('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2'; | |
return bReturn; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.iDataSort" ); | |
$(document).ready( function () { | |
/* Should know that sorting already works by default from other tests, so we can jump | |
* right in here | |
*/ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "iDataSort": 4 }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Sorting on first column is uneffected", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } | |
); | |
oTest.fnWaitTest( | |
"Sorting on second column is the order of the fifth", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnWaitTest( | |
"Reserve sorting on second column uses fifth column as well", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } | |
); | |
oTest.fnWaitTest( | |
"Sorting on 5th column retains it's own sorting", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnWaitTest( | |
"Use 2nd col for sorting 5th col and via-versa - no effect on first col sorting", | |
function () { | |
mTmp = 0; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "iDataSort": 4 }, | |
null, | |
null, | |
{ "iDataSort": 1 } | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'Gecko'; } | |
); | |
oTest.fnWaitTest( | |
"2nd col sorting uses fifth col", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; } | |
); | |
oTest.fnWaitTest( | |
"2nd col sorting uses fifth col - reversed", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'X'; } | |
); | |
oTest.fnWaitTest( | |
"5th col sorting uses 2nd col", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; } | |
); | |
oTest.fnWaitTest( | |
"5th col sorting uses 2nd col - reversed", | |
function () { $('#example thead th:eq(4)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'Seamonkey 1.1'; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sClass" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"By default the test class hasn't been applied to the column (sanity!)", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
null, | |
{ "sClass": 'unittest' }, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - third row", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - last row", | |
null, | |
function () { return $('#example tbody tr:eq(9) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to other columns - 1st", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to other columns - 5th", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - seventh row - second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody tr:eq(6) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to header", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to footer", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Class defined for multiple columns - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
{ "sClass": 'unittest2' }, | |
null, | |
null, | |
{ "sClass": 'unittest1' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest2') && | |
$('#example tbody tr:eq(8) td:eq(3)').hasClass('unittest1'); | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 1", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').hasClass('unittest1') == false; } | |
); | |
oTest.fnWaitTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 2", | |
null, | |
function () { return $('#example tbody tr:eq(6) td:eq(4)').hasClass('unittest2') == false; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sName" ); | |
/* This has no effect at all in DOM methods - so we just check that it has applied the name */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sName": 'unit test' }, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Names are stored in the columns object", | |
null, | |
function () { return oSettings.aoColumns[3].sName =="unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sTitle" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"If not given, then the columns titles are empty", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Browser" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Can set a single column title - and others are read from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Can set multiple column titles", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test 1' }, | |
null, | |
null, | |
{ "sTitle": 'unit test 2' } | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test 1" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "unit test 2"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sWidth" ); | |
/* NOTE - we need to disable the auto width for the majority of these test in order to preform | |
* these tests as the auto width will convert the width to a px value. We can do 'non-exact' tests | |
* with auto width enabled however to ensure it scales columns as required | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
{ "sWidth": '40%' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"With auto width disabled the width for one column is appled", | |
null, | |
function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; } | |
); | |
oTest.fnWaitTest( | |
"With auto width disabled the width for one column is appled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
null, | |
{ "sWidth": '20%' }, | |
{ "sWidth": '30%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(2)')[0].style.width == "20%" && | |
$('#example thead th:eq(3)')[0].style.width == "30%"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"With auto width, it will make the smallest column the largest with percentage width given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sWidth": '40%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoSearchCols" ); | |
/* We could be here forever testing this one, so we test a limited subset on a couple of colums */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default should be to have a empty colums array", | |
null, | |
function () { | |
var bReturn = | |
oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex && | |
oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex && | |
oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex && | |
oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex && | |
oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Search on a single column - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Search on two columns - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1.5" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; } | |
); | |
oTest.fnWaitTest( | |
"Search on single column - escape regex false", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
null, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Search on two columns - escape regex false on first, true on second", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
{ "sSearch": "3.3", "bEscapeRegex": true }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; } | |
); | |
oTest.fnWaitTest( | |
"Search on two columns (no records) - escape regex false on first, true on second", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"aoSearchCols": [ | |
{ "sSearch": ".*ML", "bEscapeRegex": false }, | |
{ "sSearch": "Allan", "bEscapeRegex": true }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "asStripClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Default row striping is applied", | |
null, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Row striping on the second page", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
/* No striping */ | |
oTest.fnWaitTest( | |
"No row striping", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"asStripClasses": [] | |
} ); | |
}, | |
function () { | |
if ( typeof $('#example tbody tr:eq(1)')[0] == 'undefined' ) | |
{ | |
/* Use the 'wait for' to allow this to become true */ | |
return false; | |
} | |
return $('#example tbody tr:eq(0)')[0].className == "" && | |
$('#example tbody tr:eq(1)')[0].className == "" && | |
$('#example tbody tr:eq(2)')[0].className == "" && | |
$('#example tbody tr:eq(3)')[0].className == ""; | |
} | |
); | |
/* Custom striping */ | |
oTest.fnWaitTest( | |
"Custom striping [2]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"asStripClasses": [ 'test1', 'test2' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test1') && | |
$('#example tbody tr:eq(3)').hasClass('test2'); | |
} | |
); | |
/* long array of striping */ | |
oTest.fnWaitTest( | |
"Custom striping [4]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"asStripClasses": [ 'test1', 'test2', 'test3', 'test4' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Custom striping is restarted on second page [2]", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bAutoWidth" ); | |
/* It's actually a little tricky to test this. We can't test absolute numbers because | |
* different browsers and different platforms will render the width of the columns slightly | |
* differently. However, we certainly can test the principle of what should happen (column | |
* width doesn't change over pages) | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Auto width is enabled by default", | |
null, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnWaitTest( | |
"First column has a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style').match(/width/i); } | |
); | |
/* | |
This would seem like a better test - but there appear to be difficulties with tables | |
which are bigger (calculated) than there is actually room for. I suspect this is actually | |
a bug in datatables | |
oTest.fnWaitTest( | |
"Check column widths on first page match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
console.log( a0, b0, a1, b1, a2, b2, a3, b3 ); | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check column widths on second page match thid page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
*/ | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Auto width can be disabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bAutoWidth": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth == false; } | |
); | |
oTest.fnWaitTest( | |
"First column does not have a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style') == null; } | |
); | |
/* | |
oTest.fnWaitTest( | |
"Check column widths on first page do not match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return false; | |
else | |
return true; | |
} | |
); | |
*/ | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Auto width enabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bAutoWidth": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bFilter" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Filtering div exists by default", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Fltering can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bFilter": false | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Filtering enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bFilter": true | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Info div exists by default", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Info can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bInfo": false | |
} ); | |
}, | |
function () { return document.getElementById('example_info') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Info enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bInfo": true | |
} ); | |
}, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bLengthChange" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Length div exists by default", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnWaitTest( | |
"Four default options", | |
null, | |
function () { return $("select[name=example_length] option").length == 4; } | |
); | |
oTest.fnWaitTest( | |
"Default options", | |
null, | |
function () { | |
var opts = $("select[name='example_length'] option"); | |
return opts[0].getAttribute('value') == 10 && opts[1].getAttribute('value') == 25 && | |
opts[2].getAttribute('value') == 50 && opts[3].getAttribute('value') == 100; | |
} | |
); | |
oTest.fnWaitTest( | |
"Info takes length into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Change length can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bLengthChange": false | |
} ); | |
}, | |
function () { return document.getElementById('example_length') == null; } | |
); | |
oTest.fnWaitTest( | |
"Information takes length disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Length change enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bLengthChange": true | |
} ); | |
}, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bPaginate" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Pagiantion div exists by default", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnWaitTest( | |
"Information div takes paging into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bPaginate": false | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') == null; } | |
); | |
oTest.fnWaitTest( | |
"Information div takes paging disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 57 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Pagiantion enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bPaginate": true | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bProcessing" ); | |
/* It's actually a bit hard to set this one due to the fact that it will only be shown | |
* when DataTables is doing some kind of processing. The server-side processing is a bit | |
* better to test this than here - so we just the interal functions to enable it and check | |
* that it is available | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Processing is off by default", | |
null, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnWaitTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnWaitTest( | |
"Processing div cannot be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnWaitTest( | |
"Processing div cannot be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Processing can be enabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bProcessing": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == true; } | |
); | |
oTest.fnWaitTest( | |
"Processing div is in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing'); } | |
); | |
oTest.fnWaitTest( | |
"Processing div is hidden by default", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
oTest.fnWaitTest( | |
"Processing div can be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "visible"; } | |
); | |
oTest.fnWaitTest( | |
"Processing div can be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Processing disabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bProcessing": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnWaitTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bServerSide" ); | |
/* Not interested in server-side processing here other than to check that it is off */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Server side is off by default", | |
null, | |
function () { return oSettings.oFeatures.bServerSide == false; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bSort" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Sorting is on by default", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting Asc by default class applied", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); } | |
); | |
oTest.fnWaitTest( | |
"Click on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting class removed from first column", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnWaitTest( | |
"Sorting asc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); } | |
); | |
oTest.fnWaitTest( | |
"Reverse on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting acs class removed from second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnWaitTest( | |
"Sorting desc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bSort": false | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnWaitTest( | |
"Click on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnWaitTest( | |
"Reverse on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Sorting enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bSort": true | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bSortClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Sorting classes are applied by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnWaitTest( | |
"Sorting classes are applied to all required cells", | |
null, | |
function () { return $('#example tbody tr:eq(7) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnWaitTest( | |
"Sorting classes are not applied to non-sorting columns", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column - add column 1", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column - add column 2", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column - add column 3", | |
function () { | |
oDispacher.click( $('#example thead th:eq(3)')[0], { 'shift': true } ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Remove sorting classes on single column sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3') == false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting class 1 was added", | |
null, | |
function () { return $('#example tbody tr:eq(1) td:eq(4)').hasClass('sorting_1'); } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Sorting classes can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bSortClasses": false | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnWaitTest( | |
"Sorting classes disabled - add column 1 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting classes disabled - add column 2 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false; | |
} | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Sorting classes enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bSortClasses": true | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnDrawCallback" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass, bInit; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnDrawCallback == null; } | |
); | |
oTest.fnWaitTest( | |
"One argument passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
bInit = false; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnDrawCallback": function ( ) { | |
mPass = arguments.length; | |
}, | |
"fnInitComplete": function () { | |
bInit = true; | |
} | |
} ); | |
}, | |
function () { return mPass == 1 && bInit; } | |
); | |
oTest.fnWaitTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
bInit = false; | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnDrawCallback": function ( oSettings ) { | |
mPass = oSettings; | |
}, | |
"fnInitComplete": function () { | |
bInit = true; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass && bInit; } | |
); | |
/* The draw callback is called once for the init and then when the data is added */ | |
oTest.fnWaitTest( | |
"fnRowCallback called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
bInit = false; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnDrawCallback": function ( ) { | |
mPass++; | |
}, | |
"fnInitComplete": function () { | |
bInit = true; | |
} | |
} ); | |
}, | |
function () { return mPass == 2 && bInit; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called once on each draw there after as well", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass == 5; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnHeaderCallback" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass, bInit; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnHeaderCallback == null; } | |
); | |
oTest.fnWaitTest( | |
"Five arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
bInit = false; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( ) { | |
mPass = arguments.length; | |
}, | |
"fnInitComplete": function () { | |
bInit = true; | |
} | |
} ); | |
}, | |
function () { return mPass == 5 && bInit; } | |
); | |
/* The header callback is called once for the init and then when the data is added */ | |
oTest.fnWaitTest( | |
"fnHeaderCallback called once per draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
bInit = false; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
mPass++; | |
}, | |
"fnInitComplete": function () { | |
bInit = true; | |
} | |
} ); | |
}, | |
function () { return mPass == 2 && bInit; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called on paging (i.e. another draw)", | |
function () { $('#example_next').click(); }, | |
function () { return mPass == 3; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records"; | |
} | |
} ); | |
}, | |
function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; } | |
); | |
oTest.fnWaitTest( | |
"iStart correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart != 0 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"iStart correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart == 10 ) | |
{ | |
mPass = true; | |
} | |
}, | |
"fnInitComplete": function () { | |
$('#example_next').click(); | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"iEnd correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd == 20 ) | |
{ | |
mPass = true; | |
} | |
}, | |
"fnInitComplete": function () { | |
$('#example_next').click(); | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"aiDisplay length is full data when not filtered", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 57 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"aiDisplay length is 9 when filtering on 'Mozilla'", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 9 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
oTable.fnFilter( "Mozilla" ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnInitComplete" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnInitComplete == null; } | |
); | |
oTest.fnWaitTest( | |
"Two arguments passed (for Ajax!)", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnInitComplete": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 2; } | |
); | |
oTest.fnWaitTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnInitComplete": function ( oSettings ) { | |
mPass = oSettings; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass; } | |
); | |
oTest.fnWaitTest( | |
"fnInitComplete called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnInitComplete": function ( ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"fnInitComplete never called there after", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"10 rows in the table on complete", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnInitComplete": function ( ) { | |
mPass = $('#example tbody tr').length; | |
} | |
} ); | |
}, | |
function () { return mPass == 10; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnRowCallback" ); | |
/* Note - fnRowCallback MUST return the first arguments (modified or not) */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnRowCallback == null; } | |
); | |
oTest.fnWaitTest( | |
"Four arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnRowCallback": function ( nTr ) { | |
mPass = arguments.length; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 4; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called once for each drawn row", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
mPass++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 10; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
$(nTr).addClass('unit_test'); | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1)').hasClass('unit_test'); } | |
); | |
oTest.fnWaitTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( asData.length != 5 ) | |
mPass = false; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
var iCount = 0; | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( iCount != iDrawIndex ) | |
mPass = false; | |
iCount++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnServerData for Ajax sourced data" ); | |
$(document).ready( function () { | |
var mPass; | |
oTest.fnTest( | |
"Argument length", | |
function () { | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnServerData": function () { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 3; } | |
); | |
oTest.fnTest( | |
"Url", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnServerData": function (sUrl, aoData, fnCallback) { | |
mPass = sUrl == "../../../examples/examples_support/json_source.txt"; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Data array", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnServerData": function (sUrl, aoData, fnCallback) { | |
mPass = aoData.length==0; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnTest( | |
"Callback function", | |
function () { | |
$('#example').dataTable( { | |
"bDestroy": true, | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"fnServerData": function (sUrl, aoData, fnCallback) { | |
mPass = typeof fnCallback == 'function'; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "iDisplayLength" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
oTest.fnWaitTest( | |
"Default length is ten", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 10", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnWaitTest( | |
"Set initial length to 25", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"iDisplayLength": 25 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 25; } | |
); | |
oTest.fnWaitTest( | |
"Set initial length to 100", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"iDisplayLength": 100 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 100; } | |
); | |
oTest.fnWaitTest( | |
"Set initial length to 23 (unknown select menu length)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"iDisplayLength": 23 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 23; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 10 (since 23 is unknow)", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.oPaginate" ); | |
/* Note that the paging language information only has relevence in full numbers */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sPaginationType": "full_numbers" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"oLanguage.oPaginate defaults", | |
null, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "First" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Previous" && | |
oSettings.oLanguage.oPaginate.sNext == "Next" && | |
oSettings.oLanguage.oPaginate.sLast == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate defaults are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "First" && | |
$('#example_paginate .previous').html() == "Previous" && | |
$('#example_paginate .next').html() == "Next" && | |
$('#example_paginate .last').html() == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"oLanguage.oPaginate can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sPaginationType": "full_numbers", | |
"oLanguage": { | |
"oPaginate": { | |
"sFirst": "unit1", | |
"sPrevious": "test2", | |
"sNext": "unit3", | |
"sLast": "test4" | |
} | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "unit1" && | |
oSettings.oLanguage.oPaginate.sPrevious == "test2" && | |
oSettings.oLanguage.oPaginate.sNext == "unit3" && | |
oSettings.oLanguage.oPaginate.sLast == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate definitions are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "unit1" && | |
$('#example_paginate .previous').html() == "test2" && | |
$('#example_paginate .next').html() == "unit3" && | |
$('#example_paginate .last').html() == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Info language is 'Showing _START_ to _END_ of _TOTAL_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sInfo == "Showing _START_ to _END_ of _TOTAL_ entries"; } | |
); | |
oTest.fnTest( | |
"Info language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - without any macros", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfo": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfo == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "unit test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macro _START_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfo": "unit _START_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macro _END_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 10 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macro _TOTAL_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 57 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macros _START_ and _END_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macros _START_, _END_ and _TOTAL_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 57 test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sInfoEmpty" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Info empty language is 'Showing 0 to 0 of 0 entries' by default", | |
function () { oTable.fnFilter("nothinghere"); }, | |
function () { return oSettings.oLanguage.sInfoEmpty == "Showing 0 to 0 of 0 entries"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"Showing 0 to 0 of 0 entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Info empty language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfoEmpty": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return oSettings.oLanguage.sInfoEmpty == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit test"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Macro's not replaced", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfoEmpty": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit _START_ _END_ _TOTAL_ test"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sInfoPostFix" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Info post fix language is '' (blank) by default", | |
null, | |
function () { return oSettings.oLanguage.sInfoPostFix == ""; } | |
); | |
oTest.fnTest( | |
"Width no post fix, the basic info shows", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Info post fix language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfoPostFix == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit test"; } | |
); | |
oTest.fnWaitTest( | |
"Macros have no effect in the post fix", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfoPostFix": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit _START_ _END_ _TOTAL_ test"; } | |
); | |
oTest.fnWaitTest( | |
"Post fix is applied after fintering info", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 0 to 0 of 0 entries unit (filtered from 57 total entries) test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sLengthMenu" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Menu language is 'Show _MENU_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sLengthMenu == "Show _MENU_ entries"; } | |
); | |
oTest.fnTest( | |
"_MENU_ macro is replaced by select menu in DOM", | |
null, | |
function () { return $('select', oSettings.aanFeatures.l[0]).length == 1 } | |
); | |
oTest.fnTest( | |
"Default is put into DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "Show " && | |
anChildren[2].nodeValue == " entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Menu length language can be defined - no _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sLengthMenu": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sLengthMenu == "unit test"; } | |
); | |
oTest.fnTest( | |
"Menu length language definition is in the DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
return anChildren[0].nodeValue == "unit test"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Menu length language can be defined - with _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sLengthMenu": "unit _MENU_ test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "unit " && | |
anChildren[2].nodeValue == " test"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Only the _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sLengthMenu": "_MENU_" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren.length == 1 && | |
$('select', oSettings.aanFeatures.l[0]).length == 1; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sProcessing" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bProcessing": true | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Processing language is 'Processing...' by default", | |
null, | |
function () { return oSettings.oLanguage.sProcessing == "Processing..."; } | |
); | |
oTest.fnTest( | |
"Processing language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "Processing..."; } | |
); | |
oTest.fnWaitTest( | |
"Processing language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"bProcessing": true, | |
"oLanguage": { | |
"sProcessing": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sProcessing == "unit test"; } | |
); | |
oTest.fnTest( | |
"Processing language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sSearch" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Search language is 'Search:' by default", | |
null, | |
function () { return oSettings.oLanguage.sSearch == "Search:"; } | |
); | |
oTest.fnTest( | |
"Search language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "Search: "; } | |
); | |
oTest.fnWaitTest( | |
"Search language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sSearch": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sSearch == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "unit test "; } | |
); | |
oTest.fnWaitTest( | |
"Blank search has a no space (separator) inserted", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sSearch": "" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return document.getElementById('example_filter').childNodes.length == 1; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sUrl" ); | |
/* Note that we only test the internal storage of language information pulled form a file here | |
* as the other language tests will check it goes into the DOM correctly | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"sUrl is blank by default", | |
null, | |
function () { return oSettings.oLanguage.sUrl == ""; } | |
); | |
oTest.fnWaitTest( | |
"Loading of German file loads language information", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sUrl": "../../../examples/examples_support/de_DE.txt" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.sProcessing == "Bitte warten..." && | |
oSettings.oLanguage.sLengthMenu == "_MENU_ Einträge anzeigen" && | |
oSettings.oLanguage.sZeroRecords == "Keine Einträge vorhanden." && | |
oSettings.oLanguage.sInfo == "_START_ bis _END_ von _TOTAL_ Einträgen" && | |
oSettings.oLanguage.sInfoEmpty == "0 bis 0 von 0 Einträgen" && | |
oSettings.oLanguage.sInfoFiltered == "(gefiltert von _MAX_ Einträgen)" && | |
oSettings.oLanguage.sInfoPostFix == "" && | |
oSettings.oLanguage.sSearch == "Suchen" && | |
oSettings.oLanguage.oPaginate.sFirst == "Erster" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Zurück" && | |
oSettings.oLanguage.oPaginate.sNext == "Nächster" && | |
oSettings.oLanguage.oPaginate.sLast == "Letzter"; | |
return bReturn; | |
} | |
); | |
/* One DOM check just to ensure that they go into the DOM */ | |
oTest.fnTest( | |
"Loaded language goes into the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "1 bis 10 von 57 Einträgen"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sZeroRecords" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Zero records language is 'No matching records found' by default", | |
null, | |
function () { return oSettings.oLanguage.sZeroRecords == "No matching records found"; } | |
); | |
oTest.fnWaitTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere'); }, | |
function () { return $('#example tbody tr td')[0].innerHTML == "No matching records found" } | |
); | |
oTest.fnWaitTest( | |
"Zero records language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oLanguage": { | |
"sZeroRecords": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sZeroRecords == "unit test"; } | |
); | |
oTest.fnWaitTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere2'); }, | |
function () { return $('#example tbody tr td')[0].innerHTML == "unit test" } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oSearch" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default values should be blank", | |
null, | |
function () { | |
var bReturn = oSettings.oPreviousSearch.sSearch == "" && | |
!oSettings.oPreviousSearch.bRegex; | |
return bReturn; | |
} | |
); | |
/* This test might be considered iffy since the full object isn't given, but it's reasonable to | |
* expect DataTables to cope with this. It should just assumine regex false | |
*/ | |
oTest.fnWaitTest( | |
"Search term only in object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oSearch": { | |
"sSearch": "Mozilla" | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnWaitTest( | |
"New search will kill old one", | |
function () { | |
oTable.fnFilter("Opera"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } | |
); | |
oTest.fnWaitTest( | |
"Search plain text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oSearch": { | |
"sSearch": "DS", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; } | |
); | |
oTest.fnWaitTest( | |
"Search plain text term and escape regex false", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oSearch": { | |
"sSearch": "Opera", | |
"bRegex": true | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; } | |
); | |
oTest.fnWaitTest( | |
"Search regex text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oSearch": { | |
"sSearch": "1.*", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnWaitTest( | |
"Search regex text term and escape regex false", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"oSearch": { | |
"sSearch": "1.*", | |
"bRegex": true | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "sAjaxSource" ); | |
/* Sanitfy check really - all the other tests blast this */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Server side is off by default", | |
null, | |
function () { | |
return oSettings.sAjaxSource == "../../../examples/examples_support/json_source.txt"; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "sDom" ); | |
/* This is going to be brutal on the browser! There is a lot that can be tested here... */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default DOM varaible", | |
null, | |
function () { return oSettings.sDom == "lfrtip"; } | |
); | |
oTest.fnWaitTest( | |
"Default DOM in document", | |
null, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check example 1 in code propagates", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sDom": '<"wrapper"flipt>' | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.sDom == '<"wrapper"flipt>'; } | |
); | |
oTest.fnWaitTest( | |
"Check example 1 in DOM", | |
null, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var nCustomWrapper = $('div.wrapper')[0]; | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrapper && | |
nNodes[2] == nFilter && | |
nNodes[3] == nLength && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging && | |
nNodes[6] == nTable; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check example 2 in DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sDom": '<lf<t>ip>' | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
var nCustomWrappers = [] | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
/* Only the two custom divs don't have class names */ | |
if ( !jqNodes[i].getAttribute('class') ) | |
{ | |
nCustomWrappers.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrappers[0] && | |
nNodes[2] == nLength && | |
nNodes[3] == nFilter && | |
nNodes[4] == nCustomWrappers[1] && | |
nNodes[5] == nTable && | |
nNodes[6] == nInfo && | |
nNodes[7] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check no length element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sDom": 'frtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
null == nLength && | |
nNodes[1] == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check no filter element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sDom": 'lrtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
null == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
/* Note we don't test for no table as this is not supported (and it would be fairly daft! */ | |
oTest.fnWaitTest( | |
"Check no info element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sDom": 'lfrtp' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
null == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check no paging element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sDom": 'lfrti' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
null == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "sPaginationType" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Check two button paging is the default", | |
null, | |
function () { return oSettings.sPaginationType == "two_button"; } | |
); | |
oTest.fnWaitTest( | |
"Check class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_two_button'); } | |
); | |
oTest.fnWaitTest( | |
"Two div elements are in the wrapper", | |
null, | |
function () { return $('#example_paginate div').length == 2; } | |
); | |
oTest.fnWaitTest( | |
"We have the previous button", | |
null, | |
function () { return document.getElementById('example_previous'); } | |
); | |
oTest.fnWaitTest( | |
"We have the next button", | |
null, | |
function () { return document.getElementById('example_next'); } | |
); | |
oTest.fnWaitTest( | |
"Previous button is disabled", | |
null, | |
function () { return $('#example_previous').hasClass('paginate_disabled_previous'); } | |
); | |
oTest.fnWaitTest( | |
"Next button is enabled", | |
null, | |
function () { return $('#example_next').hasClass('paginate_enabled_next'); } | |
); | |
/* Don't test paging - that's done by the zero config test script. */ | |
/* Two buttons paging */ | |
var bComplete = false; | |
oTest.fnWaitTest( | |
"Can enabled full numbers paging", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"sAjaxSource": "../../../examples/examples_support/json_source.txt", | |
"sPaginationType": "full_numbers", | |
"fnInitComplete": function () { | |
bComplete = true; | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
if ( bComplete ) | |
return oSettings.sPaginationType == "full_numbers"; | |
else | |
return false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check full numbers class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_full_numbers'); } | |
); | |
var nFirst, nPrevious, nNext, nLast; | |
oTest.fnWaitTest( | |
"Jump to last page", | |
function () { | |
nFirst = $('div.dataTables_paginate span.first'); | |
nPrevious = $('div.dataTables_paginate span.previous'); | |
nNext = $('div.dataTables_paginate span.next'); | |
nLast = $('div.dataTables_paginate span.last'); | |
nLast.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Go to two pages previous", | |
function () { | |
nPrevious.click(); | |
nPrevious.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Next (second last) page", | |
function () { | |
nNext.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Jump to first page", | |
function () { | |
nFirst.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "iDraw - check that iDraw increments for each draw" ); | |
$(document).ready( function () { | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"After first draw, iDraw is 1", | |
null, | |
function () { return oSettings.iDraw == 1; } | |
); | |
oTest.fnWaitTest( | |
"After second draw, iDraw is 2", | |
function () { oTable.fnDraw() }, | |
function () { return oSettings.iDraw == 2; } | |
); | |
oTest.fnWaitTest( | |
"After sort", | |
function () { oTable.fnSort([[1,'asc']]) }, | |
function () { return oSettings.iDraw == 3; } | |
); | |
oTest.fnWaitTest( | |
"After filter", | |
function () { oTable.fnFilter('gecko') }, | |
function () { return oSettings.iDraw == 4; } | |
); | |
oTest.fnWaitTest( | |
"After another filter", | |
function () { oTable.fnFilter('gec') }, | |
function () { return oSettings.iDraw == 5; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
/* | |
* NOTE: There are some differences in this zero config script for server-side | |
* processing compared to the other data sources. The main reason for this is the | |
* difference in how the server-side processing does it's filtering. Also the | |
* sorting state is always reset on each draw. | |
*/ | |
oTest.fnStart( "Info element with display all" ); | |
$(document).ready( function () { | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTable.fnSettings()._iDisplayLength = -1; | |
oTable.oApi._fnCalculateEnd( oTable.fnSettings() ); | |
oTable.fnDraw(); | |
/* Basic checks */ | |
oTest.fnWaitTest( | |
"Check length is correct when -1 length given", | |
null, | |
function () { | |
return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 57 of 57 entries"; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "Destroy with hidden columns" ); | |
$(document).ready( function () { | |
var mTest; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumnDefs": [ | |
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] }, | |
{ "bVisible": false, "aTargets": [ 3 ] } | |
], | |
"fnInitComplete": function () { | |
this.fnDestroy(); | |
} | |
} ); | |
oTest.fnWaitTest( | |
"Check that the number of columns in table is correct", | |
null, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnTest( | |
"And with scrolling", | |
function () { | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sScrollY": 200, | |
"aoColumnDefs": [ | |
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] }, | |
{ "bVisible": false, "aTargets": [ 3 ] } | |
], | |
"fnInitComplete": function () { | |
this.fnDestroy(); | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "2600 - Display rewind when changing length" ); | |
$(document).ready( function () { | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Info correct on init", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Page 2", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 11 to 20 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Page 3", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 21 to 30 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Page 4", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 31 to 40 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Page 5", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example_info').html() == "Showing 41 to 50 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Rewind", | |
function () { $('#example_length select').val('100'); $('#example_length select').change(); }, | |
function () { return $('#example_info').html() == "Showing 1 to 57 of 57 entries"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
/* | |
* NOTE: There are some differences in this zero config script for server-side | |
* processing compared to the other data sources. The main reason for this is the | |
* difference in how the server-side processing does it's filtering. Also the | |
* sorting state is always reset on each draw. | |
*/ | |
oTest.fnStart( "Sanity checks for DataTables with data from JS" ); | |
oTest.fnWaitTest( | |
"jQuery.dataTable function", | |
null, | |
function () { return typeof jQuery().dataTable == "function"; } | |
); | |
oTest.fnWaitTest( | |
"jQuery.dataTableSettings storage array", | |
null, | |
function () { return typeof jQuery().dataTableSettings == "object"; } | |
); | |
oTest.fnWaitTest( | |
"jQuery.dataTableExt plugin object", | |
null, | |
function () { return typeof jQuery().dataTableExt == "object"; } | |
); | |
$(document).ready( function () { | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
/* Basic checks */ | |
oTest.fnWaitTest( | |
"Length changing div exists", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnWaitTest( | |
"Filtering div exists", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnWaitTest( | |
"Information div exists", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnWaitTest( | |
"Pagination div exists", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnWaitTest( | |
"Processing div is off by default", | |
null, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnWaitTest( | |
"10 rows shown on the first page", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Initial sort occured", | |
null, | |
function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
); | |
/* Need to use the WaitTest for sorting due to the setTimeout datatables uses */ | |
oTest.fnWaitTest( | |
"Sorting (first click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting (second click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting (third click) on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting (first click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting (second click) on numeric column", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column (first click)", | |
function () { | |
$('#example thead th:eq(0)').click(); | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { var b = | |
$('#example tbody td:eq(0)').html() == "Gecko" && | |
$('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; } | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column - sorting first column only", | |
function () { | |
$('#example thead th:eq(0)').click(); }, | |
function () { var b = | |
$('#example tbody td:eq(0)').html() == "Gecko" && | |
$('#example tbody td:eq(1)').html() == "Firefox 1.0"; return b; } | |
); | |
/* Basic paging */ | |
oTest.fnWaitTest( | |
"Paging to second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Mozilla 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Paging to first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Attempting to page back beyond the first page", | |
function () { $('#example_previous').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
/* Changing length */ | |
oTest.fnWaitTest( | |
"Changing table length to 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnWaitTest( | |
"Changing table length to 50 records", | |
function () { $("select[name=example_length]").val('50').change(); }, | |
function () { return $('#example tbody tr').length == 50; } | |
); | |
oTest.fnWaitTest( | |
"Changing table length to 100 records", | |
function () { $("select[name=example_length]").val('100').change(); }, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnWaitTest( | |
"Changing table length to 10 records", | |
function () { $("select[name=example_length]").val('10').change(); }, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
/* | |
* Information element | |
*/ | |
oTest.fnWaitTest( | |
"Information on zero config", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information on second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information on third page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information on last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information back on first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information with 25 records", | |
function () { $("select[name=example_length]").val('25').change(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information with 25 records - second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information with 100 records - first page", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('100').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information back to 10 records", | |
function () { | |
$('#example_previous').click(); | |
$("select[name=example_length]").val('10').change(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter 'Win' second page", | |
function () { $('#example_next').click(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter 'Win' last page", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter 'Win' back to first page", | |
function () { | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
$('#example_previous').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter 'Win' second page - second time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter increased to 'Win 98'", | |
function () { $('#example_filter input').val("Win 98").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter decreased to 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter 'Win' second page - third time", | |
function () { | |
$('#example_next').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Information with filter removed", | |
function () { $('#example_filter input').val("").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* | |
* Filtering | |
*/ | |
oTest.fnWaitTest( | |
"Filter 'W' - rows", | |
function () { | |
$('#example_filter input').val("W").keyup(); }, | |
function () { return $('#example tbody tr:eq(4) td:eq(1)').html() == "Netscape 7.2"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'W' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Wi'", | |
function () { $('#example_filter input').val("Wi").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Win'", | |
function () { $('#example_filter input').val("Win").keyup(); }, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Win' - sorting column 1", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Win' - sorting column 1 info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Win' - sorting column 1 reverse", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Win XP' - maintaing reverse sorting col 1", | |
function () { $('#example_filter input').val("Win XP").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Win XP' - sorting col 3", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "6"; } | |
); | |
/* Note the filtering is different from the DOM since the server doesn't do | |
* "smart filtering" like the client side does | |
*/ | |
oTest.fnWaitTest( | |
"Filter 'Win XP' - sorting col 3 - reversed", | |
function () { $('#example thead th:eq(3)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'Win' - sorting col 3 - reversed info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 2 of 2 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'nothinghere'", | |
function () { $('#example_filter input').val("nothinghere").keyup(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == | |
"No matching records found"; } | |
); | |
oTest.fnWaitTest( | |
"Filter 'nothinghere' - info", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnWaitTest( | |
"Filter back to blank and 1st column sorting", | |
function () { | |
$('#example_filter input').val("").keyup(); | |
$('#example thead th:eq(0)').click(); | |
}, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aaSorting" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default sorting is single column", | |
null, | |
function () { | |
return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object'; | |
} | |
); | |
oTest.fnWaitTest( | |
"Default sorting is first column asc", | |
null, | |
function () { | |
return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 && | |
oSettings.aaSorting[0][1] == 'asc'; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting is applied", | |
null, | |
function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single string column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single string column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single int column asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
); | |
oTest.fnWaitTest( | |
"Custom sorting on single int column desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','asc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','desc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / string desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','desc'], ['1','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','asc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string asc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','asc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "1.9"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / int asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','desc'], ['3','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "125.5"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (2 column) - string desc / int desc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','desc'], ['3','desc']] | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
); | |
oTest.fnWaitTest( | |
"Multi-column sorting (3 column) - string asc / int asc / string asc", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSorting": [['0','asc'], ['3','asc'], ['1','asc']] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aaSortingFixed" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"No fixed sorting by default", | |
null, | |
function () { | |
return oSettings.aaSortingFixed == null; | |
} | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSortingFixed": [['0','asc']] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on first column (string/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/asc)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aaSortingFixed": [['3','asc']] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Fixed sorting on fourth column (int/asc) with user sorting on second column (string/desc)", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "PSP browser"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bSeachable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Columns are searchable by default", | |
function () { oTable.fnFilter("Camino"); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Camino 1.0"; } | |
); | |
/* NOT ACTUALLY GOING TO TEST BSEARCHABLE HERE. Reason being is that it requires the server | |
* side to alter it's processing, and this information about columns is not actually sent to | |
* the server | |
*/ | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bSortable" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"All columns are sortable by default", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Can disable sorting from one column", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Disabled column has no sorting class", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; } | |
); | |
oTest.fnWaitTest( | |
"Other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 4.0"; } | |
); | |
oTest.fnWaitTest( | |
"Disable sorting on multiple columns - no sorting classes", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "bSortable": false }, | |
null, | |
{ "bSortable": false }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(1)').hasClass("sorting") || | |
$('#example thead th:eq(3)').hasClass("sorting") | |
return bReturn == false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting on disabled column 1 has no effect", | |
function () { | |
$('#example thead th:eq(1)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Second sort on disabled column 2 has no effect", | |
function () { | |
$('#example thead th:eq(3)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Even with multiple disabled sorting columns other columns can still sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 4.0"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bUseRendered" ); | |
/* bUseRendered is used to alter sorting data, if false then the original data is used for | |
* sorting rather than the rendered data | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( mTmp == 0 ) { | |
mTmp++; | |
return "aaa"; | |
} else | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default for bUseRendered is true - rendered data is used for sorting", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; } | |
); | |
/* Limited to what we can do here as the sorting is done on the server side. So stop here. */ | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.bVisible" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"All columns are visible by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td').length == 5; } | |
); | |
oTest.fnWaitTest( | |
"Can hide one column and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 4; } | |
); | |
oTest.fnWaitTest( | |
"Can hide one column and it removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 4; } | |
); | |
oTest.fnWaitTest( | |
"The correct thead column has been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Platform(s)" && | |
jqNodes[2].innerHTML == "Engine version" && | |
jqNodes[3].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"The correct tbody column has been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "Win 98+ / OSX.2+" && | |
jqNodes[2].innerHTML == "1.7" && | |
jqNodes[3].innerHTML == "A"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Can hide multiple columns and it removes td column from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "bVisible": false }, | |
{ "bVisible": false }, | |
null, | |
{ "bVisible": false } | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td').length == 2; } | |
); | |
oTest.fnWaitTest( | |
"Multiple hide - removes thead th column from DOM", | |
null, | |
function () { return $('#example thead tr:eq(0) th').length == 2; } | |
); | |
oTest.fnWaitTest( | |
"Multiple hide - the correct thead columns have been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Engine version" | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Multiple hide - the correct tbody columns have been hidden", | |
null, | |
function () { | |
var jqNodes = $('#example tbody tr:eq(0) td'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Gecko" && | |
jqNodes[1].innerHTML == "1.7" | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.fnRender" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var mTmp = 0; | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
mTmp++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Single column - fnRender is called once for each row", | |
null, | |
function () { return mTmp == 10; } | |
); | |
oTest.fnWaitTest( | |
"Confirm that fnRender passes one argument (an object) with three parameters", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( arguments.length != 1 || typeof a.iDataRow=='undefined' || | |
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"fnRender iDataColumn is row number", | |
function () { | |
var iCount = 0; | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( iCount != a.iDataRow ) | |
{ | |
mTmp = false; | |
} | |
iCount++; | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"fnRender iDataColumn is the column", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.iDataColumn != 1 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"fnRender aData is data array of correct size", | |
function () { | |
mTmp = true; | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
if ( a.aData.length != 5 ) | |
{ | |
mTmp = false; | |
} | |
return a.aData[a.iDataColumn]; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return mTmp; } | |
); | |
oTest.fnWaitTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest'; | |
} }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; } | |
); | |
oTest.fnWaitTest( | |
"Passed back data is put into the DOM", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
null, | |
{ "fnRender": function (a) { | |
return 'unittest1'; | |
} }, | |
{ "fnRender": function (a) { | |
return 'unittest2'; | |
} }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' && | |
$('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2'; | |
return bReturn; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sClass" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"By default the test class hasn't been applied to the column (sanity!)", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
null, | |
{ "sClass": 'unittest' }, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - third row", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - last row", | |
null, | |
function () { return $('#example tbody tr:eq(9) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to other columns - 1st", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to other columns - 5th", | |
null, | |
function () { return $('#example tbody tr:eq(3) td:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - seventh row - second page", | |
function () { $('#example_next').click(); }, | |
function () { return $('#example tbody tr:eq(6) td:eq(2)').hasClass('unittest'); } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to header", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Add a class to a single column - has not applied to footer", | |
null, | |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } | |
); | |
oTest.fnWaitTest( | |
"Class defined for multiple columns - first row", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
{ "sClass": 'unittest2' }, | |
null, | |
null, | |
{ "sClass": 'unittest1' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest2') && | |
$('#example tbody tr:eq(8) td:eq(3)').hasClass('unittest1'); | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 1", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(4)').hasClass('unittest1') == false; } | |
); | |
oTest.fnWaitTest( | |
"Class defined for multiple columns - has not applied to other columns - 5th 2", | |
null, | |
function () { return $('#example tbody tr:eq(6) td:eq(4)').hasClass('unittest2') == false; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sName" ); | |
/* This has no effect at all in DOM methods - so we just check that it has applied the name */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sName": 'unit test' }, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Names are stored in the columns object", | |
null, | |
function () { return oSettings.aoColumns[3].sName =="unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sTitle" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"If not given, then the columns titles are empty", | |
null, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "Browser" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Can set a single column title - and others are read from DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "CSS grade"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Can set multiple column titles", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
{ "sTitle": 'unit test 1' }, | |
null, | |
null, | |
{ "sTitle": 'unit test 2' } | |
] | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#example thead tr:eq(0) th'); | |
var bReturn = | |
jqNodes[0].innerHTML == "Rendering engine" && | |
jqNodes[1].innerHTML == "unit test 1" && | |
jqNodes[2].innerHTML == "Platform(s)" && | |
jqNodes[3].innerHTML == "Engine version" && | |
jqNodes[4].innerHTML == "unit test 2"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoColumns.sWidth" ); | |
/* NOTE - we need to disable the auto width for the majority of these test in order to preform | |
* these tests as the auto width will convert the width to a px value. We can do 'non-exact' tests | |
* with auto width enabled however to ensure it scales columns as required | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
{ "sWidth": '40%' }, | |
null, | |
null, | |
null | |
] | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"With auto width disabled the width for one column is appled", | |
null, | |
function () { return $('#example thead th:eq(1)')[0].style.width == "40%"; } | |
); | |
oTest.fnWaitTest( | |
"With auto width disabled the width for one column is appled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bAutoWidth": false, | |
"aoColumns": [ | |
null, | |
null, | |
{ "sWidth": '20%' }, | |
{ "sWidth": '30%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var bReturn = | |
$('#example thead th:eq(2)')[0].style.width == "20%" && | |
$('#example thead th:eq(3)')[0].style.width == "30%"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"With auto width, it will make the smallest column the largest with percentage width given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"aoColumns": [ | |
null, | |
null, | |
null, | |
{ "sWidth": '40%' }, | |
null | |
] | |
} ); | |
}, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
if ( a3>a0 && a3>a1 && a3>a2 && a3>a4 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "aoSearchCols" ); | |
/* We could be here forever testing this one, so we test a limited subset on a couple of colums */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing_filter_col.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default should be to have a empty colums array", | |
null, | |
function () { | |
var bReturn = | |
oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex && | |
oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex && | |
oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex && | |
oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex && | |
oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Search on a single column - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing_filter_col.php", | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1"; } | |
); | |
oTest.fnWaitTest( | |
"Search on two columns - no regex statement given", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing_filter_col.php", | |
"aoSearchCols": [ | |
null, | |
{ "sSearch": "Mozilla" }, | |
null, | |
{ "sSearch": "1.5" }, | |
null | |
] | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; } | |
); | |
/* No regex escape searches here - would need to be implemented on the server-side */ | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "asStripClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Default row striping is applied", | |
null, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Row striping on the second page", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('odd') && | |
$('#example tbody tr:eq(1)').hasClass('even') && | |
$('#example tbody tr:eq(2)').hasClass('odd') && | |
$('#example tbody tr:eq(3)').hasClass('even'); | |
} | |
); | |
/* No striping */ | |
oTest.fnWaitTest( | |
"No row striping", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"asStripClasses": [] | |
} ); | |
}, | |
function () { | |
if ( typeof $('#example tbody tr:eq(1)')[0] == 'undefined' ) | |
{ | |
/* Use the 'wait for' to allow this to become true */ | |
return false; | |
} | |
return $('#example tbody tr:eq(0)')[0].className == "" && | |
$('#example tbody tr:eq(1)')[0].className == "" && | |
$('#example tbody tr:eq(2)')[0].className == "" && | |
$('#example tbody tr:eq(3)')[0].className == ""; | |
} | |
); | |
/* Custom striping */ | |
oTest.fnWaitTest( | |
"Custom striping [2]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"asStripClasses": [ 'test1', 'test2' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test1') && | |
$('#example tbody tr:eq(3)').hasClass('test2'); | |
} | |
); | |
/* long array of striping */ | |
oTest.fnWaitTest( | |
"Custom striping [4]", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"asStripClasses": [ 'test1', 'test2', 'test3', 'test4' ] | |
} ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Custom striping is restarted on second page [2]", | |
function () { $('#example_next').click(); }, | |
function () { | |
return $('#example tbody tr:eq(0)').hasClass('test1') && | |
$('#example tbody tr:eq(1)').hasClass('test2') && | |
$('#example tbody tr:eq(2)').hasClass('test3') && | |
$('#example tbody tr:eq(3)').hasClass('test4'); | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bAutoWidth" ); | |
/* It's actually a little tricky to test this. We can't test absolute numbers because | |
* different browsers and different platforms will render the width of the columns slightly | |
* differently. However, we certainly can test the principle of what should happen (column | |
* width doesn't change over pages) | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Auto width is enabled by default", | |
null, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnWaitTest( | |
"First column has a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style').match(/width/i); } | |
); | |
/* | |
This would seem like a better test - but there appear to be difficulties with tables | |
which are bigger (calculated) than there is actually room for. I suspect this is actually | |
a bug in datatables | |
oTest.fnWaitTest( | |
"Check column widths on first page match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
console.log( a0, b0, a1, b1, a2, b2, a3, b3 ); | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check column widths on second page match thid page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return true; | |
else | |
return false; | |
} | |
); | |
*/ | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Auto width can be disabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bAutoWidth": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth == false; } | |
); | |
oTest.fnWaitTest( | |
"First column does not have a width assigned to it", | |
null, | |
function () { return $('#example thead th:eq(0)').attr('style') == null; } | |
); | |
/* | |
oTest.fnWaitTest( | |
"Check column widths on first page do not match second page", | |
null, | |
function () { | |
var anThs = $('#example thead th'); | |
var a0 = anThs[0].offsetWidth; | |
var a1 = anThs[1].offsetWidth; | |
var a2 = anThs[2].offsetWidth; | |
var a3 = anThs[3].offsetWidth; | |
var a4 = anThs[4].offsetWidth; | |
$('#example_next').click(); | |
var b0 = anThs[0].offsetWidth; | |
var b1 = anThs[1].offsetWidth; | |
var b2 = anThs[2].offsetWidth; | |
var b3 = anThs[3].offsetWidth; | |
var b4 = anThs[4].offsetWidth; | |
if ( a0==b0 && a1==b1 && a2==b2 && a3==b3 ) | |
return false; | |
else | |
return true; | |
} | |
); | |
*/ | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Auto width enabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bAutoWidth": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bAutoWidth; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bFilter" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Filtering div exists by default", | |
null, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Fltering can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bFilter": false | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Filtering enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bFilter": true | |
} ); | |
}, | |
function () { return document.getElementById('example_filter') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bInfiniteScroll" ); | |
$(document).ready( function () { | |
var oTable = $('#example').dataTable( { | |
"bScrollInfinite": true, | |
"sScrollY": "200px", | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"10 rows by default", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Info", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Get nodes", | |
null, | |
function () { return $('#example tbody>tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Get nodes function", | |
null, | |
function () { return $('#example').dataTable().fnGetNodes().length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Scroll on 20px adds 10 rows", | |
function () { $('div.dataTables_scrollBody').scrollTop(20); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Info after 20px scroll", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Get nodes after 20px scroll", | |
null, | |
function () { return $('#example tbody>tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Get nodes function after 20px scroll", | |
null, | |
function () { return $('#example').dataTable().fnGetNodes().length == 20; } | |
); | |
oTest.fnWaitTest( | |
"Scroll on 10px more results in the same number of rows", | |
function () { $('div.dataTables_scrollBody').scrollTop(30); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Info after 10 more px scroll", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 20 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Scroll to 240px adds another 10 rows", | |
function () { $('div.dataTables_scrollBody').scrollTop(240); }, | |
function () { return $('#example tbody tr').length == 30; } | |
); | |
oTest.fnTest( | |
"Info after 240px scroll", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 30 of 57 entries"; } | |
); | |
oTest.fnTest( | |
"Get nodes after 240px scroll", | |
null, | |
function () { return $('#example tbody>tr').length == 30; } | |
); | |
oTest.fnTest( | |
"Get nodes function after 240px scroll", | |
null, | |
function () { return $('#example').dataTable().fnGetNodes().length == 30; } | |
); | |
oTest.fnWaitTest( | |
"Filtering will drop back to 10 rows", | |
function () { oTable.fnFilter('gec') }, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Info after filtering", | |
null, | |
function () { return $('#example_info').html() == "Showing 1 to 10 of 20 entries (filtered from 57 total entries)"; } | |
); | |
oTest.fnTest( | |
"Get nodes after filtering", | |
null, | |
function () { return $('#example tbody>tr').length == 10; } | |
); | |
oTest.fnTest( | |
"Get nodes function after filtering", | |
null, | |
function () { return $('#example').dataTable().fnGetNodes().length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Scroll after filtering adds 10", | |
function () { $('div.dataTables_scrollBody').scrollTop(20); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Get nodes after filtering", | |
null, | |
function () { return $('#example tbody>tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Get nodes function after filtering", | |
null, | |
function () { return $('#example').dataTable().fnGetNodes().length == 20; } | |
); | |
oTest.fnWaitTest( | |
"Sorting will drop back to 10 rows", | |
function () { oTable.fnSort([[1,'asc']]) }, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Scroll after sorting adds 10", | |
function () { $('div.dataTables_scrollBody').scrollTop(20); }, | |
function () { return $('#example tbody tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Get nodes after scrolling", | |
null, | |
function () { return $('#example tbody>tr').length == 20; } | |
); | |
oTest.fnTest( | |
"Get nodes function after scrolling", | |
null, | |
function () { return $('#example').dataTable().fnGetNodes().length == 20; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Info div exists by default", | |
null, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Info can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bInfo": false | |
} ); | |
}, | |
function () { return document.getElementById('example_info') == null; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Info enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bInfo": true | |
} ); | |
}, | |
function () { return document.getElementById('example_info') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bLengthChange" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Length div exists by default", | |
null, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnWaitTest( | |
"Four default options", | |
null, | |
function () { return $("select[name=example_length] option").length == 4; } | |
); | |
oTest.fnWaitTest( | |
"Default options", | |
null, | |
function () { | |
var opts = $("select[name='example_length'] option"); | |
return opts[0].getAttribute('value') == 10 && opts[1].getAttribute('value') == 25 && | |
opts[2].getAttribute('value') == 50 && opts[3].getAttribute('value') == 100; | |
} | |
); | |
oTest.fnWaitTest( | |
"Info takes length into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Change length can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bLengthChange": false | |
} ); | |
}, | |
function () { return document.getElementById('example_length') == null; } | |
); | |
oTest.fnWaitTest( | |
"Information takes length disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Length change enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bLengthChange": true | |
} ); | |
}, | |
function () { return document.getElementById('example_length') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bPaginate" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Pagiantion div exists by default", | |
null, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnWaitTest( | |
"Information div takes paging into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 10 of 57 entries"; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bPaginate": false | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') == null; } | |
); | |
oTest.fnWaitTest( | |
"Information div takes paging disabled into account", | |
null, | |
function () { return document.getElementById('example_info').innerHTML == | |
"Showing 1 to 57 of 57 entries"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Pagiantion enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bPaginate": true | |
} ); | |
}, | |
function () { return document.getElementById('example_paginate') != null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bProcessing" ); | |
/* It's actually a bit hard to set this one due to the fact that it will only be shown | |
* when DataTables is doing some kind of processing. The server-side processing is a bit | |
* better to test this than here - so we just the interal functions to enable it and check | |
* that it is available | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Processing is off by default", | |
null, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnWaitTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnWaitTest( | |
"Processing div cannot be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnWaitTest( | |
"Processing div cannot be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Processing can be enabled", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bProcessing": true | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == true; } | |
); | |
oTest.fnWaitTest( | |
"Processing div is in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing'); } | |
); | |
oTest.fnWaitTest( | |
"Processing div is hidden by default", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
oTest.fnWaitTest( | |
"Processing div can be shown", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "visible"; } | |
); | |
oTest.fnWaitTest( | |
"Processing div can be hidden", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, false ); }, | |
function () { return document.getElementById('example_processing').style.visibility = "hidden"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Processing disabled override", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bProcessing": false | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oFeatures.bProcessing == false; } | |
); | |
oTest.fnWaitTest( | |
"Processing div is not in the DOM", | |
function () { oTable.oApi._fnProcessingDisplay( oSettings, true ); }, | |
function () { return document.getElementById('example_processing') == null; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bServerSide" ); | |
/* All the other scripts blast the ssp processing */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Server side can be set to on", | |
null, | |
function () { return oSettings.oFeatures.bServerSide == true; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bSort" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Sorting is on by default", | |
null, | |
function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting Asc by default class applied", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); } | |
); | |
oTest.fnWaitTest( | |
"Click on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting class removed from first column", | |
null, | |
function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnWaitTest( | |
"Sorting asc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); } | |
); | |
oTest.fnWaitTest( | |
"Reverse on second column", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
); | |
oTest.fnWaitTest( | |
"Sorting acs class removed from second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; } | |
); | |
oTest.fnWaitTest( | |
"Sorting desc class applied to second column", | |
null, | |
function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Pagiantion can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bSort": false | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnWaitTest( | |
"Click on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
oTest.fnWaitTest( | |
"Reverse on second column has no effect", | |
function () { $('#example thead th:eq(1)').click(); }, | |
function () { return $('#example tbody td:eq(3)').html() == "4"; } | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Sorting enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bSort": true | |
} ); | |
}, | |
function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "bSortClasses" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Sorting classes are applied by default", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnWaitTest( | |
"Sorting classes are applied to all required cells", | |
null, | |
function () { return $('#example tbody tr:eq(7) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnWaitTest( | |
"Sorting classes are not applied to non-sorting columns", | |
null, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column - add column 1", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column - add column 2", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting multi-column - add column 3", | |
function () { | |
oDispacher.click( $('#example thead th:eq(3)')[0], { 'shift': true } ); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3'); | |
} | |
); | |
oTest.fnWaitTest( | |
"Remove sorting classes on single column sort", | |
function () { | |
$('#example thead th:eq(4)').click(); | |
}, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false && | |
$('#example tbody tr:eq(0) td:eq(3)').hasClass('sorting_3') == false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting class 1 was added", | |
null, | |
function () { return $('#example tbody tr:eq(1) td:eq(4)').hasClass('sorting_1'); } | |
); | |
/* Check can disable */ | |
oTest.fnWaitTest( | |
"Sorting classes can be disabled", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bSortClasses": false | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false; } | |
); | |
oTest.fnWaitTest( | |
"Sorting classes disabled - add column 1 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Sorting classes disabled - add column 2 - no effect", | |
function () { | |
oDispacher.click( $('#example thead th:eq(2)')[0], { 'shift': true } ); }, | |
function () { | |
return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1') == false && | |
$('#example tbody tr:eq(0) td:eq(1)').hasClass('sorting_2') == false && | |
$('#example tbody tr:eq(0) td:eq(2)').hasClass('sorting_3') == false; | |
} | |
); | |
/* Enable makes no difference */ | |
oTest.fnWaitTest( | |
"Sorting classes enabled override", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bSortClasses": true | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').hasClass('sorting_1'); } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnDrawCallback" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnDrawCallback == null; } | |
); | |
oTest.fnWaitTest( | |
"One argument passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnDrawCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnDrawCallback": function ( oSettings ) { | |
mPass = oSettings; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnDrawCallback": function ( ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called once on each draw there after as well", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass > 1; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnHeaderCallback" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnHeaderCallback == null; } | |
); | |
oTest.fnWaitTest( | |
"Five arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 5; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called once per draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called on paging (i.e. another draw)", | |
function () { $('#example_next').click(); }, | |
function () { return mPass == 2; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records"; | |
} | |
} ); | |
}, | |
function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; } | |
); | |
oTest.fnWaitTest( | |
"iStart correct on first page", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart != 0 ) | |
{ | |
mPass = false; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"iStart correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iStart == 0 ) | |
{ | |
mPass = true; | |
} | |
}, | |
"fnInitComplete": function () { | |
$('#example_next').click(); | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"iEnd correct on second page", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( iEnd == 10 ) | |
{ | |
mPass = true; | |
} | |
}, | |
"fnInitComplete": function () { | |
$('#example_next').click(); | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"aiDisplay length is full data when not filtered", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 10 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"aiDisplay length is 9 when filtering on 'Mozilla'", | |
function () { | |
oSession.fnRestore(); | |
mPass = false; | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
if ( aiDisplay.length == 9 ) | |
{ | |
mPass = true; | |
} | |
} | |
} ); | |
oTable.fnFilter( "Mozilla" ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnInitComplete" ); | |
/* Fairly boring function compared to the others! */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnInitComplete == null; } | |
); | |
oTest.fnWaitTest( | |
"One argument passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnInitComplete": function ( ) { | |
mPass = arguments.length; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"That one argument is the settings object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnInitComplete": function ( oSettings ) { | |
mPass = oSettings; | |
} | |
} ); | |
}, | |
function () { return oTable.fnSettings() == mPass; } | |
); | |
oTest.fnWaitTest( | |
"fnInitComplete called once on first draw", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnInitComplete": function ( ) { | |
mPass++; | |
} | |
} ); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"fnInitComplete never called there after", | |
function () { | |
$('#example_next').click(); | |
$('#example_next').click(); | |
$('#example_next').click(); | |
}, | |
function () { return mPass == 1; } | |
); | |
oTest.fnWaitTest( | |
"10 rows in the table on complete", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnInitComplete": function ( ) { | |
mPass = $('#example tbody tr').length; | |
} | |
} ); | |
}, | |
function () { return mPass == 10; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "fnRowCallback" ); | |
/* Note - fnRowCallback MUST return the first arguments (modified or not) */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
var mPass; | |
oTest.fnWaitTest( | |
"Default should be null", | |
null, | |
function () { return oSettings.fnRowCallback == null; } | |
); | |
oTest.fnWaitTest( | |
"Four arguments passed", | |
function () { | |
oSession.fnRestore(); | |
mPass = -1; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnRowCallback": function ( nTr ) { | |
mPass = arguments.length; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 4; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback called once for each drawn row", | |
function () { | |
oSession.fnRestore(); | |
mPass = 0; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
mPass++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass == 10; } | |
); | |
oTest.fnWaitTest( | |
"fnRowCallback allows us to alter row information", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
$(nTr).addClass('unit_test'); | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(1)').hasClass('unit_test'); } | |
); | |
oTest.fnWaitTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( asData.length != 5 ) | |
mPass = false; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnWaitTest( | |
"Data array has length matching columns", | |
function () { | |
oSession.fnRestore(); | |
mPass = true; | |
var iCount = 0; | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) { | |
if ( iCount != iDrawIndex ) | |
mPass = false; | |
iCount++; | |
return nTr; | |
} | |
} ); | |
}, | |
function () { return mPass; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "iDisplayLength" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
oTest.fnWaitTest( | |
"Default length is ten", | |
null, | |
function () { return $('#example tbody tr').length == 10; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 10", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnWaitTest( | |
"Set initial length to 25", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"iDisplayLength": 25 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 25; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 25; } | |
); | |
oTest.fnWaitTest( | |
"Set initial length to 100", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"iDisplayLength": 100 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 57; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 25", | |
null, | |
function () { return $('#example_length select').val() == 100; } | |
); | |
oTest.fnWaitTest( | |
"Set initial length to 23 (unknown select menu length)", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"iDisplayLength": 23 | |
} ); | |
}, | |
function () { return $('#example tbody tr').length == 23; } | |
); | |
oTest.fnWaitTest( | |
"Select menu shows 10 (since 23 is unknow)", | |
null, | |
function () { return $('#example_length select').val() == 10; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.oPaginate" ); | |
/* Note that the paging language information only has relevence in full numbers */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sPaginationType": "full_numbers" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"oLanguage.oPaginate defaults", | |
null, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "First" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Previous" && | |
oSettings.oLanguage.oPaginate.sNext == "Next" && | |
oSettings.oLanguage.oPaginate.sLast == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate defaults are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "First" && | |
$('#example_paginate .previous').html() == "Previous" && | |
$('#example_paginate .next').html() == "Next" && | |
$('#example_paginate .last').html() == "Last"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"oLanguage.oPaginate can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sPaginationType": "full_numbers", | |
"oLanguage": { | |
"oPaginate": { | |
"sFirst": "unit1", | |
"sPrevious": "test2", | |
"sNext": "unit3", | |
"sLast": "test4" | |
} | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.oPaginate.sFirst == "unit1" && | |
oSettings.oLanguage.oPaginate.sPrevious == "test2" && | |
oSettings.oLanguage.oPaginate.sNext == "unit3" && | |
oSettings.oLanguage.oPaginate.sLast == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnTest( | |
"oLanguage.oPaginate definitions are in the DOM", | |
null, | |
function () { | |
var bReturn = | |
$('#example_paginate .first').html() == "unit1" && | |
$('#example_paginate .previous').html() == "test2" && | |
$('#example_paginate .next').html() == "unit3" && | |
$('#example_paginate .last').html() == "test4"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sInfo" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Info language is 'Showing _START_ to _END_ of _TOTAL_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sInfo == "Showing _START_ to _END_ of _TOTAL_ entries"; } | |
); | |
oTest.fnTest( | |
"Info language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - without any macros", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfo": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfo == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "unit test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macro _START_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfo": "unit _START_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macro _END_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 10 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macro _TOTAL_ only", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfo": "unit _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 57 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macros _START_ and _END_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 test"; } | |
); | |
oTest.fnWaitTest( | |
"Info language can be defined - with macros _START_, _END_ and _TOTAL_", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfo": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "unit 1 10 57 test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sInfoEmpty" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Info empty language is 'Showing 0 to 0 of 0 entries' by default", | |
function () { oTable.fnFilter("nothinghere"); }, | |
function () { return oSettings.oLanguage.sInfoEmpty == "Showing 0 to 0 of 0 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"Showing 0 to 0 of 0 entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Info empty language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfoEmpty": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return oSettings.oLanguage.sInfoEmpty == "unit test"; } | |
); | |
oTest.fnWaitTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit test"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Macro's not replaced", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfoEmpty": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { | |
var bReturn = document.getElementById('example_info').innerHTML.replace( | |
' '+oSettings.oLanguage.sInfoFiltered.replace( '_MAX_', '57' ), "" ) == | |
"unit _START_ _END_ _TOTAL_ test"; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sInfoPostFix" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Info post fix language is '' (blank) by default", | |
null, | |
function () { return oSettings.oLanguage.sInfoPostFix == ""; } | |
); | |
oTest.fnTest( | |
"Width no post fix, the basic info shows", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries"; } | |
); | |
oTest.fnWaitTest( | |
"Info post fix language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sInfoPostFix == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info empty language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit test"; } | |
); | |
oTest.fnWaitTest( | |
"Macros have no effect in the post fix", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfoPostFix": "unit _START_ _END_ _TOTAL_ test" | |
} | |
} ); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 1 to 10 of 57 entries unit _START_ _END_ _TOTAL_ test"; } | |
); | |
oTest.fnWaitTest( | |
"Post fix is applied after fintering info", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sInfoPostFix": "unit test" | |
} | |
} ); | |
oTable.fnFilter("nothinghere"); | |
}, | |
function () { return document.getElementById('example_info').innerHTML = "Showing 0 to 0 of 0 entries unit (filtered from 57 total entries) test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sLengthMenu" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Menu language is 'Show _MENU_ entries' by default", | |
null, | |
function () { return oSettings.oLanguage.sLengthMenu == "Show _MENU_ entries"; } | |
); | |
oTest.fnTest( | |
"_MENU_ macro is replaced by select menu in DOM", | |
null, | |
function () { return $('select', oSettings.aanFeatures.l[0]).length == 1 } | |
); | |
oTest.fnTest( | |
"Default is put into DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "Show " && | |
anChildren[2].nodeValue == " entries"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Menu length language can be defined - no _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sLengthMenu": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sLengthMenu == "unit test"; } | |
); | |
oTest.fnTest( | |
"Menu length language definition is in the DOM", | |
null, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
return anChildren[0].nodeValue == "unit test"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Menu length language can be defined - with _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sLengthMenu": "unit _MENU_ test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren[0].nodeValue == "unit " && | |
anChildren[2].nodeValue == " test"; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Only the _MENU_ macro", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sLengthMenu": "_MENU_" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var anChildren = oSettings.aanFeatures.l[0].childNodes; | |
var bReturn = | |
anChildren.length == 1 && | |
$('select', oSettings.aanFeatures.l[0]).length == 1; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sProcessing" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bProcessing": true | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Processing language is 'Processing...' by default", | |
null, | |
function () { return oSettings.oLanguage.sProcessing == "Processing..."; } | |
); | |
oTest.fnTest( | |
"Processing language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "Processing..."; } | |
); | |
oTest.fnWaitTest( | |
"Processing language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"bProcessing": true, | |
"oLanguage": { | |
"sProcessing": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sProcessing == "unit test"; } | |
); | |
oTest.fnTest( | |
"Processing language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_processing').innerHTML = "unit test"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sSearch" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Search language is 'Search:' by default", | |
null, | |
function () { return oSettings.oLanguage.sSearch == "Search:"; } | |
); | |
oTest.fnTest( | |
"Search language default is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "Search: "; } | |
); | |
oTest.fnWaitTest( | |
"Search language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sSearch": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sSearch == "unit test"; } | |
); | |
oTest.fnTest( | |
"Info language definition is in the DOM", | |
null, | |
function () { return document.getElementById('example_filter').childNodes[0].nodeValue | |
== "unit test "; } | |
); | |
oTest.fnWaitTest( | |
"Blank search has no space (separator) inserted", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sSearch": "" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return document.getElementById('example_filter').childNodes.length == 1; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sUrl" ); | |
/* Note that we only test the internal storage of language information pulled form a file here | |
* as the other language tests will check it goes into the DOM correctly | |
*/ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnTest( | |
"sUrl is blank by default", | |
null, | |
function () { return oSettings.oLanguage.sUrl == ""; } | |
); | |
oTest.fnWaitTest( | |
"Loading of German file loads language information", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sUrl": "../../../examples/examples_support/de_DE.txt" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
var bReturn = | |
oSettings.oLanguage.sProcessing == "Bitte warten..." && | |
oSettings.oLanguage.sLengthMenu == "_MENU_ Einträge anzeigen" && | |
oSettings.oLanguage.sZeroRecords == "Keine Einträge vorhanden." && | |
oSettings.oLanguage.sInfo == "_START_ bis _END_ von _TOTAL_ Einträgen" && | |
oSettings.oLanguage.sInfoEmpty == "0 bis 0 von 0 Einträgen" && | |
oSettings.oLanguage.sInfoFiltered == "(gefiltert von _MAX_ Einträgen)" && | |
oSettings.oLanguage.sInfoPostFix == "" && | |
oSettings.oLanguage.sSearch == "Suchen" && | |
oSettings.oLanguage.oPaginate.sFirst == "Erster" && | |
oSettings.oLanguage.oPaginate.sPrevious == "Zurück" && | |
oSettings.oLanguage.oPaginate.sNext == "Nächster" && | |
oSettings.oLanguage.oPaginate.sLast == "Letzter"; | |
return bReturn; | |
} | |
); | |
/* One DOM check just to ensure that they go into the DOM */ | |
oTest.fnTest( | |
"Loaded language goes into the DOM", | |
null, | |
function () { return document.getElementById('example_info').innerHTML = "1 bis 10 von 57 Einträgen"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oLanguage.sZeroRecords" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Zero records language is 'No matching records found' by default", | |
null, | |
function () { return oSettings.oLanguage.sZeroRecords == "No matching records found"; } | |
); | |
oTest.fnWaitTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere'); }, | |
function () { | |
if ( $('#example tbody tr td').length == 0 ) | |
return false; | |
return $('#example tbody tr td')[0].innerHTML == "No matching records found"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Zero records language can be defined", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oLanguage": { | |
"sZeroRecords": "unit test" | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.oLanguage.sZeroRecords == "unit test"; } | |
); | |
oTest.fnWaitTest( | |
"Text is shown when empty table (after filtering)", | |
function () { oTable.fnFilter('nothinghere2'); }, | |
function () { | |
if ( $('#example tbody tr td').length == 0 ) | |
return false; | |
return $('#example tbody tr td')[0].innerHTML == "unit test" | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "oSearch" ); | |
/* Note with my server-side scripts the regex option has no effect - this just runs that down */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default values should be blank", | |
null, | |
function () { | |
var bReturn = oSettings.oPreviousSearch.sSearch == "" && | |
!oSettings.oPreviousSearch.bRegex; | |
return bReturn; | |
} | |
); | |
/* This test might be considered iffy since the full object isn't given, but it's reasonable to | |
* expect DataTables to cope with this. It should just assumine regex false | |
*/ | |
oTest.fnWaitTest( | |
"Search term only in object", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oSearch": { | |
"sSearch": "Mozilla" | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1"; } | |
); | |
oTest.fnWaitTest( | |
"New search will kill old one", | |
function () { | |
oTable.fnFilter("Opera"); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Opera 7.0"; } | |
); | |
oTest.fnWaitTest( | |
"Search plain text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oSearch": { | |
"sSearch": "DS", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; } | |
); | |
oTest.fnWaitTest( | |
"Search plain text term and escape regex false", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oSearch": { | |
"sSearch": "Opera", | |
"bRegex": true | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Opera 7.0"; } | |
); | |
oTest.fnWaitTest( | |
"Search regex text term and escape regex true", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"oSearch": { | |
"sSearch": "1.*", | |
"bRegex": false | |
} | |
} ); | |
}, | |
function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; } | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "sAjaxSource" ); | |
/* Sanitfy check really - all the other tests blast this */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Server side is off by default", | |
null, | |
function () { | |
return oSettings.sAjaxSource == "../../../examples/examples_support/server_processing.php"; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "sDom" ); | |
/* This is going to be brutal on the browser! There is a lot that can be tested here... */ | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Default DOM varaible", | |
null, | |
function () { return oSettings.sDom == "lfrtip"; } | |
); | |
oTest.fnWaitTest( | |
"Default DOM in document", | |
null, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check example 1 in code propagates", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sDom": '<"wrapper"flipt>' | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { return oSettings.sDom == '<"wrapper"flipt>'; } | |
); | |
oTest.fnWaitTest( | |
"Check example 1 in DOM", | |
null, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var nCustomWrapper = $('div.wrapper')[0]; | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrapper && | |
nNodes[2] == nFilter && | |
nNodes[3] == nLength && | |
nNodes[4] == nInfo && | |
nNodes[5] == nPaging && | |
nNodes[6] == nTable; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check example 2 in DOM", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sDom": '<lf<t>ip>' | |
} ); | |
}, | |
function () { | |
var jqNodes = $('#demo div, #demo table'); | |
var nNodes = []; | |
var nCustomWrappers = [] | |
/* Strip the paging nodes */ | |
for ( var i=0, iLen=jqNodes.length ; i<iLen ; i++ ) | |
{ | |
if ( jqNodes[i].getAttribute('id') != "example_previous" && | |
jqNodes[i].getAttribute('id') != "example_next" ) | |
{ | |
nNodes.push( jqNodes[i] ); | |
} | |
/* Only the two custom divs don't have class names */ | |
if ( !jqNodes[i].getAttribute('class') ) | |
{ | |
nCustomWrappers.push( jqNodes[i] ); | |
} | |
} | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nCustomWrappers[0] && | |
nNodes[2] == nLength && | |
nNodes[3] == nFilter && | |
nNodes[4] == nCustomWrappers[1] && | |
nNodes[5] == nTable && | |
nNodes[6] == nInfo && | |
nNodes[7] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check no length element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sDom": 'frtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
null == nLength && | |
nNodes[1] == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check no filter element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sDom": 'lrtip' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
null == nFilter && | |
nNodes[2] == nTable && | |
nNodes[3] == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
/* Note we don't test for no table as this is not supported (and it would be fairly daft! */ | |
oTest.fnWaitTest( | |
"Check no info element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sDom": 'lfrtp' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
null == nInfo && | |
nNodes[4] == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check no paging element", | |
function () { | |
oSession.fnRestore(); | |
$('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sDom": 'lfrti' | |
} ); | |
}, | |
function () { | |
var nNodes = $('#demo div, #demo table'); | |
var nWrapper = document.getElementById('example_wrapper'); | |
var nLength = document.getElementById('example_length'); | |
var nFilter = document.getElementById('example_filter'); | |
var nInfo = document.getElementById('example_info'); | |
var nPaging = document.getElementById('example_paginate'); | |
var nTable = document.getElementById('example'); | |
var bReturn = | |
nNodes[0] == nWrapper && | |
nNodes[1] == nLength && | |
nNodes[2] == nFilter && | |
nNodes[3] == nTable && | |
nNodes[4] == nInfo && | |
null == nPaging; | |
return bReturn; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
// DATA_TEMPLATE: empty_table | |
oTest.fnStart( "sPaginationType" ); | |
$(document).ready( function () { | |
/* Check the default */ | |
var oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php" | |
} ); | |
var oSettings = oTable.fnSettings(); | |
oTest.fnWaitTest( | |
"Check two button paging is the default", | |
null, | |
function () { return oSettings.sPaginationType == "two_button"; } | |
); | |
oTest.fnWaitTest( | |
"Check class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_two_button'); } | |
); | |
oTest.fnWaitTest( | |
"Two div elements are in the wrapper", | |
null, | |
function () { return $('#example_paginate div').length == 2; } | |
); | |
oTest.fnWaitTest( | |
"We have the previous button", | |
null, | |
function () { return document.getElementById('example_previous'); } | |
); | |
oTest.fnWaitTest( | |
"We have the next button", | |
null, | |
function () { return document.getElementById('example_next'); } | |
); | |
oTest.fnWaitTest( | |
"Previous button is disabled", | |
null, | |
function () { return $('#example_previous').hasClass('paginate_disabled_previous'); } | |
); | |
oTest.fnWaitTest( | |
"Next button is enabled", | |
null, | |
function () { return $('#example_next').hasClass('paginate_enabled_next'); } | |
); | |
/* Don't test paging - that's done by the zero config test script. */ | |
/* Two buttons paging */ | |
var bComplete = false; | |
oTest.fnWaitTest( | |
"Can enabled full numbers paging", | |
function () { | |
oSession.fnRestore(); | |
oTable = $('#example').dataTable( { | |
"bServerSide": true, | |
"sAjaxSource": "../../../examples/examples_support/server_processing.php", | |
"sPaginationType": "full_numbers", | |
"fnInitComplete": function () { | |
setTimeout( function () { | |
bComplete = true; | |
}, 500 ); | |
} | |
} ); | |
oSettings = oTable.fnSettings(); | |
}, | |
function () { | |
if ( bComplete ) | |
return oSettings.sPaginationType == "full_numbers"; | |
else | |
return false; | |
} | |
); | |
oTest.fnWaitTest( | |
"Check full numbers class is applied", | |
null, | |
function () { return $('#example_paginate').hasClass('paging_full_numbers'); } | |
); | |
var nFirst, nPrevious, nNext, nLast; | |
oTest.fnWaitTest( | |
"Jump to last page", | |
function () { | |
nFirst = $('div.dataTables_paginate span.first'); | |
nPrevious = $('div.dataTables_paginate span.previous'); | |
nNext = $('div.dataTables_paginate span.next'); | |
nLast = $('div.dataTables_paginate span.last'); | |
nLast.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Go to two pages previous", | |
function () { | |
nPrevious.click(); | |
nPrevious.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 31 to 40 of 57 entries"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Next (second last) page", | |
function () { | |
nNext.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 41 to 50 of 57 entries"; | |
} | |
); | |
oTest.fnWaitTest( | |
"Jump to first page", | |
function () { | |
nFirst.click(); | |
}, | |
function () { | |
return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; | |
} | |
); | |
oTest.fnComplete(); | |
} ); |
/* | |
* File: unit_test.js | |
* Version: 0.0.1 | |
* CVS: $Id$ | |
* Description: Unit test framework | |
* Author: Allan Jardine (www.sprymedia.co.uk) | |
* Created: Sun Mar 8 22:02:49 GMT 2009 | |
* Modified: $Date$ by $Author$ | |
* Language: Javascript | |
* License: GPL v2 or BSD 3 point style | |
* Project: DataTables | |
* Contact: allan.jardine@sprymedia.co.uk | |
* | |
* Copyright 2009 Allan Jardine, all rights reserved. | |
* | |
* Description: | |
* This is a javascript library suitable for use as a unit testing framework. Employing a queuing | |
* mechanisim to take account of async events in javascript, this library will communicates with | |
* a controller frame (to report individual test status). | |
* | |
*/ | |
var oTest = { | |
/* Block further tests from occuring - might be end of tests or due to async wait */ | |
bBlock: false, | |
/* Number of times to try retesting for a blocking test */ | |
iReTestLimit: 20, | |
/* Amount of time to wait between trying for an async test */ | |
iReTestDelay: 150, | |
/* End tests - external control */ | |
bEnd: false, | |
/* Internal variables */ | |
_aoQueue: [], | |
_iReTest: 0, | |
_bFinished: false, | |
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
* Recommened public functions | |
*/ | |
/* | |
* Function: fnTest | |
* Purpose: Add a test to the queue | |
* Returns: - | |
* Inputs: string:sMessage - name of the test | |
* function:fnTest - function which will be evaludated to get the test result | |
*/ | |
"fnTest": function ( sMessage, fnSetup, fnTest ) | |
{ | |
this._aoQueue.push( { | |
"sMessage": sMessage, | |
"fnSetup": fnSetup, | |
"fnTest": fnTest, | |
"bPoll": false | |
} ); | |
this._fnNext(); | |
}, | |
/* | |
* Function: fnWaitTest | |
* Purpose: Add a test to the queue which has a re-test cycle | |
* Returns: - | |
* Inputs: string:sMessage - name of the test | |
* function:fnTest - function which will be evaludated to get the test result | |
*/ | |
"fnWaitTest": function ( sMessage, fnSetup, fnTest ) | |
{ | |
this._aoQueue.push( { | |
"sMessage": sMessage, | |
"fnSetup": fnSetup, | |
"fnTest": fnTest, | |
"bPoll": true | |
} ); | |
this._fnNext(); | |
}, | |
/* | |
* Function: fnStart | |
* Purpose: Indicate that this is a new unit and what it is testing (message to end user) | |
* Returns: - | |
* Inputs: string:sMessage - message to give to the user about this unit | |
*/ | |
"fnStart": function ( sMessage ) | |
{ | |
window.parent.controller.fnStartMessage( sMessage ); | |
}, | |
/* | |
* Function: fnComplete | |
* Purpose: Tell the controller that we are all done here | |
* Returns: - | |
* Inputs: - | |
*/ | |
"fnComplete": function () | |
{ | |
this._bFinished = true; | |
this._fnNext(); | |
}, | |
/* | |
* Function: fnCookieDestroy | |
* Purpose: Destroy a cookie of a given name | |
* Returns: - | |
* Inputs: - | |
*/ | |
"fnCookieDestroy": function ( oTable ) | |
{ | |
var sName = oTable.fnSettings().sCookiePrefix+oTable.fnSettings().sInstance; | |
var aParts = window.location.pathname.split('/'); | |
var sNameFile = sName + '_' + aParts.pop().replace(/[\/:]/g,"").toLowerCase(); | |
document.cookie = sNameFile+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+ | |
aParts.join('/') + "/"; | |
}, | |
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
* Internal functions | |
*/ | |
"_fnReTest": function ( oTestInfo ) | |
{ | |
var bResult = oTestInfo.fnTest( ); | |
if ( bResult ) | |
{ | |
/* Test passed on retry */ | |
this._fnResult( true ); | |
this._fnNext(); | |
} | |
else | |
{ | |
if ( this._iReTest < this.iReTestLimit ) | |
{ | |
this._iReTest++; | |
setTimeout( function() { | |
oTest._fnReTest( oTestInfo ); | |
}, this.iReTestDelay ); | |
} | |
else | |
{ | |
this._fnResult( false ); | |
} | |
} | |
}, | |
"_fnNext": function () | |
{ | |
if ( this.bEnd ) | |
{ | |
return; | |
} | |
if ( !this.bBlock && this._aoQueue.length > 0 ) | |
{ | |
var oNextTest = this._aoQueue.shift(); | |
window.parent.controller.fnTestStart( oNextTest.sMessage ); | |
this.bBlock = true; | |
if ( typeof oNextTest.fnSetup == 'function' ) | |
{ | |
oNextTest.fnSetup( ); | |
} | |
var bResult = oNextTest.fnTest( ); | |
//bResult = false; | |
if ( oNextTest.bPoll ) | |
{ | |
if ( bResult ) | |
{ | |
this._fnResult( true ); | |
this._fnNext(); | |
} | |
else | |
{ | |
_iReTest = 0; | |
setTimeout( function() { | |
oTest._fnReTest( oNextTest ); | |
}, this.iReTestDelay ); | |
} | |
} | |
else | |
{ | |
this._fnResult( bResult ); | |
this._fnNext(); | |
} | |
} | |
else if ( !this.bBlock && this._aoQueue.length == 0 && this._bFinished ) | |
{ | |
window.parent.controller.fnUnitComplete( ); | |
} | |
}, | |
"_fnResult": function ( b ) | |
{ | |
window.parent.controller.fnTestResult( b ); | |
this.bBlock = false; | |
if ( !b ) | |
{ | |
this.bEnd = true; | |
} | |
} | |
}; | |
var oDispacher = { | |
"click": function ( nNode, oSpecial ) | |
{ | |
var evt = this.fnCreateEvent( 'click', nNode, oSpecial ); | |
if ( nNode.dispatchEvent ) | |
nNode.dispatchEvent(evt); | |
else | |
nNode.fireEvent('onclick', evt); | |
}, | |
"change": function ( nNode ) | |
{ | |
var evt = this.fnCreateEvent( 'change', nNode ); | |
if ( nNode.dispatchEvent ) | |
nNode.dispatchEvent(evt); | |
else | |
nNode.fireEvent('onchange', evt); | |
}, | |
/* | |
* Function: fnCreateEvent | |
* Purpose: Create an event oject based on the type to trigger an event - x-platform | |
* Returns: event:evt | |
* Inputs: string:sType - type of event | |
* node:nTarget - target node of the event | |
*/ | |
fnCreateEvent: function( sType, nTarget, oSpecial ) | |
{ | |
var evt = null; | |
var oTargetPos = this._fnGetPos( nTarget ); | |
var sTypeGroup = this._fnEventTypeGroup( sType ); | |
if ( typeof oSpecial == 'undefined' ) | |
{ | |
oSpecial = {}; | |
} | |
var ctrlKey = false; | |
var altKey = false; | |
var shiftKey = (typeof oSpecial.shift != 'undefined') ? oSpecial.shift : false; | |
var metaKey = false; | |
var button = false; | |
if ( document.createEvent ) | |
{ | |
switch ( sTypeGroup ) | |
{ | |
case 'mouse': | |
evt = document.createEvent( "MouseEvents" ); | |
evt.initMouseEvent( sType, true, true, window, 0, oTargetPos[0], oTargetPos[1], | |
oTargetPos[0], oTargetPos[1], ctrlKey, altKey, shiftKey, | |
metaKey, button, null ); | |
break; | |
case 'html': | |
evt = document.createEvent( "HTMLEvents" ); | |
evt.initEvent( sType, true, true ); | |
break; | |
case 'ui': | |
evt = document.createEvent( "UIEvents" ); | |
evt.initUIEvent( sType, true, true, window, 0 ); | |
break; | |
default: | |
break; | |
} | |
} | |
else if ( document.createEventObject ) | |
{ | |
switch ( sTypeGroup ) | |
{ | |
case 'mouse': | |
evt = document.createEventObject(); | |
evt.screenX = oTargetPos[0]; | |
evt.screenX = oTargetPos[1]; | |
evt.clientX = oTargetPos[0]; | |
evt.clientY = oTargetPos[1]; | |
evt.ctrlKey = ctrlKey; | |
evt.altKey = altKey; | |
evt.shiftKey = shiftKey; | |
evt.metaKey = metaKey; | |
evt.button = button; | |
evt.relatedTarget = null; | |
break; | |
case 'html': | |
/* fall through to basic event object */ | |
case 'ui': | |
evt = document.createEventObject(); | |
break; | |
default: | |
break; | |
} | |
} | |
return evt; | |
}, | |
/* | |
* Function: DesignCore.fnGetPos | |
* Purpose: Get the position of an element on the page | |
* Returns: array[ 0-int:left, 1-int:top ] | |
* Inputs: node:obj - node to analyse | |
*/ | |
_fnGetPos: function ( obj ) | |
{ | |
var curleft = 0; | |
var curtop = 0; | |
if (obj.offsetParent) | |
{ | |
curleft = obj.offsetLeft; | |
curtop = obj.offsetTop; | |
while (obj = obj.offsetParent ) | |
{ | |
curleft += obj.offsetLeft; | |
curtop += obj.offsetTop; | |
} | |
} | |
return [curleft,curtop]; | |
}, | |
/* | |
* Function: _fnEventTypeGroup | |
* Purpose: Group the event types as per w3c groupings | |
* Returns: - | |
* Inputs: string:sType | |
*/ | |
_fnEventTypeGroup: function ( sType ) | |
{ | |
switch ( sType ) | |
{ | |
case 'click': | |
case 'dblclick': | |
case 'mousedown': | |
case 'mousemove': | |
case 'mouseout': | |
case 'mouseover': | |
case 'mouseup': | |
return 'mouse'; | |
case 'change': | |
case 'focus': | |
case 'blur': | |
case 'select': | |
case 'submit': | |
return 'html'; | |
case 'keydown': | |
case 'keypress': | |
case 'keyup': | |
case 'load': | |
case 'unload': | |
return 'ui'; | |
default: | |
return 'custom'; | |
} | |
} | |
} | |
var oSession = { | |
nTable: null, | |
fnCache: function () | |
{ | |
this.nTable = document.getElementById('demo').cloneNode(true); | |
}, | |
fnRestore: function () | |
{ | |
while( $.fn.dataTableSettings.length > 0 ) | |
{ | |
$.fn.dataTableSettings[0].oInstance.fnDestroy(); | |
} | |
//$.fn.dataTableSettings.splice( 0, $.fn.dataTableSettings.length ); | |
var nDemo = document.getElementById('demo'); | |
nDemo.innerHTML = ""; | |
for ( var i=0, iLen=this.nTable.childNodes.length ; i<iLen ; i++ ) | |
{ | |
nDemo.appendChild( this.nTable.childNodes[0] ); | |
} | |
this.fnCache(); | |
} | |
} | |
$(document).ready( function () { | |
oSession.fnCache(); | |
} ); | |