mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-20 18:54:15 +01:00
Tidy up the constructor to take account of the fact that we now have every possible property in the initalisation objects, since it is being extended from the details - i.e. no need to check for 'undefined' any more.
This commit is contained in:
parent
d20b87f885
commit
dcf88a2609
80
media/js/jquery.dataTables.js
vendored
80
media/js/jquery.dataTables.js
vendored
@ -6341,12 +6341,11 @@
|
||||
/* Base check on table node */
|
||||
if ( _aoSettings[i].nTable == this )
|
||||
{
|
||||
if ( typeof oInit == 'undefined' ||
|
||||
( typeof oInit.bRetrieve != 'undefined' && oInit.bRetrieve === true ) )
|
||||
if ( typeof oInit == 'undefined' || oInit.bRetrieve )
|
||||
{
|
||||
return _aoSettings[i].oInstance;
|
||||
}
|
||||
else if ( typeof oInit.bDestroy != 'undefined' && oInit.bDestroy === true )
|
||||
else if ( oInit.bDestroy )
|
||||
{
|
||||
_aoSettings[i].oInstance.fnDestroy();
|
||||
break;
|
||||
@ -6377,7 +6376,6 @@
|
||||
|
||||
/* Make a complete and independent copy of the settings object */
|
||||
var oSettings = $.extend( true, {}, DataTable.models.oSettings );
|
||||
|
||||
_aoSettings.push( oSettings );
|
||||
|
||||
var bInitHandedOff = false;
|
||||
@ -6424,8 +6422,8 @@
|
||||
oSettings.oInit = oInit;
|
||||
|
||||
oInit = (typeof oInit === 'undefined' || oInit === null) ?
|
||||
$( true, {}, DataTable.models.oInit ) :
|
||||
$( true, {}, DataTable.models.oInit, oInit );
|
||||
$.extend( true, {}, DataTable.models.oInit ) :
|
||||
$.extend( true, {}, DataTable.models.oInit, oInit );
|
||||
|
||||
|
||||
_fnMap( oSettings.oFeatures, oInit, "bPaginate" );
|
||||
@ -6525,7 +6523,7 @@
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof oInit.bJQueryUI != 'undefined' && oInit.bJQueryUI )
|
||||
if ( oInit.bJQueryUI )
|
||||
{
|
||||
/* Use the JUI classes object for display. You could clone the oStdClasses object if
|
||||
* you want to have multiple tables with multiple independent classes
|
||||
@ -6549,8 +6547,7 @@
|
||||
oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
|
||||
}
|
||||
|
||||
if ( typeof oInit.iDisplayStart != 'undefined' &&
|
||||
typeof oSettings.iInitDisplayStart == 'undefined' )
|
||||
if ( typeof oSettings.iInitDisplayStart == 'undefined' )
|
||||
{
|
||||
/* Display start point, taking into account the save saving */
|
||||
oSettings.iInitDisplayStart = oInit.iDisplayStart;
|
||||
@ -6558,9 +6555,9 @@
|
||||
}
|
||||
|
||||
/* Must be done after everything which can be overridden by a cookie! */
|
||||
if ( typeof oInit.bStateSave != 'undefined' )
|
||||
if ( oInit.bStateSave )
|
||||
{
|
||||
oSettings.oFeatures.bStateSave = oInit.bStateSave;
|
||||
oSettings.oFeatures.bStateSave = true;
|
||||
_fnLoadState( oSettings, oInit );
|
||||
oSettings.aoDrawCallback.push( {
|
||||
"fn": _fnSaveState,
|
||||
@ -6568,40 +6565,30 @@
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof oInit.iDeferLoading != 'undefined' )
|
||||
if ( oInit.iDeferLoading !== null )
|
||||
{
|
||||
oSettings.bDeferLoading = true;
|
||||
oSettings._iRecordsTotal = oInit.iDeferLoading;
|
||||
oSettings._iRecordsDisplay = oInit.iDeferLoading;
|
||||
}
|
||||
|
||||
if ( typeof oInit.aaData != 'undefined' )
|
||||
if ( oInit.aaData !== null )
|
||||
{
|
||||
bUsePassedData = true;
|
||||
}
|
||||
|
||||
/* Backwards compatability */
|
||||
/* aoColumns / aoData - remove at some point... */
|
||||
if ( typeof oInit != 'undefined' && typeof oInit.aoData != 'undefined' )
|
||||
{
|
||||
oInit.aoColumns = oInit.aoData;
|
||||
}
|
||||
|
||||
/* Language definitions */
|
||||
if ( typeof oInit.oLanguage != 'undefined' )
|
||||
if ( oInit.oLanguage.sUrl !== "" )
|
||||
{
|
||||
if ( typeof oInit.oLanguage.sUrl != 'undefined' && oInit.oLanguage.sUrl !== "" )
|
||||
{
|
||||
/* Get the language definitions from a file */
|
||||
oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
|
||||
$.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
|
||||
_fnLanguageProcess( oSettings, json, true ); } );
|
||||
bInitHandedOff = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fnLanguageProcess( oSettings, oInit.oLanguage, false );
|
||||
}
|
||||
/* Get the language definitions from a file */
|
||||
oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
|
||||
$.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
|
||||
_fnLanguageProcess( oSettings, json, true ); } );
|
||||
bInitHandedOff = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fnLanguageProcess( oSettings, oInit.oLanguage, false );
|
||||
}
|
||||
/* Warning: The _fnLanguageProcess function is async to the remainder of this function due
|
||||
* to the XHR. We use _bInitialised in _fnLanguageProcess() to check this the processing
|
||||
@ -6610,21 +6597,9 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Stripes
|
||||
* Add the stripe classes now that we know which classes to apply - unless overruled
|
||||
*/
|
||||
console.log( oSettings.oClasses, DataTable.models );
|
||||
if ( typeof oInit.asStripClasses == 'undefined' &&
|
||||
typeof oInit.asStripeClasses == 'undefined' )
|
||||
{
|
||||
oSettings.asStripeClasses.push( oSettings.oClasses.sStripeOdd );
|
||||
oSettings.asStripeClasses.push( oSettings.oClasses.sStripeEven );
|
||||
}
|
||||
|
||||
/* Remove row stripe classes if they are already on the table row */
|
||||
var bStripeRemove = false;
|
||||
@ -6662,6 +6637,7 @@
|
||||
anRows.removeClass( oSettings.asStripeClasses.join(' ') );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Columns
|
||||
* See if we should load columns automatically or use defined ones
|
||||
@ -6676,7 +6652,7 @@
|
||||
}
|
||||
|
||||
/* If not given a column array, generate one with nulls */
|
||||
if ( typeof oInit.aoColumns == 'undefined' )
|
||||
if ( oInit.aoColumns === null )
|
||||
{
|
||||
aoColumnsInit = [];
|
||||
for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
|
||||
@ -6706,7 +6682,7 @@
|
||||
}
|
||||
|
||||
/* Add options from column definations */
|
||||
if ( typeof oInit.aoColumnDefs != 'undefined' )
|
||||
if ( oInit.aoColumnDefs !== null )
|
||||
{
|
||||
/* Loop over the column defs array - loop in reverse so first instace has priority */
|
||||
for ( i=oInit.aoColumnDefs.length-1 ; i>=0 ; i-- )
|
||||
@ -6762,6 +6738,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sorting
|
||||
* Check the aaSorting array
|
||||
@ -6803,6 +6780,7 @@
|
||||
*/
|
||||
_fnSortingClasses( oSettings );
|
||||
|
||||
|
||||
/*
|
||||
* Final init
|
||||
* Cache the header, body and footer as required, creating them if needed
|
||||
@ -7045,7 +7023,7 @@
|
||||
* "sSearch" and "bEscapeRegex" (the latter is optional). 'null' is also
|
||||
* accepted and the default will be used.
|
||||
* @type array
|
||||
* @default null
|
||||
* @default []
|
||||
*
|
||||
* @example
|
||||
* $(document).ready( function() {
|
||||
@ -7059,7 +7037,7 @@
|
||||
* } );
|
||||
* } )
|
||||
*/
|
||||
"aoSearchCols": null,
|
||||
"aoSearchCols": [],
|
||||
|
||||
|
||||
/**
|
||||
@ -7072,11 +7050,11 @@
|
||||
* @example
|
||||
* $(document).ready( function() {
|
||||
* $('#example').dataTable( {
|
||||
* "asStripClasses": [ 'strip1', 'strip2', 'strip3' ]
|
||||
* "asStripeClasses": [ 'strip1', 'strip2', 'strip3' ]
|
||||
* } );
|
||||
* } )
|
||||
*/
|
||||
"asStripClasses": [ 'odd', 'even' ],
|
||||
"asStripeClasses": [ 'odd', 'even' ],
|
||||
|
||||
|
||||
/**
|
||||
|
@ -7,12 +7,11 @@ for ( i=0, iLen=_aoSettings.length ; i<iLen ; i++ )
|
||||
/* Base check on table node */
|
||||
if ( _aoSettings[i].nTable == this )
|
||||
{
|
||||
if ( typeof oInit == 'undefined' ||
|
||||
( typeof oInit.bRetrieve != 'undefined' && oInit.bRetrieve === true ) )
|
||||
if ( typeof oInit == 'undefined' || oInit.bRetrieve )
|
||||
{
|
||||
return _aoSettings[i].oInstance;
|
||||
}
|
||||
else if ( typeof oInit.bDestroy != 'undefined' && oInit.bDestroy === true )
|
||||
else if ( oInit.bDestroy )
|
||||
{
|
||||
_aoSettings[i].oInstance.fnDestroy();
|
||||
break;
|
||||
@ -43,7 +42,6 @@ for ( i=0, iLen=_aoSettings.length ; i<iLen ; i++ )
|
||||
|
||||
/* Make a complete and independent copy of the settings object */
|
||||
var oSettings = $.extend( true, {}, DataTable.models.oSettings );
|
||||
|
||||
_aoSettings.push( oSettings );
|
||||
|
||||
var bInitHandedOff = false;
|
||||
@ -90,8 +88,8 @@ oSettings.sDestroyWidth = $(this).width();
|
||||
oSettings.oInit = oInit;
|
||||
|
||||
oInit = (typeof oInit === 'undefined' || oInit === null) ?
|
||||
$( true, {}, DataTable.models.oInit ) :
|
||||
$( true, {}, DataTable.models.oInit, oInit );
|
||||
$.extend( true, {}, DataTable.models.oInit ) :
|
||||
$.extend( true, {}, DataTable.models.oInit, oInit );
|
||||
|
||||
|
||||
_fnMap( oSettings.oFeatures, oInit, "bPaginate" );
|
||||
@ -191,7 +189,7 @@ else if ( oSettings.oFeatures.bDeferRender )
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof oInit.bJQueryUI != 'undefined' && oInit.bJQueryUI )
|
||||
if ( oInit.bJQueryUI )
|
||||
{
|
||||
/* Use the JUI classes object for display. You could clone the oStdClasses object if
|
||||
* you want to have multiple tables with multiple independent classes
|
||||
@ -215,8 +213,7 @@ if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
|
||||
oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
|
||||
}
|
||||
|
||||
if ( typeof oInit.iDisplayStart != 'undefined' &&
|
||||
typeof oSettings.iInitDisplayStart == 'undefined' )
|
||||
if ( typeof oSettings.iInitDisplayStart == 'undefined' )
|
||||
{
|
||||
/* Display start point, taking into account the save saving */
|
||||
oSettings.iInitDisplayStart = oInit.iDisplayStart;
|
||||
@ -224,9 +221,9 @@ if ( typeof oInit.iDisplayStart != 'undefined' &&
|
||||
}
|
||||
|
||||
/* Must be done after everything which can be overridden by a cookie! */
|
||||
if ( typeof oInit.bStateSave != 'undefined' )
|
||||
if ( oInit.bStateSave )
|
||||
{
|
||||
oSettings.oFeatures.bStateSave = oInit.bStateSave;
|
||||
oSettings.oFeatures.bStateSave = true;
|
||||
_fnLoadState( oSettings, oInit );
|
||||
oSettings.aoDrawCallback.push( {
|
||||
"fn": _fnSaveState,
|
||||
@ -234,40 +231,30 @@ if ( typeof oInit.bStateSave != 'undefined' )
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof oInit.iDeferLoading != 'undefined' )
|
||||
if ( oInit.iDeferLoading !== null )
|
||||
{
|
||||
oSettings.bDeferLoading = true;
|
||||
oSettings._iRecordsTotal = oInit.iDeferLoading;
|
||||
oSettings._iRecordsDisplay = oInit.iDeferLoading;
|
||||
}
|
||||
|
||||
if ( typeof oInit.aaData != 'undefined' )
|
||||
if ( oInit.aaData !== null )
|
||||
{
|
||||
bUsePassedData = true;
|
||||
}
|
||||
|
||||
/* Backwards compatability */
|
||||
/* aoColumns / aoData - remove at some point... */
|
||||
if ( typeof oInit != 'undefined' && typeof oInit.aoData != 'undefined' )
|
||||
{
|
||||
oInit.aoColumns = oInit.aoData;
|
||||
}
|
||||
|
||||
/* Language definitions */
|
||||
if ( typeof oInit.oLanguage != 'undefined' )
|
||||
if ( oInit.oLanguage.sUrl !== "" )
|
||||
{
|
||||
if ( typeof oInit.oLanguage.sUrl != 'undefined' && oInit.oLanguage.sUrl !== "" )
|
||||
{
|
||||
/* Get the language definitions from a file */
|
||||
oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
|
||||
$.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
|
||||
_fnLanguageProcess( oSettings, json, true ); } );
|
||||
bInitHandedOff = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fnLanguageProcess( oSettings, oInit.oLanguage, false );
|
||||
}
|
||||
/* Get the language definitions from a file */
|
||||
oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
|
||||
$.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
|
||||
_fnLanguageProcess( oSettings, json, true ); } );
|
||||
bInitHandedOff = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_fnLanguageProcess( oSettings, oInit.oLanguage, false );
|
||||
}
|
||||
/* Warning: The _fnLanguageProcess function is async to the remainder of this function due
|
||||
* to the XHR. We use _bInitialised in _fnLanguageProcess() to check this the processing
|
||||
@ -276,20 +263,9 @@ if ( typeof oInit.oLanguage != 'undefined' )
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Stripes
|
||||
* Add the stripe classes now that we know which classes to apply - unless overruled
|
||||
*/
|
||||
if ( typeof oInit.asStripClasses == 'undefined' &&
|
||||
typeof oInit.asStripeClasses == 'undefined' )
|
||||
{
|
||||
oSettings.asStripeClasses.push( oSettings.oClasses.sStripeOdd );
|
||||
oSettings.asStripeClasses.push( oSettings.oClasses.sStripeEven );
|
||||
}
|
||||
|
||||
/* Remove row stripe classes if they are already on the table row */
|
||||
var bStripeRemove = false;
|
||||
@ -327,6 +303,7 @@ if ( bStripeRemove )
|
||||
anRows.removeClass( oSettings.asStripeClasses.join(' ') );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Columns
|
||||
* See if we should load columns automatically or use defined ones
|
||||
@ -341,7 +318,7 @@ if ( nThead.length !== 0 )
|
||||
}
|
||||
|
||||
/* If not given a column array, generate one with nulls */
|
||||
if ( typeof oInit.aoColumns == 'undefined' )
|
||||
if ( oInit.aoColumns === null )
|
||||
{
|
||||
aoColumnsInit = [];
|
||||
for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
|
||||
@ -371,7 +348,7 @@ for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
|
||||
}
|
||||
|
||||
/* Add options from column definations */
|
||||
if ( typeof oInit.aoColumnDefs != 'undefined' )
|
||||
if ( oInit.aoColumnDefs !== null )
|
||||
{
|
||||
/* Loop over the column defs array - loop in reverse so first instace has priority */
|
||||
for ( i=oInit.aoColumnDefs.length-1 ; i>=0 ; i-- )
|
||||
@ -427,6 +404,7 @@ if ( typeof aoColumnsInit != 'undefined' )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sorting
|
||||
* Check the aaSorting array
|
||||
@ -468,6 +446,7 @@ for ( i=0, iLen=oSettings.aaSorting.length ; i<iLen ; i++ )
|
||||
*/
|
||||
_fnSortingClasses( oSettings );
|
||||
|
||||
|
||||
/*
|
||||
* Final init
|
||||
* Cache the header, body and footer as required, creating them if needed
|
||||
|
@ -182,7 +182,7 @@ DataTable.models.oInit = {
|
||||
* "sSearch" and "bEscapeRegex" (the latter is optional). 'null' is also
|
||||
* accepted and the default will be used.
|
||||
* @type array
|
||||
* @default null
|
||||
* @default []
|
||||
*
|
||||
* @example
|
||||
* $(document).ready( function() {
|
||||
@ -196,7 +196,7 @@ DataTable.models.oInit = {
|
||||
* } );
|
||||
* } )
|
||||
*/
|
||||
"aoSearchCols": null,
|
||||
"aoSearchCols": [],
|
||||
|
||||
|
||||
/**
|
||||
@ -209,11 +209,11 @@ DataTable.models.oInit = {
|
||||
* @example
|
||||
* $(document).ready( function() {
|
||||
* $('#example').dataTable( {
|
||||
* "asStripClasses": [ 'strip1', 'strip2', 'strip3' ]
|
||||
* "asStripeClasses": [ 'strip1', 'strip2', 'strip3' ]
|
||||
* } );
|
||||
* } )
|
||||
*/
|
||||
"asStripClasses": [ 'odd', 'even' ],
|
||||
"asStripeClasses": [ 'odd', 'even' ],
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user