mirror of
https://github.com/DataTables/DataTables.git
synced 2024-11-29 11:24:10 +01:00
New: Support TH elements in the table's TBODY. TH elements are now treated just like TDs in the body. This will work only with DOM sourced data out of the box - any body cell elements that DataTables creates are still TD.
This commit is contained in:
parent
d4b8495378
commit
06d1802874
13
media/js/jquery.dataTables.js
vendored
13
media/js/jquery.dataTables.js
vendored
@ -2781,7 +2781,7 @@
|
||||
{
|
||||
var iLoop, i, iLen, j, jLen, jInner,
|
||||
nTds, nTrs, nTd, aLocalData, iThisIndex,
|
||||
iRow, iRows, iColumn, iColumns;
|
||||
iRow, iRows, iColumn, iColumns, sNodeName;
|
||||
|
||||
/*
|
||||
* Process by row first
|
||||
@ -2810,7 +2810,8 @@
|
||||
|
||||
for ( j=0, jLen=nTds.length ; j<jLen ; j++ )
|
||||
{
|
||||
if ( nTds[j].nodeName.toUpperCase() == "TD" )
|
||||
sNodeName = nTds[j].nodeName.toUpperCase();
|
||||
if ( sNodeName == "TD" || sNodeName == "TH" )
|
||||
{
|
||||
_fnSetCellData( oSettings, iThisIndex, jInner, $.trim(nTds[j].innerHTML) );
|
||||
jInner++;
|
||||
@ -2831,7 +2832,8 @@
|
||||
for ( j=0, jLen=nTrs[i].childNodes.length ; j<jLen ; j++ )
|
||||
{
|
||||
nTd = nTrs[i].childNodes[j];
|
||||
if ( nTd.nodeName.toUpperCase() == "TD" )
|
||||
sNodeName = nTd.nodeName.toUpperCase();
|
||||
if ( sNodeName == "TD" || sNodeName == "TH" )
|
||||
{
|
||||
nTds.push( nTd );
|
||||
}
|
||||
@ -5823,7 +5825,7 @@
|
||||
var iCorrector;
|
||||
var anTds;
|
||||
var iRow, iRows=oSettings.aoData.length,
|
||||
iColumn, iColumns, oData;
|
||||
iColumn, iColumns, oData, sNodeName;
|
||||
|
||||
for ( iRow=0 ; iRow<iRows ; iRow++ )
|
||||
{
|
||||
@ -5834,7 +5836,8 @@
|
||||
anTds = [];
|
||||
for ( iColumn=0, iColumns=oData.nTr.childNodes.length ; iColumn<iColumns ; iColumn++ )
|
||||
{
|
||||
if ( oData.nTr.childNodes[iColumn].nodeName.toLowerCase() == 'td' )
|
||||
sNodeName = oData.nTr.childNodes[iColumn].nodeName.toLowerCase();
|
||||
if ( sNodeName == 'td' || sNodeName == 'th' )
|
||||
{
|
||||
anTds.push( oData.nTr.childNodes[iColumn] );
|
||||
}
|
||||
|
465
media/unit_testing/templates/dom_data_th.php
Normal file
465
media/unit_testing/templates/dom_data_th.php
Normal file
@ -0,0 +1,465 @@
|
||||
<?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 = explode( ":", $_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">
|
||||
<th>Gecko</th>
|
||||
<th>Netscape Navigator 9</th>
|
||||
<th>Win 98+ / OSX.2+</th>
|
||||
<th class="center">1.8</th>
|
||||
<th class="center">A</th>
|
||||
</tr>
|
||||
<tr class="gradeA">
|
||||
<td>Gecko</td>
|
||||
<th>Mozilla 1.0</th>
|
||||
<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>
|
437
media/unit_testing/tests_onhold/1_dom/th_in_body.js
Executable file
437
media/unit_testing/tests_onhold/1_dom/th_in_body.js
Executable file
@ -0,0 +1,437 @@
|
||||
// DATA_TEMPLATE: dom_data_th
|
||||
oTest.fnStart( "Sanity checks for DataTables with DOM data and a TH in the body" );
|
||||
|
||||
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();
|
||||
} );
|
Loading…
Reference in New Issue
Block a user