1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-30 23:52:11 +01:00

Merge branch 'master' of github.com:DataTables/DataTables

This commit is contained in:
Allan Jardine 2012-10-07 12:23:07 +01:00
commit 7a388a0a76
5 changed files with 31 additions and 44 deletions

View File

@ -1,5 +1,4 @@
/**
* Provide a common method for plug-ins to check the version of DataTables being used, in order
* to ensure compatibility.
@ -15,25 +14,24 @@
*/
DataTable.fnVersionCheck = function( sVersion )
{
/* This is cheap, but effective */
var fnZPad = function (Zpad, count)
{
while(Zpad.length < count) {
Zpad += '0';
}
return Zpad;
};
var aThis = DataTable.ext.sVersion.split('.');
var aThat = sVersion.split('.');
var sThis = '', sThat = '';
var iThis, sThat;
for ( var i=0, iLen=aThat.length ; i<iLen ; i++ )
{
sThis += fnZPad( aThis[i], 3 );
sThat += fnZPad( aThat[i], 3 );
for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ){
iThis = parseInt( aThis[i], 10 ) || 0;
iThat = parseInt( aThat[i], 10 ) || 0;
// Parts are the same, keep comparing
if (iThis === iThat)
{
continue;
}
// Parts are different, return immediately
return iThis > iThat;
}
return parseInt(sThis, 10) >= parseInt(sThat, 10);
return true;
};

View File

@ -21,10 +21,7 @@ function _fnAjaxUpdate( oSettings )
}, oSettings );
return false;
}
else
{
return true;
}
return true;
}
@ -132,10 +129,7 @@ function _fnAjaxUpdateDraw ( oSettings, json )
{
return;
}
else
{
oSettings.iDraw = json.sEcho * 1;
}
oSettings.iDraw = json.sEcho * 1;
}
if ( !oSettings.oScroll.bInfinite || oSettings.bSorted || oSettings.bFiltered )

View File

@ -380,15 +380,12 @@ function _fnDraw( oSettings )
iRowCount++;
/* If there is an open row - and it is attached to this parent - attach it on redraw */
if ( iOpenRows !== 0 )
for ( var k=0 ; k<iOpenRows ; k++ )
{
for ( var k=0 ; k<iOpenRows ; k++ )
if ( nRow == oSettings.aoOpenRows[k].nParent )
{
if ( nRow == oSettings.aoOpenRows[k].nParent )
{
anRows.push( oSettings.aoOpenRows[k].nTr );
break;
}
anRows.push( oSettings.aoOpenRows[k].nTr );
break;
}
}
}
@ -438,7 +435,7 @@ function _fnDraw( oSettings )
var
nAddFrag = document.createDocumentFragment(),
nRemoveFrag = document.createDocumentFragment(),
nBodyPar, nTrs;
nBodyPar;
if ( oSettings.nTBody )
{

View File

@ -1,4 +1,3 @@
/**
* Generate the node required for the info display
* @param {object} oSettings dataTables settings object
@ -85,8 +84,10 @@ function _fnUpdateInfo ( oSettings )
function _fnInfoMacros ( oSettings, str )
{
// When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
// internally
var
iStart = oSettings._iDisplayStart+1,
iStart = oSettings.oScroll.bInfinite ? 1 : oSettings._iDisplayStart+1,
sStart = oSettings.fnFormatNumber( iStart ),
iEnd = oSettings.fnDisplayEnd(),
sEnd = oSettings.fnFormatNumber( iEnd ),
@ -95,13 +96,6 @@ function _fnInfoMacros ( oSettings, str )
iMax = oSettings.fnRecordsTotal(),
sMax = oSettings.fnFormatNumber( iMax );
// When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
// internally
if ( oSettings.oScroll.bInfinite )
{
sStart = oSettings.fnFormatNumber( 1 );
}
return str.
replace(/_START_/g, sStart).
replace(/_END_/g, sEnd).

View File

@ -1,12 +1,16 @@
$.extend( DataTable.ext.oSort, {
/*
* text sorting
*/
"string-pre": function ( a )
{
if ( typeof a != 'string' ) {
a = (a !== null && a.toString) ? a.toString() : '';
if ( typeof a != 'string' )
{
if (a === null || a === undefined || !a.toString)
{
return '';
}
a = a.toString();
}
return a.toLowerCase();
},