Major update to doc comment formatting for new DataTables web-site

Also correct a load of JS errors such as leaking variables and use
consistent formatting.
pull/40/head
Allan Jardine 11 years ago
parent 0ab60d10ee
commit 4f29d7fda6

@ -1,6 +1,8 @@
/** /**
* Average the values in a data set. * Average the values in a data set.
*
* @name average() * @name average()
* @summary
* @author [Allan Jardine](http://sprymedia.co.uk) * @author [Allan Jardine](http://sprymedia.co.uk)
* @requires DataTables 1.10+ * @requires DataTables 1.10+
* *

@ -6,9 +6,10 @@
* This function is a drop in replacement for fnAddData with one important * This function is a drop in replacement for fnAddData with one important
* exception, it will only take a 1D array or an object, and not a 2D array * exception, it will only take a 1D array or an object, and not a 2D array
* (i.e. it will not add multiple rows like fnAddData). * (i.e. it will not add multiple rows like fnAddData).
*
* @name fnAddDataAndDisplay * @name fnAddDataAndDisplay
* @anchor fnAddDataAndDisplay * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -17,7 +18,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnAddDataAndDisplay = function ( oSettings, aData ) jQuery.fn.dataTableExt.oApi.fnAddDataAndDisplay = function ( oSettings, aData )
{ {
/* Add the data */ /* Add the data */
var iAdded = this.oApi._fnAddData( oSettings, aData ); var iAdded = this.oApi._fnAddData( oSettings, aData );

