/*
* File: jquery.dataTables.js
* Version: 1.9.0.dev
* Description: Paginate, search and sort HTML tables
* Author: Allan Jardine (www.sprymedia.co.uk)
* Created: 28/3/2008
* Language: Javascript
* License: GPL v2 or BSD 3 point style
* Project: Mtaala
* Contact: allan.jardine@sprymedia.co.uk
*
* Copyright 2008-2011 Allan Jardine, all rights reserved.
*
* This source file is free software, under either the GPL v2 license or a
* BSD style license, as supplied with this software.
*
* This source file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
*
* For details please refer to: http://www.datatables.net
*/
/*
* When considering jsLint, we need to allow eval() as it it is used for reading cookies
*/
/*jslint evil: true, undef: true, browser: true */
/*globals $, jQuery,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnArrayCmp,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn*/
(function($, window, document) {
/**
* DataTables is a plug-in for the jQuery Javascript library. It is a
* highly flexible tool, based upon the foundations of progressive
* enhancement, which will add advanced interaction controls to any
* HTML table. For a full list of features please refer to
* DataTables.net.
* @class
* @constructor
* @param {object} [oInit={}] Configuration object for DataTables. Options
* are defined by {@link FixedColumns.defaults}
* @requires jQuery 1.3+
*
* @example
* // Basic initialisation
* $(document).ready( function {
* $('#example').dataTable();
* } );
*
* @example
* // Initialisation with configuration options - in this case, disable
* // pagination and sorting.
* $(document).ready( function {
* $('#example').dataTable( {
* "bPaginate": false,
* "bSort": false
* } );
* } );
*/
window.DataTable = function( oInit )
{
/**
* Add a column to the list used for the table with default values
* @param {object} oSettings dataTables settings object
* @param {node} nTh The th element for this column
* @private
*/
function _fnAddColumn( oSettings, nTh )
{
var iCol = oSettings.aoColumns.length;
var oCol = {
"sType": null,
"_bAutoType": true,
"bVisible": true,
"bSearchable": true,
"bSortable": true,
"asSorting": [ 'asc', 'desc' ],
"sSortingClass": oSettings.oClasses.sSortable,
"sSortingClassJUI": oSettings.oClasses.sSortJUI,
"sTitle": nTh ? nTh.innerHTML : '',
"sName": '',
"sWidth": null,
"sWidthOrig": null,
"sClass": null,
"fnRender": null,
"bUseRendered": true,
"aDataSort": [ iCol ],
"mDataProp": iCol,
"fnGetData": null,
"fnSetData": null,
"sSortDataType": 'std',
"sDefaultContent": null,
"sContentPadding": "",
"nTh": nTh ? nTh : document.createElement('th'),
"nTf": null
};
oSettings.aoColumns.push( oCol );
/* Add a column specific filter */
if ( typeof oSettings.aoPreSearchCols[ iCol ] == 'undefined' ||
oSettings.aoPreSearchCols[ iCol ] === null )
{
oSettings.aoPreSearchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch );
}
else
{
/* Don't require that the user must specify bRegex and / or bSmart */
if ( typeof oSettings.aoPreSearchCols[ iCol ].bRegex == 'undefined' )
{
oSettings.aoPreSearchCols[ iCol ].bRegex = true;
}
if ( typeof oSettings.aoPreSearchCols[ iCol ].bSmart == 'undefined' )
{
oSettings.aoPreSearchCols[ iCol ].bSmart = true;
}
}
/* Use the column options function to initialise classes etc */
_fnColumnOptions( oSettings, iCol, null );
}
/**
* Apply options for a column
* @param {object} oSettings dataTables settings object
* @param {int} iCol column index to consider
* @param {object} oOptions object with sType, bVisible and bSearchable
* @private
*/
function _fnColumnOptions( oSettings, iCol, oOptions )
{
var oCol = oSettings.aoColumns[ iCol ];
/* User specified column options */
if ( typeof oOptions != 'undefined' && oOptions !== null )
{
if ( typeof oOptions.sType != 'undefined' )
{
oCol.sType = oOptions.sType;
oCol._bAutoType = false;
}
_fnMap( oCol, oOptions, "bVisible" );
_fnMap( oCol, oOptions, "bSearchable" );
_fnMap( oCol, oOptions, "bSortable" );
_fnMap( oCol, oOptions, "sTitle" );
_fnMap( oCol, oOptions, "sName" );
_fnMap( oCol, oOptions, "sWidth" );
_fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
_fnMap( oCol, oOptions, "sClass" );
_fnMap( oCol, oOptions, "fnRender" );
_fnMap( oCol, oOptions, "bUseRendered" );
_fnMap( oCol, oOptions, "mDataProp" );
_fnMap( oCol, oOptions, "asSorting" );
_fnMap( oCol, oOptions, "sSortDataType" );
_fnMap( oCol, oOptions, "sDefaultContent" );
_fnMap( oCol, oOptions, "sContentPadding" );
/* iDataSort to be applied (backwards compatibility), but aDataSort will take
* priority if defined
*/
if ( typeof oOptions.iDataSort != 'undefined' )
{
oCol.aDataSort = [ oOptions.iDataSort ];
}
_fnMap( oCol, oOptions, "aDataSort" );
}
/* Cache the data get and set functions for speed */
oCol.fnGetData = _fnGetObjectDataFn( oCol.mDataProp );
oCol.fnSetData = _fnSetObjectDataFn( oCol.mDataProp );
/* Feature sorting overrides column specific when off */
if ( !oSettings.oFeatures.bSort )
{
oCol.bSortable = false;
}
/* Check that the class assignment is correct for sorting */
if ( !oCol.bSortable ||
($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) )
{
oCol.sSortingClass = oSettings.oClasses.sSortableNone;
oCol.sSortingClassJUI = "";
}
else if ( oCol.bSortable ||
($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) )
{
oCol.sSortingClass = oSettings.oClasses.sSortable;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUI;
}
else if ( $.inArray('asc', oCol.asSorting) != -1 && $.inArray('desc', oCol.asSorting) == -1 )
{
oCol.sSortingClass = oSettings.oClasses.sSortableAsc;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIAscAllowed;
}
else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) != -1 )
{
oCol.sSortingClass = oSettings.oClasses.sSortableDesc;
oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIDescAllowed;
}
}
/**
* Adjust the table column widths for new data. Note: you would probably want to
* do a redraw after calling this function!
* @param {object} oSettings dataTables settings object
* @private
*/
function _fnAdjustColumnSizing ( oSettings )
{
/* Not interested in doing column width calculation if autowidth is disabled */
if ( oSettings.oFeatures.bAutoWidth === false )
{
return false;
}
_fnCalculateColumnWidths( oSettings );
for ( var i=0 , iLen=oSettings.aoColumns.length ; i=0 if successful (index of new aoData entry), -1 if failed
* @private
*/
function _fnAddData ( oSettings, aDataSupplied )
{
var oCol;
/* Take an independent copy of the data source so we can bash it about as we wish */
var aDataIn = ($.isArray(aDataSupplied)) ?
aDataSupplied.slice() :
$.extend( true, {}, aDataSupplied );
/* Create the object for storing information about this new row */
var iRow = oSettings.aoData.length;
var oData = $.extend( true, {}, DataTable.models.oRow, {
"_aData": aDataIn
} );
oSettings.aoData.push( oData );
/* Create the cells */
var nTd, sThisType;
for ( var i=0, iLen=oSettings.aoColumns.length ; i iTarget )
{
a[i]--;
}
}
if ( iTargetIndex != -1 )
{
a.splice( iTargetIndex, 1 );
}
}
/**
* Create a new TR element (and it's TD children) for a row
* @param {object} oSettings dataTables settings object
* @param {int} iRow Row to consider
* @private
*/
function _fnCreateTr ( oSettings, iRow )
{
var oData = oSettings.aoData[iRow];
var nTd;
if ( oData.nTr === null )
{
oData.nTr = document.createElement('tr');
/* Special parameters can be given by the data source to be used on the row */
if ( typeof oData._aData.DT_RowId != 'undefined' )
{
oData.nTr.setAttribute( 'id', oData._aData.DT_RowId );
}
if ( typeof oData._aData.DT_RowClass != 'undefined' )
{
$(oData.nTr).addClass( oData._aData.DT_RowClass );
}
/* Process each column */
for ( var i=0, iLen=oSettings.aoColumns.length ; i=0 ; j-- )
{
if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
{
aoLocal[i].splice( j, 1 );
}
}
/* Prep the applied array - it needs an element for each row */
aApplied.push( [] );
}
for ( i=0, iLen=aoLocal.length ; i= oSettings.fnRecordsDisplay()) ?
0 : oSettings.iInitDisplayStart;
}
oSettings.iInitDisplayStart = -1;
_fnCalculateEnd( oSettings );
}
/* Server-side processing draw intercept */
if ( oSettings.bDeferLoading )
{
oSettings.bDeferLoading = false;
oSettings.iDraw++;
}
else if ( !oSettings.oFeatures.bServerSide )
{
oSettings.iDraw++;
}
else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
{
return;
}
if ( oSettings.aiDisplay.length !== 0 )
{
var iStart = oSettings._iDisplayStart;
var iEnd = oSettings._iDisplayEnd;
if ( oSettings.oFeatures.bServerSide )
{
iStart = 0;
iEnd = oSettings.aoData.length;
}
for ( var j=iStart ; j=0 ; i-- )
{
nTrs[i].parentNode.removeChild( nTrs[i] );
}
}
/* Put the draw table into the dom */
for ( i=0, iLen=anRows.length ; i=0 ; i-- )
{
oSettings.aoDrawCallback[i].fn.call( oSettings.oInstance, oSettings );
}
$(oSettings.oInstance).trigger('draw', oSettings);
/* Draw is complete, sorting and filtering must be as well */
oSettings.bSorted = false;
oSettings.bFiltered = false;
oSettings.bDrawing = false;
if ( oSettings.oFeatures.bServerSide )
{
_fnProcessingDisplay( oSettings, false );
if ( typeof oSettings._bInitComplete == 'undefined' )
{
_fnInitComplete( oSettings );
}
}
}
/**
* Redraw the table - taking account of the various features which are enabled
* @param {object} oSettings dataTables settings object
* @private
*/
function _fnReDraw( oSettings )
{
if ( oSettings.oFeatures.bSort )
{
/* Sorting will refilter and draw for us */
_fnSort( oSettings, oSettings.oPreviousSearch );
}
else if ( oSettings.oFeatures.bFilter )
{
/* Filtering will redraw for us */
_fnFilterComplete( oSettings, oSettings.oPreviousSearch );
}
else
{
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
}
/**
* Update the table using an Ajax call
* @param {object} oSettings dataTables settings object
* @returns {boolean} Block the table drawing or not
* @private
*/
function _fnAjaxUpdate( oSettings )
{
if ( oSettings.bAjaxDataGet )
{
oSettings.iDraw++;
_fnProcessingDisplay( oSettings, true );
var iColumns = oSettings.aoColumns.length;
var aoData = _fnAjaxParameters( oSettings );
_fnServerParams( oSettings, aoData );
oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aoData,
function(json) {
_fnAjaxUpdateDraw( oSettings, json );
}, oSettings );
return false;
}
else
{
return true;
}
}
/**
* Build up the parameters in an object needed for a server-side processing request
* @param {object} oSettings dataTables settings object
* @returns {bool} block the table drawing or not
* @private
*/
function _fnAjaxParameters( oSettings )
{
var iColumns = oSettings.aoColumns.length;
var aoData = [], mDataProp;
var i;
aoData.push( { "name": "sEcho", "value": oSettings.iDraw } );
aoData.push( { "name": "iColumns", "value": iColumns } );
aoData.push( { "name": "sColumns", "value": _fnColumnOrdering(oSettings) } );
aoData.push( { "name": "iDisplayStart", "value": oSettings._iDisplayStart } );
aoData.push( { "name": "iDisplayLength", "value": oSettings.oFeatures.bPaginate !== false ?
oSettings._iDisplayLength : -1 } );
for ( i=0 ; i' )
{
/* End container div */
nInsertNode = nInsertNode.parentNode;
}
else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange )
{
/* Length */
nTmp = _fnFeatureHtmlLength( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'f' && oSettings.oFeatures.bFilter )
{
/* Filter */
nTmp = _fnFeatureHtmlFilter( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'r' && oSettings.oFeatures.bProcessing )
{
/* pRocessing */
nTmp = _fnFeatureHtmlProcessing( oSettings );
iPushFeature = 1;
}
else if ( cOption == 't' )
{
/* Table */
nTmp = _fnFeatureHtmlTable( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'i' && oSettings.oFeatures.bInfo )
{
/* Info */
nTmp = _fnFeatureHtmlInfo( oSettings );
iPushFeature = 1;
}
else if ( cOption == 'p' && oSettings.oFeatures.bPaginate )
{
/* Pagination */
nTmp = _fnFeatureHtmlPaginate( oSettings );
iPushFeature = 1;
}
else if ( _oExt.aoFeatures.length !== 0 )
{
/* Plug-in features */
var aoFeatures = _oExt.aoFeatures;
for ( var k=0, kLen=aoFeatures.length ; k') :
sSearchStr==="" ? '' : sSearchStr+' ';
var nFilter = document.createElement( 'div' );
nFilter.className = oSettings.oClasses.sFilter;
nFilter.innerHTML = '';
if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.f == "undefined" )
{
nFilter.setAttribute( 'id', oSettings.sTableId+'_filter' );
}
var jqFilter = $("input", nFilter);
jqFilter.val( oSettings.oPreviousSearch.sSearch.replace('"','"') );
jqFilter.bind( 'keyup.DT', function(e) {
/* Update all other filter input elements for the new display */
var n = oSettings.aanFeatures.f;
for ( var i=0, iLen=n.length ; i=0 ; i-- )
{
var sData = _fnDataToSearch( _fnGetCellData( oSettings, oSettings.aiDisplay[i], iColumn, 'filter' ),
oSettings.aoColumns[iColumn].sType );
if ( ! rpSearch.test( sData ) )
{
oSettings.aiDisplay.splice( i, 1 );
iIndexCorrector++;
}
}
}
/**
* Filter the data table based on user input and draw the table
* @param {object} oSettings dataTables settings object
* @param {string} sInput string to filter on
* @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0)
* @param {bool} bRegex treat as a regular expression or not
* @param {bool} bSmart perform smart filtering or not
* @private
*/
function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart )
{
var i;
var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart );
/* Check if we are forcing or not - optional parameter */
if ( typeof iForce == 'undefined' || iForce === null )
{
iForce = 0;
}
/* Need to take account of custom filtering functions - always filter */
if ( _oExt.afnFiltering.length !== 0 )
{
iForce = 1;
}
/*
* If the input is blank - we want the full data set
*/
if ( sInput.length <= 0 )
{
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
}
else
{
/*
* We are starting a new search or the new search string is smaller
* then the old one (i.e. delete). Search from the master array
*/
if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
oSettings.oPreviousSearch.sSearch.length > sInput.length || iForce == 1 ||
sInput.indexOf(oSettings.oPreviousSearch.sSearch) !== 0 )
{
/* Nuke the old display array - we are going to rebuild it */
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
/* Force a rebuild of the search array */
_fnBuildSearchArray( oSettings, 1 );
/* Search through all records to populate the search array
* The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1
* mapping
*/
for ( i=0 ; i tag - remove it */
sSearch = sSearch.replace(/\n/g," ").replace(/\r/g,"");
}
return sSearch;
}
/**
* Build a regular expression object suitable for searching a table
* @param {string} sSearch string to search for
* @param {bool} bRegex treat as a regular expression or not
* @param {bool} bSmart perform smart filtering or not
* @returns {RegExp} constructed object
* @private
*/
function _fnFilterCreateSearch( sSearch, bRegex, bSmart )
{
var asSearch, sRegExpString;
if ( bSmart )
{
/* Generate the regular expression to use. Something along the lines of:
* ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
*/
asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' );
sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
return new RegExp( sRegExpString, "i" );
}
else
{
sSearch = bRegex ? sSearch : _fnEscapeRegex( sSearch );
return new RegExp( sSearch, "i" );
}
}
/**
* Convert raw data into something that the user can search on
* @param {string} sData data to be modified
* @param {string} sType data type
* @returns {string} search string
* @private
*/
function _fnDataToSearch ( sData, sType )
{
if ( typeof _oExt.ofnSearch[sType] == "function" )
{
return _oExt.ofnSearch[sType]( sData );
}
else if ( sType == "html" )
{
return sData.replace(/[\r\n]/g," ").replace( /<.*?>/g, "" );
}
else if ( typeof sData == "string" )
{
return sData.replace(/[\r\n]/g," ");
}
else if ( sData === null )
{
return '';
}
return sData;
}
/**
* scape a string stuch that it can be used in a regular expression
* @param {string} sVal string to escape
* @returns {string} escaped string
* @private
*/
function _fnEscapeRegex ( sVal )
{
var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^' ];
var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
return sVal.replace(reReplace, '\\$1');
}
/**
* Generate the node required for the info display
* @param {object} oSettings dataTables settings object
* @returns {node} Information element
* @private
*/
function _fnFeatureHtmlInfo ( oSettings )
{
var nInfo = document.createElement( 'div' );
nInfo.className = oSettings.oClasses.sInfo;
/* Actions that are to be taken once only for this feature */
if ( typeof oSettings.aanFeatures.i == "undefined" )
{
/* Add draw callback */
oSettings.aoDrawCallback.push( {
"fn": _fnUpdateInfo,
"sName": "information"
} );
/* Add id */
if ( oSettings.sTableId !== '' )
{
nInfo.setAttribute( 'id', oSettings.sTableId+'_info' );
}
}
return nInfo;
}
/**
* Update the information elements in the display
* @param {object} oSettings dataTables settings object
* @private
*/
function _fnUpdateInfo ( oSettings )
{
/* Show information about the table */
if ( !oSettings.oFeatures.bInfo || oSettings.aanFeatures.i.length === 0 )
{
return;
}
var
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;
/* When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
* internally
*/
if ( oSettings.oScroll.bInfinite )
{
sStart = oSettings.fnFormatNumber( 1 );
}
if ( oSettings.fnRecordsDisplay() === 0 &&
oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
{
/* Empty record set */
sOut = oSettings.oLanguage.sInfoEmpty+ oSettings.oLanguage.sInfoPostFix;
}
else if ( oSettings.fnRecordsDisplay() === 0 )
{
/* Rmpty record set after filtering */
sOut = oSettings.oLanguage.sInfoEmpty +' '+
oSettings.oLanguage.sInfoFiltered.replace('_MAX_', sMax)+
oSettings.oLanguage.sInfoPostFix;
}
else if ( oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
{
/* Normal record set */
sOut = oSettings.oLanguage.sInfo.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_TOTAL_', sTotal)+
oSettings.oLanguage.sInfoPostFix;
}
else
{
/* Record set after filtering */
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;
}
if ( oSettings.oLanguage.fnInfoCallback !== null )
{
sOut = oSettings.oLanguage.fnInfoCallback( oSettings, iStart, iEnd, iMax, iTotal, sOut );
}
var n = oSettings.aanFeatures.i;
for ( var i=0, iLen=n.length ; i';
var i, iLen;
if ( oSettings.aLengthMenu.length == 2 && typeof oSettings.aLengthMenu[0] == 'object' &&
typeof oSettings.aLengthMenu[1] == 'object' )
{
for ( i=0, iLen=oSettings.aLengthMenu[0].length ; i'+
oSettings.aLengthMenu[1][i]+'';
}
}
else
{
for ( i=0, iLen=oSettings.aLengthMenu.length ; i'+
oSettings.aLengthMenu[i]+'';
}
}
sStdMenu += '';
var nLength = document.createElement( 'div' );
if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.l == "undefined" )
{
nLength.setAttribute( 'id', oSettings.sTableId+'_length' );
}
nLength.className = oSettings.oClasses.sLength;
nLength.innerHTML = '';
/*
* Set the length to the current display length - thanks to Andrea Pavlovic for this fix,
* and Stefan Skopnik for fixing the fix!
*/
$('select option[value="'+oSettings._iDisplayLength+'"]',nLength).attr("selected",true);
$('select', nLength).bind( 'change.DT', function(e) {
var iVal = $(this).val();
/* Update all other length options for the new display */
var n = oSettings.aanFeatures.l;
for ( i=0, iLen=n.length ; i oSettings.aiDisplay.length ||
oSettings._iDisplayLength == -1 )
{
oSettings._iDisplayEnd = oSettings.aiDisplay.length;
}
else
{
oSettings._iDisplayEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
}
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Note that most of the paging logic is done in
* _oExt.oPagination
*/
/**
* Generate the node required for default pagination
* @param {object} oSettings dataTables settings object
* @returns {node} Pagination feature node
* @private
*/
function _fnFeatureHtmlPaginate ( oSettings )
{
if ( oSettings.oScroll.bInfinite )
{
return null;
}
var nPaginate = document.createElement( 'div' );
nPaginate.className = oSettings.oClasses.sPaging+oSettings.sPaginationType;
_oExt.oPagination[ oSettings.sPaginationType ].fnInit( oSettings, nPaginate,
function( oSettings ) {
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
);
/* Add a draw callback for the pagination on first instance, to update the paging display */
if ( typeof oSettings.aanFeatures.p == "undefined" )
{
oSettings.aoDrawCallback.push( {
"fn": function( oSettings ) {
_oExt.oPagination[ oSettings.sPaginationType ].fnUpdate( oSettings, function( oSettings ) {
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
} );
},
"sName": "pagination"
} );
}
return nPaginate;
}
/**
* Alter the display settings to change the page
* @param {object} oSettings dataTables settings object
* @param {string} sAction paging action to take: "first", "previous", "next" or "last"
* @returns {bool} true page has changed, false - no change (no effect) eg 'first' on page 1
* @private
*/
function _fnPageChange ( oSettings, sAction )
{
var iOldStart = oSettings._iDisplayStart;
if ( sAction == "first" )
{
oSettings._iDisplayStart = 0;
}
else if ( sAction == "previous" )
{
oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ?
oSettings._iDisplayStart - oSettings._iDisplayLength :
0;
/* Correct for underrun */
if ( oSettings._iDisplayStart < 0 )
{
oSettings._iDisplayStart = 0;
}
}
else if ( sAction == "next" )
{
if ( oSettings._iDisplayLength >= 0 )
{
/* Make sure we are not over running the display array */
if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
{
oSettings._iDisplayStart += oSettings._iDisplayLength;
}
}
else
{
oSettings._iDisplayStart = 0;
}
}
else if ( sAction == "last" )
{
if ( oSettings._iDisplayLength >= 0 )
{
var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1;
oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength;
}
else
{
oSettings._iDisplayStart = 0;
}
}
else
{
_fnLog( oSettings, 0, "Unknown paging action: "+sAction );
}
$(oSettings.oInstance).trigger('page', oSettings);
return iOldStart != oSettings._iDisplayStart;
}
/**
* Generate the node required for the processing node
* @param {object} oSettings dataTables settings object
* @returns {node} Processing element
* @private
*/
function _fnFeatureHtmlProcessing ( oSettings )
{
var nProcessing = document.createElement( 'div' );
if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.r == "undefined" )
{
nProcessing.setAttribute( 'id', oSettings.sTableId+'_processing' );
}
nProcessing.innerHTML = oSettings.oLanguage.sProcessing;
nProcessing.className = oSettings.oClasses.sProcessing;
oSettings.nTable.parentNode.insertBefore( nProcessing, oSettings.nTable );
return nProcessing;
}
/**
* Display or hide the processing indicator
* @param {object} oSettings dataTables settings object
* @param {bool} bShow Show the processing indicator (true) or not (false)
* @private
*/
function _fnProcessingDisplay ( oSettings, bShow )
{
if ( oSettings.oFeatures.bProcessing )
{
var an = oSettings.aanFeatures.r;
for ( var i=0, iLen=an.length ; i
$(oSettings.nTable).height() - oSettings.oScroll.iLoadGap )
{
/* Only do the redraw if we have to - we might be at the end of the data */
if ( oSettings.fnDisplayEnd() < oSettings.fnRecordsDisplay() )
{
_fnPageChange( oSettings, 'next' );
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
}
}
} );
}
oSettings.nScrollHead = nScrollHead;
oSettings.nScrollFoot = nScrollFoot;
return nScroller;
}
/**
* Update the various tables for resizing. It's a bit of a pig this function, but
* basically the idea to:
* 1. Re-create the table inside the scrolling div
* 2. Take live measurements from the DOM
* 3. Apply the measurements
* 4. Clean up
* @param {object} o dataTables settings object
* @returns {node} Node to add to the DOM
* @private
*/
function _fnScrollDraw ( o )
{
var
nScrollHeadInner = o.nScrollHead.getElementsByTagName('div')[0],
nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
nScrollBody = o.nTable.parentNode,
i, iLen, j, jLen, anHeadToSize, anHeadSizers, anFootSizers, anFootToSize, oStyle, iVis,
iWidth, aApplied=[], iSanityWidth,
nScrollFootInner = (o.nTFoot !== null) ? o.nScrollFoot.getElementsByTagName('div')[0] : null,
nScrollFootTable = (o.nTFoot !== null) ? nScrollFootInner.getElementsByTagName('table')[0] : null,
ie67 = $.browser.msie && $.browser.version <= 7;
/*
* 1. Re-create the table inside the scrolling div
*/
/* Remove the old minimised thead and tfoot elements in the inner table */
var nTheadSize = o.nTable.getElementsByTagName('thead');
if ( nTheadSize.length > 0 )
{
o.nTable.removeChild( nTheadSize[0] );
}
if ( o.nTFoot !== null )
{
/* Remove the old minimised footer element in the cloned header */
var nTfootSize = o.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
o.nTable.removeChild( nTfootSize[0] );
}
}
/* Clone the current header and footer elements and then place it into the inner table */
nTheadSize = o.nTHead.cloneNode(true);
o.nTable.insertBefore( nTheadSize, o.nTable.childNodes[0] );
if ( o.nTFoot !== null )
{
nTfootSize = o.nTFoot.cloneNode(true);
o.nTable.insertBefore( nTfootSize, o.nTable.childNodes[1] );
}
/*
* 2. Take live measurements from the DOM - do not alter the DOM itself!
*/
/* Remove old sizing and apply the calculated column widths
* Get the unique column headers in the newly created (cloned) header. We want to apply the
* calclated sizes to this header
*/
if ( o.oScroll.sX === "" )
{
nScrollBody.style.width = '100%';
nScrollHeadInner.parentNode.style.width = '100%';
}
var nThs = _fnGetUniqueThs( o, nTheadSize );
for ( i=0, iLen=nThs.length ; i
nScrollBody.offsetHeight || $(nScrollBody).css('overflow-y') == "scroll") )
{
o.nTable.style.width = _fnStringToCss( $(o.nTable).outerWidth()-o.oScroll.iBarWidth );
}
}
else
{
if ( o.oScroll.sXInner !== "" )
{
/* x scroll inner has been given - use it */
o.nTable.style.width = _fnStringToCss(o.oScroll.sXInner);
}
else if ( iSanityWidth == $(nScrollBody).width() &&
$(nScrollBody).height() < $(o.nTable).height() )
{
/* There is y-scrolling - try to take account of the y scroll bar */
o.nTable.style.width = _fnStringToCss( iSanityWidth-o.oScroll.iBarWidth );
if ( $(o.nTable).outerWidth() > iSanityWidth-o.oScroll.iBarWidth )
{
/* Not possible to take account of it */
o.nTable.style.width = _fnStringToCss( iSanityWidth );
}
}
else
{
/* All else fails */
o.nTable.style.width = _fnStringToCss( iSanityWidth );
}
}
/* Recalculate the sanity width - now that we've applied the required width, before it was
* a temporary variable. This is required because the column width calculation is done
* before this table DOM is created.
*/
iSanityWidth = $(o.nTable).outerWidth();
/* We want the hidden header to have zero height, so remove padding and borders. Then
* set the width based on the real headers
*/
anHeadToSize = o.nTHead.getElementsByTagName('tr');
anHeadSizers = nTheadSize.getElementsByTagName('tr');
_fnApplyToChildren( function(nSizer, nToSize) {
oStyle = nSizer.style;
oStyle.paddingTop = "0";
oStyle.paddingBottom = "0";
oStyle.borderTopWidth = "0";
oStyle.borderBottomWidth = "0";
oStyle.height = 0;
iWidth = $(nSizer).width();
nToSize.style.width = _fnStringToCss( iWidth );
aApplied.push( iWidth );
}, anHeadSizers, anHeadToSize );
$(anHeadSizers).height(0);
if ( o.nTFoot !== null )
{
/* Clone the current footer and then place it into the body table as a "hidden header" */
anFootSizers = nTfootSize.getElementsByTagName('tr');
anFootToSize = o.nTFoot.getElementsByTagName('tr');
_fnApplyToChildren( function(nSizer, nToSize) {
oStyle = nSizer.style;
oStyle.paddingTop = "0";
oStyle.paddingBottom = "0";
oStyle.borderTopWidth = "0";
oStyle.borderBottomWidth = "0";
oStyle.height = 0;
iWidth = $(nSizer).width();
nToSize.style.width = _fnStringToCss( iWidth );
aApplied.push( iWidth );
}, anFootSizers, anFootToSize );
$(anFootSizers).height(0);
}
/*
* 3. Apply the measurements
*/
/* "Hide" the header and footer that we used for the sizing. We want to also fix their width
* to what they currently are
*/
_fnApplyToChildren( function(nSizer) {
nSizer.innerHTML = "";
nSizer.style.width = _fnStringToCss( aApplied.shift() );
}, anHeadSizers );
if ( o.nTFoot !== null )
{
_fnApplyToChildren( function(nSizer) {
nSizer.innerHTML = "";
nSizer.style.width = _fnStringToCss( aApplied.shift() );
}, anFootSizers );
}
/* Sanity check that the table is of a sensible width. If not then we are going to get
* misalignment - try to prevent this by not allowing the table to shrink below its min width
*/
if ( $(o.nTable).outerWidth() < iSanityWidth )
{
/* The min width depends upon if we have a vertical scrollbar visible or not */
var iCorrection = ((nScrollBody.scrollHeight > nScrollBody.offsetHeight ||
$(nScrollBody).css('overflow-y') == "scroll")) ?
iSanityWidth+o.oScroll.iBarWidth : iSanityWidth;
/* IE6/7 are a law unto themselves... */
if ( ie67 && (nScrollBody.scrollHeight >
nScrollBody.offsetHeight || $(nScrollBody).css('overflow-y') == "scroll") )
{
o.nTable.style.width = _fnStringToCss( iCorrection-o.oScroll.iBarWidth );
}
/* Apply the calculated minimum width to the table wrappers */
nScrollBody.style.width = _fnStringToCss( iCorrection );
nScrollHeadInner.parentNode.style.width = _fnStringToCss( iCorrection );
if ( o.nTFoot !== null )
{
nScrollFootInner.parentNode.style.width = _fnStringToCss( iCorrection );
}
/* And give the user a warning that we've stopped the table getting too small */
if ( o.oScroll.sX === "" )
{
_fnLog( o, 1, "The table cannot fit into the current element which will cause column"+
" misalignment. The table has been drawn at its minimum possible width." );
}
else if ( o.oScroll.sXInner !== "" )
{
_fnLog( o, 1, "The table cannot fit into the current element which will cause column"+
" misalignment. Increase the sScrollXInner value or remove it to allow automatic"+
" calculation" );
}
}
else
{
nScrollBody.style.width = _fnStringToCss( '100%' );
nScrollHeadInner.parentNode.style.width = _fnStringToCss( '100%' );
if ( o.nTFoot !== null )
{
nScrollFootInner.parentNode.style.width = _fnStringToCss( '100%' );
}
}
/*
* 4. Clean up
*/
if ( o.oScroll.sY === "" )
{
/* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
* the scrollbar height from the visible display, rather than adding it on. We need to
* set the height in order to sort this. Don't want to do it in any other browsers.
*/
if ( ie67 )
{
nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+o.oScroll.iBarWidth );
}
}
if ( o.oScroll.sY !== "" && o.oScroll.bCollapse )
{
nScrollBody.style.height = _fnStringToCss( o.oScroll.sY );
var iExtra = (o.oScroll.sX !== "" && o.nTable.offsetWidth > nScrollBody.offsetWidth) ?
o.oScroll.iBarWidth : 0;
if ( o.nTable.offsetHeight < nScrollBody.offsetHeight )
{
nScrollBody.style.height = _fnStringToCss( $(o.nTable).height()+iExtra );
}
}
/* Finally set the width's of the header and footer tables */
var iOuterWidth = $(o.nTable).outerWidth();
nScrollHeadTable.style.width = _fnStringToCss( iOuterWidth );
nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth+o.oScroll.iBarWidth );
if ( o.nTFoot !== null )
{
nScrollFootInner.style.width = _fnStringToCss( o.nTable.offsetWidth+o.oScroll.iBarWidth );
nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth );
}
/* If sorting or filtering has occurred, jump the scrolling back to the top */
if ( o.bSorted || o.bFiltered )
{
nScrollBody.scrollTop = 0;
}
}
/**
* Apply a given function to the display child nodes of an element array (typically
* TD children of TR rows
* @param {function} fn Method to apply to the objects
* @param array {nodes} an1 List of elements to look through for display children
* @param array {nodes} an2 Another list (identical structure to the first) - optional
* @private
*/
function _fnApplyToChildren( fn, an1, an2 )
{
for ( var i=0, iLen=an1.length ; itd', nCalcTmp);
}
/* Apply custom sizing to the cloned header */
var nThs = _fnGetUniqueThs( oSettings, nTheadClone );
iCorrector = 0;
for ( i=0 ; i 0 )
{
oSettings.aoColumns[i].sWidth = _fnStringToCss( iWidth );
}
iCorrector++;
}
}
var cssWidth = $(nCalcTmp).css('width');
oSettings.nTable.style.width = (cssWidth.indexOf('%') !== -1) ?
cssWidth : _fnStringToCss( $(nCalcTmp).outerWidth() );
nCalcTmp.parentNode.removeChild( nCalcTmp );
}
}
/**
* Adjust a table's width to take account of scrolling
* @param {object} oSettings dataTables settings object
* @param {node} n table node
* @private
*/
function _fnScrollingWidthAdjust ( oSettings, n )
{
if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY !== "" )
{
/* When y-scrolling only, we want to remove the width of the scroll bar so the table
* + scroll bar will fit into the area avaialble.
*/
var iOrigWidth = $(n).width();
n.style.width = _fnStringToCss( $(n).outerWidth()-oSettings.oScroll.iBarWidth );
}
else if ( oSettings.oScroll.sX !== "" )
{
/* When x-scrolling both ways, fix the table at it's current size, without adjusting */
n.style.width = _fnStringToCss( $(n).outerWidth() );
}
}
/**
* Get the widest node
* @param {object} oSettings dataTables settings object
* @param {int} iCol column of interest
* @returns {string} max strlens for each column
* @private
*/
function _fnGetWidestNode( oSettings, iCol )
{
var iMaxIndex = _fnGetMaxLenString( oSettings, iCol );
if ( iMaxIndex < 0 )
{
return null;
}
if ( oSettings.aoData[iMaxIndex].nTr === null )
{
var n = document.createElement('td');
n.innerHTML = _fnGetCellData( oSettings, iMaxIndex, iCol, '' );
return n;
}
return _fnGetTdNodes(oSettings, iMaxIndex)[iCol];
}
/**
* Get the maximum strlen for each data column
* @param {object} oSettings dataTables settings object
* @param {int} iCol column of interest
* @returns {string} max strlens for each column
* @private
*/
function _fnGetMaxLenString( oSettings, iCol )
{
var iMax = -1;
var iMaxIndex = -1;
for ( var i=0 ; i/g, "" );
if ( s.length > iMax )
{
iMax = s.length;
iMaxIndex = i;
}
}
return iMaxIndex;
}
/**
* Append a CSS unit (only if required) to a string
* @param {array} aArray1 first array
* @param {array} aArray2 second array
* @returns {int} 0 if match, 1 if length is different, 2 if no match
* @private
*/
function _fnStringToCss( s )
{
if ( s === null )
{
return "0px";
}
if ( typeof s == 'number' )
{
if ( s < 0 )
{
return "0px";
}
return s+"px";
}
/* Check if the last character is not 0-9 */
var c = s.charCodeAt( s.length-1 );
if (c < 0x30 || c > 0x39)
{
return s;
}
return s+"px";
}
/**
* Get the width of a scroll bar in this browser being used
* @returns {int} width in pixels
* @private
*/
function _fnScrollBarWidth ()
{
var inner = document.createElement('p');
var style = inner.style;
style.width = "100%";
style.height = "200px";
style.padding = "0px";
var outer = document.createElement('div');
style = outer.style;
style.position = "absolute";
style.top = "0px";
style.left = "0px";
style.visibility = "hidden";
style.width = "200px";
style.height = "150px";
style.padding = "0px";
style.overflow = "hidden";
outer.appendChild(inner);
document.body.appendChild(outer);
var w1 = inner.offsetWidth;
outer.style.overflow = 'scroll';
var w2 = inner.offsetWidth;
if ( w1 == w2 )
{
w2 = outer.clientWidth;
}
document.body.removeChild(outer);
return (w1 - w2);
}
/**
* Change the order of the table
* @param {object} oSettings dataTables settings object
* @param {bool} bApplyClasses optional - should we apply classes or not
* @private
*/
function _fnSort ( oSettings, bApplyClasses )
{
var
i, iLen, j, jLen, k, kLen,
aaSort = [],
aiOrig = [],
oSort = _oExt.oSort,
aoData = oSettings.aoData,
aoColumns = oSettings.aoColumns;
/* No sorting required if server-side or no sorting array */
if ( !oSettings.oFeatures.bServerSide &&
(oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) )
{
if ( oSettings.aaSortingFixed !== null )
{
aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting );
}
else
{
aaSort = oSettings.aaSorting.slice();
}
/* If there is a sorting data type, and a fuction belonging to it, then we need to
* get the data from the developer's function and apply it for this column
*/
for ( i=0 ; i= iColumns )
{
for ( i=0 ; i 4096 ) /* Magic 10 for padding */
{
var aCookies =document.cookie.split(';');
for ( var i=0, iLen=aCookies.length ; i
*
1D array of data - add a single row with the data provided
*
2D array of arrays - add multiple rows in a single call
*
object - data object when using mDataProp
*
array of objects - multiple data objects when using mDataProp
*
* @param {bool} [bRedraw=true] redraw the table or not
* @returns {array} An array of integers, representing the list of indexes in
* aoData ({@link DataTable.models.oSettings}) that have been added to
* the table.
*
* @example
* // Global var for counter
* var giCount = 2;
*
* $(document).ready(function() {
* $('#example').dataTable();
* } );
*
* function fnClickAddRow() {
* $('#example').dataTable().fnAddData( [
* giCount+".1",
* giCount+".2",
* giCount+".3",
* giCount+".4" ]
* );
*
* giCount++;
* }
*/
this.fnAddData = function( mData, bRedraw )
{
if ( mData.length === 0 )
{
return [];
}
var aiReturn = [];
var iTest;
/* Find settings from table node */
var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
/* Check if we want to add multiple rows or not */
if ( typeof mData[0] == "object" )
{
for ( var i=0 ; i= oSettings.aiDisplay.length )
{
oSettings._iDisplayStart -= oSettings._iDisplayLength;
if ( oSettings._iDisplayStart < 0 )
{
oSettings._iDisplayStart = 0;
}
}
if ( typeof bRedraw == 'undefined' || bRedraw )
{
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
return oData;
};
/**
* Restore the table to it's original state in the DOM by removing all of DataTables
* enhancements, alterations to the DOM structure of the table and event listeners.
*
* @example
* $(document).ready(function() {
* // This example is fairly pointless in reality, but shows how fnDestroy can be used
* var oTable = $('#example').dataTable();
* oTable.fnDestroy();
* } );
*/
this.fnDestroy = function ( )
{
var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
var nOrig = oSettings.nTableWrapper.parentNode;
var nBody = oSettings.nTBody;
var i, iLen;
/* Flag to note that the table is currently being destroyed - no action should be taken */
oSettings.bDestroying = true;
/* Restore hidden columns */
for ( i=0, iLen=oSettings.aoDestroyCallback.length ; itr>td.'+oSettings.oClasses.sRowEmpty, oSettings.nTable).parent().remove();
/* When scrolling we had to break the table up - restore it */
if ( oSettings.nTable != oSettings.nTHead.parentNode )
{
$(oSettings.nTable).children('thead').remove();
oSettings.nTable.appendChild( oSettings.nTHead );
}
if ( oSettings.nTFoot && oSettings.nTable != oSettings.nTFoot.parentNode )
{
$(oSettings.nTable).children('tfoot').remove();
oSettings.nTable.appendChild( oSettings.nTFoot );
}
/* Remove the DataTables generated nodes, events and classes */
oSettings.nTable.parentNode.removeChild( oSettings.nTable );
$(oSettings.nTableWrapper).remove();
oSettings.aaSorting = [];
oSettings.aaSortingFixed = [];
_fnSortingClasses( oSettings );
$(_fnGetTrNodes( oSettings )).removeClass( oSettings.asStripeClasses.join(' ') );
if ( !oSettings.bJUI )
{
$('th', oSettings.nTHead).removeClass( [ _oExt.oStdClasses.sSortable,
_oExt.oStdClasses.sSortableAsc,
_oExt.oStdClasses.sSortableDesc,
_oExt.oStdClasses.sSortableNone ].join(' ')
);
}
else
{
$('th, td', oSettings.nTHead).removeClass( [ _oExt.oStdClasses.sSortable,
_oExt.oJUIClasses.sSortableAsc,
_oExt.oJUIClasses.sSortableDesc,
_oExt.oJUIClasses.sSortableNone ].join(' ')
);
$('th span.'+_oExt.oJUIClasses.sSortIcon
+ ', td span.'+_oExt.oJUIClasses.sSortIcon, oSettings.nTHead).remove();
$('th, td', oSettings.nTHead).each( function () {
var jqWrapper = $('div.'+_oExt.oJUIClasses.sSortJUIWrapper, this);
var kids = jqWrapper.contents();
$(this).append( kids );
jqWrapper.remove();
} );
}
/* Add the TR elements back into the table in their original order */
if ( oSettings.nTableReinsertBefore )
{
nOrig.insertBefore( oSettings.nTable, oSettings.nTableReinsertBefore );
}
else
{
nOrig.appendChild( oSettings.nTable );
}
for ( i=0, iLen=oSettings.aoData.length ; i= _fnVisbleColumns( oSettings ));
/* Which coloumn should we be inserting before? */
if ( !bAppend )
{
for ( i=iCol ; i=0 ; i-- )
{
/* Each column def can target multiple columns, as it is an array */
var aTargets = oInit.aoColumnDefs[i].aTargets;
if ( !$.isArray( aTargets ) )
{
_fnLog( oSettings, 1, 'aTargets must be an array of targets, not a '+(typeof aTargets) );
}
for ( j=0, jLen=aTargets.length ; j= 0 )
{
/* 0+ integer, left to right column counting. We add columns which are unknown
* automatically. Is this the right behaviour for this? We should at least
* log it in future. We cannot do this for the negative or class targets, only here.
*/
while( oSettings.aoColumns.length <= aTargets[j] )
{
_fnAddColumn( oSettings );
}
_fnColumnOptions( oSettings, aTargets[j], oInit.aoColumnDefs[i] );
}
else if ( typeof aTargets[j] == 'number' && aTargets[j] < 0 )
{
/* Negative integer, right to left column counting */
_fnColumnOptions( oSettings, oSettings.aoColumns.length+aTargets[j],
oInit.aoColumnDefs[i] );
}
else if ( typeof aTargets[j] == 'string' )
{
/* Class name matching on TH element */
for ( k=0, kLen=oSettings.aoColumns.length ; k= oSettings.aoColumns.length )
{
oSettings.aaSorting[i][0] = 0;
}
var oColumn = oSettings.aoColumns[ oSettings.aaSorting[i][0] ];
/* Add a default sorting index */
if ( typeof oSettings.aaSorting[i][2] == 'undefined' )
{
oSettings.aaSorting[i][2] = 0;
}
/* If aaSorting is not defined, then we use the first indicator in asSorting */
if ( typeof oInit.aaSorting == "undefined" &&
typeof oSettings.saved_aaSorting == "undefined" )
{
oSettings.aaSorting[i][1] = oColumn.asSorting[0];
}
/* Set the current sorting index based on aoColumns.asSorting */
for ( j=0, jLen=oColumn.asSorting.length ; j 0 )
{
oSettings.nTFoot = tfoot[0];
_fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
}
/* Check if there is data passing into the constructor */
if ( bUsePassedData )
{
for ( i=0 ; i
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{array|object} Data for the row to be processed (same as the original format
* that was passed in as the data source, or an array from a DOM data source
*
{int} Row index in aoData ({@link DataTable.models.oSettings.aoData}), which can
* be useful to retrieve the TR element if you need DOM interaction.
*
*
*
* Function return:
*
*
{boolean} Include the row in the filtered result set (true) or not (false)
*
*
*
* @type array
* @default []
*
* @example
* // The following example shows custom filtering being applied to the fourth column (i.e.
* // the aData[3] index) based on two input values from the end-user, matching the data in
* // a certain range.
* $.fn.dataTableExt.afnFiltering.push(
* function( oSettings, aData, iDataIndex ) {
* var iMin = document.getElementById('min').value * 1;
* var iMax = document.getElementById('max').value * 1;
* var iVersion = aData[3] == "-" ? 0 : aData[3]*1;
* if ( iMin == "" && iMax == "" ) {
* return true;
* }
* else if ( iMin == "" && iVersion < iMax ) {
* return true;
* }
* else if ( iMin < iVersion && "" == iMax ) {
* return true;
* }
* else if ( iMin < iVersion && iVersion < iMax ) {
* return true;
* }
* return false;
* }
* );
*/
"afnFiltering": [],
/**
* Plug-in sorting functions - this method of sorting is complimentary to the default type
* based sorting that DataTables does automatically, allowing much greater control over the
* the data that is being used to sort a column. This is useful if you want to do sorting
* based on live data (for example the contents of an 'input' element) rather than just the
* static string that DataTables knows of. The way these plug-ins work is that you create
* an array of the values you wish to be sorted for the column in question and then return
* that array. Which pre-sorting function is run here depends on the sSortDataType parameter
* that is used for the column (if any). This is the corollary of ofnSearch for sort
* data.
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{int} Target column index
*
*
*
* Function return:
*
*
{array} Data for the column to be sorted upon
*
*
*
*
* Note that as of v1.9, it is typically preferable to use mDataProp to prepare data for
* the different uses that DataTables can put the data to. Specifically mDataProp when
* used as a function will give you a 'type' (sorting, filtering etc) that you can use to
* prepare the data as required for the different types. As such, this method is deprecated.
* @type array
* @default []
* @deprecated
*
* @example
* // Updating the cached sorting information with user entered values in HTML input elements
* jQuery.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn )
* {
* var aData = [];
* $( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
* aData.push( this.value );
* } );
* return aData;
* }
*/
"afnSortData": [],
/**
* Feature plug-ins - This is an array of objects which describe the feature plug-ins that are
* available to DataTables. These feature plug-ins are accessible through the sDom initialisation
* option. As such, each feature plug-in must describe a function that is used to initialise
* itself (fnInit), a character so the feature can be enabled by sDom (cFeature) and the name
* of the feature (sFeature). Thus the objects attached to this method must provide:
*
*
{function} fnInit Initialisation of the plug-in
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
*
*
* Function return:
*
*
{node|null} The element which contains your feature. Note that the return
* may also be void if your plug-in does not require to inject any DOM elements
* into DataTables control (sDom) - for example this might be useful when
* developing a plug-in which allows table control via keyboard entry.
*
*
*
*
*
{character} cFeature Character that will be matched in sDom - case sensitive
*
{string} sFeature Feature name
*
* @type array
* @default []
*
* @example
* // How TableTools initialises itself.
* $.fn.dataTableExt.aoFeatures.push( {
* "fnInit": function( oSettings ) {
* return new TableTools( { "oDTSettings": oSettings } );
* },
* "cFeature": "T",
* "sFeature": "TableTools"
* } );
*/
"aoFeatures": [],
/**
* Type detection plug-in functions - DataTables utilises types to define how sorting and
* filtering behave, and types can be either be defined by the developer (sType for the
* column) or they can be automatically detected by the methods in this array. The functions
* defined in the array are quite simple, taking a single parameter (the data to analyse)
* and returning the type if it is a known type, or null otherwise.
*
*
* Function input parameters:
*
*
{*} Data from the column cell to be analysed
*
*
*
* Function return:
*
*
{string|null} Data type detected, or null if unknown (and thus pass it
* on to the other type detection functions.
*
*
*
* @type array
* @default []
*
* @example
* // Currency type detection plug-in:
* jQuery.fn.dataTableExt.aTypes.push(
* function ( sData ) {
* var sValidChars = "0123456789.-";
* var Char;
*
* // Check the numeric part
* for ( i=1 ; i= parseInt(sThat, 10);
},
/**
* Index for what 'this' index API functions should use
* @type int
* @default 0
*/
"iApiIndex": 0,
/**
* Pre-processing of filtering data plug-ins - When you assign the sType for a column
* (or have it automatically detected for you by DataTables or a type detection plug-in),
* you will typically be using this for custom sorting, but it can also be used to provide
* custom filtering by allowing you to pre-processing the data and returning the data in
* the format that should be filtered upon. This is done by adding functions this object
* with a parameter name which matches the sType for that target column. This is the
* corollary of afnSortData for filtering data.
*
*
* Function input parameters:
*
*
{*} Data from the column cell to be prepared for filtering
*
*
*
* Function return:
*
*
{string|null} Formatted string that will be used for the filtering.
*
*
*
*
* Note that as of v1.9, it is typically preferable to use mDataProp to prepare data for
* the different uses that DataTables can put the data to. Specifically mDataProp when
* used as a function will give you a 'type' (sorting, filtering etc) that you can use to
* prepare the data as required for the different types. As such, this method is deprecated.
* @type object
* @default {}
* @deprecated
*
* @example
* $.fn.dataTableExt.ofnSearch['title-numeric'] = function ( sData ) {
* return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
* }
*/
"ofnSearch": {},
/**
* Container for all private functions in DataTables so they can be exposed externally
* @type object
* @default {}
*/
"oApi": {},
/**
* Storage for the various classes that DataTables uses
* @type object
* @default {}
*/
"oStdClasses": {},
/**
* Storage for the various classes that DataTables uses - jQuery UI suitable
* @type object
* @default {}
*/
"oJUIClasses": {},
/**
* Pagination plug-in methods - The style and controls of the pagination can significantly
* impact on how the end user interacts with the data in your table, and DataTables allows
* the addition of pagination controls by extending this object, which can then be enabled
* through the sPaginationType initialisation parameter. Each pagination type that
* is added is an object (the property name of which is what sPaginationType refers
* to) that has two properties, both methods that are used by DataTables to update the
* control's state.
*
*
* fnInit - Initialisation of the paging controls. Called only during initialisation
* of the table. It is expected that this function will add the required DOM elements
* to the page for the paging controls to work. The element pointer
* 'oSettings.aanFeatures.p' array is provided by DataTables to contain the paging
* controls (note that this is a 2D array to allow for multiple instances of each
* DataTables DOM element). It is suggested that you add the controls to this element
* as children
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{node} Container into which the pagination controls must be inserted
*
{function} Draw callback function - whenever the controls cause a page
* change, this method must be called to redraw the table.
*
*
*
* Function return:
*
*
No return required
*
*
*
*
*
* fnInit - This function is called whenever the paging status of the table changes and is
* typically used to update classes and/or text of the paging controls to reflex the new
* status.
*
*
* Function input parameters:
*
*
{object} DataTables settings object: see {@link DataTable.models.oSettings}.
*
{function} Draw callback function - in case you need to redraw the table again
* or attach new event listeners
{int} Sorting match: <0 if first parameter should be sorted lower than
* the second parameter, ===0 if the two parameters are equal and >0 if
* the first parameter should be sorted height than the second parameter.
*
*
*
* @type object
* @default {}
*
* @example
* // Case-sensitive string sorting, with no pre-formatting method
* $.extend( $.fn.dataTableExt.oSort, {
* "string-case-asc": function(x,y) {
* return ((x < y) ? -1 : ((x > y) ? 1 : 0));
* },
* "string-case-desc": function(x,y) {
* return ((x < y) ? 1 : ((x > y) ? -1 : 0));
* }
* } );
*
* @example
* // Case-insensitive string sorting, with pre-formatting
* $.extend( $.fn.dataTableExt.oSort, {
* "string-pre": function(x) {
* return x.toLowerCase();
* },
* "string-asc": function(x,y) {
* return ((x < y) ? -1 : ((x > y) ? 1 : 0));
* },
* "string-desc": function(x,y) {
* return ((x < y) ? 1 : ((x > y) ? -1 : 0));
* }
* } );
*/
"oSort": {},
/**
* Version string for plug-ins to check compatibility. Allowed format is
* a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and
* e are optional
* @type string
* @default Version number
*/
"sVersion": DataTable.version,
/**
* How should DataTables report an error. Can take the value 'alert' or 'throw'
* @type string
* @default alert
*/
"sErrMode": "alert",
/**
* Store information for DataTables to access globally about other instances
* @namespace
* @private
*/
"_oExternConfig": {
/* int:iNextUnique - next unique number for an instance */
"iNextUnique": 0
}
};
/**
* Template object for the way in which DataTables holds information about
* search information for the global filter and individual column filters.
* @namespace
*/
DataTable.models.oSearch = {
/**
* Applied search term
* @type string
* @default Empty string
*/
"sSearch": "",
/**
* Flag to indicate if the search term should be interpreted as a
* regular expression (true) or not (false) and therefore and special
* regex characters escaped.
* @type boolean
* @default false
*/
"bRegex": false,
/**
* Flag to indicate if DataTables is to use its smart filtering or not.
* @type boolean
* @default true
*/
"bSmart": true
};
/**
* Template object for the way in which DataTables holds information about
* each individual row. This is the object format used for the settings
* aoData array.
* @namespace
*/
DataTable.models.oRow = {
/**
* TR element for the row
* @type node
* @default null
*/
"nTr": null,
/**
* Data object from the original data source for the row. This is either
* an array if using the traditional form of DataTables, or an object if
* using mDataProp options. The exact type will depend on the passed in
* data from the data source, or will be an array if using DOM a data
* source.
* @type array|object
* @default []
*/
"_aData": [],
/**
* Sorting data cache - this array is ostensibly the same length as the
* number of columns (although each index is generated only as it is
* needed), and holds the data that is used for sorting each column in the
* row. We do this cache generation at the start of the sort in order that
* the formatting of the sort data need be done only once for each cell
* per sort. This array should not be read from or written to by anything
* other than the master sorting methods.
* @type array
* @default []
* @private
*/
"_aSortData": [],
/**
* Array of TD elements that are cached for hidden rows, so they can be
* reinserted into the table if a column is made visible again (or to act
* as a store if a column is made hidden). Only hidden columns have a
* reference in the array. For non-hidden columns the value is either
* undefined or null.
* @type array nodes
* @default []
* @private
*/
"_anHidden": [],
/**
* Cache of the class name that DataTables has applied to the row, so we
* can quickly look at this variable rather than needing to do a DOM check
* on className for the nTr property.
* @type string
* @default Empty string
* @private
*/
"_sRowStripe": ""
};
/**
* Template object for the column information object in DataTables. This object
* is held in the settings aoColumns array and contains all the information that
* DataTables needs about each individual column.
*
* Note that this object is related to {@link DataTable.models.oInitColumns}
* but this one is the internal data store for DataTables's cache of columns.
* It should NOT be manipulated outside of DataTables. Any configuration should
* be done through the initialisation options.
* @namespace
*/
DataTable.models.oColumn = {
/**
* A list of the columns that sorting should occur on when this column
* is sorted. That this property is an array allows multi-column sorting
* to be defined for a column (for example first name / last name columns
* would benefit from this). The values are integers pointing to the
* columns to be sorted on (typically it will be a single integer pointing
* at itself, but that doesn't need to be the case).
* @type array
* @default []
*/
"aDataSort": [],
/**
* Define the sorting directions that are applied to the column, in sequence
* as the column is repeatedly sorted upon - i.e. the first value is used
* as the sorting direction when the column if first sorted (clicked on).
* Sort it again (click again) and it will move on to the next index.
* Repeat until loop.
* @type array
* @default ['asc', 'desc']
*/
"asSorting": ['asc', 'desc'],
/**
* Flag to indicate if the column is searchable, and thus should be included
* in the filtering or not.
* @type boolean
* @default true
*/
"bSearchable": true,
/**
* Flag to indicate if the column is sortable or not.
* @type boolean
* @default true
*/
"bSortable": true,
/**
* When using fnRender, you have two options for what to do with the data,
* and this property serves as the switch. Firstly, you can have the sorting
* and filtering use the rendered value (true - default), or you can have
* the sorting and filtering us the original value (false).
*
* *NOTE* It is it is advisable now to use mDataProp as a function and make
* use of the 'type' that it gives, allowing (potentially) different data to
* be used for sorting, filtering, display and type detection.
* @type boolean
* @default true
* @deprecated
*/
"bUseRendered": true,
/**
* Flag to indicate if the column is currently visible in the table or not
* @type boolean
* @default true
*/
"bVisible": true,
/**
* Flag to indicate to the type detection method if the automatic type
* detection should be used, or if a column type (sType) has been specified
* @type boolean
* @default true
* @private
*/
"_bAutoType": true,
/**
* Function to get data from a cell in a column. You should never
* access data directly through _aData internally in DataTables - always use
* the method attached to this property. It allows mDataProp to function as
* required. This function is automatically assigned by the column
* initialisation method
* @type function
* @param {array|object} oData The data array/object for the array
* (i.e. aoData[]._aData)
* @param {string} sSpecific The specific data type you want to get -
* 'display', 'type' 'filter' 'sort'
* @returns {*} The data for the cell from the given row's data
* @default null
*/
"fnGetData": null,
/**
* Custom display function that will be called for the display of each cell
* in this column.
* @type function
* @param {object} o Object with the following parameters:
* @param {int} o.iDataRow The row in aoData
* @param {int} o.iDataColumn The column in question
* @param {array o.aData The data for the row in question
* @param {object} o.oSettings The settings object for this DataTables instance
* @returns {string} The string you which to use in the display
* @default null
*/
"fnRender": null,
/**
* Function to set data for a cell in the column. You should never
* set the data directly to _aData internally in DataTables - always use
* this method. It allows mDataProp to function as required. This function
* is automatically assigned by the column initialisation method
* @type function
* @param {array|object} oData The data array/object for the array
* (i.e. aoData[]._aData)
* @param {*} sValue Value to set
* @default null
*/
"fnSetData": null,
/**
* Property to read the value for the cells in the column from the data
* source array / object. If null, then the default content is used, if a
* function is given then the return from the function is used.
* @type function|int|string|null
* @default null
*/
"mDataProp": null,
/**
* Unique header TH/TD element for this column - this is what the sorting
* listener is attached to (if sorting is enabled.)
* @type node
* @default null
*/
"nTh": null,
/**
* Unique footer TH/TD element for this column (if there is one). Not used
* in DataTables as such, but can be used for plug-ins to reference the
* footer for each column.
* @type node
* @default null
*/
"nTf": null,
/**
* The class to apply to all TD elements in the table's TBODY for the column
* @type string
* @default null
*/
"sClass": null,
/**
* When DataTables calculates the column widths to assign to each column,
* it finds the longest string in each column and then constructs a
* temporary table and reads the widths from that. The problem with this
* is that "mmm" is much wider then "iiii", but the latter is a longer
* string - thus the calculation can go wrong (doing it properly and putting
* it into an DOM object and measuring that is horribly(!) slow). Thus as
* a "work around" we provide this option. It will append its value to the
* text that is found to be the longest string for the column - i.e. padding.
* @type string
* @default Empty string
*/
"sContentPadding": "",
/**
* Allows a default value to be given for a column's data, and will be used
* whenever a null data source is encountered (this can be because mDataProp
* is set to null, or because the data source itself is null).
* @type string
* @default null
*/
"sDefaultContent": null,
/**
* Name for the column, allowing reference to the column by name as well as
* by index (needs a lookup to work by name).
* @type string
* @default Empty string
*/
"sName": '',
/**
* Custom sorting data type - defines which of the available plug-ins in
* afnSortData the custom sorting will use - if any is defined.
* @type string
* @default std
*/
"sSortDataType": 'std',
/**
* Class to be applied to the header element when sorting on this column
* @type string
* @default null
*/
"sSortingClass": null,
/**
* Class to be applied to the header element when sorting on this column -
* when jQuery UI theming is used.
* @type string
* @default null
*/
"sSortingClassJUI": null,
/**
* Title of the column - what is seen in the TH element (nTh).
* @type string
* @default Empty string - automatically detected
*/
"sTitle": '',
/**
* Column sorting and filtering type
* @type string
* @default null
*/
"sType": null,
/**
* Width of the column
* @type string
* @default null
*/
"sWidth": null,
/**
* Width of the column when it was first "encountered"
* @type string
* @default null
*/
"sWidthOrig": null
};
/**
* Initialisation options that can be given to DataTables at initialisation
* time.
* @namespace
*/
DataTable.models.oInit = {
/**
* An array of data to use for the table, passed in at initialisation which
* will be used in preference to any data which is already in the DOM. This is
* particularly useful for constructing tables purely in Javascript, for
* example with a custom Ajax call.
* @type array
* @default null
*
* @example
* // Using a 2D array data source
* $(document).ready( function () {
* $('#example').dataTable( {
* "aaData": [
* ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
* ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
* ],
* "aoColumns": [
* { "sTitle": "Engine" },
* { "sTitle": "Browser" },
* { "sTitle": "Platform" },
* { "sTitle": "Version" },
* { "sTitle": "Grade" }
* ]
* } );
* } );
*
* @example
* // Using an array of objects as a data source (mDataProp)
* $(document).ready( function () {
* $('#example').dataTable( {
* "aaData": [
* {
* "engine": "Trident",
* "browser": "Internet Explorer 4.0",
* "platform": "Win 95+",
* "version": 4,
* "grade": "X"
* },
* {
* "engine": "Trident",
* "browser": "Internet Explorer 5.0",
* "platform": "Win 95+",
* "version": 5,
* "grade": "C"
* }
* ],
* "aoColumns": [
* { "sTitle": "Engine", "mDataProp": "engine" },
* { "sTitle": "Browser", "mDataProp": "browser" },
* { "sTitle": "Platform", "mDataProp": "platform" },
* { "sTitle": "Version", "mDataProp": "version" },
* { "sTitle": "Grade", "mDataProp": "grade" }
* ]
* } );
* } );
*/
"aaData": null,
/**
* If sorting is enabled, then DataTables will perform a first pass sort on
* initialisation. You can define which column(s) the sort is performed upon,
* and the sorting direction, with this variable. The aaSorting array should
* contain an array for each column to be sorted initially containing the
* column's index and a direction string ('asc' or 'desc').
* @type array
* @default [[0,'asc']]
*
* @example
* // Sort by 3rd column first, and then 4th column
* $(document).ready( function() {
* $('#example').dataTable( {
* "aaSorting": [[2,'asc'], [3,'desc']]
* } );
* } );
*
* // No initial sorting
* $(document).ready( function() {
* $('#example').dataTable( {
* "aaSorting": []
* } );
* } );
*/
"aaSorting": [[0,'asc']],
/**
* This parameter is basically identical to the aaSorting parameter, but
* cannot be overridden by user interaction with the table. What this means
* is that you could have a column (visible or hidden) which the sorting will
* always be forced on first - any sorting after that (from the user) will
* then be performed as required. This can be useful for grouping rows
* together.
* @type array
* @default null
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "aaSortingFixed": [[0,'asc']]
* } );
* } )
*/
"aaSortingFixed": null,
/**
* This parameter allows you to readily specify the entries in the length drop
* down menu that DataTables shows when pagination is enabled. It can be
* either a 1D array of options which will be used for both the displayed
* option and the value, or a 2D array which will use the array in the first
* position as the value, and the array in the second position as the
* displayed options (useful for language strings such as 'All').
* @type array
* @default [ 10, 25, 50, 100 ]
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
* } );
* } );
*
* @example
* // Setting the default display length as well as length menu
* // This is likely to be wanted if you remove the '10' option which
* // is the iDisplayLength default.
* $(document).ready(function() {
* $('#example').dataTable( {
* "iDisplayLength": 25,
* "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
* } );
* } );
*/
"aLengthMenu": [ 10, 25, 50, 100 ],
/**
* The aoColumns option in the initialisation parameter allows you to define
* details about the way individual columns behave. For a full list of
* column options that can be set, please see
* {@link DataTable.models.oInitColumns}. Note that if you use aoColumns to
* define your columns, you must have an entry in the array for every single
* column that you have in your table (these can be null if you don't which
* to specify any options).
* @namespace
*/
"aoColumns": null,
/**
* Very similar to aoColumns, aoColumnDefs allows you to target a specific
* column, multiple columns, or all columns, using the aTargets property of
* each object in the array. This allows great flexibility when creating
* tables, as the aoColumnDefs arrays can be of any length, targeting the
* columns you specifically want. aoColumnDefs may use any of the column
* options available: {@link DataTable.models.oInitColumns}, but it _must_
* have aTargets defined in each object in the array. Values in the aTargets
* array may be:
*
*
a string - class name will be matched on the TH for the column
*
0 or a positive integer - column index counting from the left
*
a negative integer - column index counting from the right
*
the string "_all" - all columns (i.e. assign a default)
*
* @namespace
*/
"aoColumnDefs": null,
/**
* Basically the same as oSearch, this parameter defines the individual column
* filtering state at initialisation time. The array must be of the same size
* as the number of columns, and each element be an object with the parameters
* "sSearch" and "bEscapeRegex" (the latter is optional). 'null' is also
* accepted and the default will be used.
* @type array
* @default []
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "aoSearchCols": [
* null,
* { "sSearch": "My filter" },
* null,
* { "sSearch": "^[0-9]", "bEscapeRegex": false }
* ]
* } );
* } )
*/
"aoSearchCols": [],
/**
* An array of CSS classes that should be applied to displayed rows. This
* array may be of any length, and DataTables will apply each class
* sequentially, looping when required.
* @type array
* @default [ 'odd', 'even' ]
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "asStripeClasses": [ 'strip1', 'strip2', 'strip3' ]
* } );
* } )
*/
"asStripeClasses": [ 'odd', 'even' ],
/**
* Enable or disable automatic column width calculation. This can be disabled
* as an optimisation (it takes some time to calculate the widths) if the
* tables widths are passed in using aoColumns.
* @type boolean
* @default true
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bAutoWidth": false
* } );
* } );
*/
"bAutoWidth": true,
/**
* Deferred rendering can provide DataTables with a huge speed boost when you
* are using an Ajax or JS data source for the table. This option, when set to
* true, will cause DataTables to defer the creation of the table elements for
* each row until they are needed for a draw - saving a significant amount of
* time.
* @type boolean
* @default false
*
* @example
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "sAjaxSource": "sources/arrays.txt",
* "bDeferRender": true
* } );
* } );
*/
"bDeferRender": false,
/**
* Replace a DataTable which matches the given selector and replace it with
* one which has the properties of the new initialisation object passed. If no
* table matches the selector, then the new DataTable will be constructed as
* per normal.
* @type boolean
* @default false
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollY": "200px",
* "bPaginate": false
* } );
*
* // Some time later....
* $('#example').dataTable( {
* "bFilter": false,
* "bDestroy": true
* } );
* } );
*/
"bDestroy": false,
/**
* Enable or disable filtering of data. Filtering in DataTables is "smart" in
* that it allows the end user to input multiple words (space separated) and
* will match a row containing those words, even if not in the order that was
* specified (this allow matching across multiple columns). Note that if you
* wish to use filtering in DataTables this must remain 'true' - to remove the
* default filtering input box and retain filtering abilities, please use
* @ref{sDom}.
* @type boolean
* @default true
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bFilter": false
* } );
* } );
*/
"bFilter": true,
/**
* Enable or disable the table information display. This shows information
* about the data that is currently visible on the page, including information
* about filtered data if that action is being performed.
* @type boolean
* @default true
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bInfo": false
* } );
* } );
*/
"bInfo": true,
/**
* Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
* slightly different and additional mark-up from what DataTables has
* traditionally used).
* @type boolean
* @default false
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "bJQueryUI": true
* } );
* } );
*/
"bJQueryUI": false,
/**
* Allows the end user to select the size of a formatted page from a select
* menu (sizes are 10, 25, 50 and 100). Requires pagination (bPaginate).
* @type boolean
* @default true
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bLengthChange": false
* } );
* } );
*/
"bLengthChange": true,
/**
* Enable or disable pagination.
* @type boolean
* @default true
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bPaginate": false
* } );
* } );
*/
"bPaginate": true,
/**
* Enable or disable the display of a 'processing' indicator when the table is
* being processed (e.g. a sort). This is particularly useful for tables with
* large amounts of data where it can take a noticeable amount of time to sort
* the entries.
* @type boolean
* @default false
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bProcessing": true
* } );
* } );
*/
"bProcessing": false,
/**
* Retrieve the DataTables object for the given selector. Note that if the
* table has already been initialised, this parameter will cause DataTables
* to simply return the object that has already been set up - it will not take
* account of any changes you might have made to the initialisation object
* passed to DataTables (setting this parameter to true is an acknowledgement
* that you understand this). bDestroy can be used to reinitialise a table if
* you need.
* @type boolean
* @default false
*
* @example
* $(document).ready(function() {
* initTable();
* tableActions();
* } );
*
* function initTable ()
* {
* return $('#example').dataTable( {
* "sScrollY": "200px",
* "bPaginate": false,
* "bRetrieve": true
* } );
* }
*
* function tableActions ()
* {
* var oTable = initTable();
* // perform API operations with oTable
* }
*/
"bRetrieve": false,
/**
* When vertical (y) scrolling is enabled, DataTables will force the height of
* the table's viewport to the given height at all times (useful for layout).
* However, this can look odd when filtering data down to a small data set,
* and the footer is left "floating" further down. This parameter (when
* enabled) will cause DataTables to collapse the table's viewport down when
* the result set will fit within the given Y height.
* @type boolean
* @default false
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollY": "200",
* "bScrollCollapse": true
* } );
* } );
*/
"bScrollCollapse": false,
/**
* Enable infinite scrolling for DataTables (to be used in combination with
* sScrollY). Infinite scrolling means that DataTables will continually load
* data as a user scrolls through a table, which is very useful for large
* dataset. This cannot be used with pagination, which is automatically
* disabled.
* @type boolean
* @default false
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bScrollInfinite": true,
* "bScrollCollapse": true,
* "sScrollY": "200px"
* } );
* } );
*/
"bScrollInfinite": false,
/**
* Configure DataTables to use server-side processing. Note that the
* sAjaxSource parameter must also be given in order to give DataTables a
* source to obtain the required data for each draw.
* @type boolean
* @default false
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bServerSide": true,
* "sAjaxSource": "xhr.php"
* } );
* } );
*/
"bServerSide": false,
/**
* Enable or disable sorting of columns. Sorting of individual columns can be
* disabled by the "bSortable" option for each column.
* @type boolean
* @default true
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bSort": false
* } );
* } );
*/
"bSort": true,
/**
* Allows control over whether DataTables should use the top (true) unique
* cell that is found for a single column, or the bottom (false - default).
* This is useful when using complex headers.
* @type boolean
* @default false
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bSortCellsTop": true
* } );
* } );
*/
"bSortCellsTop": false,
/**
* Enable or disable the addition of the classes 'sorting_1', 'sorting_2' and
* 'sorting_3' to the columns which are currently being sorted on. This is
* presented as a feature switch as it can increase processing time (while
* classes are removed and added) so for large data sets you might want to
* turn this off.
* @type boolean
* @default true
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bSortClasses": false
* } );
* } );
*/
"bSortClasses": true,
/**
* Enable or disable state saving. When enabled a cookie will be used to save
* table display information such as pagination information, display length,
* filtering and sorting. As such when the end user reloads the page the
* display display will match what thy had previously set up.
* @type boolean
* @default false
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bStateSave": true
* } );
* } );
*/
"bStateSave": false,
/**
* Customise the cookie and / or the parameters being stored when using
* DataTables with state saving enabled. This function is called whenever
* the cookie is modified, and it expects a fully formed cookie string to be
* returned. Note that the data object passed in is a Javascript object which
* must be converted to a string (JSON.stringify for example).
* @type function
* @param {string} sName Name of the cookie defined by DataTables
* @param {object} oData Data to be stored in the cookie
* @param {string} sExpires Cookie expires string
* @param {string} sPath Path of the cookie to set
* @returns {string} Cookie formatted string (which should be encoded by
* using encodeURIComponent())
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "fnCookieCallback": function (sName, oData, sExpires, sPath) {
* // Customise oData or sName or whatever else here
* return sName + "="+JSON.stringify(oData)+"; expires=" + sExpires +"; path=" + sPath;
* }
* } );
* } );
*/
"fnCookieCallback": null,
/**
* This function is called on every 'draw' event, and allows you to
* dynamically modify any aspect you want about the created DOM.
* @type function
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "fnDrawCallback": function() {
* alert( 'DataTables has redrawn the table' );
* }
* } );
* } );
*/
"fnDrawCallback": null,
/**
* Identical to fnHeaderCallback() but for the table footer this function
* allows you to modify the table footer on every 'draw' even.
* @type function
* @param {node} nFoot "TR" element for the footer
* @param {array} aData Full table data (as derived from the original HTML)
* @param {int} iStart Index for the current display starting point in the
* display array
* @param {int} iEnd Index for the current display ending point in the
* display array
* @param {array int} aiDisplay Index array to translate the visual position
* to the full data array
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay ) {
* nFoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+iStart;
* }
* } );
* } )
*/
"fnFooterCallback": null,
/**
* When rendering large numbers in the information element for the table
* (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
* to have a comma separator for the 'thousands' units (e.g. 1 million is
* rendered as "1,000,000") to help readability for the end user. This
* function will override the default method DataTables uses.
* @type function
* @param {int} iIn number to be formatted
* @returns {string} formatted string for DataTables to show the number
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "fnFormatNumber": function ( iIn ) {
* if ( iIn < 1000 ) {
* return iIn;
* } else {
* var
* s=(iIn+""),
* a=s.split(""), out="",
* iLen=s.length;
*
* for ( var i=0 ; i<iLen ; i++ ) {
* if ( i%3 === 0 && i !== 0 ) {
* out = "'"+out;
* }
* out = a[iLen-i-1]+out;
* }
* }
* return out;
* };
* } );
* } );
*/
"fnFormatNumber": function ( iIn ) {
if ( iIn < 1000 )
{
// A small optimisation for what is likely to be the majority of use cases
return iIn;
}
else
{
var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
for ( var i=0 ; i
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "fnInitComplete": function(oSettings, json) {
* alert( 'DataTables has finished its initialisation.' );
* }
* } );
* } )
*/
"fnInitComplete": null,
/**
* Called at the very start of each table draw and can be used to cancel the
* draw by returning false, any other return (including undefined) results in
* the full draw occurring).
* @type function
* @param {object} oSettings DataTables settings object
* @returns {boolean} False will cancel the draw, anything else (including no
* return) will allow it to complete.
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "fnPreDrawCallback": function( oSettings ) {
* if ( $('#test').val() == 1 ) {
* return false;
* }
* }
* } );
* } );
*/
"fnPreDrawCallback": null,
/**
* This function allows you to 'post process' each row after it have been
* generated for each table draw, but before it is rendered on screen. This
* function might be used for setting the row class name etc.
* @type function
* @param {node} nRow "TR" element for the current row
* @param {array} aData Raw data array for this row
* @param {int} iDisplayIndex The display index for the current table draw
* @param {int} iDisplayIndexFull The index of the data in the full list of
* rows (after filtering)
* @returns {node} "TR" element for the current row
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
* // Bold the grade for all 'A' grade browsers
* if ( aData[4] == "A" )
* {
* $('td:eq(4)', nRow).html( 'A' );
* }
* return nRow;
* }
* } );
* } );
*/
"fnRowCallback": null,
/**
* This parameter allows you to override the default function which obtains
* the data from the server ($.getJSON) so something more suitable for your
* application. For example you could use POST data, or pull information from
* a Gears or AIR database.
* @type function
* @param {string} sSource HTTP source to obtain the data from (sAjaxSource)
* @param {array} aoData A key/value pair object containing the data to send
* to the server
* @param {function} fnCallback to be called on completion of the data get
* process that will draw the data on the page.
* @param {object} oSettings DataTables settings object
*
* @example
* // POST data to server
* $(document).ready(function() {
* $('#example').dataTable( {
* "bProcessing": true,
* "bServerSide": true,
* "sAjaxSource": "xhr.php",
* "fnServerData": function ( sSource, aoData, fnCallback ) {
* $.ajax( {
* "dataType": 'json',
* "type": "POST",
* "url": sSource,
* "data": aoData,
* "success": fnCallback
* } );
* }
* } );
* } );
*/
"fnServerData": function ( sUrl, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"url": sUrl,
"data": aoData,
"success": function (json) {
$(oSettings.oInstance).trigger('xhr', oSettings);
fnCallback( json );
},
"dataType": "json",
"cache": false,
"type": oSettings.sServerMethod,
"error": function (xhr, error, thrown) {
if ( error == "parsererror" ) {
alert( "DataTables warning: JSON data from server could not be parsed. "+
"This is caused by a JSON formatting error." );
}
}
} );
},
/**
* It is often useful to send extra data to the server when making an Ajax
* request - for example custom filtering information, and this callback
* function makes it trivial to send extra information to the server. The
* passed in parameter is the data set that has been constructed by
* DataTables, and you can add to this or modify it as you require.
* @type function
* @param {array} aoData Data array (array of objects which are name/value
* pairs) that has been constructed by DataTables and will be sent to the
* server. In the case of Ajax sourced data with server-side processing
* this will be an empty array, for server-side processing there will be a
* significant number of parameters!
* @returns {undefined} Ensure that you modify the aoData array passed in,
* as this is passed by reference.
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bProcessing": true,
* "bServerSide": true,
* "sAjaxSource": "scripts/server_processing.php",
* "fnServerParams": function ( aoData ) {
* aoData.push( { "name": "more_data", "value": "my_value" } );
* }
* } );
* } );
*/
"fnServerParams": null,
/**
* State saving in DataTables is very useful, but it does a blanket save on
* all properties that the user can modify, so the table is restored. This
* callback method can be used to modify the saved properties as you require,
* just prior to them being loaded. This method can also be used to override
* the state loading altogether by returning false.
* @type function
* @param {object} oSettings DataTables settings object
* @param {object} oData Object containing information retrieved from the
* state saving cookie which should be restored. For the exact properties
* please refer to the DataTables code.
* @returns {boolean} false if the state should not be loaded, true otherwise
*
* @example
* // Remove a previously saved filter
* $(document).ready( function () {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoadCallback": function ( oSettings, oData ) {
* oData.sFilter = "";
* return true;
* }
* } );
* } );
*
* @example
* // Override state loading
* $(document).ready( function () {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoadCallback": function ( oSettings, oData ) {
* return false;
* }
* } );
* } );
*/
"fnStateLoadCallback": null,
/**
* When using state saving it can be useful to store your own custom
* parameters in the state saving cookie that DataTables uses, or to modify
* the settings that DataTables uses. Note that this function can be quite
* involved to use since it uses JSON notation in a string, given that jQuery
* does not provide a "stringify" option for JSON objects.
* @type function
* @param {object} oSettings DataTables settings object
* @param {string} sValue a JSON string (without the final closing brace)
* which should be stored in the state saving cookie.
* @returns {string} The full string that should be used to save the state
*
* @example
* // Add a custom parameter
* $(document).ready( function () {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateSaveCallback": function ( oSettings, sValue ) {
* sValue += ',"myCustomParameter": "myValue"';
* return sValue;
* }
* } );
* } );
*
* @example
* // Modify saved filter to be blank
* $(document).ready( function () {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateSaveCallback": function ( oSettings, sValue ) {
* sValue = sValue.replace( /"sFilter":".*?"/, '"sFilter":""' );
* return sValue;
* }
* } );
* } );
*
* @example
* // Modify saved filter to be blank - using JSON2.js
* $(document).ready( function () {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateSaveCallback": function ( oSettings, sValue ) {
* var oData = JSON.parse( sValue+"}" );
* oData.sFilter = "";
* return JSON.stringify( oData ).slice( 0, -1 );
* }
* } );
* } );
*/
"fnStateSaveCallback": null,
/**
* Duration of the cookie which is used for storing session information. This
* value is given in seconds.
* @type int
* @default 7200 (2 hours)
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "iCookieDuration": 60*60*24 // 1 day
* } );
* } )
*/
"iCookieDuration": 7200,
/**
* When enabled DataTables will not make a request to the server for the first
* page draw - rather it will use the data already on the page (no sorting etc
* will be applied to it), thus saving on an XHR at load time. iDeferLoading
* is used to indicate that deferred loading is required, but it is also used
* to tell DataTables how many records there are in the full table (allowing
* the information element and pagination to be displayed correctly).
* @type int
* @default null
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bServerSide": true,
* "sAjaxSource": "scripts/server_processing.php",
* "iDeferLoading": 57
* } );
* } );
*/
"iDeferLoading": null,
/**
* Number of rows to display on a single page when using pagination. If
* feature enabled (bLengthChange) then the end user will be able to override
* this to a custom setting using a pop-up menu.
* @type int
* @default 10
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "iDisplayLength": 50
* } );
* } )
*/
"iDisplayLength": 10,
/**
* Define the starting point for data display when using DataTables with
* pagination. Note that this parameter is the number of records, rather than
* the page number, so if you have 10 records per page and want to start on
* the third page, it should be "20".
* @type int
* @default 0
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "iDisplayStart": 20
* } );
* } )
*/
"iDisplayStart": 0,
/**
* The scroll gap is the amount of scrolling that is left to go before
* DataTables will load the next 'page' of data automatically. You typically
* want a gap which is big enough that the scrolling will be smooth for the
* user, while not so large that it will load more data than need.
* @type int
* @default 100
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bScrollInfinite": true,
* "bScrollCollapse": true,
* "sScrollY": "200px",
* "iScrollLoadGap": 50
* } );
* } );
*/
"iScrollLoadGap": 100,
/**
* All strings that DataTables uses in the user interface that it creates
* are defined in this object, allowing you to modified them individually or
* completely replace them all as required.
* @namespace
*/
"oLanguage": {
/**
* Pnagation string used by DataTables for the two built-in pagination
* control types ("two_button" and "full_numbers")
* @namespace
*/
"oPaginate": {
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button
* to take the user to the first page.
* @type string
* @default First
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sFirst": "First page"
* }
* }
* } );
* } );
*/
"sFirst": "First",
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the last page.
* @type string
* @default Last
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sLast": "Last page"
* }
* }
* } );
* } );
*/
"sLast": "Last",
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the next page.
* @type string
* @default Next
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sNext": "Next page"
* }
* }
* } );
* } );
*/
"sNext": "Next",
/**
* Text to use when using the 'full_numbers' type of pagination for the
* button to take the user to the previous page.
* @type string
* @default Previous
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "oPaginate": {
* "sPrevious": "Previous page"
* }
* }
* } );
* } );
*/
"sPrevious": "Previous",
},
/**
* This string is shown in preference to sZeroRecords when the table is
* empty of data (regardless of filtering). Note that this is an optional
* parameter - if it is not given, the value of sZeroRecords will be used
* instead (either the default or given value).
* @type string
* @default No data available in table
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sEmptyTable": "No data available in table"
* }
* } );
* } );
*/
"sEmptyTable": "No data available in table",
/**
* This string gives information to the end user about the information that
* is current on display on the page. The _START_, _END_ and _TOTAL_
* variables are all dynamically replaced as the table display updates, and
* can be freely moved or removed as the language requirements change.
* @type string
* @default Showing _START_ to _END_ of _TOTAL_ entries
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfo": "Got a total of _TOTAL_ entries to show (_START_ to _END_)"
* }
* } );
* } );
*/
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
/**
* Display information string for when the table is empty. Typically the
* format of this string should match sInfo.
* @type string
* @default Showing 0 to 0 of 0 entries
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoEmpty": "No entries to show"
* }
* } );
* } );
*/
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
/**
* When a user filters the information in a table, this string is appended
* to the information (sInfo) to give an idea of how strong the filtering
* is. The variable _MAX_ is dynamically updated.
* @type string
* @default (filtered from _MAX_ total entries)
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoFiltered": " - filtering from _MAX_ records"
* }
* } );
* } );
*/
"sInfoFiltered": "(filtered from _MAX_ total entries)",
/**
* If can be useful to append extra information to the info string at times,
* and this variable does exactly that. This information will be appended to
* the sInfo (sInfoEmpty and sInfoFiltered in whatever combination they are
* being used) at all times.
* @type string
* @default Empty string
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoPostFix": "All records shown are derived from real information."
* }
* } );
* } );
*/
"sInfoPostFix": "",
/**
* DataTables has a build in number formatter (fnFormatNumber) which is used
* to format large numbers that are used in the table information. By
* default a comma is used, but this can be trivially changed to any
* character you wish with this parameter.
* @type string
* @default ,
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sInfoThousands": "'"
* }
* } );
* } );
*/
"sInfoThousands": ",",
/**
* Detail the action that will be taken when the drop down menu for the
* pagination length option is changed. The '_MENU_' variable is replaced
* with a default select list of 10, 25, 50 and 100, and can be replaced
* with a custom select box if required.
* @type string
* @default Show _MENU_ entries
*
* @example
* // Language change only
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sLengthMenu": "Display _MENU_ records"
* }
* } );
* } );
*
* @example
* // Language and options change
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sLengthMenu": 'Display records'
* }
* } );
* } );
*/
"sLengthMenu": "Show _MENU_ entries",
/**
* When using Ajax sourced data and during the first draw when DataTables is
* gathering the data, this message is shown in an empty row in the table to
* indicate to the end user the the data is being loaded. Note that this
* parameter is not used when loading data by server-side processing, just
* Ajax sourced data with client-side processing.
* @type string
* @default Loading...
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sLoadingRecords": "Please wait - loading..."
* }
* } );
* } );
*/
"sLoadingRecords": "Loading...",
/**
* Text which is displayed when the table is processing a user action
* (usually a sort command or similar).
* @type string
* @default Processing...
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sProcessing": "DataTables is currently busy"
* }
* } );
* } );
*/
"sProcessing": "Processing...",
/**
* Details the actions that will be taken when the user types into the
* filtering input text box. The variable "_INPUT_", if used in the string,
* is replaced with the HTML text box for the filtering input allowing
* control over where it appears in the string. If "_INPUT_" is not given
* then the input box is appended to the string automatically.
* @type string
* @default Search:
*
* @example
* // Input text box will be appended at the end automatically
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sSearch": "Filter records:"
* }
* } );
* } );
*
* @example
* // Specify where the filter should appear
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sSearch": "Apply filter _INPUT_ to table"
* }
* } );
* } );
*/
"sSearch": "Search:",
/**
* All of the language information can be stored in a file on the
* server-side, which DataTables will look up if this parameter is passed.
* It must store the URL of the language file, which is in a JSON format,
* and the object has the same properties as the oLanguage object in the
* initialiser object (i.e. the above parameters). Please refer to one of
* the example language files to see how this works in action.
* @type string
* @default Empty string - i.e. disabled
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sUrl": "http://www.sprymedia.co.uk/dataTables/lang.txt"
* }
* } );
* } );
*/
"sUrl": "",
/**
* Text shown inside the table records when the is no information to be
* displayed after filtering. sEmptyTable is shown when there is simply no
* information in the table at all (regardless of filtering).
* @type string
* @default No matching records found
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "oLanguage": {
* "sZeroRecords": "No records to display"
* }
* } );
* } );
*/
"sZeroRecords": "No matching records found",
},
/**
* This parameter allows you to have define the global filtering state at
* initialisation time. As an object the "sSearch" parameter must be
* defined, but the "bRegex" and "bSmart" parameters are optional. When
* "bRegex" is true, the search string will be treated as a regular
* expression, when false (default) it will be treated as a straight string.
* When "bSmart" DataTables will use it's smart filtering methods (to word
* match at any point in the data), when false this will not be done.
* @type object
* @extends DataTable.models.oSearch
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "oSearch": {"sSearch": "Initial search"}
* } );
* } )
*/
"oSearch": $.extend( {}, DataTable.models.oSearch ),
/**
* By default DataTables will look for the property 'aaData' when obtaining
* data from an Ajax source or for server-side processing - this parameter
* allows that property to be changed. You can use Javascript dotted object
* notation to get a data source for multiple levels of nesting.
* @type string
* @default aaData
*
* @example
* // Get data from { "data": [...] }
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "sAjaxSource": "sources/data.txt",
* "sAjaxDataProp": "data"
* } );
* } );
*
* @example
* // Get data from { "data": { "inner": [...] } }
* $(document).ready(function() {
* var oTable = $('#example').dataTable( {
* "sAjaxSource": "sources/data.txt",
* "sAjaxDataProp": "data.inner"
* } );
* } );
*/
"sAjaxDataProp": "aaData",
/**
* You can instruct DataTables to load data from an external source using this
* parameter (use aData if you want to pass data in you already have). Simply
* provide a url a JSON object can be obtained from. This object must include
* the parameter 'aaData' which is a 2D array with the source data.
* @type string
* @default null
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "sAjaxSource": "http://www.sprymedia.co.uk/dataTables/json.php"
* } );
* } )
*/
"sAjaxSource": null,
/**
* Address from which DataTables should load the remote data from when using
* server-side processing. Note that sAjaxSource can also be used without
* server-side processing to indicate a "one time get" of JSON formatted data.
* @type string
* @default null
*
* @example
* $(document).ready( function () {
* $('#example').dataTable( {
* "bProcessing": false,
* "sAjaxSource": "xhr.php"
* } );
* } );
*/
"sAjaxSource": null,
/**
* This parameter can be used to override the default prefix that DataTables
* assigns to a cookie when state saving is enabled.
* @type string
* @default SpryMedia_DataTables_
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sCookiePrefix": "my_datatable_",
* } );
* } );
*/
"sCookiePrefix": "SpryMedia_DataTables_",
/**
* This initialisation variable allows you to specify exactly where in the
* DOM you want DataTables to inject the various controls it adds to the page
* (for example you might want the pagination controls at the top of the
* table). DIV elements (with or without a custom class) can also be added to
* aid styling. The follow syntax is used:
*
*
* @type string
* @default lfrtip (when bJQueryUI is false)or
* <"H"lfr>t<"F"ip> (when bJQueryUI is true)
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sDom": '<"top"i>rt<"bottom"flp><"clear"&lgt;'
* } );
* } );
*/
"sDom": "lfrtip",
/**
* DataTables features two different built-in pagination interaction methods
* ('two_button' or 'full_numbers') which present different page controls to
* the end user. Further methods can be added using the API (see below).
* @type string
* @default two_button
*
* @example
* $(document).ready( function() {
* $('#example').dataTable( {
* "sPaginationType": "full_numbers"
* } );
* } )
*/
"sPaginationType": "two_button",
/**
* Enable horizontal scrolling. When a table is too wide to fit into a certain
* layout, or you have a large number of columns in the table, you can enable
* x-scrolling to show the table in a viewport, which can be scrolled. This
* property can by any CSS unit, or a number (in which case it will be treated
* as a pixel measurement).
* @type string
* @default blank string - i.e. disabled
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollX": "100%",
* "bScrollCollapse": true
* } );
* } );
*/
"sScrollX": "",
/**
* This property can be used to force a DataTable to use more width than it
* might otherwise do when x-scrolling is enabled. For example if you have a
* table which requires to be well spaced, this parameter is useful for
* "over-sizing" the table, and thus forcing scrolling. This property can by
* any CSS unit, or a number (in which case it will be treated as a pixel
* measurement).
* @type string
* @default blank string - i.e. disabled
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollX": "100%",
* "sScrollXInner": "110%"
* } );
* } );
*/
"sScrollXInner": "",
/**
* Enable vertical scrolling. Vertical scrolling will constrain the DataTable
* to the given height, an enable scrolling for any data which overflows the
* current viewport. This can be used as an alternative to paging to display
* a lot of data in a small area (although paging and scrolling can both be
* enabled at the same time). This property can by any CSS unit, or a number
* (in which case it will be treated as a pixel measurement).
* @type string
* @default blank string - i.e. disabled
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "sScrollY": "200px",
* "bPaginate": false
* } );
* } );
*/
"sScrollY": "",
/**
* Set the HTTP method that is used to make the Ajax call for server-side
* processing or Ajax sourced data.
* @type string
* @default GET
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "bServerSide": true,
* "sAjaxSource": "scripts/post.php",
* "sServerMethod": "POST"
* } );
* } );
*/
"sServerMethod": "GET"
};
/*
* Variable: dataTableSettings
* Purpose: Store the settings for each dataTables instance
* Scope: jQuery.fn
*/
var _aoSettings = [];
/**
* DataTables settings object - this holds all the information needed for a
* given table, including configuration, data and current application of the
* table options. DataTables does not have a single instance for each DataTable
* with the settings attached to that instance, but rather instances of the
* DataTable "class" are created on-the-fly as needed (typically by a
* $().dataTable() call) and the settings object is then applied to that
* instance.
*
* Note that this object is related to {@link DataTable.models.oInit} but this
* one is the internal data store for DataTables's cache of columns. It should
* NOT be manipulated outside of DataTables. Any configuration should be done
* through the initialisation options.
* @namespace
* @todo Really should attach the settings object to individual instances so we
* don't need to create new instances on each $().dataTable() call (if the
* table already exists). It would also save passing oSettings around and
* into every single function. However, this is a very significant
* architecture change for DataTables and will almost certainly break
* backwards compatibility with older installations. This is something that
* will be done in 2.0.
*/
DataTable.models.oSettings = {
/**
* Primary features of DataTables and their enablement state.
* @namespace
*/
"oFeatures": {
/**
* Flag to say if DataTables should automatically try to calculate the
* optimum table and columns widths (true) or not (false).
* @type boolean
* @default true
*/
"bAutoWidth": true,
/**
* Delay the creation of TR and TD elements until they are actually
* needed by a driven page draw. This can give a significant speed
* increase for Ajax source and Javascript source data, but makes no
* difference at all fro DOM and server-side processing tables.
* @type boolean
* @default false
*/
"bDeferRender": false,
/**
* Enable filtering on the table or not. Note that if this is disabled
* then there is no filtering at all on the table, including fnFilter.
* To just remove the filtering input use sDom and remove the 'f' option
* @type boolean
* @default true
*/
"bFilter": true,
/**
* Table information element (the 'Showing x of y records' div) enable
* flag
* @type boolean
* @default true
*/
"bInfo": true,
/**
* Present a user control allowing the end user to change the page size
* when pagination is enabled.
* @type boolean
* @default true
*/
"bLengthChange": true,
/**
* Pagination enabled or not. Note that if this is disabled then length
* changing must also be disabled.
* @type boolean
* @default true
*/
"bPaginate": true,
/**
* Processing indicator enable flag whenever DataTables is enacting a
* user request - typically an Ajax request for server-side processing.
* @type boolean
* @default false
*/
"bProcessing": false,
/**
* Server-side processing enabled flag - when enabled DataTables will
* get all data from the server for every draw - there is no filtering,
* sorting or paging done on the client-side.
* @type boolean
* @default false
*/
"bServerSide": false,
/**
* Sorting enablement flag.
* @type boolean
* @default true
*/
"bSort": true,
/**
* Apply a class to the columns which are being sorted to provide a
* visual highlight or not. This can slow things down when enabled since
* there is a lot of DOM interaction.
* @type boolean
* @default true
*/
"bSortClasses": true,
/**
* State saving enablement flag.
* @type boolean
* @default false
*/
"bStateSave": false
},
/**
* Scrolling settings for a table.
* @namespace
*/
"oScroll": {
/**
* Indicate if DataTables should be allowed to set the padding / margin
* etc for the scrolling header elements or not. Typically you will want
* this.
* @type boolean
* @default true
*/
"bAutoCss": true,
/**
* When the table is shorter in height than sScrollY, collapse the
* table container down to the height of the table (when true)
* @type boolean
* @default false
*/
"bCollapse": false,
/**
* Infinite scrolling enablement flag. Now deprecated in favour of
* using the Scroller plug-in.
* @type boolean
* @default false
* @deprecated
*/
"bInfinite": false,
/**
* Width of the scrollbar for the web-browser's platform. Calculated
* during table initialisation.
* @type int
* @default 0
*/
"iBarWidth": 0,
/**
* Space (in pixels) between the bottom of the scrolling container and
* the bottom of the scrolling viewport before the next page is loaded
* when using infinite scrolling.
* @type int
* @default 100
* @deprecated
*/
"iLoadGap": 100,
/**
* Viewport width for horizontal scrolling. Horizontal scrolling is
* disabled if an empty string.
* @type string
* @default Empty string
*/
"sX": "",
/**
* Width to expand the table to when using x-scrolling. Typically you
* should not need to use this.
* @type string
* @default Empty string
* @deprecated
*/
"sXInner": "",
/**
* Viewport height for vertical scrolling. Vertical scrolling is disabled
* if an empty string.
* @type string
* @default Empty string
*/
"sY": ""
},
/**
* Language information for the table.
* @namespace
* @extends DataTable.models.oInit.oLanguage
*/
"oLanguage": {
/**
* Information callback function. See
* {@link DataTable.models.oInit.fnInfoCallback}
* @type function
* @default
*/
"fnInfoCallback": null
},
/**
* Array referencing the nodes which are used for the features. The
* parameters of this object match what is allowed by sDom - i.e.
*
*
'l' - Length changing
*
'f' - Filtering input
*
't' - The table!
*
'i' - Information
*
'p' - Pagination
*
'r' - pRocessing
*
* @type array
* @default []
*/
"aanFeatures": [],
/**
* Store data information - see {@link DataTable.models.oRow} for detailed
* information.
* @type array
* @default []
*/
"aoData": [],
/**
* Array of indexes which are in the current display (after filtering etc)
* @type array
* @default []
*/
"aiDisplay": [],
/**
* Array of indexes for display - no filtering
* @type array
* @default []
*/
"aiDisplayMaster": [],
/**
* Store information about each column that is in use
* @type array
* @default []
*/
"aoColumns": [],
/**
* Store information about the table's header
* @type array
* @default []
*/
"aoHeader": [],
/**
* Store information about the table's footer
* @type array
* @default []
*/
"aoFooter": [],
/**
* Search data array for regular expression searching
* @type array
* @default []
*/
"asDataSearch": [],
/**
* Store the applied global search information in case we want to force a
* research or compare the old search to a new one
* @namespace
* @extends DataTable.models.oSearch
*/
"oPreviousSearch": {},
/**
* Store the applied search for each column - see
* {@link DataTable.models.oSearch} for the format that is used for the
* filtering information for each column.
* @type array
* @default []
*/
"aoPreSearchCols": [],
/**
* Sorting that is applied to the table. Note that the inner arrays are
* used in the following manner:
*
*
Index 0 - column number
*
Index 1 - current sorting direction
*
Index 2 - index of asSorting for this column
*
* @type array
* @default [[0, 'asc', 0]]
* @todo These inner arrays should really be objects
*/
"aaSorting": [[0, 'asc', 0]],
/**
* Sorting that is always applied to the table (i.e. prefixed in front of
* aaSorting).
* @type array|null
* @default null
*/
"aaSortingFixed": null,
/**
* Classes to use for the striping of a table
* @type array
* @default []
*/
"asStripeClasses": [],
/**
* If restoring a table - we should restore its striping classes as well
* @type array
* @default []
*/
"asDestroyStripes": [],
/**
* If restoring a table - we should restore its width
* @type int
* @default 0
*/
"sDestroyWidth": 0,
/**
* Call this function every time a row is inserted (draw)
* @type function
* @default null
* @todo Make into an array so plug-ins can hook in
*/
"fnRowCallback": null,
/**
* Callback function for the header on each draw
* @type function
* @default null
* @todo Make into an array so plug-ins can hook in
*/
"fnHeaderCallback": null,
/**
* Callback function for the footer on each draw
* @type function
* @default null
* @todo Make into an array so plug-ins can hook in
*/
"fnFooterCallback": null,
/**
* Array of callback functions for draw callback functions
* @type array
* @default []
*/
"aoDrawCallback": [],
/**
* Callback function for just before the table is redrawn. A return of
* false will be used to cancel the draw.
* @type function
* @default null
* @todo Make into an array so plug-ins can hook in
*/
"fnPreDrawCallback": null,
/**
* Callback function for when the table has been initialised
* @type function
* @default null
* @todo Make into an array so plug-ins can hook in
*/
"fnInitComplete": null,
/**
* Cache the table ID for quick access
* @type string
* @default Empty string
*/
"sTableId": "",
/**
* The TABLE node for the main table
* @type node
* @default null
*/
"nTable": null,
/**
* Permanent ref to the thead element
* @type node
* @default null
*/
"nTHead": null,
/**
* Permanent ref to the tfoot element - if it exists
* @type node
* @default null
*/
"nTFoot": null,
/**
* Permanent ref to the tbody element
* @type node
* @default null
*/
"nTBody": null,
/**
* Cache the wrapper node (contains all DataTables controlled elements)
* @type node
* @default null
*/
"nTableWrapper": null,
/**
* Indicate if when using server-side processing the loading of data
* should be deferred until the second draw
* @type boolean
* @default false
*/
"bDeferLoading": false,
/**
* Indicate if all required information has been read in
* @type boolean
* @default false
*/
"bInitialised": false,
/**
* Information about open rows. Each object in the array has the parameters
* 'nTr' and 'nParent'
* @type array
* @default []
*/
"aoOpenRows": [],
/**
* Dictate the positioning of DataTables' control elements - see
* {@link DataTable.model.oInit.sDom}.
* @type string
* @default null
*/
"sDom": null,
/**
* Which type of pagination should be used
* @type string
* @default two_button
*/
"sPaginationType": "two_button",
/**
* The cookie duration (for bStateSave) in seconds
* @type int
* @default 0
*/
"iCookieDuration": 0,
/**
* The cookie name prefix
* @type string
* @default Empty string
*/
"sCookiePrefix": "",
/**
* Callback function for cookie creation
* @type function
* @default null
*/
"fnCookieCallback": null,
/**
* Array of callback functions for state saving. Each array element is an
* object with the following parameters:
*
*
function:fn - function to call. Takes two parameters, oSettings
* and the JSON string to save that has been thus far created. Returns
* a JSON string to be inserted into a json object
* (i.e. '"param": [ 0, 1, 2]')
*
string:sName - name of callback
*
* @type array
* @default []
*/
"aoStateSave": [],
/**
* Array of callback functions for state loading. Each array element is an
* object with the following parameters:
*
*
function:fn - function to call. Takes two parameters, oSettings
* and the object stored. May return false to cancel state loading
*
string:sName - name of callback
*
* @type array
* @default []
*/
"aoStateLoad": [],
/**
* State that was loaded from the cookie. Useful for back reference
* @type object
* @default null
*/
"oLoadedState": null,
/**
* Source url for AJAX data for the table
* @type string
* @default null
*/
"sAjaxSource": null,
/**
* Property from a given object from which to read the table data from. This
* can be an empty string (when not server-side processing), in which case
* it is assumed an an array is given directly.
* @type string
* @default aaData
*/
"sAjaxDataProp": 'aaData',
/**
* Note if draw should be blocked while getting data
* @type boolean
* @default true
*/
"bAjaxDataGet": true,
/**
* The last jQuery XHR object that was used for server-side data gathering.
* This can be used for working with the XHR information in one of the
* callbacks
* @type object
* @default null
*/
"jqXHR": null,
/**
* Function to get the server-side data
* @type function
* @default null
*/
"fnServerData": null,
/**
* Functions which are called prior to sending an Ajax request so extra
* parameters can easily be sent to the server
* @type array
* @default []
*/
"aoServerParams": [],
/**
* Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
* required)
* @type string
* @default GET
*/
"sServerMethod": "GET",
/**
* Format numbers for display
* @type function
* @default null
*/
"fnFormatNumber": null,
/**
* List of options that can be used for the user selectable length menu
* @type array
* @default []
*/
"aLengthMenu": [],
/**
* Counter for the draws that the table does. Also used as a tracker for
* server-side processing
* @type int
* @default 0
*/
"iDraw": 0,
/**
* Indicate if a redraw is being done - useful for Ajax
* @type boolean
* @default false
*/
"bDrawing": false,
/**
* Draw index (iDraw) of the last error when parsing the returned data
* @type int
* @default -1
*/
"iDrawError": -1,
/**
* Paging display length
* @type int
* @default 10
*/
"_iDisplayLength": 10,
/**
* Paging start point - aiDisplay index
* @type int
* @default 0
*/
"_iDisplayStart": 0,
/**
* Paging end point - aiDisplay index. Use fnDisplayEnd rather than
* this property to get the end point
* @type int
* @default 10
* @private
*/
"_iDisplayEnd": 10,
/**
* Server-side processing - number of records in the result set
* (i.e. before filtering), Use fnRecordsTotal rather than
* this property to get the value of the number of records, regardless of
* the server-side processing setting.
* @type int
* @default 0
* @private
*/
"_iRecordsTotal": 0,
/**
* Server-side processing - number of records in the current display set
* (i.e. after filtering). Use fnRecordsDisplay rather than
* this property to get the value of the number of records, regardless of
* the server-side processing setting.
* @type boolean
* @default 0
* @private
*/
"_iRecordsDisplay": 0,
/**
* Flag to indicate if jQuery UI marking and classes should be used
* @type boolean
* @default false
*/
"bJUI": false,
/**
* The classes to use for the table
* @type object
* @default null
*/
"oClasses": null,
/**
* Flag attached to the settings object so you can check in the draw
* callback if filtering has been done in the draw. Deprecated in favour of
* events.
* @type boolean
* @default false
* @deprecated
*/
"bFiltered": false,
/**
* Flag attached to the settings object so you can check in the draw
* callback if sorting has been done in the draw. Deprecated in favour of
* events.
* @type boolean
* @default false
* @deprecated
*/
"bSorted": false,
/**
* Indicate that if multiple rows are in the header and there is more than
* one unique cell per column, if the top one (true) or bottom one (false)
* should be used for sorting / title by DataTables
* @type boolean
* @default false
*/
"bSortCellsTop": false,
/**
* Initialisation object that is used for the table
* @type object
* @default null
*/
"oInit": null,
/**
* Destroy callback functions - for plug-ins to attach themselves to the
* destroy so they can clean up markup and events.
* @type array
* @default []
*/
"aoDestroyCallback": [],
/**
* Get the number of records in the current record set, before filtering
* @type function
*/
"fnRecordsTotal": function ()
{
if ( this.oFeatures.bServerSide ) {
return parseInt(this._iRecordsTotal, 10);
} else {
return this.aiDisplayMaster.length;
}
},
/**
* Get the number of records in the current record set, after filtering
* @type function
*/
"fnRecordsDisplay": function ()
{
if ( this.oFeatures.bServerSide ) {
return parseInt(this._iRecordsDisplay, 10);
} else {
return this.aiDisplay.length;
}
},
/**
* Set the display end point - aiDisplay index
* @type function
* @todo Should do away with _iDisplayEnd and calculate it on-the-fly here
*/
"fnDisplayEnd": function ()
{
if ( this.oFeatures.bServerSide ) {
if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
return this._iDisplayStart+this.aiDisplay.length;
} else {
return Math.min( this._iDisplayStart+this._iDisplayLength,
this._iRecordsDisplay );
}
} else {
return this._iDisplayEnd;
}
},
/**
* The DataTables object for this table
* @type object
* @default null
*/
"oInstance": null,
/**
* Unique identifier for each instance of the DataTables object. If there
* is an ID on the table node, then it takes that value, otherwise an
* incrementing internal counter is used.
* @type string
* @default null
*/
"sInstance": null
};
var _oExt = $.extend( true, {}, DataTable.models.ext );
$.extend( _oExt.oStdClasses, {
/* Two buttons buttons */
"sPagePrevEnabled": "paginate_enabled_previous",
"sPagePrevDisabled": "paginate_disabled_previous",
"sPageNextEnabled": "paginate_enabled_next",
"sPageNextDisabled": "paginate_disabled_next",
"sPageJUINext": "",
"sPageJUIPrev": "",
/* Full numbers paging buttons */
"sPageButton": "paginate_button",
"sPageButtonActive": "paginate_active",
"sPageButtonStaticDisabled": "paginate_button paginate_button_disabled",
"sPageFirst": "first",
"sPagePrevious": "previous",
"sPageNext": "next",
"sPageLast": "last",
/* Striping classes */
"sStripeOdd": "odd",
"sStripeEven": "even",
/* Empty row */
"sRowEmpty": "dataTables_empty",
/* Features */
"sWrapper": "dataTables_wrapper",
"sFilter": "dataTables_filter",
"sInfo": "dataTables_info",
"sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
"sLength": "dataTables_length",
"sProcessing": "dataTables_processing",
/* Sorting */
"sSortAsc": "sorting_asc",
"sSortDesc": "sorting_desc",
"sSortable": "sorting", /* Sortable in both directions */
"sSortableAsc": "sorting_asc_disabled",
"sSortableDesc": "sorting_desc_disabled",
"sSortableNone": "sorting_disabled",
"sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
"sSortJUIAsc": "",
"sSortJUIDesc": "",
"sSortJUI": "",
"sSortJUIAscAllowed": "",
"sSortJUIDescAllowed": "",
"sSortJUIWrapper": "",
"sSortIcon": "",
/* Scrolling */
"sScrollWrapper": "dataTables_scroll",
"sScrollHead": "dataTables_scrollHead",
"sScrollHeadInner": "dataTables_scrollHeadInner",
"sScrollBody": "dataTables_scrollBody",
"sScrollFoot": "dataTables_scrollFoot",
"sScrollFootInner": "dataTables_scrollFootInner",
/* Misc */
"sFooterTH": ""
} );
$.extend( _oExt.oJUIClasses, {
/* Two buttons buttons */
"sPagePrevEnabled": "fg-button ui-button ui-state-default ui-corner-left",
"sPagePrevDisabled": "fg-button ui-button ui-state-default ui-corner-left ui-state-disabled",
"sPageNextEnabled": "fg-button ui-button ui-state-default ui-corner-right",
"sPageNextDisabled": "fg-button ui-button ui-state-default ui-corner-right ui-state-disabled",
"sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
"sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",
/* Full numbers paging buttons */
"sPageButton": "fg-button ui-button ui-state-default",
"sPageButtonActive": "fg-button ui-button ui-state-default ui-state-disabled",
"sPageButtonStaticDisabled": "fg-button ui-button ui-state-default ui-state-disabled",
"sPageFirst": "first ui-corner-tl ui-corner-bl",
"sPagePrevious": "previous",
"sPageNext": "next",
"sPageLast": "last ui-corner-tr ui-corner-br",
/* Striping classes */
"sStripeOdd": "odd",
"sStripeEven": "even",
/* Empty row */
"sRowEmpty": "dataTables_empty",
/* Features */
"sWrapper": "dataTables_wrapper",
"sFilter": "dataTables_filter",
"sInfo": "dataTables_info",
"sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
"ui-buttonset-multi paging_", /* Note that the type is postfixed */
"sLength": "dataTables_length",
"sProcessing": "dataTables_processing",
/* Sorting */
"sSortAsc": "ui-state-default",
"sSortDesc": "ui-state-default",
"sSortable": "ui-state-default",
"sSortableAsc": "ui-state-default",
"sSortableDesc": "ui-state-default",
"sSortableNone": "ui-state-default",
"sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
"sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
"sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
"sSortJUI": "css_right ui-icon ui-icon-carat-2-n-s",
"sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n",
"sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s",
"sSortJUIWrapper": "DataTables_sort_wrapper",
"sSortIcon": "DataTables_sort_icon",
/* Scrolling */
"sScrollWrapper": "dataTables_scroll",
"sScrollHead": "dataTables_scrollHead ui-state-default",
"sScrollHeadInner": "dataTables_scrollHeadInner",
"sScrollBody": "dataTables_scrollBody",
"sScrollFoot": "dataTables_scrollFoot ui-state-default",
"sScrollFootInner": "dataTables_scrollFootInner",
/* Misc */
"sFooterTH": "ui-state-default"
} );
/*
* Variable: oPagination
* Purpose:
* Scope: jQuery.fn.dataTableExt
*/
$.extend( _oExt.oPagination, {
/*
* Variable: two_button
* Purpose: Standard two button (forward/back) pagination
* Scope: jQuery.fn.dataTableExt.oPagination
*/
"two_button": {
/*
* Function: oPagination.two_button.fnInit
* Purpose: Initialise dom elements required for pagination with forward/back buttons only
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* node:nPaging - the DIV which contains this pagination control
* function:fnCallbackDraw - draw function which must be called on update
*/
"fnInit": function ( oSettings, nPaging, fnCallbackDraw )
{
var nPrevious, nNext, nPreviousInner, nNextInner;
var fnClickHandler = function ( e ) {
if ( oSettings.oApi._fnPageChange( oSettings, e.data.action ) )
{
fnCallbackDraw( oSettings );
}
};
/* Store the next and previous elements in the oSettings object as they can be very
* useful for automation - particularly testing
*/
nPrevious = document.createElement( 'a' );
nNext = document.createElement( 'a' );
if ( oSettings.bJUI )
{
nNextInner = document.createElement('span');
nNextInner.className = oSettings.oClasses.sPageJUINext;
nNext.appendChild( nNextInner );
nPreviousInner = document.createElement('span');
nPreviousInner.className = oSettings.oClasses.sPageJUIPrev;
nPrevious.appendChild( nPreviousInner );
}
nPrevious.className = oSettings.oClasses.sPagePrevDisabled;
nNext.className = oSettings.oClasses.sPageNextDisabled;
nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious;
nNext.title = oSettings.oLanguage.oPaginate.sNext;
nPaging.appendChild( nPrevious );
nPaging.appendChild( nNext );
$(nPrevious)
.bind( 'click.DT', { action: "previous" }, fnClickHandler )
.bind( 'selectstart.DT', function () { return false; } ); /* Take the brutal approach to cancelling text selection */
$(nNext)
.bind( 'click.DT', { action: "next" }, fnClickHandler )
.bind( 'selectstart.DT', function () { return false; } );
/* ID the first elements only */
if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" )
{
nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
}
},
/*
* Function: oPagination.two_button.fnUpdate
* Purpose: Update the two button pagination at the end of the draw
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* function:fnCallbackDraw - draw function to call on page change
*/
"fnUpdate": function ( oSettings, fnCallbackDraw )
{
if ( !oSettings.aanFeatures.p )
{
return;
}
/* Loop over each instance of the pager */
var an = oSettings.aanFeatures.p;
for ( var i=0, iLen=an.length ; i= (iPages - iPageCountHalf))
{
iStartButton = iPages - iPageCount + 1;
iEndButton = iPages;
}
else
{
iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
iEndButton = iStartButton + iPageCount - 1;
}
}
}
/* Build the dynamic list */
for ( i=iStartButton ; i<=iEndButton ; i++ )
{
if ( iCurrentPage != i )
{
sList += ''+i+'';
}
else
{
sList += ''+i+'';
}
}
/* Loop over each instance of the pager */
var an = oSettings.aanFeatures.p;
var anButtons, anStatic, nPaginateList;
var fnClick = function(e) {
/* Use the information in the element to jump to the required page */
var iTarget = (this.innerHTML * 1) - 1;
oSettings._iDisplayStart = iTarget * oSettings._iDisplayLength;
fnCallbackDraw( oSettings );
e.preventDefault();
};
var fnFalse = function () { return false; };
for ( i=0, iLen=an.length ; i y) ? 1 : 0));
},
"string-desc": function ( x, y )
{
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
},
/*
* html sorting (ignore html tags)
*/
"html-pre": function ( a )
{
return a.replace( /<.*?>/g, "" ).toLowerCase();
},
"html-asc": function ( x, y )
{
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
},
"html-desc": function ( x, y )
{
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
},
/*
* date sorting
*/
"date-pre": function ( a )
{
var x = Date.parse( a );
if ( isNaN(x) || x==="" )
{
x = Date.parse( "01/01/1970 00:00:00" );
}
return x;
},
"date-asc": function ( x, y )
{
return x - y;
},
"date-desc": function ( x, y )
{
return y - x;
},
/*
* numerical sorting
*/
"numeric-pre": function ( a )
{
return (a=="-" || a==="") ? 0 : a*1;
},
"numeric-asc": function ( x, y )
{
return x - y;
},
"numeric-desc": function ( x, y )
{
return y - x;
}
} );
$.extend( _oExt.aTypes, [
/*
* Function: -
* Purpose: Check to see if a string is numeric
* Returns: string:'numeric' or null
* Inputs: mixed:sText - string to check
*/
function ( sData )
{
/* Allow zero length strings as a number */
if ( typeof sData == 'number' )
{
return 'numeric';
}
else if ( typeof sData != 'string' )
{
return null;
}
var sValidFirstChars = "0123456789-";
var sValidChars = "0123456789.";
var Char;
var bDecimal = false;
/* Check for a valid first char (no period and allow negatives) */
Char = sData.charAt(0);
if (sValidFirstChars.indexOf(Char) == -1)
{
return null;
}
/* Check all the other characters are valid */
for ( var i=1 ; i') != -1 )
{
return 'html';
}
return null;
}
] );
DataTable.ext = {};
// jQuery aliases
$.fn.dataTable = DataTable;
$.fn.dataTableSettings = _aoSettings;
$.fn.dataTableExt = _oExt;
})(jQuery, window, document);