From 9e6094e792d501c818c3c00695ca7d2026059bfb Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 17 Aug 2010 23:29:12 +0100 Subject: [PATCH] New: Language callback function for the information element. This can be used to customise the language shown in the information element beyond what is possible with the built in language string options (for example plurals). The arguments are fnInfoCallback( oSettings, iStart, iEnd, iMax /*no filter*/, iTotal /*after filter*/, sOut /*DT rendered string*/ ) - 2520 --- media/js/jquery.dataTables.js | 44 +++---- .../tests_onhold/1_dom/fnInfoCallback.js | 115 ++++++++++++++++++ 2 files changed, 138 insertions(+), 21 deletions(-) create mode 100755 media/unit_testing/tests_onhold/1_dom/fnInfoCallback.js diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 097b18c7..5e6fca64 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -967,7 +967,8 @@ "sPrevious": "Previous", "sNext": "Next", "sLast": "Last" - } + }, + "fnInfoCallback": null }; /* @@ -4651,56 +4652,56 @@ return; } - var jqFirst = $(oSettings.aanFeatures.i[0]); var - sMax = oSettings.fnFormatNumber(oSettings.fnRecordsTotal()), - sStart = oSettings.fnFormatNumber(oSettings._iDisplayStart+1), - sEnd = oSettings.fnFormatNumber(oSettings.fnDisplayEnd()), - sTotal = oSettings.fnFormatNumber(oSettings.fnRecordsDisplay()); + iStart = oSettings._iDisplayStart+1, iEnd = oSettings.fnDisplayEnd(), + iMax = oSettings.fnRecordsTotal(), iTotal = oSettings.fnRecordsDisplay(), + sStart = oSettings.fnFormatNumber( iStart ), sEnd = oSettings.fnFormatNumber( iEnd ), + sMax = oSettings.fnFormatNumber( iMax ), sTotal = oSettings.fnFormatNumber( iTotal ), + sOut; if ( oSettings.fnRecordsDisplay() === 0 && oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() ) { /* Empty record set */ - jqFirst.html( oSettings.oLanguage.sInfoEmpty+ oSettings.oLanguage.sInfoPostFix ); + sOut = oSettings.oLanguage.sInfoEmpty+ oSettings.oLanguage.sInfoPostFix; } else if ( oSettings.fnRecordsDisplay() === 0 ) { /* Rmpty record set after filtering */ - jqFirst.html( oSettings.oLanguage.sInfoEmpty +' '+ + sOut = oSettings.oLanguage.sInfoEmpty +' '+ oSettings.oLanguage.sInfoFiltered.replace('_MAX_', sMax)+ - oSettings.oLanguage.sInfoPostFix ); + oSettings.oLanguage.sInfoPostFix; } else if ( oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() ) { /* Normal record set */ - jqFirst.html( oSettings.oLanguage.sInfo. + sOut = oSettings.oLanguage.sInfo. replace('_START_', sStart). replace('_END_', sEnd). replace('_TOTAL_', sTotal)+ - oSettings.oLanguage.sInfoPostFix ); + oSettings.oLanguage.sInfoPostFix; } else { /* Record set after filtering */ - jqFirst.html( oSettings.oLanguage.sInfo. + sOut = oSettings.oLanguage.sInfo. replace('_START_', sStart). replace('_END_', sEnd). replace('_TOTAL_', sTotal) +' '+ oSettings.oLanguage.sInfoFiltered.replace('_MAX_', oSettings.fnFormatNumber(oSettings.fnRecordsTotal()))+ - oSettings.oLanguage.sInfoPostFix ); + oSettings.oLanguage.sInfoPostFix; } - /* No point in recalculating for the other info elements, just copy the first one in */ - var n = oSettings.aanFeatures.i; - if ( n.length > 1 ) + if ( oSettings.oLanguage.fnInfoCallback != null ) { - var sInfo = jqFirst.html(); - for ( var i=1, iLen=n.length ; i