@ -1,15 +1,16 @@
/** /**
* Take a TR element and add it to a DataTables table. Useful for maintaining * Take a TR element and add it to a DataTables table. Useful for maintaining
* custom classes and other attributes. * custom classes and other attributes.
*
* @name fnAddTr * @name fnAddTr
* @anchor fnAddTr * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* *
*/ */
$.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) { jQuery.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) {
if ( typeof bRedraw == 'undefined' ) if ( typeof bRedraw == 'undefined' )
{ {
bRedraw = true; bRedraw = true;
@ -24,7 +25,8 @@ $.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) {
var aData = []; var aData = [];
var aInvisible = []; var aInvisible = [];
for ( var i=0 ; i<nTds.length ; i++ ) var i;
for ( i=0 ; i<nTds.length ; i++ )
{ {
aData.push( nTds[i].innerHTML ); aData.push( nTds[i].innerHTML );
if (!oSettings.aoColumns[i].bVisible) if (!oSettings.aoColumns[i].bVisible)
@ -41,7 +43,7 @@ $.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) {
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(); oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
// Hidding invisible columns // Hidding invisible columns
for ( var i = (aInvisible.length - 1) ; i >= 0 ; i-- ) for ( i = (aInvisible.length - 1) ; i >= 0 ; i-- )
{ {
oSettings.aoData[iIndex]._anHidden[ i ] = nTds[aInvisible[i]]; oSettings.aoData[iIndex]._anHidden[ i ] = nTds[aInvisible[i]];
nTr.removeChild( nTds[aInvisible[i]] ); nTr.removeChild( nTds[aInvisible[i]] );

@ -4,9 +4,10 @@
* index value for the column positions. This function converts the data * index value for the column positions. This function converts the data
* column index (i.e. all columns regardless of visibility) into a visible * column index (i.e. all columns regardless of visibility) into a visible
* column index. * column index.
*
* @name fnColumnIndexToVisible * @name fnColumnIndexToVisible
* @anchor fnColumnIndexToVisible * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* *

@ -1,18 +1,19 @@
/** /**
* Update the internal data for a TR element based on what is used in the * Update the internal data for a TR element based on what is used in the
* DOM. You will likely want to call fnDraw() after this function. * DOM. You will likely want to call fnDraw() after this function.
*
* @name fnDataUpdate * @name fnDataUpdate
* @anchor fnDataUpdate * @summary
* @author Lior Gerson * @author Lior Gerson
* *
* @example * @example
* *
*/ */
$.fn.dataTableExt.oApi.fnDataUpdate = function ( oSettings, nRowObject, iRowIndex ) jQuery.fn.dataTableExt.oApi.fnDataUpdate = function ( oSettings, nRowObject, iRowIndex )
{ {
$(nRowObject).find("TD").each( function(i) { jQuery(nRowObject).find("TD").each( function(i) {
var iColIndex = oSettings.oApi._fnVisibleToColumnIndex( oSettings, i ); var iColIndex = oSettings.oApi._fnVisibleToColumnIndex( oSettings, i );
oSettings.oApi._fnSetCellData( oSettings, iRowIndex, iColIndex, $(this).html() ); oSettings.oApi._fnSetCellData( oSettings, iRowIndex, iColIndex, jQuery(this).html() );
} ); } );
}; };

@ -1,8 +1,9 @@
/** /**
* Take a TR element and alter the table's paging to show the TR in question. * Take a TR element and alter the table's paging to show the TR in question.
*
* @name fnDisplayRow * @name fnDisplayRow
* @anchor fnDisplayRow * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -12,7 +13,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnDisplayRow = function ( oSettings, nRow ) jQuery.fn.dataTableExt.oApi.fnDisplayRow = function ( oSettings, nRow )
{ {
// Account for the "display" all case - row is already displayed // Account for the "display" all case - row is already displayed
if ( oSettings._iDisplayLength == -1 ) if ( oSettings._iDisplayLength == -1 )

@ -1,15 +1,16 @@
/** /**
* Set the point at which DataTables will start it's display of data in the * Set the point at which DataTables will start it's display of data in the
* table. * table.
*
* @name fnDisplayStart * @name fnDisplayStart
* @anchor fnDisplayStart * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* *
*/ */
$.fn.dataTableExt.oApi.fnDisplayStart = function ( oSettings, iStart, bRedraw ) jQuery.fn.dataTableExt.oApi.fnDisplayStart = function ( oSettings, iStart, bRedraw )
{ {
if ( typeof bRedraw == 'undefined' ) if ( typeof bRedraw == 'undefined' )
{ {

@ -1,17 +1,18 @@
/** /**
* Creates rowspan cells in a column when there are two or more cells in a * Creates rowspan cells in a column when there are two or more cells in a
* row with the same content, effectively grouping them together visually. * row with the same content, effectively grouping them together visually.
* <b>Note</b> - this plug-in currently only operates correctly with * *Note* - this plug-in currently only operates correctly with
* <b>server-side processing</b>. * *server-side processing*.
*
* @name fnFakeRowspan * @name fnFakeRowspan
* @anchor fnFakeRowspan * @summary
* @author Fredrik Wendel * @author Fredrik Wendel
* *
* @example * @example
* $('#example').dataTable().fnFakeRowspan(3); * $('#example').dataTable().fnFakeRowspan(3);
*/ */
$.fn.dataTableExt.oApi.fnFakeRowspan = function ( oSettings, iColumn, bCaseSensitive ) { jQuery.fn.dataTableExt.oApi.fnFakeRowspan = function ( oSettings, iColumn, bCaseSensitive ) {
/* Fail silently on missing/errorenous parameter data. */ /* Fail silently on missing/errorenous parameter data. */
if (isNaN(iColumn)) { if (isNaN(iColumn)) {
return false; return false;
@ -22,12 +23,8 @@ $.fn.dataTableExt.oApi.fnFakeRowspan = function ( oSettings, iColumn, bCaseSensi
return false; return false;
} }
var oSettings = oSettings,
iColumn = iColumn,
bCaseSensitive = (typeof(bCaseSensitive) != 'boolean' ? true : bCaseSensitive); bCaseSensitive = (typeof(bCaseSensitive) != 'boolean' ? true : bCaseSensitive);
oSettings.aoDrawCallback.push({ "fn": fakeRowspan, "sName": "fnFakeRowspan" });
function fakeRowspan () { function fakeRowspan () {
var firstOccurance = null, var firstOccurance = null,
value = null, value = null,
@ -57,5 +54,7 @@ $.fn.dataTableExt.oApi.fnFakeRowspan = function ( oSettings, iColumn, bCaseSensi
}); });
} }
oSettings.aoDrawCallback.push({ "fn": fakeRowspan, "sName": "fnFakeRowspan" });
return this; return this;
}; };

@ -2,9 +2,10 @@
* Apply the same filter to all DataTable instances on a particular page. The * Apply the same filter to all DataTable instances on a particular page. The
* function call exactly matches that used by fnFilter() so regular expression * function call exactly matches that used by fnFilter() so regular expression
* and individual column sorting can be used. * and individual column sorting can be used.
*
* @name fnFilterAll * @name fnFilterAll
* @anchor fnFilterAll * @summary
* @author <a href="http://www.kmmtiming.se/">Kristoffer Karlström</a> * @author [Kristoffer Karlström](http://www.kmmtiming.se/)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -17,7 +18,7 @@
* }); * });
*/ */
$.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, bRegex, bSmart) { jQuery.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, bRegex, bSmart) {
var settings = $.fn.dataTableSettings; var settings = $.fn.dataTableSettings;
for ( var i=0 ; i<settings.length ; i++ ) { for ( var i=0 ; i<settings.length ; i++ ) {

@ -1,9 +1,10 @@
/** /**
* Remove all filtering that has been applied to a DataTable, be it column * Remove all filtering that has been applied to a DataTable, be it column
* based filtering or global filtering. * based filtering or global filtering.
*
* @name fnFilterClear * @name fnFilterClear
* @anchor fnFilterClear * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -18,8 +19,10 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnFilterClear = function ( oSettings ) jQuery.fn.dataTableExt.oApi.fnFilterClear = function ( oSettings )
{ {
var i, iLen;
/* Remove global filter */ /* Remove global filter */
oSettings.oPreviousSearch.sSearch = ""; oSettings.oPreviousSearch.sSearch = "";
@ -27,7 +30,7 @@ $.fn.dataTableExt.oApi.fnFilterClear = function ( oSettings )
if ( typeof oSettings.aanFeatures.f != 'undefined' ) if ( typeof oSettings.aanFeatures.f != 'undefined' )
{ {
var n = oSettings.aanFeatures.f; var n = oSettings.aanFeatures.f;
for ( var i=0, iLen=n.length ; i<iLen ; i++ ) for ( i=0, iLen=n.length ; i<iLen ; i++ )
{ {
$('input', n[i]).val( '' ); $('input', n[i]).val( '' );
} }
@ -36,7 +39,7 @@ $.fn.dataTableExt.oApi.fnFilterClear = function ( oSettings )
/* Remove the search text for the column filters - NOTE - if you have input boxes for these /* Remove the search text for the column filters - NOTE - if you have input boxes for these
* filters, these will need to be reset * filters, these will need to be reset
*/ */
for ( var i=0, iLen=oSettings.aoPreSearchCols.length ; i<iLen ; i++ ) for ( i=0, iLen=oSettings.aoPreSearchCols.length ; i<iLen ; i++ )
{ {
oSettings.aoPreSearchCols[i].sSearch = ""; oSettings.aoPreSearchCols[i].sSearch = "";
} }

@ -2,9 +2,10 @@
* This plug-in removed the default behaviour of DataTables to filter on each * This plug-in removed the default behaviour of DataTables to filter on each
* keypress, and replaces with it the requirement to press the enter key to * keypress, and replaces with it the requirement to press the enter key to
* perform the filter. * perform the filter.
*
* @name fnFilterOnReturn * @name fnFilterOnReturn
* @anchor fnFilterOnReturn * @summary
* @author <a href="http://www.mvccms.com/">Jon Ranes</a> * @author [Jon Ranes](http://www.mvccms.com/)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {

@ -3,9 +3,10 @@
* can be restricted to a single column). The return value is an array with * can be restricted to a single column). The return value is an array with
* the data indexes (from DataTables' internal data store) for any rows which * the data indexes (from DataTables' internal data store) for any rows which
* match. * match.
*
* @name fnFindCellRowIndexes * @name fnFindCellRowIndexes
* @anchor fnFindCellRowIndexes * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -17,7 +18,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnFindCellRowIndexes = function ( oSettings, sSearch, iColumn ) jQuery.fn.dataTableExt.oApi.fnFindCellRowIndexes = function ( oSettings, sSearch, iColumn )
{ {
var var
i,iLen, j, jLen, i,iLen, j, jLen,
@ -45,4 +46,3 @@ $.fn.dataTableExt.oApi.fnFindCellRowIndexes = function ( oSettings, sSearch, iCo
return aOut; return aOut;
}; };

@ -3,9 +3,10 @@
* matching data (optionally the search can be restricted to a single column), * matching data (optionally the search can be restricted to a single column),
* but in this case the returned array contains TR nodes of the matching rows, * but in this case the returned array contains TR nodes of the matching rows,
* rather than data indexes. * rather than data indexes.
*
* @name fnFindCellRowNodes * @name fnFindCellRowNodes
* @anchor fnFindCellRowNodes * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -17,7 +18,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnFindCellRowNodes = function ( oSettings, sSearch, iColumn ) jQuery.fn.dataTableExt.oApi.fnFindCellRowNodes = function ( oSettings, sSearch, iColumn )
{ {
var var
i,iLen, j, jLen, i,iLen, j, jLen,

@ -6,9 +6,10 @@
* situation. It takes two parameters, the target node, and a boolean * situation. It takes two parameters, the target node, and a boolean
* indicating if the adjacent row retrieved should be the next (true, or no * indicating if the adjacent row retrieved should be the next (true, or no
* value) or the previous (false). * value) or the previous (false).
*
* @name fnGetAdjacentTr * @name fnGetAdjacentTr
* @anchor fnGetAdjacentTr * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -20,7 +21,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnGetAdjacentTr = function ( oSettings, nTr, bNext ) jQuery.fn.dataTableExt.oApi.fnGetAdjacentTr = function ( oSettings, nTr, bNext )
{ {
/* Find the node's position in the aoData store */ /* Find the node's position in the aoData store */
var iCurrent = oSettings.oApi._fnNodeToDataIndex( oSettings, nTr ); var iCurrent = oSettings.oApi._fnNodeToDataIndex( oSettings, nTr );

@ -1,9 +1,10 @@
/** /**
* Return an array of table values from a particular column, with various * Return an array of table values from a particular column, with various
* filtering options. * filtering options.
*
* @name fnGetColumnData * @name fnGetColumnData
* @anchor fnGetColumnData * @summary
* @author <a href="http://mind2.de">Benedikt Forchhammer</a> * @author [Benedikt Forchhammer](http://mind2.de)
* *
* @example * @example
* *
@ -11,40 +12,58 @@
jQuery.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { jQuery.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
// check that we have a column id // check that we have a column id
if ( typeof iColumn == "undefined" ) return []; if ( typeof iColumn == "undefined" ) {
return [];
}
// by default we only wany unique data // by default we only wany unique data
if ( typeof bUnique == "undefined" ) bUnique = true; if ( typeof bUnique == "undefined" ) {
bUnique = true;
}
// by default we do want to only look at filtered data // by default we do want to only look at filtered data
if ( typeof bFiltered == "undefined" ) bFiltered = true; if ( typeof bFiltered == "undefined" ) {
bFiltered = true;
}
// by default we do not wany to include empty values // by default we do not wany to include empty values
if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true; if ( typeof bIgnoreEmpty == "undefined" ) {
bIgnoreEmpty = true;
}
// list of rows which we're going to loop through // list of rows which we're going to loop through
var aiRows; var aiRows;
// use only filtered rows // use only filtered rows
if (bFiltered == true) aiRows = oSettings.aiDisplay; if (bFiltered === true) {
aiRows = oSettings.aiDisplay;
}
// use all rows // use all rows
else aiRows = oSettings.aiDisplayMaster; // all row numbers else {
aiRows = oSettings.aiDisplayMaster; // all row numbers
}
// set up data array // set up data array
var asResultData = new Array(); var asResultData = [];
for (var i=0,c=aiRows.length; i<c; i++) { for (var i=0,c=aiRows.length; i<c; i++) {
iRow = aiRows[i]; var iRow = aiRows[i];
var sValue = this.fnGetData(iRow, iColumn); var sValue = this.fnGetData(iRow, iColumn);
// ignore empty values? // ignore empty values?
if (bIgnoreEmpty == true && sValue.length == 0) continue; if (bIgnoreEmpty === true && sValue.length === 0) {
continue;
}
// ignore unique values? // ignore unique values?
else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue; else if (bUnique === true && jQuery.inArray(sValue, asResultData) > -1) {
continue;
}
// else push the value onto the result data array // else push the value onto the result data array
else asResultData.push(sValue); else {
asResultData.push(sValue);
}
} }
return asResultData; return asResultData;

@ -4,15 +4,16 @@
* needs to change due to an added or removed column. This plug-in function * needs to change due to an added or removed column. This plug-in function
* will match a given string to the title of a column in the table and return * will match a given string to the title of a column in the table and return
* the column index, helping to overcome this problem. * the column index, helping to overcome this problem.
*
* @name fnGetColumnIndex * @name fnGetColumnIndex
* @anchor fnGetColumnIndex * @summary
* @author <a href="http://www.rosstechassociates.com/">Michael Ross</a> * @author [Michael Ross](http://www.rosstechassociates.com/)
* *
* @example * @example
* *
*/ */
$.fn.dataTableExt.oApi.fnGetColumnIndex = function ( oSettings, sCol ) jQuery.fn.dataTableExt.oApi.fnGetColumnIndex = function ( oSettings, sCol )
{ {
var cols = oSettings.aoColumns; var cols = oSettings.aoColumns;
for ( var x=0, xLen=cols.length ; x<xLen ; x++ ) for ( var x=0, xLen=cols.length ; x<xLen ; x++ )
@ -20,7 +21,7 @@ $.fn.dataTableExt.oApi.fnGetColumnIndex = function ( oSettings, sCol )
if ( cols[x].sTitle.toLowerCase() == sCol.toLowerCase() ) if ( cols[x].sTitle.toLowerCase() == sCol.toLowerCase() )
{ {
return x; return x;
}; }
} }
return -1; return -1;
}; };

@ -1,19 +1,20 @@
/** /**
* Get a list of all TR nodes in the table which are not currently visible * Get a list of all TR nodes in the table which are not currently visible
* (useful for building forms). * (useful for building forms).
*
* @name fnGetHiddenNodes * @name fnGetHiddenNodes
* @anchor fnGetHiddenNodes * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
*/ */
$.fn.dataTableExt.oApi.fnGetHiddenNodes = function ( settings ) jQuery.fn.dataTableExt.oApi.fnGetHiddenNodes = function ( settings )
{ {
var nodes; var nodes;
var display = $('tbody tr', settings.nTable); var display = jQuery('tbody tr', settings.nTable);
if ( $.fn.dataTable.versionCheck ) { if ( jQuery.fn.dataTable.versionCheck ) {
// DataTables 1.10 // DataTables 1.10
var api = new $.fn.dataTable.Api( settings ); var api = new jQuery.fn.dataTable.Api( settings );
nodes = api.rows().nodes().toArray(); nodes = api.rows().nodes().toArray();
} }
else { else {

@ -4,9 +4,10 @@
* DOM methods, jQuery or whatever, it becomes a lot more complicated when * DOM methods, jQuery or whatever, it becomes a lot more complicated when
* taking into account hidden rows and columns. This function can be used to * taking into account hidden rows and columns. This function can be used to
* overcome these difficulties. * overcome these difficulties.
*
* @name fnGetTd * @name fnGetTd
* @anchor fnGetTd * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -18,7 +19,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnGetTd = function ( oSettings, mTr, iTd, bVisOnly ) jQuery.fn.dataTableExt.oApi.fnGetTd = function ( oSettings, mTr, iTd, bVisOnly )
{ {
/* Take either a TR node or aoData index as the mTr property */ /* Take either a TR node or aoData index as the mTr property */
var iRow = (typeof mTr == 'object') ? var iRow = (typeof mTr == 'object') ?

@ -1,9 +1,10 @@
/** /**
* Get an array of TD nodes from DataTables for a given row, including any * Get an array of TD nodes from DataTables for a given row, including any
* column elements which are hidden. * column elements which are hidden.
*
* @name fnGetTds * @name fnGetTds
* @anchor fnGetTds * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -15,7 +16,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnGetTds = function ( oSettings, mTr ) jQuery.fn.dataTableExt.oApi.fnGetTds = function ( oSettings, mTr )
{ {
var anTds = []; var anTds = [];
var anVisibleTds = []; var anVisibleTds = [];

@ -1,9 +1,10 @@
/** /**
* Change the number of records that can be viewed on a single page in * Change the number of records that can be viewed on a single page in
* DataTables. * DataTables.
*
* @name fnLengthChange * @name fnLengthChange
* @anchor fnLengthChange * @summary
* @author <a href="http://www.webdetails.pt/">Pedro Alves</a> * @author [Pedro Alves](http://www.webdetails.pt/)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -12,7 +13,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnLengthChange = function ( oSettings, iDisplay ) jQuery.fn.dataTableExt.oApi.fnLengthChange = function ( oSettings, iDisplay )
{ {
oSettings._iDisplayLength = iDisplay; oSettings._iDisplayLength = iDisplay;
oSettings.oApi._fnCalculateEnd( oSettings ); oSettings.oApi._fnCalculateEnd( oSettings );

@ -4,9 +4,10 @@
* processing). Used in combination with the column sName parameter, simply * processing). Used in combination with the column sName parameter, simply
* pass in an object with the key/value pair being the column you wish to * pass in an object with the key/value pair being the column you wish to
* search on, and the value you wish to search for. * search on, and the value you wish to search for.
*
* @name fnMultiFilter * @name fnMultiFilter
* @anchor fnMultiFilter * @summary
* @author <i>mrkevans</i> * @author _mrkevans_
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -23,7 +24,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnMultiFilter = function( oSettings, oData ) { jQuery.fn.dataTableExt.oApi.fnMultiFilter = function( oSettings, oData ) {
for ( var key in oData ) for ( var key in oData )
{ {
if ( oData.hasOwnProperty(key) ) if ( oData.hasOwnProperty(key) )

@ -2,9 +2,10 @@
* Get information about the paging settings that DataTables is currently * Get information about the paging settings that DataTables is currently
* using to display each page, including the number of records shown, start * using to display each page, including the number of records shown, start
* and end points in the data set etc. * and end points in the data set etc.
*
* @name fnPagingInfo * @name fnPagingInfo
* @anchor fnPagingInfo * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -16,7 +17,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) jQuery.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
{ {
return { return {
"iStart": oSettings._iDisplayStart, "iStart": oSettings._iDisplayStart,

@ -3,8 +3,9 @@
* data loading from the server) it can be useful to make use of the * data loading from the server) it can be useful to make use of the
* 'processing' indicator built-into DataTables. This plug-in function * 'processing' indicator built-into DataTables. This plug-in function
* exposes the internal DataTables function so it can be used for exactly this. * exposes the internal DataTables function so it can be used for exactly this.
*
* @name fnProcessingIndicator * @name fnProcessingIndicator
* @anchor fnProcessingIndicator * @summary
* @author Allan Chappell * @author Allan Chappell
* *
* @example * @example

@ -3,9 +3,10 @@
* time, however it can be useful to re-read an Ajax source and have the table * time, however it can be useful to re-read an Ajax source and have the table
* update. Typically you would need to use the fnClearTable() and fnAddData() * update. Typically you would need to use the fnClearTable() and fnAddData()
* functions, however this wraps it all up in a single function call. * functions, however this wraps it all up in a single function call.
*
* @name fnReloadAjax * @name fnReloadAjax
* @anchor fnReloadAjax * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* // Example call to load a new file * // Example call to load a new file
@ -15,13 +16,13 @@
* oTable.fnReloadAjax(); * oTable.fnReloadAjax();
*/ */
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw ) jQuery.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{ {
// DataTables 1.10 compatibility - if 1.10 then `versionCheck` exists. // DataTables 1.10 compatibility - if 1.10 then `versionCheck` exists.
// 1.10's API has ajax reloading built in, so we use those abilities // 1.10's API has ajax reloading built in, so we use those abilities
// directly. // directly.
if ( $.fn.dataTable.versionCheck ) { if ( jQuery.fn.dataTable.versionCheck ) {
var api = new $.fn.dataTable.Api( oSettings ); var api = new jQuery.fn.dataTable.Api( oSettings );
if ( sNewSource ) { if ( sNewSource ) {
api.ajax.url( sNewSource ).load( fnCallback, !bStandingRedraw ); api.ajax.url( sNewSource ).load( fnCallback, !bStandingRedraw );

@ -2,8 +2,8 @@
* Enables filtration delay for keeping the browser more responsive while * Enables filtration delay for keeping the browser more responsive while
* searching for a longer keyword. * searching for a longer keyword.
* @name fnSetFilteringDelay * @name fnSetFilteringDelay
* @anchor fnSetFilteringDelay * @summary
* @author <a href="http://www.zygimantas.com/">Zygimantas Berziunas</a>, <a href="http://www.sprymedia.co.uk/">Allan Jardine</a> and <i>vex</i> * @author [Zygimantas Berziunas](http://www.zygimantas.com/), [Allan Jardine](http://www.sprymedia.co.uk/) and _vex_
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {

@ -5,9 +5,10 @@
* initialisation, it can sometimes be useful to restore the original order * initialisation, it can sometimes be useful to restore the original order
* after sorting has already occurred - which is exactly what this function * after sorting has already occurred - which is exactly what this function
* does. * does.
*
* @name fnSortNeutral * @name fnSortNeutral
* @anchor fnSortNeutral * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -18,7 +19,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnSortNeutral = function ( oSettings ) jQuery.fn.dataTableExt.oApi.fnSortNeutral = function ( oSettings )
{ {
/* Remove any current sorting */ /* Remove any current sorting */
oSettings.aaSorting = []; oSettings.aaSorting = [];

@ -1,8 +1,9 @@
/** /**
* Redraw the table (i.e. fnDraw) to take account of sorting and filtering, * Redraw the table (i.e. fnDraw) to take account of sorting and filtering,
* but retain the current pagination settings. * but retain the current pagination settings.
*
* @name fnStandingRedraw * @name fnStandingRedraw
* @anchor fnStandingRedraw * @summary
* @author Jonathan Hoguet * @author Jonathan Hoguet
* *
* @example * @example
@ -12,7 +13,7 @@
* } ); * } );
*/ */
$.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) { jQuery.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) {
if(oSettings.oFeatures.bServerSide === false){ if(oSettings.oFeatures.bServerSide === false){
var before = oSettings._iDisplayStart; var before = oSettings._iDisplayStart;

@ -3,15 +3,16 @@
* fnSetColumnVis) it removes these elements from the DOM, effecting the index * fnSetColumnVis) it removes these elements from the DOM, effecting the index
* value for the column positions. This function converts the visible column * value for the column positions. This function converts the visible column
* index into a data column index (i.e. all columns regardless of visibility). * index into a data column index (i.e. all columns regardless of visibility).
*
* @name fnVisibleToColumnIndex * @name fnVisibleToColumnIndex
* @anchor fnVisibleToColumnIndex * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* *
*/ */
$.fn.dataTableExt.oApi.fnVisibleToColumnIndex = function ( oSettings, iMatch ) jQuery.fn.dataTableExt.oApi.fnVisibleToColumnIndex = function ( oSettings, iMatch )
{ {
return oSettings.oApi._fnVisibleToColumnIndex( oSettings, iMatch ); return oSettings.oApi._fnVisibleToColumnIndex( oSettings, iMatch );
}; };

@ -0,0 +1,20 @@
/**
* Jump to data
*
* @name page.JumpToData()
* @summary
* @author [Allan Jardine](http://sprymedia.co.uk)
* @requires DataTables 1.10+
*
* @example
* table.page.jumpToData( 0, "Allan Jardine" );
*/
jQuery.fn.dataTable.Api.register( 'page.jumpToData()', function ( column, data ) {
var pos = this.column(column, {order:'current'}).data().indexOf( data );
if ( pos >= 0 ) {
var page = Math.floor( pos / this.page.info().length );
this.page( page ).draw( false );
}
} );

@ -1,8 +1,9 @@
/** /**
* Sum the values in a data set. * Sum the values in a data set.
*
* @name sum() * @name sum()
* @anchor sum() * @summary
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* @requires DataTables 1.10+ * @requires DataTables 1.10+
* *
* @example * @example

@ -1,6 +1,11 @@
/** /**
* Used in combination with TableTools and selectable rows, this will allow you to switch between showing all rows and just the selected ones. * Used in combination with TableTools and selectable rows, this will allow you
* @author <a href="http://stackoverflow.com/users/8507/phloopy">Caleb Harrelson</a> * to switch between showing all rows and just the selected ones.
*
* @name Show selected only
* @summary Show only selected rows, or all rows, through filtering
* @requires TableTools
* @author [Caleb Harrelson](http://stackoverflow.com/users/8507/phloopy)
* *
* @example * @example
* $('#example').dataTable({ * $('#example').dataTable({

@ -2,17 +2,18 @@
* Filter a column on a specific date range. Note that you will likely need * Filter a column on a specific date range. Note that you will likely need
* to change the id's on the inputs and the columns in which the start and * to change the id's on the inputs and the columns in which the start and
* end date exist. * end date exist.
* @name Range filtering (dates) *
* @anchor range_dates * @name Date range filter
* @author <i>guillimon</i> * @summary Filter the table based on two dates in different columns
* @author _guillimon_
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
* var oTable = $('#example').dataTable(); * var table = $('#example').DataTable();
* *
* // Add event listeners to the two range filtering inputs * // Add event listeners to the two range filtering inputs
* $('#min').keyup( function() { oTable.fnDraw(); } ); * $('#min').keyup( function() { table.draw(); } );
* $('#max').keyup( function() { oTable.fnDraw(); } ); * $('#max').keyup( function() { table.draw(); } );
* } ); * } );
*/ */
@ -23,21 +24,21 @@ $.fn.dataTableExt.afnFiltering.push(
var iStartDateCol = 6; var iStartDateCol = 6;
var iEndDateCol = 7; var iEndDateCol = 7;
iFini=iFini.substring(6,10) + iFini.substring(3,5)+ iFini.substring(0,2) iFini=iFini.substring(6,10) + iFini.substring(3,5)+ iFini.substring(0,2);
iFfin=iFfin.substring(6,10) + iFfin.substring(3,5)+ iFfin.substring(0,2) iFfin=iFfin.substring(6,10) + iFfin.substring(3,5)+ iFfin.substring(0,2);
var datofini=aData[iStartDateCol].substring(6,10) + aData[iStartDateCol].substring(3,5)+ aData[iStartDateCol].substring(0,2); var datofini=aData[iStartDateCol].substring(6,10) + aData[iStartDateCol].substring(3,5)+ aData[iStartDateCol].substring(0,2);
var datoffin=aData[iEndDateCol].substring(6,10) + aData[iEndDateCol].substring(3,5)+ aData[iEndDateCol].substring(0,2); var datoffin=aData[iEndDateCol].substring(6,10) + aData[iEndDateCol].substring(3,5)+ aData[iEndDateCol].substring(0,2);
if ( iFini == "" && iFfin == "" ) if ( iFini === "" && iFfin === "" )
{ {
return true; return true;
} }
else if ( iFini <= datofini && iFfin == "") else if ( iFini <= datofini && iFfin === "")
{ {
return true; return true;
} }
else if ( iFfin >= datoffin && iFini == "") else if ( iFfin >= datoffin && iFini === "")
{ {
return true; return true;
} }

@ -2,18 +2,19 @@
* Filter a specific numeric column on the value being between two given * Filter a specific numeric column on the value being between two given
* numbers. Note that you will likely need to change the id's on the inputs * numbers. Note that you will likely need to change the id's on the inputs
* and the column in which the numeric value is given. * and the column in which the numeric value is given.
*
* @summary Filter the data between two numbers (inclusive)
* @name Range filtering (numbers) * @name Range filtering (numbers)
* @anchor range_numbers * @author [Allan Jardine](http://sprymedia.co.uk)
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a>
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
* // Initialise datatables * // Initialise datatables
* var oTable = $('#example').dataTable(); * var table = $('#example').DataTable();
* *
* // Add event listeners to the two range filtering inputs * // Add event listeners to the two range filtering inputs
* $('#min').keyup( function() { oTable.fnDraw(); } ); * $('#min').keyup( function() { table.draw(); } );
* $('#max').keyup( function() { oTable.fnDraw(); } ); * $('#max').keyup( function() { table.draw(); } );
* } ); * } );
*/ */
@ -24,15 +25,15 @@ jQuery.fn.dataTableExt.afnFiltering.push(
var iMax = document.getElementById('max').value * 1; var iMax = document.getElementById('max').value * 1;
var iVersion = aData[iColumn] == "-" ? 0 : aData[iColumn]*1; var iVersion = aData[iColumn] == "-" ? 0 : aData[iColumn]*1;
if ( iMin == "" && iMax == "" ) if ( iMin === "" && iMax === "" )
{ {
return true; return true;
} }
else if ( iMin == "" && iVersion < iMax ) else if ( iMin === "" && iVersion < iMax )
{ {
return true; return true;
} }
else if ( iMin < iVersion && "" == iMax ) else if ( iMin < iVersion && "" === iMax )
{ {
return true; return true;
} }

@ -0,0 +1,56 @@
/**
* When search a table with accented characters, it can be frustrating to have
* an input such as _Zurich_ not match _Zürich_ in the table (`u !== ü`). This
* type based search plug-in replaces the built-in string formatter in
* DataTables with a function that will remove replace the accented characters
* with their unaccented counterparts for fast and easy filtering.
*
* Note that with the accented characters being replaced, a search input using
* accented characters will no longer match. The second example below shows
* how the function can be used to remove accents from the search input as well,
* to mitigate this problem.
*
* @summary Replace accented characters with unaccented counterparts
* @name Accent neutralise
* @author Allan Jardine
*
* @example
* $(document).ready(function() {
* $('#example').dataTable();
* } );
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable();
*
* // Remove accented character from search input as well
* $('#myInput').keyup( function () {
* table
* .search(
* jQuery.fn.DataTable.ext.type.search.string( this )
* )
* .draw()
* } );
* } );
*/
jQuery.fn.DataTable.ext.type.search.string = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
data
.replace( /\n/g, ' ' )
.replace( /á/g, 'a' )
.replace( /é/g, 'e' )
.replace( /í/g, 'i' )
.replace( /ó/g, 'o' )
.replace( /ú/g, 'u' )
.replace( /ê/g, 'e' )
.replace( /î/g, 'i' )
.replace( /ô/g, 'o' )
.replace( /è/g, 'e' )
.replace( /ï/g, 'i' )
.replace( /ü/g, 'u' )
.replace( /ç/g, 'c' ) :
data;
};

@ -1,32 +1,38 @@
/** /**
* DataTables has a built in type called 'html' which will strip HTML tags * DataTables has a built in type called `html` which will strip HTML tags
* from a search string, but it doesn't cope with nested HTML inside another * from a search string, but it doesn't cope with nested HTML inside another
* element's attributes (for example DOM0 events with have HTML in them). This * element's attributes (for example DOM0 events with have HTML in them). This
* plug-in function overrules the built-in method and provides complete HTML * plug-in function overrules the built-in method and provides complete HTML
* tag removal. Note that this function is not included in DataTables by * tag removal.
*
* Note that this function is not included in DataTables by
* default because it is slightly slower than the built-in method, which is * default because it is slightly slower than the built-in method, which is
* good enough for by far the majority of use cases. * good enough for by far the majority of use cases.
*
* @summary Strip HTML using DOM methods
* @name html * @name html
* @anchor html_column * @author _guillimon_
* @author <i>guillimon</i>
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
* var oTable = $('#example').dataTable({ * $('#example').dataTable({
* "aoColumns": [ * "columnDefs": [
* "sType": "html", * { type: "html", target: 0 }
* null
* ] * ]
* }); * });
* } ); * } );
*/ */
jQuery.fn.dataTableExt.ofnSearch['html'] = function ( sData ) { (function () {
var n = document.createElement('div');
n.innerHTML = sData; var _div = document.createElement('div');
if ( n.textContent ) {
return n.textContent.replace(/\n/g," "); jQuery.fn.dataTable.ext.type.search.html = function ( data ) {
} else { _div.innerHTML = data;
return n.innerText.replace(/\n/g," ");
} return _div.textContent ?
_div.textContent.replace(/\n/g," ") :
_div.innerText.replace(/\n/g," ");
}; };
})();

@ -0,0 +1,31 @@
/**
* Telephone numbers are a common data point to display in HTML tables, and are
* often formatted (e.g. `dt-string 555-1234`). Typically, when searching a
* table a user would need to enter the number in exactly the same format it is
* displayed in, but this is not always convenient (e.g. you might search for
* `dt-string 5551`).
*
* This filtering plug-in will allow both forms to be matched be providing both
* the formatted and de-formatted data to the table's search.
*
* @summary Make phone numbers searchable formatted or unformatted
* @name Phone number
* @author Allan Jardine
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* columnDefs: [
* { type: 'phoneNumber', target: 4 }
* ]
* } );
* } );
*/
jQuery.fn.DataTable.ext.type.search.phoneNumber = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
data + data.replace(/[ \-]/g, '') :
data;
};

@ -1,15 +1,23 @@
/* /*
* This plug-in adds another pagination option similar to full_numbers, * This plug-in adds another pagination option similar to `full_numbers`, except
* except it adds ellipses around the page numbers when applicable. * it adds ellipses around the page numbers when applicable. You can set how
* You can set how many page numbers should be displayed with the iShowPages option. * many page numbers should be displayed with the iShowPages option.
*
* This plug- in extends the oStdClasses object with the following properties: * This plug- in extends the oStdClasses object with the following properties:
* sPageEllipsis, sPageNumber and sPageNumbers. * sPageEllipsis, sPageNumber and sPageNumbers.
*
* It also extends the oSettings object with the following properties: * It also extends the oSettings object with the following properties:
* _iShowPages, _iShowPagesHalf, _iCurrentPage, _iTotalPages, _iFirstPage and _iLastPage. * _iShowPages, _iShowPagesHalf, _iCurrentPage, _iTotalPages, _iFirstPage and
* _iLastPage.
*
* Note that DataTables 1.10 has this ability built in. As such, this plug-ins
* has been marked as depreciated, but may still be useful for if you are using
* an old version of DataTables.
* *
* @name Ellipses * @name Ellipses
* @anchor ellipses * @summary Show ellipses in the pagination control where there is a gap in numbers
* @author <a href="http://daveden.wordpress.com/">Dave Kennedy</a> * @depreciated
* @author [Dave Kennedy](http://daveden.wordpress.com/)
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
* $('#example').dataTable({ * $('#example').dataTable({

@ -1,9 +1,10 @@
/** /**
* This pagination plug-in provides pagination controls for DataTables which * This pagination plug-in provides pagination controls for DataTables which
* match the style and interaction of the ExtJS library's grid component. * match the style and interaction of the ExtJS library's grid component.
*
* @name ExtJS style * @name ExtJS style
* @anchor extjs * @summary Pagination in the styling of ExtJS
* @author <a href="http://zachariahtimothy.wordpress.com/">Zach Curtis</a> * @author [Zach Curtis](http://zachariahtimothy.wordpress.com/)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {

@ -1,10 +1,17 @@
/** /**
* The built-in pagination functions provide either two buttons (forward / back) * The built-in pagination functions provide either two buttons (forward / back)
* or lots of buttons (forward, back, first, last and individual pages). This * or lots of buttons (forward, back, first, last and individual pages). This
* plug-in meets the two in the middle providing navigation controls for forward, back, first and last. * plug-in meets the two in the middle providing navigation controls for
* forward, back, first and last.
*
* DataTables has this ability built in using the `dt-string full` option of
* the `dt-init pagingType` initialisation option. As such, this plug-in is
* marked as depreciated.
*
* @name Four button navigation * @name Four button navigation
* @anchor four_button * @summary Display forward, back, first and last buttons.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -17,10 +24,10 @@
$.fn.dataTableExt.oPagination.four_button = { $.fn.dataTableExt.oPagination.four_button = {
"fnInit": function ( oSettings, nPaging, fnCallbackDraw ) "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
{ {
nFirst = document.createElement( 'span' ); var nFirst = document.createElement( 'span' );
nPrevious = document.createElement( 'span' ); var nPrevious = document.createElement( 'span' );
nNext = document.createElement( 'span' ); var nNext = document.createElement( 'span' );
nLast = document.createElement( 'span' ); var nLast = document.createElement( 'span' );
nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) ); nFirst.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sFirst ) );
nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) ); nPrevious.appendChild( document.createTextNode( oSettings.oLanguage.oPaginate.sPrevious ) );

@ -4,9 +4,10 @@
* text input box to accept new paging numbers (arrow keys are also allowed * text input box to accept new paging numbers (arrow keys are also allowed
* for), and four standard navigation buttons are also presented to the end * for), and four standard navigation buttons are also presented to the end
* user. * user.
*
* @name Navigation with text input * @name Navigation with text input
* @anchor text_input * @summary Shows an input element into which the user can type a page number
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {
@ -82,7 +83,6 @@ $.fn.dataTableExt.oPagination.input = {
} ); } );
$(nInput).keyup( function (e) { $(nInput).keyup( function (e) {
if ( e.which == 38 || e.which == 39 ) if ( e.which == 38 || e.which == 39 )
{ {
this.value++; this.value++;
@ -92,7 +92,7 @@ $.fn.dataTableExt.oPagination.input = {
this.value--; this.value--;
} }
if ( this.value == "" || this.value.match(/[^0-9]/) ) if ( this.value === "" || this.value.match(/[^0-9]/) )
{ {
/* Nothing entered or non-numeric character */ /* Nothing entered or non-numeric character */
return; return;
@ -133,7 +133,7 @@ $.fn.dataTableExt.oPagination.input = {
{ {
var spans = an[i].getElementsByTagName('span'); var spans = an[i].getElementsByTagName('span');
var inputs = an[i].getElementsByTagName('input'); var inputs = an[i].getElementsByTagName('input');
spans[3].innerHTML = " of "+iPages spans[3].innerHTML = " of "+iPages;
inputs[0].value = iCurrentPage; inputs[0].value = iCurrentPage;
} }
} }

@ -3,9 +3,10 @@
* adds a little animation effect to the paging action by redrawing the table * adds a little animation effect to the paging action by redrawing the table
* multiple times for each event, each draw progressing by one row until the * multiple times for each event, each draw progressing by one row until the
* required point in the table is reached. * required point in the table is reached.
*
* @name Scrolling navigation * @name Scrolling navigation
* @anchor scrolling * @summary Show page changes as a redraw of the table, scrolling records.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {

@ -1,9 +1,10 @@
/** /**
* This pagination plug-in provides a select menu with the list of the page * This pagination plug-in provides a `dt-tag select` menu with the list of the page
* numbers that are available for viewing. * numbers that are available for viewing.
*
* @name Select list * @name Select list
* @anchor listbox * @summary Show a `dt-tag select` list of pages the user can pick from.
* @author <i>jneilliii</i> * @author _jneilliii_
* *
* @example * @example
* $(document).ready(function() { * $(document).ready(function() {

@ -2,9 +2,17 @@
* Sort on the 'alt' tag of images in a column. This is particularly useful if * Sort on the 'alt' tag of images in a column. This is particularly useful if
* you have a column of images (ticks and crosses for example) and you want to * you have a column of images (ticks and crosses for example) and you want to
* control the sorting using the alt tag. * control the sorting using the alt tag.
*
* @name Alt string * @name Alt string
* @anchor alt * @summary Use the `alt` attribute of an image tag as the data to sort upon.
* @author <i>Jumpy</i> * @author _Jumpy_
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'alt-string', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -3,9 +3,17 @@
* the word "the" at the start of some individual titles, which you don't want * the word "the" at the start of some individual titles, which you don't want
* to include in your sorting order. This plug-in will strip the word "the" * to include in your sorting order. This plug-in will strip the word "the"
* from the start of a string and sort on what is left. * from the start of a string and sort on what is left.
*
* @name Anti-"the" * @name Anti-"the"
* @anchor anti_the * @summary Sort with the prefixed word `dt-string The` removed, if present
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'anti-the', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,17 +1,29 @@
/** /**
* Sorting in Javascript for Chinese Character. The Chinese Characters are sorted on the radical and number of * Sorting in Javascript for Chinese Character. The Chinese Characters are
* strokes. This plug-in performs sorting for Chinese characters. * sorted on the radical and number of strokes. This plug-in performs sorting
* <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/localeCompare">localeCompare MDC documentation</a>. * for Chinese characters using the Javascript [localeCompare](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/localeCompare)
* Please also see <a href="http://www.datatables.net/forums/discussion/9700/sorting-non-ascii-characters-and-data-content-html-tag-sorting/p1">note about localeCompare and IE9</a>. * function.
*
* Please note that `localeCompare` is not implemented in the same way in all
* browsers, potentially leading to different results (particularly in IE).
*
* @name Chinese (string) * @name Chinese (string)
* @anchor chinese-string * @summary Sort Chinese characters
* @author <a href="http://www.lcube.se/sorting-chinese-characters-in-javascript/">Patrik Lindstr<EFBFBD>m</a> * @author [Patrik Lindström](http://www.lcube.se/sorting-chinese-characters-in-javascript/)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'chinese-string', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"chinese-string-asc" : function (s1, s2) { "chinese-string-asc" : function (s1, s2) {
return s1.localeCompare(s2); return s1.localeCompare(s2);
}, },
"chinese-string-desc" : function (s1, s2) { "chinese-string-desc" : function (s1, s2) {
return s2.localeCompare(s1); return s2.localeCompare(s1);
} }

@ -2,9 +2,22 @@
* This plug-in will provide numeric sorting for currency columns (either * This plug-in will provide numeric sorting for currency columns (either
* detected automatically with the currency type detection plug-in or set * detected automatically with the currency type detection plug-in or set
* manually) while taking account of the currency symbol ($ or £ by default). * manually) while taking account of the currency symbol ($ or £ by default).
*
* DataTables 1.10+ has currency sorting abilities built-in and will be
* automatically detected. As such this plug-in is marked as depreciated, but
* might be useful when working with old versions of DataTables.
*
* @name Currency * @name Currency
* @anchor currency * @summary Sort data numerically when it has a leading currency symbol.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'currency', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,15 +1,15 @@
/** /**
* Read information from a column of checkboxes (input elements with type * Read information from a column of checkboxes (input elements with type
* checkbox) and return an array to use as a basis for sorting. * checkbox) and return an array to use as a basis for sorting.
*
* @summary Sort based on the checked state of checkboxes in a column
* @name Checkbox data source * @name Checkbox data source
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
*/ */
$.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, iColumn ) $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col )
{ {
var aData = []; return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () { return $('input', td).prop('checked') ? '1' : '0';
aData.push( this.checked==true ? "1" : "0" );
} ); } );
return aData;
}; };

@ -1,15 +1,16 @@
/** /**
* Read information from a column of select (drop down) menus and return an * Read information from a column of select (drop down) menus and return an
* array to use as a basis for sorting. * array to use as a basis for sorting.
*
* @summary Sort based on the value of the `dt-tag select` options in a column
* @name Select menu data source * @name Select menu data source
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @requires DataTables 1.10+
* @author [Allan Jardine](http://sprymedia.co.uk)
*/ */
$.fn.dataTableExt.afnSortData['dom-select'] = function ( oSettings, iColumn ) $.fn.dataTable.ext.order['dom-select'] = function ( settings, col )
{ {
var aData = []; return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
$( 'td:eq('+iColumn+') select', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () { return $('select', td).val();
aData.push( $(this).val() );
} ); } );
return aData;
}; };

@ -1,15 +1,16 @@
/** /**
* Read information from a column of input (type text) elements and return an * Read information from a column of input (type text) elements and return an
* array to use as a basis for sorting. * array to use as a basis for sorting.
*
* @summary Sorting based on the values of `dt-tag input` elements in a column.
* @name Input element data source * @name Input element data source
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @requires DataTables 1.10+
* @author [Allan Jardine](http://sprymedia.co.uk)
*/ */
$.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn ) $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
{ {
var aData = []; return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
$( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () { return $('input', td).val();
aData.push( this.value );
} ); } );
return aData;
}; };

@ -1,18 +1,26 @@
/* /*
* Adds a new sorting option to dataTables called <code>date-dd-mmm-yyyy</code>. Also * Adds a new sorting option to dataTables called `date-dd-mmm-yyyy`. Also
* includes a type detection plug-in. Matches and sorts date strings in * includes a type detection plug-in. Matches and sorts date strings in
* the format: <code>(dd/mmm/yyyy</code>. For example: * the format: `dd/mmm/yyyy`. For example:
* <ul>
* <li>02-FEB-1978</li>
* <li>17-MAY-2013</li>
* <li>31-JAN-2014</li>
* </ul>
* *
* @name Date dd-mmm-yyyy * * 02-FEB-1978
* @anchor date-dd-mmm-yyyy * * 17-MAY-2013
* @author <a href="http://www.appliedinter.net/jeromy_works/">Jeromy French</a> * * 31-JAN-2014
*
* @name Date (dd-mmm-yyyy)
* @summary Sort dates in the format `dd-mmm-yyyy`
* @author [Jeromy French](http://www.appliedinter.net/jeromy_works/)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'date-dd-mmm-yyyy', targets: 0 }
* ]
* } );
*/ */
(function () {
var customDateDDMMMYYYYToOrd = function (date) { var customDateDDMMMYYYYToOrd = function (date) {
"use strict"; //let's avoid tom-foolery in this function "use strict"; //let's avoid tom-foolery in this function
// Convert to a number YYYYMMDD which we can use to order // Convert to a number YYYYMMDD which we can use to order
@ -20,7 +28,8 @@ var customDateDDMMMYYYYToOrd = function (date) {
return (dateParts[2] * 10000) + ($.inArray(dateParts[1].toUpperCase(), ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]) * 100) + dateParts[0]; return (dateParts[2] * 10000) + ($.inArray(dateParts[1].toUpperCase(), ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]) * 100) + dateParts[0];
}; };
// This will help DataTables magic detect the "dd-MMM-yyyy" format; Unshift so that it's the first data type (so it takes priority over existing) // This will help DataTables magic detect the "dd-MMM-yyyy" format; Unshift
// so that it's the first data type (so it takes priority over existing)
jQuery.fn.dataTableExt.aTypes.unshift( jQuery.fn.dataTableExt.aTypes.unshift(
function (sData) { function (sData) {
"use strict"; //let's avoid tom-foolery in this function "use strict"; //let's avoid tom-foolery in this function
@ -45,3 +54,5 @@ jQuery.fn.dataTableExt.oSort['date-dd-mmm-yyyy-desc'] = function (a, b) {
ordB = customDateDDMMMYYYYToOrd(b); ordB = customDateDDMMMYYYYToOrd(b);
return (ordA < ordB) ? 1 : ((ordA > ordB) ? -1 : 0); return (ordA < ordB) ? 1 : ((ordA > ordB) ? -1 : 0);
}; };
})();

@ -0,0 +1,64 @@
/**
* This sorting plug-in for DataTables will correctly sort data in date time
* format typically used in Germany - `dd.mm.YYYY HH:mm`.
*
* @name Date / time (dd.mm.YYYY HH:mm)
* @summary Sort date / time in the format `dd.mm.YYYY HH:mm`.
* @author [Ronny Vedrilla](http://www.ambient-innovation.com)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'de_datetime', targets: 0 }
* ]
* } );
*/
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"de_datetime-asc": function ( a, b ) {
var x, y;
if ($.trim(a) !== '') {
var deDatea = $.trim(a).split(' ');
var deTimea = deDatea[1].split(':');
var deDatea2 = deDatea[0].split('.');
x = (deDatea2[2] + deDatea2[1] + deDatea2[0] + deTimea[0] + deTimea[1]) * 1;
} else {
x = Infinity; // = l'an 1000 ...
}
if ($.trim(b) !== '') {
var deDateb = $.trim(b).split(' ');
var deTimeb = deDateb[1].split(':');
deDateb = deDateb[0].split('.');
y = (deDateb[2] + deDateb[1] + deDateb[0] + deTimeb[0] + deTimeb[1]) * 1;
} else {
y = Infinity;
}
var z = ((x < y) ? -1 : ((x > y) ? 1 : 0));
return z;
},
"de_datetime-desc": function ( a, b ) {
var x, y;
if ($.trim(a) !== '') {
var deDatea = $.trim(a).split(' ');
var deTimea = deDatea[1].split(':');
var deDatea2 = deDatea[0].split('.');
x = (deDatea2[2] + deDatea2[1] + deDatea2[0] + deTimea[0] + deTimea[1]) * 1;
} else {
x = Infinity;
}
if ($.trim(b) !== '') {
var deDateb = $.trim(b).split(' ');
var deTimeb = deDateb[1].split(':');
deDateb = deDateb[0].split('.');
y = (deDateb[2] + deDateb[1] + deDateb[0] + deTimeb[0] + deTimeb[1]) * 1;
} else {
y = Infinity;
}
var z = ((x < y) ? 1 : ((x > y) ? -1 : 0));
return z;
}
} );

@ -2,28 +2,37 @@
* Similar to the Date (dd/mm/YY) data sorting plug-in, this plug-in offers * Similar to the Date (dd/mm/YY) data sorting plug-in, this plug-in offers
* additional flexibility with support for spaces between the values and * additional flexibility with support for spaces between the values and
* either . or / notation for the separators. * either . or / notation for the separators.
*
* @name Date (dd . mm[ . YYYY]) * @name Date (dd . mm[ . YYYY])
* @anchor date_eu * @summary Sort dates in the format `dd/mm/YY[YY]` (with optional spaces)
* @author <a href="http://galjot.si/">Robert Sedovšek</a> * @author [Robert Sedovšek](http://galjot.si/)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'date-eu', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"date-eu-pre": function ( date ) { "date-eu-pre": function ( date ) {
var date = date.replace(" ", ""); date = date.replace(" ", "");
var eu_date, year;
if (date.indexOf('.') > 0) { if (date.indexOf('.') > 0) {
/*date a, format dd.mn.(yyyy) ; (year is optional)*/ /*date a, format dd.mn.(yyyy) ; (year is optional)*/
var eu_date = date.split('.'); eu_date = date.split('.');
} else { } else {
/*date a, format dd/mn/(yyyy) ; (year is optional)*/ /*date a, format dd/mn/(yyyy) ; (year is optional)*/
var eu_date = date.split('/'); eu_date = date.split('/');
} }
/*year (optional)*/ /*year (optional)*/
if (eu_date[2]) { if (eu_date[2]) {
var year = eu_date[2]; year = eu_date[2];
} else { } else {
var year = 0; year = 0;
} }
/*month*/ /*month*/

@ -3,20 +3,31 @@
* formatting, which is common in France and other European countries. It can * formatting, which is common in France and other European countries. It can
* also be quickly adapted for other formatting as required. Furthermore, this * also be quickly adapted for other formatting as required. Furthermore, this
* date sorting plug-in allows for empty values in the column. * date sorting plug-in allows for empty values in the column.
*
* @name Date (dd/mm/YYY hh:ii:ss) * @name Date (dd/mm/YYY hh:ii:ss)
* @anchor date_euro * @summary Sort date / time in the format `dd/mm/YYY hh:ii:ss`
* @author <a href="http://coolforest.net/">Ronan Guilloux</a> * @author [Ronan Guilloux](http://coolforest.net/)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'date-euro', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"date-euro-pre": function ( a ) { "date-euro-pre": function ( a ) {
if ($.trim(a) != '') { var x;
if ( $.trim(a) !== '' ) {
var frDatea = $.trim(a).split(' '); var frDatea = $.trim(a).split(' ');
var frTimea = frDatea[1].split(':'); var frTimea = frDatea[1].split(':');
var frDatea2 = frDatea[0].split('/'); var frDatea2 = frDatea[0].split('/');
var x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1; x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1;
} else { }
var x = 10000000000000; // = l'an 1000 ... else {
x = Infinity;
} }
return x; return x;

@ -1,13 +1,21 @@
/** /**
* DataTables internal date sorting replies on Date.parse() which is part of * DataTables internal date sorting replies on `Date.parse()` which is part of
* the Javascript language, but you may wish to sort on dates which is doesn't * the Javascript language, but you may wish to sort on dates which is doesn't
* recognise. The following is a plug-in for sorting dates in the format * recognise. The following is a plug-in for sorting dates in the format
* dd/mm/yy. * `dd/mm/yy`.
* *
* An automatic type detection plug-in is available for this sorting plug-in. * An automatic type detection plug-in is available for this sorting plug-in.
*
* @name Date (dd/mm/YY) * @name Date (dd/mm/YY)
* @anchor date_uk * @summary Sort dates in the format `dd/mm/YY`
* @author Andy McMaster * @author Andy McMaster
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'date-uk', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,16 +1,23 @@
/* /*
* Adds a new sorting option to dataTables called <code>datetime-us</code>. Also * Adds a new sorting option to dataTables called `datetime-us`.
* includes a type detection plug-in. Matches and sorts date / time strings in *
* the format: <code>(m)m/(d)d/(yy)yy (h)h/m(m) (am|pm)</code>. For example: * Also included is a type detection plug-in. Matches and sorts date / time
* <ul> * strings in the format: `(m)m/(d)d/(yy)yy (h)h/m(m) (am|pm)`. For example:
* <li>1/1/13 1:4 pm</li> *
* <li>01/01/2013 01:04 PM</li> * * 1/1/13 1:4 pm
* <li>1/1/2013 1:04 Pm</li> * * 01/01/2013 01:04 PM
* </ul> * * 1/1/2013 1:04 Pm
* *
* @name Date / time - US * @name Date / time - US
* @anchor datetime_us * @summary Sort date / time in the format `m/d/yy h:m am|pm`
* @author <a href="http://mrkmg.com/">Kevin Gravier</a> * @author [Kevin Gravier](http://mrkmg.com/)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'datetime-us', targets: 0 }
* ]
* } );
*/ */
jQuery.extend(jQuery.fn.dataTableExt.oSort, { jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"datetime-us-pre": function (a) { "datetime-us-pre": function (a) {
@ -22,21 +29,38 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
min = b[5], min = b[5],
ap = b[6]; ap = b[6];
if(hour == '12') hour = '0'; if (hour == '12') {
if(ap == 'pm') hour = parseInt(hour, 10)+12; hour = '0';
if (ap == 'pm') {
hour = parseInt(hour, 10) + 12;
}
if (year.length == 2) { if (year.length == 2) {
if(parseInt(year, 10)<70) year = '20'+year; if (parseInt(year, 10) < 70) {
else year = '19'+year; year = '20' + year;
}
else {
year = '19' + year;
}
}
if (month.length == 1) {
month = '0' + month;
}
if (day.length == 1) {
day = '0' + day;
}
if (hour.length == 1) {
hour = '0' + hour;
}
if (min.length == 1) {
min = '0' + min;
} }
if(month.length == 1) month = '0'+month;
if(day.length == 1) day = '0'+day;
if(hour.length == 1) hour = '0'+hour;
if(min.length == 1) min = '0'+min;
var tt = year + month + day + hour + min; var tt = year + month + day + hour + min;
return tt; return tt;
}
}, },
"datetime-us-asc": function (a, b) { "datetime-us-asc": function (a, b) {
return a - b; return a - b;
}, },
@ -47,10 +71,8 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
}); });
jQuery.fn.dataTableExt.aTypes.unshift( jQuery.fn.dataTableExt.aTypes.unshift(
function ( sData ) function (sData) {
{ if (sData !== null && sData.match(/\d{1,2}\/\d{1,2}\/\d{2,4} \d{1,2}:\d{1,2} (am|pm|AM|PM|Am|Pm)/)) {
if (sData !== null && sData.match(/\d{1,2}\/\d{1,2}\/\d{2,4} \d{1,2}:\d{1,2} (am|pm|AM|PM|Am|Pm)/))
{
return 'datetime-us'; return 'datetime-us';
} }

@ -1,11 +1,19 @@
/** /**
* Sort by priority through an enumerated list. In this case the words 'High', * Sort by priority through an enumerated list. In this case the words _High_,
* 'Medium' and 'Low' are used and thus sorted in priority order. This works * _Medium_ and _Low_ are used and thus sorted in priority order. This works
* by converting the works to a numerical value and then sorting based on that * by converting the works to a numerical value and then sorting based on that
* value. * value.
*
* @name enum * @name enum
* @anchor enum * @summary Sort an enumerated list of options
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'enum', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -4,9 +4,17 @@
* magnitude of the file size. This plug-in allows sorting to take these * magnitude of the file size. This plug-in allows sorting to take these
* indicates of size into account. A counterpart type detection plug-in * indicates of size into account. A counterpart type detection plug-in
* is also available. * is also available.
*
* @name File size * @name File size
* @anchor file_size * @summary Sort abbreviated file sizes correctly (8MB, 4KB etc)
* @author <i>anjibman</i> * @author _anjibman_
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'file-size', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,10 +1,23 @@
/** /**
* This plug-in will provide numeric sorting for numeric columns which have extra * This plug-in will provide numeric sorting for numeric columns which have
* formatting, such as thousands seperators, currency symobols or any other * extra formatting, such as thousands separators, currency symbols or any other
* non-numeric data. * non-numeric data.
*
* DataTables 1.10+ has formatted number detection and sorting abilities built-
* in. As such this plug-in is marked as depreciated, but might be useful when
* working with old versions of DataTables.
*
* @name Formatted numbers * @name Formatted numbers
* @anchor formatted_numbers * @summary Sort numbers which are displayed with thousand separators
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'formatted-num', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -3,9 +3,17 @@
* be most useful when using DataTables for a networking application, and * be most useful when using DataTables for a networking application, and
* reporting information containing IP address. Also has a matching type * reporting information containing IP address. Also has a matching type
* detection plug-in for automatic type detection. * detection plug-in for automatic type detection.
*
* @name IP addresses * @name IP addresses
* @anchor ip_address * @summary Sort IP addresses numerically
* @author Brad Wasson * @author Brad Wasson
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'ip-address', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,9 +1,17 @@
/** /**
* This sorting plug-in will sort, in calendar order, data which * This sorting plug-in will sort, in calendar order, data which
* is in the format "MM YY". * is in the format "MM YY".
* @name Month / year sorting *
* @anchor monthYear * @name Date (MM YY)
* @anchor Sort dates in the format `MM YY`
* @author Michael Motek * @author Michael Motek
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'monthYear', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,13 +1,22 @@
/** /**
* Data can often be a complicated mix of numbers and letters (file names * Data can often be a complicated mix of numbers and letters (file names
* are a common example) and sorting them in a natural manner is quite a * are a common example) and sorting them in a natural manner is quite a
* difficult problem. Fortunately a deal of work has already been done in * difficult problem.
* this area by other authors - the following plug-in uses the naturalSort() *
* function by Jim Palmer (<a href="http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm-with-unicode-support/">download it here</a>) * Fortunately a deal of work has already been done in this area by other
* to provide natural sorting in DataTables. * authors - the following plug-in uses the [naturalSort() function by Jim
* Palmer](http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm-with-unicode-support) to provide natural sorting in DataTables.
*
* @name Natural sorting * @name Natural sorting
* @anchor natrual * @summary Sort data with a mix of numbers and letters _naturally_.
* @author <a href="http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm/">Jim Palmer</a> * @author [Jim Palmer](http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm-with-unicode-support)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'natural', targets: 0 }
* ]
* } );
*/ */
(function() { (function() {
@ -31,26 +40,39 @@ function naturalSort (a, b) {
xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
// numeric, hex or date detection // numeric, hex or date detection
xD = parseInt(x.match(hre)) || (xN.length != 1 && x.match(dre) && Date.parse(x)), xD = parseInt(x.match(hre), 10) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
yD = parseInt(y.match(hre)) || xD && y.match(dre) && Date.parse(y) || null; yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
// first try and sort Hex codes or Dates // first try and sort Hex codes or Dates
if (yD) if (yD) {
if ( xD < yD ) return -1; if ( xD < yD ) {
else if ( xD > yD ) return 1; return -1;
}
else if ( xD > yD ) {
return 1;
}
}
// natural sorting through split numeric strings and default strings // natural sorting through split numeric strings and default strings
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) { for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
// find floats not starting with '0', string or 0 if not defined (Clint Priest) // find floats not starting with '0', string or 0 if not defined (Clint Priest)
var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0; var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc], 10) || xN[cLoc] || 0;
var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0; var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc], 10) || yN[cLoc] || 0;
// handle numeric vs string comparison - number < string - (Kyle Adams) // handle numeric vs string comparison - number < string - (Kyle Adams)
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) return (isNaN(oFxNcL)) ? 1 : -1; if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
return (isNaN(oFxNcL)) ? 1 : -1;
}
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2' // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
else if (typeof oFxNcL !== typeof oFyNcL) { else if (typeof oFxNcL !== typeof oFyNcL) {
oFxNcL += ''; oFxNcL += '';
oFyNcL += ''; oFyNcL += '';
} }
if (oFxNcL < oFyNcL) return -1; if (oFxNcL < oFyNcL) {
if (oFxNcL > oFyNcL) return 1; return -1;
}
if (oFxNcL > oFyNcL) {
return 1;
}
} }
return 0; return 0;
} }

@ -4,9 +4,22 @@
* strips the HTML and then sorts by numbers. Note also that this sorting * strips the HTML and then sorts by numbers. Note also that this sorting
* plug-in has an equivalent type detection plug-in which can make integration * plug-in has an equivalent type detection plug-in which can make integration
* easier. * easier.
*
* DataTables 1.10+ has HTML numeric data type detection and sorting abilities
* built-in. As such this plug-in is marked as depreciated, but might be useful
* when working with old versions of DataTables.
*
* @name Numbers with HTML * @name Numbers with HTML
* @anchor numbers_html * @summary Sort data which is a mix of HTML and numeric data.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'num-html', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,15 +1,24 @@
/** /**
* It is not uncommon for non-English speaking countries to use a comma for a * It is not uncommon for non-English speaking countries to use a comma for a
* decimal place. This sorting plug-in shows how that can be taken account of in * decimal place. This sorting plug-in shows how that can be taken account of in
* sorting by adding the type 'numeric-comma' to DataTables. A type detection * sorting by adding the type `numeric-comma` to DataTables. A type detection
* plug-in for this sorting method is provided below. * plug-in for this sorting method is provided below.
* *
* Please note that the 'Formatted numbers' type detection and sorting plug-ins * Please note that the 'Formatted numbers' type detection and sorting plug-ins
* offer greater flexibility that this plug-in and should be used in preference * offer greater flexibility that this plug-in and should be used in preference
* to this method. * to this method.
*
* @name Commas for decimal place * @name Commas for decimal place
* @anchor numeric_comma * @summary Sort numbers correctly which use a common as the decimal place.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'numeric-comma', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,8 +1,21 @@
/** /**
* Sort numeric data which has a percent sign with it. * Sort numeric data which has a percent sign with it.
*
* DataTables 1.10+ has percentage data type detection and sorting abilities
* built-in. As such this plug-in is marked as depreciated, but might be useful
* when working with old versions of DataTables.
*
* @name Percentage * @name Percentage
* @anchor percentage * @summary Sort numeric data with a postfixed percentage symbol
* @author <a href="http://jonathanromley.org/">Jonathan Romley</a> * @depreciated
* @author [Jonathan Romley](http://jonathanromley.org/)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'percent', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -2,9 +2,17 @@
* Sorting in Javascript can be difficult to get right with non-Roman * Sorting in Javascript can be difficult to get right with non-Roman
* characters - for which special consideration must be made. This plug-in * characters - for which special consideration must be made. This plug-in
* performs correct sorting on Persian characters. * performs correct sorting on Persian characters.
*
* @name Persian * @name Persian
* @anchor Persian * @summary Sort Persian strings alphabetically
* @author <a href="http://www.afshinblog.com/">Afshin Mehrabani</a> * @author [Afshin Mehrabani](http://www.afshinblog.com/)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'pstring', targets: 0 }
* ]
* } );
*/ */
(function(){ (function(){
@ -14,23 +22,25 @@ var persianSort = [ 'آ', 'ا', 'ب', 'پ', 'ت', 'ث', 'ج', 'چ', 'ح', 'خ',
function GetUniCode(source) { function GetUniCode(source) {
source = $.trim(source); source = $.trim(source);
result = ''; var result = '';
var i, index;
for (i = 0; i < source.length; i++) { for (i = 0; i < source.length; i++) {
//Check and fix IE indexOf bug //Check and fix IE indexOf bug
if (!Array.indexOf) { if (!Array.indexOf) {
var index = jQuery.inArray(source.charAt(i), persianSort); index = jQuery.inArray(source.charAt(i), persianSort);
}else{ }else{
var index = persianSort.indexOf(source.charAt(i)); index = persianSort.indexOf(source.charAt(i));
} }
if (index < 0) { if (index < 0) {
index = source.charCodeAt(i); index = source.charCodeAt(i);
} }
if (index < 10) if (index < 10) {
index = '0' + index; index = '0' + index;
}
result += '00' + index; result += '00' + index;
} }
return 'a' + result; return 'a' + result;
}; }
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"pstring-pre": function ( a ) { "pstring-pre": function ( a ) {

@ -1,9 +1,17 @@
/** /**
* This plug-in will treat numbers which are in scientific notation (for * This plug-in will treat numbers which are in scientific notation (for
* example 1E-10, 1.2E6 etc) and sort them numerically. * example `1E-10`, `1.2E6` etc) and sort them numerically.
*
* @name Scientific notation sorting * @name Scientific notation sorting
* @anchor scientific * @summary Sort data which is written in exponential notation.
* @author <a href="http://datatables.net/forums/profile/21757/nickschurch">Nick Schurch</a> * @author [Nick Schurch](http://datatables.net/forums/profile/21757/nickschurch)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'scientific', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -2,9 +2,17 @@
* Although DataTables' internal numeric sorting works no problem on negative * Although DataTables' internal numeric sorting works no problem on negative
* numbers, it does not accept positively signed numbers. This plug-in will * numbers, it does not accept positively signed numbers. This plug-in will
* sort just such data numerically. * sort just such data numerically.
*
* @name Fully signed numbers sorting * @name Fully signed numbers sorting
* @anchor Signed_Numbers * @summary Sort data numerically with a leading `+` symbol (as well as `-`).
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'signed-num', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -5,10 +5,23 @@
* difficulties of sorting formatted numbers is to have the data to be sorted * difficulties of sorting formatted numbers is to have the data to be sorted
* upon separate from the visual data. This sorting function pair will use the * upon separate from the visual data. This sorting function pair will use the
* 'title' attribute of en empty span element (or anything else) to sort * 'title' attribute of en empty span element (or anything else) to sort
* numerically (for example <span title="1000000"><span>1'000'000). * numerically (for example `<span title="1000000"><span>1'000'000`).
*
* Note that the HTML5 `data-sort` attribute can be [used to supply sorting data
* to DataTables](//datatables.net/manual/orthogonal-data) and is preferable to
* using this method, which is therefore marked as depreciated.
*
* @name Hidden title numeric sorting * @name Hidden title numeric sorting
* @anchor hidden_title * @summary Sort data numerically based on an attribute on an empty element.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'title-numeric', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,11 +1,23 @@
/** /**
* Just like the "hidden title numeric sorting" plug-in, this sorting plug-in * Just like the _hidden title numeric sorting_ plug-in, this sorting plug-in
* will take the information to be sorted on from the title attribute of a span * will take the information to be sorted on from the title attribute of a span
* element. The only difference is that it is string based sorting rather than * element. The only difference is that it is string based sorting rather than
* numeric. * numeric.
*
* Note that the HTML5 `data-sort` attribute can be [used to supply sorting data
* to DataTables](//datatables.net/manual/orthogonal-data) and is preferable to
* using this method, which is therefore marked as depreciated.
*
* @name Hidden title string sorting * @name Hidden title string sorting
* @anchor hidden_title_string * @summary Sort data as a string based on an attribute on an empty element.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'title-string', targets: 0 }
* ]
* } );
*/ */
jQuery.extend( jQuery.fn.dataTableExt.oSort, { jQuery.extend( jQuery.fn.dataTableExt.oSort, {

@ -1,11 +1,17 @@
/** /**
* This plug-in will add automatic detection for currency columns to * This plug-in will add automatic detection for currency columns to
* DataTables. Note that only $ and £ symbols are detected with this code, * DataTables. Note that only $, £ and symbols are detected with this code,
* but it is trivial to add more or change the current ones. This is best used * but it is trivial to add more or change the current ones. This is best used
* in conjunction with the currency sorting plug-in. * in conjunction with the currency sorting plug-in.
*
* DataTables 1.10+ has currency sorting abilities built-in and will be
* automatically detected. As such this plug-in is marked as depreciated, but
* might be useful when working with old versions of DataTables.
*
* @name Currency * @name Currency
* @anchor currency * @summary Detect data of numeric type with a leading currency symbol.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a>, Nuno Gomes * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk), Nuno Gomes
*/ */
(function(){ (function(){

@ -1,8 +1,9 @@
/** /**
* Automatically detect British (dd/mm/yyyy) date types. Goes with the UK * Automatically detect British (`dd/mm/yyyy`) date types. Goes with the UK
* date sorting plug-in. * date sorting plug-in.
* @name UK date type detection *
* @anchor uk_date * @name Date (`dd/mm/yyyy`)
* @summary Detect data which is in the date format `dd/mm/yyyy`
* @author Andy McMaster * @author Andy McMaster
*/ */

@ -2,9 +2,10 @@
* Detect "file size" type columns automatically. Commonly used for computer * Detect "file size" type columns automatically. Commonly used for computer
* file sizes, this can allow sorting to take the order of magnitude indicated * file sizes, this can allow sorting to take the order of magnitude indicated
* by the label (GB etc) into account. * by the label (GB etc) into account.
*
* @name File size * @name File size
* @anchor file_size * @summary Detect abbreviated file size data (8MB, 4KB etc)
* @author <i>anjibman</i> * @author _anjibman_
*/ */
jQuery.fn.dataTableExt.aTypes.unshift( jQuery.fn.dataTableExt.aTypes.unshift(
@ -14,7 +15,7 @@ jQuery.fn.dataTableExt.aTypes.unshift(
var Char; var Char;
/* Check the numeric part */ /* Check the numeric part */
for ( i=0 ; i<(sData.length - 3) ; i++ ) for ( var i=0 ; i<(sData.length - 3) ; i++ )
{ {
Char = sData.charAt(i); Char = sData.charAt(i);
if (sValidChars.indexOf(Char) == -1) if (sValidChars.indexOf(Char) == -1)

@ -3,11 +3,16 @@
* formatted number (for example 1,000,000) can be detected automatically and * formatted number (for example 1,000,000) can be detected automatically and
* sorted numerically. Note that characters a-z are not automatically removed, * sorted numerically. Note that characters a-z are not automatically removed,
* otherwise there is a risk of detecting columns as numeric which should not * otherwise there is a risk of detecting columns as numeric which should not
* be. Also note that the jQuery 1.7 method isNumeric is used, so jQuery 1.7 * be.
* is required. *
* DataTables 1.10+ has formatted number type detection and sorting abilities
* built-in. As such this plug-in is marked as depreciated, but might be useful
* when working with old versions of DataTables.
*
* @name Formatted numbers * @name Formatted numbers
* @anchor formatted_numbers * @summary formatted_numbers
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*/ */
jQuery.fn.dataTableExt.aTypes.unshift( jQuery.fn.dataTableExt.aTypes.unshift(

@ -1,8 +1,9 @@
/** /**
* Automatically detect IP addresses in dot notation. Goes perfectly with the * Automatically detect IP addresses in dot notation. Goes perfectly with the
* IP address sorting function. * IP address sorting function.
*
* @name IP address detection * @name IP address detection
* @anchor ip_address * @summary Detect data which is in IP address notation
* @author Brad Wasson * @author Brad Wasson
*/ */

@ -3,9 +3,15 @@
* strip the HTML tags and then check to see if the remaining data is numeric. * strip the HTML tags and then check to see if the remaining data is numeric.
* If it is, then the data can be sorted numerically with the Numbers with HTML * If it is, then the data can be sorted numerically with the Numbers with HTML
* sorting plug-in. * sorting plug-in.
*
* DataTables 1.10+ has numeric HTML data type and sorting abilities built-in.
* As such this plug-in is marked as depreciated, but might be useful when
* working with old versions of DataTables.
*
* @name Numbers with HTML * @name Numbers with HTML
* @anchor numbers_html * @summary Detect data which is a mix of HTML and numeric data.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*/ */
jQuery.fn.dataTableExt.aTypes.unshift( function ( sData ) jQuery.fn.dataTableExt.aTypes.unshift( function ( sData )

@ -5,9 +5,11 @@
* Please note that the 'Formatted numbers' type detection and sorting plug-ins * Please note that the 'Formatted numbers' type detection and sorting plug-ins
* offer greater flexibility that this plug-in and should be used in preference * offer greater flexibility that this plug-in and should be used in preference
* to this method. * to this method.
*
* @name Commas for decimal place * @name Commas for decimal place
* @anchor numeric_comma * @summary Detect numeric data which uses a comma as the decimal place.
* @author <a href="http://sprymedia.co.uk">Allan Jardine</a> * @depreciated
* @author [Allan Jardine](http://sprymedia.co.uk)
*/ */
jQuery.fn.dataTableExt.aTypes.unshift( jQuery.fn.dataTableExt.aTypes.unshift(
@ -24,7 +26,7 @@ jQuery.fn.dataTableExt.aTypes.unshift(
} }
/* Check the numeric part */ /* Check the numeric part */
for ( i=iStart ; i<sData.length ; i++ ) for ( var i=iStart ; i<sData.length ; i++ )
{ {
Char = sData.charAt(i); Char = sData.charAt(i);
if (sValidChars.indexOf(Char) == -1) if (sValidChars.indexOf(Char) == -1)

Loading…
Cancel
Save