1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

ize - refactor _fnInitialise for size. Only about 60 bytes saved

This commit is contained in:
Allan Jardine 2013-10-11 14:21:49 +01:00
parent 5c0cdd86cd
commit c3a2ad6f40
2 changed files with 48 additions and 52 deletions

View File

@ -1 +1 @@
a0417585115ca4bb8a6675eed7738724432ad032
3818add76a9bf921d51be2488f47e190677f4883

View File

@ -2609,82 +2609,78 @@
/**
* Draw the table for the first time, adding all required features
* @param {object} oSettings dataTables settings object
* @param {object} settings dataTables settings object
* @memberof DataTable#oApi
*/
function _fnInitialise ( oSettings )
function _fnInitialise ( settings )
{
var i, iLen, iAjaxStart=oSettings.iInitDisplayStart;
var i, iLen, iAjaxStart=settings.iInitDisplayStart;
var columns = settings.aoColumn, column;
var features = settings.oFeatures;
/* Ensure that the table data is fully initialised */
if ( oSettings.bInitialised === false )
{
setTimeout( function(){ _fnInitialise( oSettings ); }, 200 );
if ( ! settings.bInitialised ) {
setTimeout( function(){ _fnInitialise( settings ); }, 200 );
return;
}
/* Show the display HTML options */
_fnAddOptionsHtml( oSettings );
_fnAddOptionsHtml( settings );
/* Build and draw the header / footer for the table */
_fnBuildHead( oSettings );
_fnDrawHead( oSettings, oSettings.aoHeader );
_fnDrawHead( oSettings, oSettings.aoFooter );
_fnBuildHead( settings );
_fnDrawHead( settings, settings.aoHeader );
_fnDrawHead( settings, settings.aoFooter );
/* Okay to show that something is going on now */
_fnProcessingDisplay( oSettings, true );
_fnProcessingDisplay( settings, true );
/* Calculate sizes for columns */
if ( oSettings.oFeatures.bAutoWidth )
{
_fnCalculateColumnWidths( oSettings );
if ( features.bAutoWidth ) {
_fnCalculateColumnWidths( settings );
}
for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
{
if ( oSettings.aoColumns[i].sWidth !== null )
{
oSettings.aoColumns[i].nTh.style.width = _fnStringToCss( oSettings.aoColumns[i].sWidth );
for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
column = columns[i];
if ( column.sWidth ) {
column.nTh.style.width = _fnStringToCss( column.sWidth );
}
}
/* If there is default sorting required - let's do it. The sort function will do the
* drawing for us. Otherwise we draw the table regardless of the Ajax source - this allows
* the table to look initialised for Ajax sourcing data (show 'loading' message possibly)
*/
_fnReDraw( oSettings );
// If there is default sorting required - let's do it. The sort function
// will do the drawing for us. Otherwise we draw the table regardless of the
// Ajax source - this allows the table to look initialised for Ajax sourcing
// data (show 'loading' message possibly)
_fnReDraw( settings );
/* if there is an ajax source load the data */
if ( (oSettings.sAjaxSource || oSettings.ajax) && !oSettings.oFeatures.bServerSide )
{
var aoData = [];
_fnBuildAjax( oSettings, [], function(json) {
var aData = _fnAjaxDataSrc( oSettings, json );
// Server-side processing init complete is done by _fnAjaxUpdateDraw
if ( ! features.bServerSide ) {
// if there is an ajax source load the data
if ( settings.sAjaxSource || settings.ajax ) {
_fnBuildAjax( settings, [], function(json) {
var aData = _fnAjaxDataSrc( settings, json );
/* Got the data - add it to the table */
for ( i=0 ; i<aData.length ; i++ )
{
_fnAddData( oSettings, aData[i] );
}
// Got the data - add it to the table
for ( i=0 ; i<aData.length ; i++ ) {
_fnAddData( settings, aData[i] );
}
/* Reset the init display for cookie saving. We've already done a filter, and
* therefore cleared it before. So we need to make it appear 'fresh'
*/
oSettings.iInitDisplayStart = iAjaxStart;
// Reset the init display for cookie saving. We've already done
// a filter, and therefore cleared it before. So we need to make
// it appear 'fresh'
settings.iInitDisplayStart = iAjaxStart;
_fnReDraw( oSettings );
_fnReDraw( settings );
_fnProcessingDisplay( oSettings, false );
_fnInitComplete( oSettings, json );
}, oSettings );
return;
}
/* Server-side processing init complete is done by _fnAjaxUpdateDraw */
if ( !oSettings.oFeatures.bServerSide )
{
_fnProcessingDisplay( oSettings, false );
_fnInitComplete( oSettings );
_fnProcessingDisplay( settings, false );
_fnInitComplete( settings, json );
}, settings );
}
else {
_fnProcessingDisplay( settings, false );
_fnInitComplete( settings );
}
}
}