1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-19 17:54:14 +01:00

New: Add no-footer class to the wrapper element when the table has no

footer

Update: Update CSS to display the table border properly when there is no
footer when scrolling

Dev: Update the _fnAddOptionsHtml function to be smaller in code size.
Identical functionality, just smaller code
This commit is contained in:
Allan Jardine 2014-01-31 14:15:51 +00:00
parent 9486f3ea02
commit 2d3c29a9d5
3 changed files with 50 additions and 56 deletions

View File

@ -1 +1 @@
dcfefb9ec6d6d94c9bf758a1d24f76368c2a8340
5d035215dcd0b65bde70c00de28bcbc3154bb447

View File

@ -349,16 +349,18 @@ table.dataTable td {
}
.dataTables_wrapper .dataTables_scroll {
clear: both;
border-bottom: 1px solid #111111;
}
.dataTables_wrapper .dataTables_scroll div.dataTables_scrollHead table.no-footer,
.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody table.no-footer {
border-bottom: none;
}
.dataTables_wrapper .dataTables_scrollBody {
.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody {
*margin-top: -1px;
-webkit-overflow-scrolling: touch;
}
.dataTables_wrapper.no-footer .dataTables_scrollBody {
border-bottom: 1px solid #111111;
}
.dataTables_wrapper.no-footer div.dataTables_scrollHead table,
.dataTables_wrapper.no-footer div.dataTables_scrollBody table {
border-bottom: none;
}
.dataTables_wrapper:after {
visibility: hidden;
display: block;

View File

@ -1938,34 +1938,33 @@
*/
function _fnAddOptionsHtml ( oSettings )
{
/*
* Create a temporary, empty, div which we can later on replace with what we have generated
* we do it this way to rendering the 'options' html offline - speed :-)
*/
var nHolding = $('<div></div>')[0];
oSettings.nTable.parentNode.insertBefore( nHolding, oSettings.nTable );
var classes = oSettings.oClasses;
var table = $(oSettings.nTable);
var holding = $('<div/>').insertBefore( table ); // Holding element for speed
var features = oSettings.oFeatures;
/*
* All DataTables are wrapped in a div
*/
oSettings.nTableWrapper = $('<div id="'+oSettings.sTableId+'_wrapper" class="'+oSettings.oClasses.sWrapper+'" role="grid"></div>')[0];
// All DataTables are wrapped in a div
var insert = $('<div/>', {
role: 'grid',
id: oSettings.sTableId+'_wrapper',
'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
} );
oSettings.nTableWrapper = insert[0];
oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
/* Track where we want to insert the option */
var nInsertNode = oSettings.nTableWrapper;
/* Loop over the user set positioning and place the elements as needed */
var aDom = oSettings.sDom.split('');
var nTmp, iPushFeature, cOption, nNewNode, cNext, sAttr, j;
var featureNode, cOption, nNewNode, cNext, sAttr, j;
for ( var i=0 ; i<aDom.length ; i++ )
{
iPushFeature = 0;
featureNode = null;
cOption = aDom[i];
if ( cOption == '<' )
{
/* New container div */
nNewNode = $('<div></div>')[0];
nNewNode = $('<div/>')[0];
/* Check to see if we should append an id and/or a class name to the container */
cNext = aDom[i+1];
@ -1982,11 +1981,11 @@
/* Replace jQuery UI constants @todo depreciated */
if ( sAttr == "H" )
{
sAttr = oSettings.oClasses.sJUIHeader;
sAttr = classes.sJUIHeader;
}
else if ( sAttr == "F" )
{
sAttr = oSettings.oClasses.sJUIFooter;
sAttr = classes.sJUIFooter;
}
/* The attribute can be in the format of "#id.class", "#id" or "class" This logic
@ -2010,50 +2009,44 @@
i += j; /* Move along the position array */
}
nInsertNode.appendChild( nNewNode );
nInsertNode = nNewNode;
insert.append( nNewNode );
insert = $(nNewNode);
}
else if ( cOption == '>' )
{
/* End container div */
nInsertNode = nInsertNode.parentNode;
insert = insert.parent();
}
// @todo Move options into their own plugins?
else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange )
else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
{
/* Length */
nTmp = _fnFeatureHtmlLength( oSettings );
iPushFeature = 1;
featureNode = _fnFeatureHtmlLength( oSettings );
}
else if ( cOption == 'f' && oSettings.oFeatures.bFilter )
else if ( cOption == 'f' && features.bFilter )
{
/* Filter */
nTmp = _fnFeatureHtmlFilter( oSettings );
iPushFeature = 1;
featureNode = _fnFeatureHtmlFilter( oSettings );
}
else if ( cOption == 'r' && oSettings.oFeatures.bProcessing )
else if ( cOption == 'r' && features.bProcessing )
{
/* pRocessing */
nTmp = _fnFeatureHtmlProcessing( oSettings );
iPushFeature = 1;
featureNode = _fnFeatureHtmlProcessing( oSettings );
}
else if ( cOption == 't' )
{
/* Table */
nTmp = _fnFeatureHtmlTable( oSettings );
iPushFeature = 1;
featureNode = _fnFeatureHtmlTable( oSettings );
}
else if ( cOption == 'i' && oSettings.oFeatures.bInfo )
else if ( cOption == 'i' && features.bInfo )
{
/* Info */
nTmp = _fnFeatureHtmlInfo( oSettings );
iPushFeature = 1;
featureNode = _fnFeatureHtmlInfo( oSettings );
}
else if ( cOption == 'p' && oSettings.oFeatures.bPaginate )
else if ( cOption == 'p' && features.bPaginate )
{
/* Pagination */
nTmp = _fnFeatureHtmlPaginate( oSettings );
iPushFeature = 1;
featureNode = _fnFeatureHtmlPaginate( oSettings );
}
else if ( DataTable.ext.feature.length !== 0 )
{
@ -2063,30 +2056,29 @@
{
if ( cOption == aoFeatures[k].cFeature )
{
nTmp = aoFeatures[k].fnInit( oSettings );
if ( nTmp )
{
iPushFeature = 1;
}
featureNode = aoFeatures[k].fnInit( oSettings );
break;
}
}
}
/* Add to the 2D features array */
if ( iPushFeature == 1 && nTmp !== null )
if ( featureNode )
{
if ( typeof oSettings.aanFeatures[cOption] !== 'object' )
var aanFeatures = oSettings.aanFeatures;
if ( ! aanFeatures[cOption] )
{
oSettings.aanFeatures[cOption] = [];
aanFeatures[cOption] = [];
}
oSettings.aanFeatures[cOption].push( nTmp );
nInsertNode.appendChild( nTmp );
aanFeatures[cOption].push( featureNode );
insert.append( featureNode );
}
}
/* Built our DOM structure - replace the holding div with what we want */
nHolding.parentNode.replaceChild( oSettings.nTableWrapper, nHolding );
holding.replaceWith( insert );
}