1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-18 16:54:14 +01:00

Internal and API methods now use JSDoc comments rather than my old system

This commit is contained in:
Allan Jardine 2011-12-01 17:53:59 +00:00
parent 5c67be62ae
commit aeedb9afdc
17 changed files with 1278 additions and 1458 deletions

View File

@ -823,12 +823,11 @@
{ {
/* /**
* Function: _fnAddColumn * Add a column to the list used for the table with default values
* Purpose: Add a column to the list used for the table with default values * @param {object} oSettings dataTables settings object
* Returns: - * @param {node} nTh The th element for this column
* Inputs: object:oSettings - dataTables settings object * @private
* node:nTh - the th element for this column
*/ */
function _fnAddColumn( oSettings, nTh ) function _fnAddColumn( oSettings, nTh )
{ {
@ -885,13 +884,13 @@
_fnColumnOptions( oSettings, iCol, null ); _fnColumnOptions( oSettings, iCol, null );
} }
/*
* Function: _fnColumnOptions /**
* Purpose: Apply options for a column * Apply options for a column
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iCol column index to consider
* int:iCol - column index to consider * @param {object} oOptions object with sType, bVisible and bSearchable
* object:oOptions - object with sType, bVisible and bSearchable * @private
*/ */
function _fnColumnOptions( oSettings, iCol, oOptions ) function _fnColumnOptions( oSettings, iCol, oOptions )
{ {
@ -968,14 +967,11 @@
} }
/**
* Adjust the table column widths for new data. Note: you would probably want to
/* * do a redraw after calling this function!
* Function: _fnAdjustColumnSizing * @param {object} oSettings dataTables settings object
* Purpose: Adjust the table column widths for new data * @private
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* Notes: You would probably want to do a redraw after calling this function!
*/ */
function _fnAdjustColumnSizing ( oSettings ) function _fnAdjustColumnSizing ( oSettings )
{ {
@ -993,19 +989,13 @@
} }
/**
* Covert the index of a visible column to the index in the data array (take account
* of hidden columns)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @param {object} oSettings dataTables settings object
* Section - Support functions * @param {int} iMatch Visible column index to lookup
*/ * @returns {int} i the data index
* @private
/*
* Function: _fnVisibleToColumnIndex
* Purpose: Covert the index of a visible column to the index in the data array (take account
* of hidden columns)
* Returns: int:i - the data index
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnVisibleToColumnIndex( oSettings, iMatch ) function _fnVisibleToColumnIndex( oSettings, iMatch )
{ {
@ -1027,12 +1017,14 @@
return null; return null;
} }
/*
* Function: _fnColumnIndexToVisible /**
* Purpose: Covert the index of an index in the data array and convert it to the visible * Covert the index of an index in the data array and convert it to the visible
* column index (take account of hidden columns) * column index (take account of hidden columns)
* Returns: int:i - the data index * @param {int} iMatch Column index to lookup
* Inputs: object:oSettings - dataTables settings object * @param {object} oSettings dataTables settings object
* @returns {int} i the data index
* @private
*/ */
function _fnColumnIndexToVisible( oSettings, iMatch ) function _fnColumnIndexToVisible( oSettings, iMatch )
{ {
@ -1054,12 +1046,11 @@
} }
/**
/* * Get the number of visible columns
* Function: _fnVisbleColumns * @returns {int} i the number of visible columns
* Purpose: Get the number of visible columns * @param {object} oS dataTables settings object
* Returns: int:i - the number of visible columns * @private
* Inputs: object:oS - dataTables settings object
*/ */
function _fnVisbleColumns( oS ) function _fnVisbleColumns( oS )
{ {
@ -1075,13 +1066,11 @@
} }
/* /**
* Function: _fnDetectType * Get the sort type based on an input string
* Purpose: Get the sort type based on an input string * @param {string} sData data we wish to know the type of
* Returns: string: - type (defaults to 'string' if no type can be detected) * @returns {string} type (defaults to 'string' if no type can be detected)
* Inputs: string:sData - data we wish to know the type of * @private
* Notes: This function makes use of the DataTables plugin objct _oExt
* (.aTypes) such that new types can easily be added.
*/ */
function _fnDetectType( sData ) function _fnDetectType( sData )
{ {
@ -1101,11 +1090,11 @@
} }
/* /**
* Function: _fnReOrderIndex * Figure out how to reorder a display list
* Purpose: Figure out how to reorder a display list * @param {object} oSettings dataTables settings object
* Returns: array int:aiReturn - index list for reordering * @returns array {int} aiReturn index list for reordering
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnReOrderIndex ( oSettings, sColumns ) function _fnReOrderIndex ( oSettings, sColumns )
{ {
@ -1127,11 +1116,12 @@
return aiReturn; return aiReturn;
} }
/*
* Function: _fnColumnOrdering /**
* Purpose: Get the column ordering that DataTables expects * Get the column ordering that DataTables expects
* Returns: string: - comma separated list of names * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {string} comma separated list of names
* @private
*/ */
function _fnColumnOrdering ( oSettings ) function _fnColumnOrdering ( oSettings )
{ {
@ -1148,15 +1138,15 @@
} }
/*
* Function: _fnAddData /**
* Purpose: Add a data array to the table, creating DOM node etc * Add a data array to the table, creating DOM node etc. This is the parallel to
* Returns: int: - >=0 if successful (index of new aoData entry), -1 if failed * _fnGatherData, but for adding rows from a Javascript source, rather than a
* Inputs: object:oSettings - dataTables settings object * DOM source.
* array:aData - data array to be added * @param {object} oSettings dataTables settings object
* Notes: There are two basic methods for DataTables to get data to display - a JS array * @param {array} aData data array to be added
* (which is dealt with by this function), and the DOM, which has it's own optimised * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
* function (_fnGatherData). Be careful to make the same changes here as there and vice-versa * @private
*/ */
function _fnAddData ( oSettings, aDataSupplied ) function _fnAddData ( oSettings, aDataSupplied )
{ {
@ -1224,13 +1214,11 @@
return iRow; return iRow;
} }
/*
* Function: _fnGatherData /**
* Purpose: Read in the data from the target table from the DOM * Read in the data from the target table from the DOM
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
* Notes: This is a optimised version of _fnAddData (more or less) for reading information
* from the DOM. The basic actions must be identical in the two functions.
*/ */
function _fnGatherData( oSettings ) function _fnGatherData( oSettings )
{ {
@ -1382,15 +1370,12 @@
} }
/**
* Take a TR element and convert it to an index in aoData
* @param {object} s dataTables settings object
/* * @param {node} n the TR element to find
* Function: _fnNodeToDataIndex * @returns {int} index if found, null if not
* Purpose: Take a TR element and convert it to an index in aoData * @private
* Returns: int:i - index if found, null if not
* Inputs: object:s - dataTables settings object
* node:n - the TR element to find
*/ */
function _fnNodeToDataIndex( s, n ) function _fnNodeToDataIndex( s, n )
{ {
@ -1419,15 +1404,13 @@
} }
/**
* Get an array of data for a given row from the internal data cache
/* * @param {object} oSettings dataTables settings object
* Function: _fnGetRowData * @param {int} iRow aoData row id
* Purpose: Get an array of data for a given row from the internal data cache * @param {string} sSpecific data get type ('type' 'filter' 'sort')
* Returns: array: - Data array * @returns {array} Data array
* Inputs: object:oSettings - dataTables settings object * @private
* int:iRow - aoData row id
* string:sSpecific - data get type ('type' 'filter' 'sort')
*/ */
function _fnGetRowData( oSettings, iRow, sSpecific ) function _fnGetRowData( oSettings, iRow, sSpecific )
{ {
@ -1439,14 +1422,15 @@
return out; return out;
} }
/*
* Function: _fnGetCellData /**
* Purpose: Get the data for a given cell from the internal cache, taking into account data mapping * Get the data for a given cell from the internal cache, taking into account data mapping
* Returns: *: - Cell data * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iRow aoData row id
* int:iRow - aoData row id * @param {int} iCol Column index
* int:iCol - Column index * @param {string} sSpecific data get type ('display', 'type' 'filter' 'sort')
* string:sSpecific - data get type ('display', 'type' 'filter' 'sort') * @returns {*} Cell data
* @private
*/ */
function _fnGetCellData( oSettings, iRow, iCol, sSpecific ) function _fnGetCellData( oSettings, iRow, iCol, sSpecific )
{ {
@ -1483,14 +1467,14 @@
return sData; return sData;
} }
/*
* Function: _fnSetCellData /**
* Purpose: Set the value for a specific cell, into the internal data cache * Set the value for a specific cell, into the internal data cache
* Returns: *: - Cell data * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iRow aoData row id
* int:iRow - aoData row id * @param {int} iCol Column index
* int:iCol - Column index * @param {*} val Value to set
* *:val - Value to set * @private
*/ */
function _fnSetCellData( oSettings, iRow, iCol, val ) function _fnSetCellData( oSettings, iRow, iCol, val )
{ {
@ -1500,12 +1484,13 @@
oCol.fnSetData( oData, val ); oCol.fnSetData( oData, val );
} }
/*
* Function: _fnGetObjectDataFn /**
* Purpose: Return a function that can be used to get data from a source object, taking * Return a function that can be used to get data from a source object, taking
* into account the ability to use nested objects as a source * into account the ability to use nested objects as a source
* Returns: function: - Data get function * @param {string|int|function} mSource The data source for the object
* Inputs: string|int|function:mSource - The data source for the object * @returns {function} Data get function
* @private
*/ */
function _fnGetObjectDataFn( mSource ) function _fnGetObjectDataFn( mSource )
{ {
@ -1561,12 +1546,13 @@
} }
} }
/*
* Function: _fnSetObjectDataFn /**
* Purpose: Return a function that can be used to set data from a source object, taking * Return a function that can be used to set data from a source object, taking
* into account the ability to use nested objects as a source * into account the ability to use nested objects as a source
* Returns: function: - Data set function * @param {string|int|function} mSource The data source for the object
* Inputs: string|int|function:mSource - The data source for the object * @returns {function} Data set function
* @private
*/ */
function _fnSetObjectDataFn( mSource ) function _fnSetObjectDataFn( mSource )
{ {
@ -1619,11 +1605,12 @@
} }
} }
/*
* Function: _fnGetDataMaster /**
* Purpose: Return an array with the full table data * Return an array with the full table data
* Returns: array array:aData - Master data array * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns array {array} aData Master data array
* @private
*/ */
function _fnGetDataMaster ( oSettings ) function _fnGetDataMaster ( oSettings )
{ {
@ -1637,11 +1624,10 @@
} }
/* /**
* Function: _fnClearTable * Nuke the table
* Purpose: Nuke the table * @param {object} oSettings dataTables settings object
* Returns: - * @private
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnClearTable( oSettings ) function _fnClearTable( oSettings )
{ {
@ -1652,13 +1638,12 @@
} }
/* /**
* Function: _fnDeleteIndex * Take an array of integers (index array) and remove a target integer (value - not
* Purpose: Take an array of integers (index array) and remove a target integer (value - not * the key!)
* the key!) * @param {array} a Index array to target
* Returns: - * @param {int} iTarget value to find
* Inputs: a:array int - Index array to target * @private
* int:iTarget - value to find
*/ */
function _fnDeleteIndex( a, iTarget ) function _fnDeleteIndex( a, iTarget )
{ {
@ -1683,12 +1668,12 @@
} }
/*
* Function: _fnCreateTr /**
* Purpose: Create a new TR element (and it's TD children) for a row * Create a new TR element (and it's TD children) for a row
* Returns: void * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iRow Row to consider
* int:iRow - Row to consider * @private
*/ */
function _fnCreateTr ( oSettings, iRow ) function _fnCreateTr ( oSettings, iRow )
{ {
@ -1753,13 +1738,10 @@
} }
/**
* Create the HTML header for the table
/* * @param {object} oSettings dataTables settings object
* Function: _fnBuildHead * @private
* Purpose: Create the HTML header for the table
* Returns: -
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnBuildHead( oSettings ) function _fnBuildHead( oSettings )
{ {
@ -1873,24 +1855,18 @@
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Section - Drawing functions * Draw the header (or footer) element based on the column visibility states. The
*/ * methodology here is to use the layout array from _fnDetectHeader, modified for
* the instantaneous column visibility, to construct the new layout. The grid is
/* * traversed over cell at a time in a rows x columns grid fashion, although each
* Function: _fnDrawHead * cell insert can cover multiple elements in the grid - which is tracks using the
* Purpose: Draw the header (or footer) element based on the column visibility states. The * aApplied array. Cell inserts in the grid will only occur where there isn't
* methodology here is to use the layout array from _fnDetectHeader, modified for * already a cell in that position.
* the instantaneous column visibility, to construct the new layout. The grid is * @param {object} oSettings dataTables settings object
* traversed over cell at a time in a rows x columns grid fashion, although each * @param array {objects} aoSource Layout array from _fnDetectHeader
* cell insert can cover multiple elements in the grid - which is tracks using the * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
* aApplied array. Cell inserts in the grid will only occur where there isn't * @private
* already a cell in that position.
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* array objects:aoSource - Layout array from _fnDetectHeader
* boolean:bIncludeHidden - If true then include the hidden columns in the calc,
* - optional: default false
*/ */
function _fnDrawHead( oSettings, aoSource, bIncludeHidden ) function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
{ {
@ -1976,11 +1952,11 @@
} }
} }
/*
* Function: _fnDraw /**
* Purpose: Insert the required TR nodes into the table for display * Insert the required TR nodes into the table for display
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnDraw( oSettings ) function _fnDraw( oSettings )
{ {
@ -2200,11 +2176,11 @@
} }
} }
/*
* Function: _fnReDraw /**
* Purpose: Redraw the table - taking account of the various features which are enabled * Redraw the table - taking account of the various features which are enabled
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnReDraw( oSettings ) function _fnReDraw( oSettings )
{ {
@ -2225,11 +2201,12 @@
} }
} }
/*
* Function: _fnAjaxUpdate /**
* Purpose: Update the table using an Ajax call * Update the table using an Ajax call
* Returns: bool: block the table drawing or not * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {boolean} Block the table drawing or not
* @private
*/ */
function _fnAjaxUpdate( oSettings ) function _fnAjaxUpdate( oSettings )
{ {
@ -2253,11 +2230,12 @@
} }
} }
/*
* Function: _fnAjaxParameters /**
* Purpose: Build up the parameters in an object needed for a server-side processing request * Build up the parameters in an object needed for a server-side processing request
* Returns: bool: block the table drawing or not * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {bool} block the table drawing or not
* @private
*/ */
function _fnAjaxParameters( oSettings ) function _fnAjaxParameters( oSettings )
{ {
@ -2318,12 +2296,12 @@
return aoData; return aoData;
} }
/*
* Function: _fnServerParams /**
* Purpose: Add Ajax parameters from plugins * Add Ajax parameters from plugins
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param array {objects} aoData name/value pairs to send to the server
* array objects:aoData - name/value pairs to send to the server * @private
*/ */
function _fnServerParams( oSettings, aoData ) function _fnServerParams( oSettings, aoData )
{ {
@ -2333,16 +2311,17 @@
} }
} }
/*
* Function: _fnAjaxUpdateDraw /**
* Purpose: Data the data from the server (nuking the old) and redraw the table * Data the data from the server (nuking the old) and redraw the table
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} json json data return from the server.
* object:json - json data return from the server. * @param {object} json.sEcho Tracking flag for DataTables to match requests
* The following must be defined: * @param {object} json.iTotalRecords Number of records in the data set, not accounting for filtering
* iTotalRecords, iTotalDisplayRecords, aaData * @param {object} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
* The following may be defined: * @param {object} json.aaData The data to display on this page
* sColumns * @param {object} [json.sColumns] Column ordering (sName, comma separated)
* @private
*/ */
function _fnAjaxUpdateDraw ( oSettings, json ) function _fnAjaxUpdateDraw ( oSettings, json )
{ {
@ -2405,17 +2384,10 @@
} }
/**
* Add the options to the page HTML for the table
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @param {object} oSettings dataTables settings object
* Section - Options (features) HTML * @private
*/
/*
* Function: _fnAddOptionsHtml
* Purpose: Add the options to the page HTML for the table
* Returns: -
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnAddOptionsHtml ( oSettings ) function _fnAddOptionsHtml ( oSettings )
{ {
@ -2576,16 +2548,14 @@
} }
/**
/* * Use the DOM source to create up an array of header cells. The idea here is to
* Function: _fnDetectHeader * create a layout grid (array) of rows x columns, which contains a reference
* Purpose: Use the DOM source to create up an array of header cells. The idea here is to * to the cell that that point in the grid (regardless of col/rowspan), such that
* create a layout grid (array) of rows x columns, which contains a reference * any column / row could be removed and the new grid constructed
* to the cell that that point in the grid (regardless of col/rowspan), such that * @param array {object} aLayout Array to store the calculated layout in
* any column / row could be removed and the new grid constructed * @param {node} nThead The header/footer element for the table
* Returns: void * @private
* Outputs: array object:aLayout - Array to store the calculated layout in
* Inputs: node:nThead - The header/footer element for the table
*/ */
function _fnDetectHeader ( aLayout, nThead ) function _fnDetectHeader ( aLayout, nThead )
{ {
@ -2648,13 +2618,14 @@
} }
} }
/*
* Function: _fnGetUniqueThs /**
* Purpose: Get an array of unique th elements, one for each column * Get an array of unique th elements, one for each column
* Returns: array node:aReturn - list of unique ths * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {node} nHeader automatically detect the layout from this node - optional
* node:nHeader - automatically detect the layout from this node - optional * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
* array object:aLayout - thead/tfoot layout from _fnDetectHeader - optional * @returns array {node} aReturn list of unique ths
* @private
*/ */
function _fnGetUniqueThs ( oSettings, nHeader, aLayout ) function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
{ {
@ -2685,15 +2656,12 @@
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Filtering
*/
/* /**
* Function: _fnFeatureHtmlFilter * Generate the node required for filtering text
* Purpose: Generate the node required for filtering text * @returns {node} Filter control element
* Returns: node * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFeatureHtmlFilter ( oSettings ) function _fnFeatureHtmlFilter ( oSettings )
{ {
@ -2745,13 +2713,13 @@
return nFilter; return nFilter;
} }
/*
* Function: _fnFilterComplete /**
* Purpose: Filter the table using both the global filter and column based filtering * Filter the table using both the global filter and column based filtering
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} oSearch search information
* object:oSearch: search information * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
* int:iForce - optional - force a research of the master array (1) or not (undefined or 0) * @private
*/ */
function _fnFilterComplete ( oSettings, oInput, iForce ) function _fnFilterComplete ( oSettings, oInput, iForce )
{ {
@ -2784,11 +2752,11 @@
_fnBuildSearchArray( oSettings, 0 ); _fnBuildSearchArray( oSettings, 0 );
} }
/*
* Function: _fnFilterCustom /**
* Purpose: Apply custom filtering functions * Apply custom filtering functions
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFilterCustom( oSettings ) function _fnFilterCustom( oSettings )
{ {
@ -2810,15 +2778,15 @@
} }
} }
/*
* Function: _fnFilterColumn /**
* Purpose: Filter the table on a per-column basis * Filter the table on a per-column basis
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {string} sInput string to filter on
* string:sInput - string to filter on * @param {int} iColumn column to filter
* int:iColumn - column to filter * @param {bool} bRegex treat search string as a regular expression or not
* bool:bRegex - treat search string as a regular expression or not * @param {bool} bSmart use smart filtering or not
* bool:bSmart - use smart filtering or not * @private
*/ */
function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart ) function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart )
{ {
@ -2842,15 +2810,15 @@
} }
} }
/*
* Function: _fnFilter /**
* Purpose: Filter the data table based on user input and draw the table * Filter the data table based on user input and draw the table
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {string} sInput string to filter on
* string:sInput - string to filter on * @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0)
* 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
* bool:bRegex - treat as a regular expression or not * @param {bool} bSmart perform smart filtering or not
* bool:bSmart - perform smart filtering or not * @private
*/ */
function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart ) function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart )
{ {
@ -2928,12 +2896,12 @@
oSettings.oPreviousSearch.bSmart = bSmart; oSettings.oPreviousSearch.bSmart = bSmart;
} }
/*
* Function: _fnBuildSearchArray /**
* Purpose: Create an array which can be quickly search through * Create an array which can be quickly search through
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iMaster use the master data array - optional
* int:iMaster - use the master data array - optional * @private
*/ */
function _fnBuildSearchArray ( oSettings, iMaster ) function _fnBuildSearchArray ( oSettings, iMaster )
{ {
@ -2953,12 +2921,12 @@
} }
} }
/*
* Function: _fnBuildSearchRow /**
* Purpose: Create a searchable string from a single data row * Create a searchable string from a single data row
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {array} aData Row data array to use for the data to search
* array:aData - Row data array to use for the data to search * @private
*/ */
function _fnBuildSearchRow( oSettings, aData ) function _fnBuildSearchRow( oSettings, aData )
{ {
@ -2990,13 +2958,13 @@
return sSearch; return sSearch;
} }
/* /**
* Function: _fnFilterCreateSearch * Build a regular expression object suitable for searching a table
* Purpose: Build a regular expression object suitable for searching a table * @param {string} sSearch string to search for
* Returns: RegExp: - constructed object * @param {bool} bRegex treat as a regular expression or not
* Inputs: string:sSearch - string to search for * @param {bool} bSmart perform smart filtering or not
* bool:bRegex - treat as a regular expression or not * @returns {RegExp} constructed object
* bool:bSmart - perform smart filtering or not * @private
*/ */
function _fnFilterCreateSearch( sSearch, bRegex, bSmart ) function _fnFilterCreateSearch( sSearch, bRegex, bSmart )
{ {
@ -3018,12 +2986,13 @@
} }
} }
/*
* Function: _fnDataToSearch /**
* Purpose: Convert raw data into something that the user can search on * Convert raw data into something that the user can search on
* Returns: string: - search string * @param {string} sData data to be modified
* Inputs: string:sData - data to be modified * @param {string} sType data type
* string:sType - data type * @returns {string} search string
* @private
*/ */
function _fnDataToSearch ( sData, sType ) function _fnDataToSearch ( sData, sType )
{ {
@ -3047,11 +3016,11 @@
} }
/* /**
* Function: _fnEscapeRegex * scape a string stuch that it can be used in a regular expression
* Purpose: scape a string stuch that it can be used in a regular expression * @param {string} sVal string to escape
* Returns: string: - escaped string * @returns {string} escaped string
* Inputs: string:sVal - string to escape * @private
*/ */
function _fnEscapeRegex ( sVal ) function _fnEscapeRegex ( sVal )
{ {
@ -3061,15 +3030,12 @@
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: HTML info
*/
/* /**
* Function: _fnFeatureHtmlInfo * Generate the node required for the info display
* Purpose: Generate the node required for the info display * @param {object} oSettings dataTables settings object
* Returns: node * @returns {node} Information element
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFeatureHtmlInfo ( oSettings ) function _fnFeatureHtmlInfo ( oSettings )
{ {
@ -3095,11 +3061,11 @@
return nInfo; return nInfo;
} }
/*
* Function: _fnUpdateInfo /**
* Purpose: Update the information elements in the display * Update the information elements in the display
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnUpdateInfo ( oSettings ) function _fnUpdateInfo ( oSettings )
{ {
@ -3170,15 +3136,12 @@
} }
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Initialisation
*/
/*
* Function: _fnInitialise /**
* Purpose: Draw the table for the first time, adding all required features * Draw the table for the first time, adding all required features
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnInitialise ( oSettings ) function _fnInitialise ( oSettings )
{ {
@ -3283,11 +3246,11 @@
} }
} }
/*
* Function: _fnInitComplete /**
* Purpose: Draw the table for the first time, adding all required features * Draw the table for the first time, adding all required features
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnInitComplete ( oSettings, json ) function _fnInitComplete ( oSettings, json )
{ {
@ -3305,13 +3268,13 @@
} }
} }
/*
* Function: _fnLanguageProcess /**
* Purpose: Copy language variables from remote object to a local one * Copy language variables from remote object to a local one
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} oLanguage Language information
* object:oLanguage - Language information * @param {bool} bInit init once complete
* bool:bInit - init once complete * @private
*/ */
function _fnLanguageProcess( oSettings, oLanguage, bInit ) function _fnLanguageProcess( oSettings, oLanguage, bInit )
{ {
@ -3339,15 +3302,13 @@
} }
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Length change
*/
/*
* Function: _fnFeatureHtmlLength /**
* Purpose: Generate the node required for user display length changing * Generate the node required for user display length changing
* Returns: node * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {node} Display length feature node
* @private
*/ */
function _fnFeatureHtmlLength ( oSettings ) function _fnFeatureHtmlLength ( oSettings )
{ {
@ -3433,11 +3394,10 @@
} }
/* /**
* Function: _fnCalculateEnd * Rcalculate the end point based on the start point
* Purpose: Rcalculate the end point based on the start point * @param {object} oSettings dataTables settings object
* Returns: - * @private
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnCalculateEnd( oSettings ) function _fnCalculateEnd( oSettings )
{ {
@ -3463,16 +3423,17 @@
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Pagination. Note that most of the paging logic is done in * Note that most of the paging logic is done in
* _oExt.oPagination * _oExt.oPagination
*/ */
/* /**
* Function: _fnFeatureHtmlPaginate * Generate the node required for default pagination
* Purpose: Generate the node required for default pagination * @param {object} oSettings dataTables settings object
* Returns: node * @returns {node} Pagination feature node
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFeatureHtmlPaginate ( oSettings ) function _fnFeatureHtmlPaginate ( oSettings )
{ {
@ -3507,12 +3468,13 @@
return nPaginate; return nPaginate;
} }
/*
* Function: _fnPageChange /**
* Purpose: Alter the display settings to change the page * Alter the display settings to change the page
* Returns: bool:true - page has changed, false - no change (no effect) eg 'first' on page 1 * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {string} sAction paging action to take: "first", "previous", "next" or "last"
* 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 ) function _fnPageChange ( oSettings, sAction )
{ {
@ -3571,15 +3533,12 @@
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Processing incidator
*/
/* /**
* Function: _fnFeatureHtmlProcessing * Generate the node required for the processing node
* Purpose: Generate the node required for the processing node * @param {object} oSettings dataTables settings object
* Returns: node * @returns {node} Processing element
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFeatureHtmlProcessing ( oSettings ) function _fnFeatureHtmlProcessing ( oSettings )
{ {
@ -3596,14 +3555,12 @@
return nProcessing; return nProcessing;
} }
/*
* Function: _fnProcessingDisplay /**
* Purpose: Display or hide the processing indicator * Display or hide the processing indicator
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {bool} bShow Show the processing indicator (true) or not (false)
* bool: * @private
* true - show the processing indicator
* false - don't show
*/ */
function _fnProcessingDisplay ( oSettings, bShow ) function _fnProcessingDisplay ( oSettings, bShow )
{ {
@ -3618,19 +3575,16 @@
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Filtering
*/
/* /**
* Function: _fnFeatureHtmlTable * Add any control elements for the table - specifically scrolling
* Purpose: Add any control elements for the table - specifically scrolling * @param {object} oSettings dataTables settings object
* Returns: node: - Node to add to the DOM * @returns {node} Node to add to the DOM
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFeatureHtmlTable ( oSettings ) function _fnFeatureHtmlTable ( oSettings )
{ {
/* Chack if scrolling is enabled or not - if not then leave the DOM unaltered */ /* Check if scrolling is enabled or not - if not then leave the DOM unaltered */
if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY === "" ) if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY === "" )
{ {
return oSettings.nTable; return oSettings.nTable;
@ -3784,16 +3738,17 @@
return nScroller; return nScroller;
} }
/*
* Function: _fnScrollDraw /**
* Purpose: Update the various tables for resizing * Update the various tables for resizing. It's a bit of a pig this function, but
* Returns: node: - Node to add to the DOM * basically the idea to:
* Inputs: object:o - dataTables settings object
* Notes: It's a bit of a pig this function, but basically the idea to:
* 1. Re-create the table inside the scrolling div * 1. Re-create the table inside the scrolling div
* 2. Take live measurements from the DOM * 2. Take live measurements from the DOM
* 3. Apply the measurements * 3. Apply the measurements
* 4. Clean up * 4. Clean up
* @param {object} o dataTables settings object
* @returns {node} Node to add to the DOM
* @private
*/ */
function _fnScrollDraw ( o ) function _fnScrollDraw ( o )
{ {
@ -4065,7 +4020,7 @@
nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth ); nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth );
} }
/* If sorting or filtering has occured, jump the scrolling back to the top */ /* If sorting or filtering has occurred, jump the scrolling back to the top */
if ( o.bSorted || o.bFiltered ) if ( o.bSorted || o.bFiltered )
{ {
nScrollBody.scrollTop = 0; nScrollBody.scrollTop = 0;
@ -4073,15 +4028,13 @@
} }
/**
/* * Apply a given function to the display child nodes of an element array (typically
* Function: _fnApplyToChildren * TD children of TR rows
* Purpose: Apply a given function to the display child nodes of an element array (typically * @param {function} fn Method to apply to the objects
* TD children of TR rows * @param array {nodes} an1 List of elements to look through for display children
* Returns: - (done by reference) * @param array {nodes} an2 Another list (identical structure to the first) - optional
* Inputs: function:fn - Method to apply to the objects * @private
* array nodes:an1 - List of elements to look through for display children
* array nodes:an2 - Another list (identical structure to the first) - optional
*/ */
function _fnApplyToChildren( fn, an1, an2 ) function _fnApplyToChildren( fn, an1, an2 )
{ {
@ -4106,13 +4059,12 @@
/* /**
* Function: _fnConvertToWidth * Convert a CSS unit width to pixels (e.g. 2em)
* Purpose: Convert a CSS unit width to pixels (e.g. 2em) * @param {string} sWidth width to be converted
* Returns: int:iWidth - width in pixels * @param {node} nParent parent to get the with for (required for relative widths) - optional
* Inputs: string:sWidth - width to be converted * @returns {int} iWidth width in pixels
* node:nParent - parent to get the with for (required for * @private
* relative widths) - optional
*/ */
function _fnConvertToWidth ( sWidth, nParent ) function _fnConvertToWidth ( sWidth, nParent )
{ {
@ -4137,11 +4089,11 @@
return ( iWidth ); return ( iWidth );
} }
/*
* Function: _fnCalculateColumnWidths /**
* Purpose: Calculate the width of columns for the table * Calculate the width of columns for the table
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnCalculateColumnWidths ( oSettings ) function _fnCalculateColumnWidths ( oSettings )
{ {
@ -4352,12 +4304,12 @@
} }
} }
/*
* Function: _fnScrollingWidthAdjust /**
* Purpose: Adjust a table's width to take account of scrolling * Adjust a table's width to take account of scrolling
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {node} n table node
* node:n - table node * @private
*/ */
function _fnScrollingWidthAdjust ( oSettings, n ) function _fnScrollingWidthAdjust ( oSettings, n )
{ {
@ -4376,12 +4328,13 @@
} }
} }
/*
* Function: _fnGetWidestNode /**
* Purpose: Get the widest node * Get the widest node
* Returns: string: - max strlens for each column * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iCol column of interest
* int:iCol - column of interest * @returns {string} max strlens for each column
* @private
*/ */
function _fnGetWidestNode( oSettings, iCol ) function _fnGetWidestNode( oSettings, iCol )
{ {
@ -4400,12 +4353,13 @@
return _fnGetTdNodes(oSettings, iMaxIndex)[iCol]; return _fnGetTdNodes(oSettings, iMaxIndex)[iCol];
} }
/*
* Function: _fnGetMaxLenString /**
* Purpose: Get the maximum strlen for each data column * Get the maximum strlen for each data column
* Returns: string: - max strlens for each column * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iCol column of interest
* int:iCol - column of interest * @returns {string} max strlens for each column
* @private
*/ */
function _fnGetMaxLenString( oSettings, iCol ) function _fnGetMaxLenString( oSettings, iCol )
{ {
@ -4426,12 +4380,13 @@
return iMaxIndex; return iMaxIndex;
} }
/*
* Function: _fnStringToCss /**
* Purpose: Append a CSS unit (only if required) to a string * Append a CSS unit (only if required) to a string
* Returns: 0 if match, 1 if length is different, 2 if no match * @param {array} aArray1 first array
* Inputs: array:aArray1 - first array * @param {array} aArray2 second array
* array:aArray2 - second array * @returns {int} 0 if match, 1 if length is different, 2 if no match
* @private
*/ */
function _fnStringToCss( s ) function _fnStringToCss( s )
{ {
@ -4459,14 +4414,10 @@
} }
/**
/* * Get the width of a scroll bar in this browser being used
* Function: _fnScrollBarWidth * @returns {int} width in pixels
* Purpose: Get the width of a scroll bar in this browser being used * @private
* Returns: int: - width in pixels
* Inputs: -
* Notes: All credit for this function belongs to Alexandre Gomes. Thanks for sharing!
* http://www.alexandre-gomes.com/?p=115
*/ */
function _fnScrollBarWidth () function _fnScrollBarWidth ()
{ {
@ -4502,20 +4453,12 @@
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Sorting
*/
/* /**
* Function: _fnSort * Change the order of the table
* Purpose: Change the order of the table * @param {object} oSettings dataTables settings object
* Returns: - * @param {bool} bApplyClasses optional - should we apply classes or not
* Inputs: object:oSettings - dataTables settings object * @private
* bool:bApplyClasses - optional - should we apply classes or not
* Notes: We always sort the master array and then apply a filter again
* if it is needed. This probably isn't optimal - but atm I can't think
* of any other way which is (each has disadvantages). we want to sort aiDisplayMaster -
* but according to aoData[]._aData
*/ */
function _fnSort ( oSettings, bApplyClasses ) function _fnSort ( oSettings, bApplyClasses )
{ {
@ -4658,14 +4601,14 @@
} }
} }
/*
* Function: _fnSortAttachListener /**
* Purpose: Attach a sort handler (click) to a node * Attach a sort handler (click) to a node
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {node} nNode node to attach the handler to
* node:nNode - node to attach the handler to * @param {int} iDataIndex column sorting index
* int:iDataIndex - column sorting index * @param {function} [fnCallback] callback function
* function:fnCallback - callback function - optional * @private
*/ */
function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback ) function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback )
{ {
@ -4777,12 +4720,12 @@
} ); } );
} }
/*
* Function: _fnSortingClasses /**
* Purpose: Set the sortting classes on the header * Set the sorting classes on the header, Note: it is safe to call this function
* Returns: - * when bSort and bSortClasses are false
* Inputs: object:oSettings - dataTables settings object * @param {object} oSettings dataTables settings object
* Notes: It is safe to call this function when bSort and bSortClasses are false * @private
*/ */
function _fnSortingClasses( oSettings ) function _fnSortingClasses( oSettings )
{ {
@ -4933,11 +4876,11 @@
} }
/*
* Function: _fnSaveState /**
* Purpose: Save the state of a table in a cookie such that the page can be reloaded * Save the state of a table in a cookie such that the page can be reloaded
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnSaveState ( oSettings ) function _fnSaveState ( oSettings )
{ {
@ -4997,12 +4940,12 @@
oSettings.iCookieDuration, oSettings.sCookiePrefix, oSettings.fnCookieCallback ); oSettings.iCookieDuration, oSettings.sCookiePrefix, oSettings.fnCookieCallback );
} }
/*
* Function: _fnLoadState /**
* Purpose: Attempt to load a saved table state from a cookie * Attempt to load a saved table state from a cookie
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} oInit DataTables init object so we can override settings
* object:oInit - DataTables init object so we can override settings * @private
*/ */
function _fnLoadState ( oSettings, oInit ) function _fnLoadState ( oSettings, oInit )
{ {
@ -5089,15 +5032,15 @@
} }
} }
/*
* Function: _fnCreateCookie /**
* Purpose: Create a new cookie with a value to store the state of a table * Create a new cookie with a value to store the state of a table
* Returns: - * @param {string} sName name of the cookie to create
* Inputs: string:sName - name of the cookie to create * @param {string} sValue the value the cookie should take
* string:sValue - the value the cookie should take * @param {int} iSecs duration of the cookie
* int:iSecs - duration of the cookie * @param {string} sBaseName sName is made up of the base + file name - this is the base
* string:sBaseName - sName is made up of the base + file name - this is the base * @param {function} fnCallback User definable function to modify the cookie
* function:fnCallback - User definable function to modify the cookie * @private
*/ */
function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback ) function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback )
{ {
@ -5164,11 +5107,12 @@
document.cookie = sFullCookie; document.cookie = sFullCookie;
} }
/*
* Function: _fnReadCookie /**
* Purpose: Read an old cookie to get a cookie with an old table state * Read an old cookie to get a cookie with an old table state
* Returns: string: - contents of the cookie - or null if no cookie with that name found * @param {string} sName name of the cookie to read
* Inputs: string:sName - name of the cookie to read * @returns {string} contents of the cookie - or null if no cookie with that name found
* @private
*/ */
function _fnReadCookie ( sName ) function _fnReadCookie ( sName )
{ {
@ -5195,12 +5139,13 @@
} }
/*
* Function: _fnArrayCmp /**
* Purpose: Compare two arrays * Compare two arrays
* Returns: 0 if match, 1 if length is different, 2 if no match * @param {array} aArray1 first array
* Inputs: array:aArray1 - first array * @param {array} aArray2 second array
* array:aArray2 - second array * @returns {int} 0 if match, 1 if length is different, 2 if no match
* @private
*/ */
function _fnArrayCmp( aArray1, aArray2 ) function _fnArrayCmp( aArray1, aArray2 )
{ {
@ -5220,11 +5165,12 @@
return 0; return 0;
} }
/*
* Function: _fnSettingsFromNode /**
* Purpose: Return the settings object for a particular table * Return the settings object for a particular table
* Returns: object: Settings object - or null if not found * @param {node} nTable table we are using as a dataTable
* Inputs: node:nTable - table we are using as a dataTable * @returns {object} Settings object - or null if not found
* @private
*/ */
function _fnSettingsFromNode ( nTable ) function _fnSettingsFromNode ( nTable )
{ {
@ -5239,11 +5185,12 @@
return null; return null;
} }
/*
* Function: _fnGetTrNodes /**
* Purpose: Return an array with the TR nodes for the table * Return an array with the TR nodes for the table
* Returns: array: - TR array * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {array} TR array
* @private
*/ */
function _fnGetTrNodes ( oSettings ) function _fnGetTrNodes ( oSettings )
{ {
@ -5258,13 +5205,14 @@
return aNodes; return aNodes;
} }
/*
* Function: _fnGetTdNodes /**
* Purpose: Return an flat array with all TD nodes for the table, or row * Return an flat array with all TD nodes for the table, or row
* Returns: array: - TD array * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} [iIndividualRow] aoData index to get the nodes for - optional
* int:iIndividualRow - aoData index to get the nodes for - optional if not * if not given then the return array will contain all nodes for the table
* given then the return array will contain all nodes for the table * @returns {array} TD array
* @private
*/ */
function _fnGetTdNodes ( oSettings, iIndividualRow ) function _fnGetTdNodes ( oSettings, iIndividualRow )
{ {
@ -5316,12 +5264,12 @@
return anReturn; return anReturn;
} }
/*
* Function: _fnLog /**
* Purpose: Log an error message * Log an error message
* Returns: - * @param {int} iLevel log error messages, or display them to the user
* Inputs: int:iLevel - log error messages, or display them to the user * @param {string} sMesg error message
* string:sMesg - error message * @private
*/ */
function _fnLog( oSettings, iLevel, sMesg ) function _fnLog( oSettings, iLevel, sMesg )
{ {
@ -5347,14 +5295,14 @@
} }
} }
/*
* Function: _fnMap /**
* Purpose: See if a property is defined on one object, if so assign it to the other object * See if a property is defined on one object, if so assign it to the other object
* Returns: - (done by reference) * @param {object} oRet target object
* Inputs: object:oRet - target object * @param {object} oSrc source object
* object:oSrc - source object * @param {string} sName property
* string:sName - property * @param {string} [sMappedName] name to map too - optional, sName used if not given
* string:sMappedName - name to map too - optional, sName used if not given * @private
*/ */
function _fnMap( oRet, oSrc, sName, sMappedName ) function _fnMap( oRet, oSrc, sName, sMappedName )
{ {
@ -5367,6 +5315,7 @@
oRet[sMappedName] = oSrc[sName]; oRet[sMappedName] = oSrc[sName];
} }
} }
/* /*
@ -5381,12 +5330,9 @@
* Section - API functions * Section - API functions
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* /**
* Function: fnDraw * Redraw the table
* Purpose: Redraw the table * @param {bool} [bComplete=true] Refilter and resort (if enabled) the table before the draw.
* Returns: -
* Inputs: bool:bComplete - Refilter and resort (if enabled) the table before the draw.
* Optional: default - true
*/ */
this.fnDraw = function( bComplete ) this.fnDraw = function( bComplete )
{ {
@ -5402,16 +5348,13 @@
} }
}; };
/* /**
* Function: fnFilter * Filter the input based on data
* Purpose: Filter the input based on data * @param {string} sInput string to filter the table on
* Returns: - * @param {int|null} [iColumn] column to limit filtering to
* Inputs: string:sInput - string to filter the table on * @param {bool} [bRegex=false] treat as regular expression or not
* int:iColumn - optional - column to limit filtering to * @param {bool} [bSmart=true] perform smart filtering or not
* bool:bRegex - optional - treat as regular expression or not - default false * @param {bool} [bShowGlobal=true] show the input global filter in it's input box(es)
* bool:bSmart - optional - perform smart filtering or not - default true
* bool:bShowGlobal - optional - show the input global filter in it's input box(es)
* - default true
*/ */
this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal ) this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal )
{ {
@ -5465,29 +5408,23 @@
} }
}; };
/* /**
* Function: fnSettings * Get the settings for a particular table for external manipulation
* Purpose: Get the settings for a particular table for extern. manipulation * @returns {object} DataTables settings object. See
* Returns: - * {@link DataTable.models.oSettings}
* Inputs: -
*/ */
this.fnSettings = function( nNode ) this.fnSettings = function()
{ {
return _fnSettingsFromNode( this[_oExt.iApiIndex] ); return _fnSettingsFromNode( this[_oExt.iApiIndex] );
}; };
/*
* Function: fnVersionCheck // xxx
* Notes: The function is the same as the 'static' function provided in the ext variable
*/
this.fnVersionCheck = _oExt.fnVersionCheck; this.fnVersionCheck = _oExt.fnVersionCheck;
/* /**
* Function: fnSort * Sort the table by a particular row
* Purpose: Sort the table by a particular row * @param {int} iCol the data index to sort on. Note that this will not match the 'display index' if you have hidden data entries
* Returns: -
* Inputs: int:iCol - the data index to sort on. Note that this will
* not match the 'display index' if you have hidden data entries
*/ */
this.fnSort = function( aaSort ) this.fnSort = function( aaSort )
{ {
@ -5496,13 +5433,11 @@
_fnSort( oSettings ); _fnSort( oSettings );
}; };
/* /**
* Function: fnSortListener * Attach a sort listener to an element for a given column
* Purpose: Attach a sort listener to an element for a given column * @param {node} nNode the element to attach the sort listener to
* Returns: - * @param {int} iColumn the column that a click on this node will sort on
* Inputs: node:nNode - the element to attach the sort listener to * @param {function} [fnCallback] callback function when sort is run
* int:iColumn - the column that a click on this node will sort on
* function:fnCallback - callback function when sort is run - optional
*/ */
this.fnSortListener = function( nNode, iColumn, fnCallback ) this.fnSortListener = function( nNode, iColumn, fnCallback )
{ {
@ -5510,18 +5445,23 @@
fnCallback ); fnCallback );
}; };
/*
* Function: fnAddData /**
* Purpose: Add new row(s) into the table * Add a single new row or multiple rows of data to the table. Please note
* Returns: array int: array of indexes (aoData) which have been added (zero length on error) * that this is suitable for client-side processing only - if you are using
* Inputs: array:mData - the data to be added. The length must match * server-side processing (i.e. "bServerSide": true), then to add data, you
* the original data from the DOM * must add it to the data source, i.e. the server-side, through an Ajax call.
* or * @param {array|object} mData The data to be added to the table. This can be:
* array array:mData - 2D array of data to be added * <ul>
* bool:bRedraw - redraw the table or not - default true * <li>1D array of data - add a single row with the data provided</li>
* Notes: Warning - the refilter here will cause the table to redraw * <li>2D array of arrays - add multiple rows in a single call</li>
* starting at zero * <li>object - data object when using <i>mDataProp</i></li>
* Notes: Thanks to Yekimov Denis for contributing the basis for this function! * <li>array of objects - multiple data objects when using <i>mDataProp</i></li>
* </ul>
* @param {bool} [bRedraw=true] redraw the table or not
* @returns {array} An array of integers, representing the list of indexes in
* <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
* the table.
*/ */
this.fnAddData = function( mData, bRedraw ) this.fnAddData = function( mData, bRedraw )
{ {
@ -5568,15 +5508,14 @@
return aiReturn; return aiReturn;
}; };
/*
* Function: fnDeleteRow /**
* Purpose: Remove a row for the table * Remove a row for the table
* Returns: array:aReturn - the row that was deleted * @param {mixed} mTarget The index of the row from aoData to be deleted, or
* Inputs: mixed:mTarget - * the TR element you want to delete
* int: - index of aoData to be deleted, or * @param {function|null} [fnCallBack] Callback function
* node(TR): - TR element you want to delete * @param {bool} [bRedraw=true] Redraw the table or not
* function:fnCallBack - callback function - default null * @returns {array} The row that was deleted
* bool:bRedraw - redraw the table or not - default true
*/ */
this.fnDeleteRow = function( mTarget, fnCallBack, bRedraw ) this.fnDeleteRow = function( mTarget, fnCallBack, bRedraw )
{ {
@ -5623,12 +5562,9 @@
return oData; return oData;
}; };
/* /**
* Function: fnClearTable * Quickly and simply clear a table
* Purpose: Quickly and simply clear a table * @param {bool} [bRedraw=true] redraw the table or not
* Returns: -
* Inputs: bool:bRedraw - redraw the table or not - default true
* Notes: Thanks to Yekimov Denis for contributing the basis for this function!
*/ */
this.fnClearTable = function( bRedraw ) this.fnClearTable = function( bRedraw )
{ {
@ -5642,13 +5578,15 @@
} }
}; };
/* /**
* Function: fnOpen * This function will place a new row directly after a row which is currently
* Purpose: Open a display row (append a row after the row in question) * on display on the page, with the HTML contents that is passed into the
* Returns: node:nNewRow - the row opened * function. This can be used, for example, to ask for confirmation that a
* Inputs: node:nTr - the table row to 'open' * particular record should be deleted.
* string|node|jQuery:mHtml - the HTML to put into the row * @param {node} nTr The table row to 'open'
* string:sClass - class to give the new TD cell * @param {string|node|jQuery} mHtml The HTML to put into the row
* @param {string} sClass Class to give the new TD cell
* @returns {node} The row opened
*/ */
this.fnOpen = function( nTr, mHtml, sClass ) this.fnOpen = function( nTr, mHtml, sClass )
{ {
@ -5688,11 +5626,11 @@
return nNewRow; return nNewRow;
}; };
/* /**
* Function: fnClose * The exact opposite of 'opening' a row, this function will close any rows which
* Purpose: Close a display row * are currently 'open'.
* Returns: int: 0 (success) or 1 (failed) * @param {node} nTr the table row to 'close'
* Inputs: node:nTr - the table row to 'close' * @returns {int} 0 on success, or 1 if failed (can't find the row)
*/ */
this.fnClose = function( nTr ) this.fnClose = function( nTr )
{ {
@ -5716,17 +5654,15 @@
return 1; return 1;
}; };
/* /**
* Function: fnGetData * Return an array with the data which is used to make up the table
* Purpose: Return an array with the data which is used to make up the table * or string if both row and column are given
* Returns: array array string: 2d data array ([row][column]) or array string: 1d data array * @param {mixed} [mRow] The TR row element to get the data for, or the aoData
* or string if both row and column are given * internal index (mapped to the TR element)
* Inputs: mixed:mRow - optional - if not present, then the full 2D array for the table * @param {int} [iCol] Optional column index that you want the data of
* if given then: * @returns {array|string} If mRow is undefined, then the data for all rows is
* int: - return data object for aoData entry of this index * returned. If mRow is defined, just data for that row, and is iCol is
* node(TR): - return data object for this TR element * defined, only data for the designated cell is returned.
* int:iCol - optional - the column that you want the data of. This will take into
* account mDataProp and return the value DataTables uses for this column
*/ */
this.fnGetData = function( mRow, iCol ) this.fnGetData = function( mRow, iCol )
{ {
@ -5747,14 +5683,11 @@
return _fnGetDataMaster( oSettings ); return _fnGetDataMaster( oSettings );
}; };
/* /**
* Function: fnGetNodes * The the TR nodes that are used in the table's body
* Purpose: Return an array with the TR nodes used for drawing the table * @param {int} [iRow] Optional row index for the TR element you want
* Returns: array node: TR elements * @returns {array|node} If iRow is undefined, returns an array of all TR elements
* or * in the table's body, or iRow is defined, just the TR element requested.
* node (if iRow specified)
* Inputs: int:iRow - optional - if present then the array returned will be the node for
* the row with the index 'iRow'
*/ */
this.fnGetNodes = function( iRow ) this.fnGetNodes = function( iRow )
{ {
@ -5767,13 +5700,12 @@
return _fnGetTrNodes( oSettings ); return _fnGetTrNodes( oSettings );
}; };
/* /**
* Function: fnGetPosition * Get the array indexes of a particular cell from it's DOM element
* Purpose: Get the array indexes of a particular cell from it's DOM element * and column index including hidden columns
* Returns: int: - row index, or array[ int, int, int ]: - row index, column index (visible) * @param {node} nNode this can either be a TR, TD or TH in the table's body
* and column index including hidden columns * @returns {int} If nNode is given as a TR, then a single index is returned, or
* Inputs: node:nNode - this can either be a TR, TD or TH in the table's body, the return is * if given as a cell, an array of [row index, column index (visible)] is given.
* dependent on this input
*/ */
this.fnGetPosition = function( nNode ) this.fnGetPosition = function( nNode )
{ {
@ -5800,21 +5732,18 @@
return null; return null;
}; };
/*
* Function: fnUpdate /**
* Purpose: Update a table cell or row - this method will accept either a single value to * Update a table cell or row - this method will accept either a single value to
* update the cell with, an array of values with one element for each column or * update the cell with, an array of values with one element for each column or
* an object in the same format as the original data source. The function is * an object in the same format as the original data source. The function is
* self-referencing in order to make the multi column updates easier. * self-referencing in order to make the multi column updates easier.
* Returns: int: 0 okay, 1 error * @param {object|array|string} mData Data to update the cell/row with
* Inputs: object | array string | string:mData - data to update the cell/row with * @param {node|int} mRow TR element you want to update or the aoData index
* mixed:mRow - * @param {int} [iColumn] The column to update (not used of mData is an array or object)
* int: - index of aoData to be updated, or * @param {bool} [bRedraw=true] Redraw the table or not
* node(TR): - TR element you want to update * @param {bool} [bAction=true] Perform predraw actions or not
* int:iColumn - the column to update - optional (not used of mData is an array or object) * @returns {int} 0 on success, 1 on error
* bool:bRedraw - redraw the table or not - default true
* bool:bAction - perform predraw actions or not (you will want this as 'true' if
* you have bRedraw as true) - default true
*/ */
this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction ) this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
{ {
@ -5898,13 +5827,11 @@
}; };
/* /**
* Function: fnSetColumnVis * Show a particular column
* Purpose: Show a particular column * @param {int} iCol The column whose display should be changed
* Returns: - * @param {bool} bShow Show (true) or hide (false) the column
* Inputs: int:iCol - the column whose display should be changed * @param {bool} [bRedraw=true] Redraw the table or not
* bool:bShow - show (true) or hide (false) the column
* bool:bRedraw - redraw the table or not - default true
*/ */
this.fnSetColumnVis = function ( iCol, bShow, bRedraw ) this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
{ {
@ -6008,12 +5935,13 @@
_fnSaveState( oSettings ); _fnSaveState( oSettings );
}; };
/*
* Function: fnPageChange /**
* Purpose: Change the pagination * Change the pagination - provides the internal logic for pagination in a simple API
* Returns: - * function. With this function you can have a DataTables table go to the next,
* Inputs: string:sAction - paging action to take: "first", "previous", "next" or "last" * previous, first or last pages.
* bool:bRedraw - redraw the table or not - optional - default true * @param {string} sAction Paging action to take: "first", "previous", "next" or "last"
* @param {bool} [bRedraw=true] Redraw the table or not
*/ */
this.fnPageChange = function ( sAction, bRedraw ) this.fnPageChange = function ( sAction, bRedraw )
{ {
@ -6027,11 +5955,9 @@
} }
}; };
/* /**
* Function: fnDestroy * Restore the table to it's original state in the DOM by removing all of DataTables
* Purpose: Destructor for the DataTable * enhancements, alterations to the DOM structure of the table and event listeners.
* Returns: -
* Inputs: -
*/ */
this.fnDestroy = function ( ) this.fnDestroy = function ( )
{ {
@ -6156,12 +6082,12 @@
oSettings = null; oSettings = null;
}; };
/* /**
* Function: fnAdjustColumnSizing * This function will make DataTables recalculate the column sizes, based on the data
* Purpose: Update table sizing based on content. This would most likely be used for scrolling * contained in the table and the sizes applied to the columns (in the DOM, CSS or
* and will typically need a redraw after it. * through the sWidth parameter). This can be useful when the width of the table's
* Returns: - * parent element changes (for example a window resize).
* Inputs: bool:bRedraw - redraw the table or not, you will typically want to - default true * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
*/ */
this.fnAdjustColumnSizing = function ( bRedraw ) this.fnAdjustColumnSizing = function ( bRedraw )
{ {
@ -6179,12 +6105,11 @@
} }
}; };
/* /**
* Function: $ * Perform a jQuery selector action on the table's TR elements (from the tbody) and
* Purpose: Do a jQuery selector action on the table's TR elements (from the tbody) and * return the resulting expression
* return the resulting expression * @param {string} sSelector jQuery selector
* Returns: jQuery object * @returns {object} jQuery object
* Inputs: string:sSelector - jQuery selector
*/ */
this.$ = function ( sSelector ) this.$ = function ( sSelector )
{ {
@ -6194,49 +6119,10 @@
}; };
/*
* Plugin API functions
*
* This call will add the functions which are defined in _oExt.oApi to the
* DataTables object, providing a rather nice way to allow plug-in API functions. Note that
* this is done here, so that API function can actually override the built in API functions if
* required for a particular purpose.
*/
/* /*
* Function: _fnExternApiFunc * This is really a good bit rubbish... - To be fixed in 2.0
* Purpose: Create a wrapper function for exporting an internal func to an external API func
* Returns: function: - wrapped function
* Inputs: string:sFunc - API function name
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[_oExt.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return _oExt.oApi[sFunc].apply( this, aArgs );
};
}
for ( var sFunc in _oExt.oApi )
{
if ( sFunc )
{
/*
* Function: anon
* Purpose: Wrap the plug-in API functions in order to provide the settings as 1st arg
* and execute in this scope
* Returns: -
* Inputs: -
*/
this[sFunc] = _fnExternApiFunc(sFunc);
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - API
* I'm not happy with this solution... - To be fixed in 2.0
*/ */
this.oApi._fnExternApiFunc = _fnExternApiFunc; this.oApi._fnExternApiFunc = _fnExternApiFunc;
this.oApi._fnInitialise = _fnInitialise; this.oApi._fnInitialise = _fnInitialise;
@ -6316,6 +6202,30 @@
this.oApi._fnGetObjectDataFn = _fnGetObjectDataFn; this.oApi._fnGetObjectDataFn = _fnGetObjectDataFn;
this.oApi._fnSetObjectDataFn = _fnSetObjectDataFn; this.oApi._fnSetObjectDataFn = _fnSetObjectDataFn;
/**
* Create a wrapper function for exporting an internal functions to an external API.
* @param {string} sFunc API function name
* @returns {function} wrapped function
* @private
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[_oExt.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return _oExt.oApi[sFunc].apply( this, aArgs );
};
}
for ( var sFunc in _oExt.oApi )
{
if ( sFunc )
{
this[sFunc] = _fnExternApiFunc(sFunc);
}
}
var _that = this; var _that = this;
return this.each(function() { return this.each(function() {

View File

@ -1,8 +1,7 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*
* Section - API * This is really a good bit rubbish... - To be fixed in 2.0
* I'm not happy with this solution... - To be fixed in 2.0
*/ */
this.oApi._fnExternApiFunc = _fnExternApiFunc; this.oApi._fnExternApiFunc = _fnExternApiFunc;
this.oApi._fnInitialise = _fnInitialise; this.oApi._fnInitialise = _fnInitialise;
@ -81,3 +80,27 @@ this.oApi._fnGetCellData = _fnGetCellData;
this.oApi._fnSetCellData = _fnSetCellData; this.oApi._fnSetCellData = _fnSetCellData;
this.oApi._fnGetObjectDataFn = _fnGetObjectDataFn; this.oApi._fnGetObjectDataFn = _fnGetObjectDataFn;
this.oApi._fnSetObjectDataFn = _fnSetObjectDataFn; this.oApi._fnSetObjectDataFn = _fnSetObjectDataFn;
/**
* Create a wrapper function for exporting an internal functions to an external API.
* @param {string} sFunc API function name
* @returns {function} wrapped function
* @private
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[_oExt.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return _oExt.oApi[sFunc].apply( this, aArgs );
};
}
for ( var sFunc in _oExt.oApi )
{
if ( sFunc )
{
this[sFunc] = _fnExternApiFunc(sFunc);
}
}

View File

@ -11,12 +11,9 @@ this.oApi = {};
* Section - API functions * Section - API functions
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* /**
* Function: fnDraw * Redraw the table
* Purpose: Redraw the table * @param {bool} [bComplete=true] Refilter and resort (if enabled) the table before the draw.
* Returns: -
* Inputs: bool:bComplete - Refilter and resort (if enabled) the table before the draw.
* Optional: default - true
*/ */
this.fnDraw = function( bComplete ) this.fnDraw = function( bComplete )
{ {
@ -32,16 +29,13 @@ this.fnDraw = function( bComplete )
} }
}; };
/* /**
* Function: fnFilter * Filter the input based on data
* Purpose: Filter the input based on data * @param {string} sInput string to filter the table on
* Returns: - * @param {int|null} [iColumn] column to limit filtering to
* Inputs: string:sInput - string to filter the table on * @param {bool} [bRegex=false] treat as regular expression or not
* int:iColumn - optional - column to limit filtering to * @param {bool} [bSmart=true] perform smart filtering or not
* bool:bRegex - optional - treat as regular expression or not - default false * @param {bool} [bShowGlobal=true] show the input global filter in it's input box(es)
* bool:bSmart - optional - perform smart filtering or not - default true
* bool:bShowGlobal - optional - show the input global filter in it's input box(es)
* - default true
*/ */
this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal ) this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal )
{ {
@ -95,29 +89,23 @@ this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal )
} }
}; };
/* /**
* Function: fnSettings * Get the settings for a particular table for external manipulation
* Purpose: Get the settings for a particular table for extern. manipulation * @returns {object} DataTables settings object. See
* Returns: - * {@link DataTable.models.oSettings}
* Inputs: -
*/ */
this.fnSettings = function( nNode ) this.fnSettings = function()
{ {
return _fnSettingsFromNode( this[_oExt.iApiIndex] ); return _fnSettingsFromNode( this[_oExt.iApiIndex] );
}; };
/*
* Function: fnVersionCheck // xxx
* Notes: The function is the same as the 'static' function provided in the ext variable
*/
this.fnVersionCheck = _oExt.fnVersionCheck; this.fnVersionCheck = _oExt.fnVersionCheck;
/* /**
* Function: fnSort * Sort the table by a particular row
* Purpose: Sort the table by a particular row * @param {int} iCol the data index to sort on. Note that this will not match the 'display index' if you have hidden data entries
* Returns: -
* Inputs: int:iCol - the data index to sort on. Note that this will
* not match the 'display index' if you have hidden data entries
*/ */
this.fnSort = function( aaSort ) this.fnSort = function( aaSort )
{ {
@ -126,13 +114,11 @@ this.fnSort = function( aaSort )
_fnSort( oSettings ); _fnSort( oSettings );
}; };
/* /**
* Function: fnSortListener * Attach a sort listener to an element for a given column
* Purpose: Attach a sort listener to an element for a given column * @param {node} nNode the element to attach the sort listener to
* Returns: - * @param {int} iColumn the column that a click on this node will sort on
* Inputs: node:nNode - the element to attach the sort listener to * @param {function} [fnCallback] callback function when sort is run
* int:iColumn - the column that a click on this node will sort on
* function:fnCallback - callback function when sort is run - optional
*/ */
this.fnSortListener = function( nNode, iColumn, fnCallback ) this.fnSortListener = function( nNode, iColumn, fnCallback )
{ {
@ -140,18 +126,23 @@ this.fnSortListener = function( nNode, iColumn, fnCallback )
fnCallback ); fnCallback );
}; };
/*
* Function: fnAddData /**
* Purpose: Add new row(s) into the table * Add a single new row or multiple rows of data to the table. Please note
* Returns: array int: array of indexes (aoData) which have been added (zero length on error) * that this is suitable for client-side processing only - if you are using
* Inputs: array:mData - the data to be added. The length must match * server-side processing (i.e. "bServerSide": true), then to add data, you
* the original data from the DOM * must add it to the data source, i.e. the server-side, through an Ajax call.
* or * @param {array|object} mData The data to be added to the table. This can be:
* array array:mData - 2D array of data to be added * <ul>
* bool:bRedraw - redraw the table or not - default true * <li>1D array of data - add a single row with the data provided</li>
* Notes: Warning - the refilter here will cause the table to redraw * <li>2D array of arrays - add multiple rows in a single call</li>
* starting at zero * <li>object - data object when using <i>mDataProp</i></li>
* Notes: Thanks to Yekimov Denis for contributing the basis for this function! * <li>array of objects - multiple data objects when using <i>mDataProp</i></li>
* </ul>
* @param {bool} [bRedraw=true] redraw the table or not
* @returns {array} An array of integers, representing the list of indexes in
* <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
* the table.
*/ */
this.fnAddData = function( mData, bRedraw ) this.fnAddData = function( mData, bRedraw )
{ {
@ -198,15 +189,14 @@ this.fnAddData = function( mData, bRedraw )
return aiReturn; return aiReturn;
}; };
/*
* Function: fnDeleteRow /**
* Purpose: Remove a row for the table * Remove a row for the table
* Returns: array:aReturn - the row that was deleted * @param {mixed} mTarget The index of the row from aoData to be deleted, or
* Inputs: mixed:mTarget - * the TR element you want to delete
* int: - index of aoData to be deleted, or * @param {function|null} [fnCallBack] Callback function
* node(TR): - TR element you want to delete * @param {bool} [bRedraw=true] Redraw the table or not
* function:fnCallBack - callback function - default null * @returns {array} The row that was deleted
* bool:bRedraw - redraw the table or not - default true
*/ */
this.fnDeleteRow = function( mTarget, fnCallBack, bRedraw ) this.fnDeleteRow = function( mTarget, fnCallBack, bRedraw )
{ {
@ -253,12 +243,9 @@ this.fnDeleteRow = function( mTarget, fnCallBack, bRedraw )
return oData; return oData;
}; };
/* /**
* Function: fnClearTable * Quickly and simply clear a table
* Purpose: Quickly and simply clear a table * @param {bool} [bRedraw=true] redraw the table or not
* Returns: -
* Inputs: bool:bRedraw - redraw the table or not - default true
* Notes: Thanks to Yekimov Denis for contributing the basis for this function!
*/ */
this.fnClearTable = function( bRedraw ) this.fnClearTable = function( bRedraw )
{ {
@ -272,13 +259,15 @@ this.fnClearTable = function( bRedraw )
} }
}; };
/* /**
* Function: fnOpen * This function will place a new row directly after a row which is currently
* Purpose: Open a display row (append a row after the row in question) * on display on the page, with the HTML contents that is passed into the
* Returns: node:nNewRow - the row opened * function. This can be used, for example, to ask for confirmation that a
* Inputs: node:nTr - the table row to 'open' * particular record should be deleted.
* string|node|jQuery:mHtml - the HTML to put into the row * @param {node} nTr The table row to 'open'
* string:sClass - class to give the new TD cell * @param {string|node|jQuery} mHtml The HTML to put into the row
* @param {string} sClass Class to give the new TD cell
* @returns {node} The row opened
*/ */
this.fnOpen = function( nTr, mHtml, sClass ) this.fnOpen = function( nTr, mHtml, sClass )
{ {
@ -318,11 +307,11 @@ this.fnOpen = function( nTr, mHtml, sClass )
return nNewRow; return nNewRow;
}; };
/* /**
* Function: fnClose * The exact opposite of 'opening' a row, this function will close any rows which
* Purpose: Close a display row * are currently 'open'.
* Returns: int: 0 (success) or 1 (failed) * @param {node} nTr the table row to 'close'
* Inputs: node:nTr - the table row to 'close' * @returns {int} 0 on success, or 1 if failed (can't find the row)
*/ */
this.fnClose = function( nTr ) this.fnClose = function( nTr )
{ {
@ -346,17 +335,15 @@ this.fnClose = function( nTr )
return 1; return 1;
}; };
/* /**
* Function: fnGetData * Return an array with the data which is used to make up the table
* Purpose: Return an array with the data which is used to make up the table * or string if both row and column are given
* Returns: array array string: 2d data array ([row][column]) or array string: 1d data array * @param {mixed} [mRow] The TR row element to get the data for, or the aoData
* or string if both row and column are given * internal index (mapped to the TR element)
* Inputs: mixed:mRow - optional - if not present, then the full 2D array for the table * @param {int} [iCol] Optional column index that you want the data of
* if given then: * @returns {array|string} If mRow is undefined, then the data for all rows is
* int: - return data object for aoData entry of this index * returned. If mRow is defined, just data for that row, and is iCol is
* node(TR): - return data object for this TR element * defined, only data for the designated cell is returned.
* int:iCol - optional - the column that you want the data of. This will take into
* account mDataProp and return the value DataTables uses for this column
*/ */
this.fnGetData = function( mRow, iCol ) this.fnGetData = function( mRow, iCol )
{ {
@ -377,14 +364,11 @@ this.fnGetData = function( mRow, iCol )
return _fnGetDataMaster( oSettings ); return _fnGetDataMaster( oSettings );
}; };
/* /**
* Function: fnGetNodes * The the TR nodes that are used in the table's body
* Purpose: Return an array with the TR nodes used for drawing the table * @param {int} [iRow] Optional row index for the TR element you want
* Returns: array node: TR elements * @returns {array|node} If iRow is undefined, returns an array of all TR elements
* or * in the table's body, or iRow is defined, just the TR element requested.
* node (if iRow specified)
* Inputs: int:iRow - optional - if present then the array returned will be the node for
* the row with the index 'iRow'
*/ */
this.fnGetNodes = function( iRow ) this.fnGetNodes = function( iRow )
{ {
@ -397,13 +381,12 @@ this.fnGetNodes = function( iRow )
return _fnGetTrNodes( oSettings ); return _fnGetTrNodes( oSettings );
}; };
/* /**
* Function: fnGetPosition * Get the array indexes of a particular cell from it's DOM element
* Purpose: Get the array indexes of a particular cell from it's DOM element * and column index including hidden columns
* Returns: int: - row index, or array[ int, int, int ]: - row index, column index (visible) * @param {node} nNode this can either be a TR, TD or TH in the table's body
* and column index including hidden columns * @returns {int} If nNode is given as a TR, then a single index is returned, or
* Inputs: node:nNode - this can either be a TR, TD or TH in the table's body, the return is * if given as a cell, an array of [row index, column index (visible)] is given.
* dependent on this input
*/ */
this.fnGetPosition = function( nNode ) this.fnGetPosition = function( nNode )
{ {
@ -430,21 +413,18 @@ this.fnGetPosition = function( nNode )
return null; return null;
}; };
/*
* Function: fnUpdate /**
* Purpose: Update a table cell or row - this method will accept either a single value to * Update a table cell or row - this method will accept either a single value to
* update the cell with, an array of values with one element for each column or * update the cell with, an array of values with one element for each column or
* an object in the same format as the original data source. The function is * an object in the same format as the original data source. The function is
* self-referencing in order to make the multi column updates easier. * self-referencing in order to make the multi column updates easier.
* Returns: int: 0 okay, 1 error * @param {object|array|string} mData Data to update the cell/row with
* Inputs: object | array string | string:mData - data to update the cell/row with * @param {node|int} mRow TR element you want to update or the aoData index
* mixed:mRow - * @param {int} [iColumn] The column to update (not used of mData is an array or object)
* int: - index of aoData to be updated, or * @param {bool} [bRedraw=true] Redraw the table or not
* node(TR): - TR element you want to update * @param {bool} [bAction=true] Perform predraw actions or not
* int:iColumn - the column to update - optional (not used of mData is an array or object) * @returns {int} 0 on success, 1 on error
* bool:bRedraw - redraw the table or not - default true
* bool:bAction - perform predraw actions or not (you will want this as 'true' if
* you have bRedraw as true) - default true
*/ */
this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction ) this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
{ {
@ -528,13 +508,11 @@ this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
}; };
/* /**
* Function: fnSetColumnVis * Show a particular column
* Purpose: Show a particular column * @param {int} iCol The column whose display should be changed
* Returns: - * @param {bool} bShow Show (true) or hide (false) the column
* Inputs: int:iCol - the column whose display should be changed * @param {bool} [bRedraw=true] Redraw the table or not
* bool:bShow - show (true) or hide (false) the column
* bool:bRedraw - redraw the table or not - default true
*/ */
this.fnSetColumnVis = function ( iCol, bShow, bRedraw ) this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
{ {
@ -638,12 +616,13 @@ this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
_fnSaveState( oSettings ); _fnSaveState( oSettings );
}; };
/*
* Function: fnPageChange /**
* Purpose: Change the pagination * Change the pagination - provides the internal logic for pagination in a simple API
* Returns: - * function. With this function you can have a DataTables table go to the next,
* Inputs: string:sAction - paging action to take: "first", "previous", "next" or "last" * previous, first or last pages.
* bool:bRedraw - redraw the table or not - optional - default true * @param {string} sAction Paging action to take: "first", "previous", "next" or "last"
* @param {bool} [bRedraw=true] Redraw the table or not
*/ */
this.fnPageChange = function ( sAction, bRedraw ) this.fnPageChange = function ( sAction, bRedraw )
{ {
@ -657,11 +636,9 @@ this.fnPageChange = function ( sAction, bRedraw )
} }
}; };
/* /**
* Function: fnDestroy * Restore the table to it's original state in the DOM by removing all of DataTables
* Purpose: Destructor for the DataTable * enhancements, alterations to the DOM structure of the table and event listeners.
* Returns: -
* Inputs: -
*/ */
this.fnDestroy = function ( ) this.fnDestroy = function ( )
{ {
@ -786,12 +763,12 @@ this.fnDestroy = function ( )
oSettings = null; oSettings = null;
}; };
/* /**
* Function: fnAdjustColumnSizing * This function will make DataTables recalculate the column sizes, based on the data
* Purpose: Update table sizing based on content. This would most likely be used for scrolling * contained in the table and the sizes applied to the columns (in the DOM, CSS or
* and will typically need a redraw after it. * through the sWidth parameter). This can be useful when the width of the table's
* Returns: - * parent element changes (for example a window resize).
* Inputs: bool:bRedraw - redraw the table or not, you will typically want to - default true * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
*/ */
this.fnAdjustColumnSizing = function ( bRedraw ) this.fnAdjustColumnSizing = function ( bRedraw )
{ {
@ -809,12 +786,11 @@ this.fnAdjustColumnSizing = function ( bRedraw )
} }
}; };
/* /**
* Function: $ * Perform a jQuery selector action on the table's TR elements (from the tbody) and
* Purpose: Do a jQuery selector action on the table's TR elements (from the tbody) and * return the resulting expression
* return the resulting expression * @param {string} sSelector jQuery selector
* Returns: jQuery object * @returns {object} jQuery object
* Inputs: string:sSelector - jQuery selector
*/ */
this.$ = function ( sSelector ) this.$ = function ( sSelector )
{ {
@ -824,41 +800,3 @@ this.$ = function ( sSelector )
}; };
/*
* Plugin API functions
*
* This call will add the functions which are defined in _oExt.oApi to the
* DataTables object, providing a rather nice way to allow plug-in API functions. Note that
* this is done here, so that API function can actually override the built in API functions if
* required for a particular purpose.
*/
/*
* Function: _fnExternApiFunc
* Purpose: Create a wrapper function for exporting an internal func to an external API func
* Returns: function: - wrapped function
* Inputs: string:sFunc - API function name
*/
function _fnExternApiFunc (sFunc)
{
return function() {
var aArgs = [_fnSettingsFromNode(this[_oExt.iApiIndex])].concat(
Array.prototype.slice.call(arguments) );
return _oExt.oApi[sFunc].apply( this, aArgs );
};
}
for ( var sFunc in _oExt.oApi )
{
if ( sFunc )
{
/*
* Function: anon
* Purpose: Wrap the plug-in API functions in order to provide the settings as 1st arg
* and execute in this scope
* Returns: -
* Inputs: -
*/
this[sFunc] = _fnExternApiFunc(sFunc);
}
}

View File

@ -1,11 +1,10 @@
/* /**
* Function: _fnAddColumn * Add a column to the list used for the table with default values
* Purpose: Add a column to the list used for the table with default values * @param {object} oSettings dataTables settings object
* Returns: - * @param {node} nTh The th element for this column
* Inputs: object:oSettings - dataTables settings object * @private
* node:nTh - the th element for this column
*/ */
function _fnAddColumn( oSettings, nTh ) function _fnAddColumn( oSettings, nTh )
{ {
@ -62,13 +61,13 @@ function _fnAddColumn( oSettings, nTh )
_fnColumnOptions( oSettings, iCol, null ); _fnColumnOptions( oSettings, iCol, null );
} }
/*
* Function: _fnColumnOptions /**
* Purpose: Apply options for a column * Apply options for a column
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iCol column index to consider
* int:iCol - column index to consider * @param {object} oOptions object with sType, bVisible and bSearchable
* object:oOptions - object with sType, bVisible and bSearchable * @private
*/ */
function _fnColumnOptions( oSettings, iCol, oOptions ) function _fnColumnOptions( oSettings, iCol, oOptions )
{ {
@ -145,14 +144,11 @@ function _fnColumnOptions( oSettings, iCol, oOptions )
} }
/**
* Adjust the table column widths for new data. Note: you would probably want to
/* * do a redraw after calling this function!
* Function: _fnAdjustColumnSizing * @param {object} oSettings dataTables settings object
* Purpose: Adjust the table column widths for new data * @private
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* Notes: You would probably want to do a redraw after calling this function!
*/ */
function _fnAdjustColumnSizing ( oSettings ) function _fnAdjustColumnSizing ( oSettings )
{ {
@ -170,19 +166,13 @@ function _fnAdjustColumnSizing ( oSettings )
} }
/**
* Covert the index of a visible column to the index in the data array (take account
* of hidden columns)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @param {object} oSettings dataTables settings object
* Section - Support functions * @param {int} iMatch Visible column index to lookup
*/ * @returns {int} i the data index
* @private
/*
* Function: _fnVisibleToColumnIndex
* Purpose: Covert the index of a visible column to the index in the data array (take account
* of hidden columns)
* Returns: int:i - the data index
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnVisibleToColumnIndex( oSettings, iMatch ) function _fnVisibleToColumnIndex( oSettings, iMatch )
{ {
@ -204,12 +194,14 @@ function _fnVisibleToColumnIndex( oSettings, iMatch )
return null; return null;
} }
/*
* Function: _fnColumnIndexToVisible /**
* Purpose: Covert the index of an index in the data array and convert it to the visible * Covert the index of an index in the data array and convert it to the visible
* column index (take account of hidden columns) * column index (take account of hidden columns)
* Returns: int:i - the data index * @param {int} iMatch Column index to lookup
* Inputs: object:oSettings - dataTables settings object * @param {object} oSettings dataTables settings object
* @returns {int} i the data index
* @private
*/ */
function _fnColumnIndexToVisible( oSettings, iMatch ) function _fnColumnIndexToVisible( oSettings, iMatch )
{ {
@ -231,12 +223,11 @@ function _fnColumnIndexToVisible( oSettings, iMatch )
} }
/**
/* * Get the number of visible columns
* Function: _fnVisbleColumns * @returns {int} i the number of visible columns
* Purpose: Get the number of visible columns * @param {object} oS dataTables settings object
* Returns: int:i - the number of visible columns * @private
* Inputs: object:oS - dataTables settings object
*/ */
function _fnVisbleColumns( oS ) function _fnVisbleColumns( oS )
{ {
@ -252,13 +243,11 @@ function _fnVisbleColumns( oS )
} }
/* /**
* Function: _fnDetectType * Get the sort type based on an input string
* Purpose: Get the sort type based on an input string * @param {string} sData data we wish to know the type of
* Returns: string: - type (defaults to 'string' if no type can be detected) * @returns {string} type (defaults to 'string' if no type can be detected)
* Inputs: string:sData - data we wish to know the type of * @private
* Notes: This function makes use of the DataTables plugin objct _oExt
* (.aTypes) such that new types can easily be added.
*/ */
function _fnDetectType( sData ) function _fnDetectType( sData )
{ {
@ -278,11 +267,11 @@ function _fnDetectType( sData )
} }
/* /**
* Function: _fnReOrderIndex * Figure out how to reorder a display list
* Purpose: Figure out how to reorder a display list * @param {object} oSettings dataTables settings object
* Returns: array int:aiReturn - index list for reordering * @returns array {int} aiReturn index list for reordering
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnReOrderIndex ( oSettings, sColumns ) function _fnReOrderIndex ( oSettings, sColumns )
{ {
@ -304,11 +293,12 @@ function _fnReOrderIndex ( oSettings, sColumns )
return aiReturn; return aiReturn;
} }
/*
* Function: _fnColumnOrdering /**
* Purpose: Get the column ordering that DataTables expects * Get the column ordering that DataTables expects
* Returns: string: - comma separated list of names * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {string} comma separated list of names
* @private
*/ */
function _fnColumnOrdering ( oSettings ) function _fnColumnOrdering ( oSettings )
{ {
@ -323,3 +313,4 @@ function _fnColumnOrdering ( oSettings )
} }
return sNames.slice(0, -1); return sNames.slice(0, -1);
} }

View File

@ -1,14 +1,13 @@
/* /**
* Function: _fnAddData * Add a data array to the table, creating DOM node etc. This is the parallel to
* Purpose: Add a data array to the table, creating DOM node etc * _fnGatherData, but for adding rows from a Javascript source, rather than a
* Returns: int: - >=0 if successful (index of new aoData entry), -1 if failed * DOM source.
* Inputs: object:oSettings - dataTables settings object * @param {object} oSettings dataTables settings object
* array:aData - data array to be added * @param {array} aData data array to be added
* Notes: There are two basic methods for DataTables to get data to display - a JS array * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
* (which is dealt with by this function), and the DOM, which has it's own optimised * @private
* function (_fnGatherData). Be careful to make the same changes here as there and vice-versa
*/ */
function _fnAddData ( oSettings, aDataSupplied ) function _fnAddData ( oSettings, aDataSupplied )
{ {
@ -76,13 +75,11 @@ function _fnAddData ( oSettings, aDataSupplied )
return iRow; return iRow;
} }
/*
* Function: _fnGatherData /**
* Purpose: Read in the data from the target table from the DOM * Read in the data from the target table from the DOM
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
* Notes: This is a optimised version of _fnAddData (more or less) for reading information
* from the DOM. The basic actions must be identical in the two functions.
*/ */
function _fnGatherData( oSettings ) function _fnGatherData( oSettings )
{ {
@ -234,15 +231,12 @@ function _fnGatherData( oSettings )
} }
/**
* Take a TR element and convert it to an index in aoData
* @param {object} s dataTables settings object
/* * @param {node} n the TR element to find
* Function: _fnNodeToDataIndex * @returns {int} index if found, null if not
* Purpose: Take a TR element and convert it to an index in aoData * @private
* Returns: int:i - index if found, null if not
* Inputs: object:s - dataTables settings object
* node:n - the TR element to find
*/ */
function _fnNodeToDataIndex( s, n ) function _fnNodeToDataIndex( s, n )
{ {
@ -271,15 +265,13 @@ function _fnNodeToDataIndex( s, n )
} }
/**
* Get an array of data for a given row from the internal data cache
/* * @param {object} oSettings dataTables settings object
* Function: _fnGetRowData * @param {int} iRow aoData row id
* Purpose: Get an array of data for a given row from the internal data cache * @param {string} sSpecific data get type ('type' 'filter' 'sort')
* Returns: array: - Data array * @returns {array} Data array
* Inputs: object:oSettings - dataTables settings object * @private
* int:iRow - aoData row id
* string:sSpecific - data get type ('type' 'filter' 'sort')
*/ */
function _fnGetRowData( oSettings, iRow, sSpecific ) function _fnGetRowData( oSettings, iRow, sSpecific )
{ {
@ -291,14 +283,15 @@ function _fnGetRowData( oSettings, iRow, sSpecific )
return out; return out;
} }
/*
* Function: _fnGetCellData /**
* Purpose: Get the data for a given cell from the internal cache, taking into account data mapping * Get the data for a given cell from the internal cache, taking into account data mapping
* Returns: *: - Cell data * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iRow aoData row id
* int:iRow - aoData row id * @param {int} iCol Column index
* int:iCol - Column index * @param {string} sSpecific data get type ('display', 'type' 'filter' 'sort')
* string:sSpecific - data get type ('display', 'type' 'filter' 'sort') * @returns {*} Cell data
* @private
*/ */
function _fnGetCellData( oSettings, iRow, iCol, sSpecific ) function _fnGetCellData( oSettings, iRow, iCol, sSpecific )
{ {
@ -335,14 +328,14 @@ function _fnGetCellData( oSettings, iRow, iCol, sSpecific )
return sData; return sData;
} }
/*
* Function: _fnSetCellData /**
* Purpose: Set the value for a specific cell, into the internal data cache * Set the value for a specific cell, into the internal data cache
* Returns: *: - Cell data * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iRow aoData row id
* int:iRow - aoData row id * @param {int} iCol Column index
* int:iCol - Column index * @param {*} val Value to set
* *:val - Value to set * @private
*/ */
function _fnSetCellData( oSettings, iRow, iCol, val ) function _fnSetCellData( oSettings, iRow, iCol, val )
{ {
@ -352,12 +345,13 @@ function _fnSetCellData( oSettings, iRow, iCol, val )
oCol.fnSetData( oData, val ); oCol.fnSetData( oData, val );
} }
/*
* Function: _fnGetObjectDataFn /**
* Purpose: Return a function that can be used to get data from a source object, taking * Return a function that can be used to get data from a source object, taking
* into account the ability to use nested objects as a source * into account the ability to use nested objects as a source
* Returns: function: - Data get function * @param {string|int|function} mSource The data source for the object
* Inputs: string|int|function:mSource - The data source for the object * @returns {function} Data get function
* @private
*/ */
function _fnGetObjectDataFn( mSource ) function _fnGetObjectDataFn( mSource )
{ {
@ -413,12 +407,13 @@ function _fnGetObjectDataFn( mSource )
} }
} }
/*
* Function: _fnSetObjectDataFn /**
* Purpose: Return a function that can be used to set data from a source object, taking * Return a function that can be used to set data from a source object, taking
* into account the ability to use nested objects as a source * into account the ability to use nested objects as a source
* Returns: function: - Data set function * @param {string|int|function} mSource The data source for the object
* Inputs: string|int|function:mSource - The data source for the object * @returns {function} Data set function
* @private
*/ */
function _fnSetObjectDataFn( mSource ) function _fnSetObjectDataFn( mSource )
{ {
@ -471,11 +466,12 @@ function _fnSetObjectDataFn( mSource )
} }
} }
/*
* Function: _fnGetDataMaster /**
* Purpose: Return an array with the full table data * Return an array with the full table data
* Returns: array array:aData - Master data array * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns array {array} aData Master data array
* @private
*/ */
function _fnGetDataMaster ( oSettings ) function _fnGetDataMaster ( oSettings )
{ {
@ -489,11 +485,10 @@ function _fnGetDataMaster ( oSettings )
} }
/* /**
* Function: _fnClearTable * Nuke the table
* Purpose: Nuke the table * @param {object} oSettings dataTables settings object
* Returns: - * @private
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnClearTable( oSettings ) function _fnClearTable( oSettings )
{ {
@ -504,13 +499,12 @@ function _fnClearTable( oSettings )
} }
/* /**
* Function: _fnDeleteIndex * Take an array of integers (index array) and remove a target integer (value - not
* Purpose: Take an array of integers (index array) and remove a target integer (value - not * the key!)
* the key!) * @param {array} a Index array to target
* Returns: - * @param {int} iTarget value to find
* Inputs: a:array int - Index array to target * @private
* int:iTarget - value to find
*/ */
function _fnDeleteIndex( a, iTarget ) function _fnDeleteIndex( a, iTarget )
{ {
@ -533,3 +527,4 @@ function _fnDeleteIndex( a, iTarget )
a.splice( iTargetIndex, 1 ); a.splice( iTargetIndex, 1 );
} }
} }

View File

@ -1,11 +1,10 @@
/* /**
* Function: _fnCreateTr * Create a new TR element (and it's TD children) for a row
* Purpose: Create a new TR element (and it's TD children) for a row * @param {object} oSettings dataTables settings object
* Returns: void * @param {int} iRow Row to consider
* Inputs: object:oSettings - dataTables settings object * @private
* int:iRow - Row to consider
*/ */
function _fnCreateTr ( oSettings, iRow ) function _fnCreateTr ( oSettings, iRow )
{ {
@ -70,13 +69,10 @@ function _fnCreateTr ( oSettings, iRow )
} }
/**
* Create the HTML header for the table
/* * @param {object} oSettings dataTables settings object
* Function: _fnBuildHead * @private
* Purpose: Create the HTML header for the table
* Returns: -
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnBuildHead( oSettings ) function _fnBuildHead( oSettings )
{ {
@ -190,24 +186,18 @@ function _fnBuildHead( oSettings )
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Section - Drawing functions * Draw the header (or footer) element based on the column visibility states. The
*/ * methodology here is to use the layout array from _fnDetectHeader, modified for
* the instantaneous column visibility, to construct the new layout. The grid is
/* * traversed over cell at a time in a rows x columns grid fashion, although each
* Function: _fnDrawHead * cell insert can cover multiple elements in the grid - which is tracks using the
* Purpose: Draw the header (or footer) element based on the column visibility states. The * aApplied array. Cell inserts in the grid will only occur where there isn't
* methodology here is to use the layout array from _fnDetectHeader, modified for * already a cell in that position.
* the instantaneous column visibility, to construct the new layout. The grid is * @param {object} oSettings dataTables settings object
* traversed over cell at a time in a rows x columns grid fashion, although each * @param array {objects} aoSource Layout array from _fnDetectHeader
* cell insert can cover multiple elements in the grid - which is tracks using the * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
* aApplied array. Cell inserts in the grid will only occur where there isn't * @private
* already a cell in that position.
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* array objects:aoSource - Layout array from _fnDetectHeader
* boolean:bIncludeHidden - If true then include the hidden columns in the calc,
* - optional: default false
*/ */
function _fnDrawHead( oSettings, aoSource, bIncludeHidden ) function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
{ {
@ -293,11 +283,11 @@ function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
} }
} }
/*
* Function: _fnDraw /**
* Purpose: Insert the required TR nodes into the table for display * Insert the required TR nodes into the table for display
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnDraw( oSettings ) function _fnDraw( oSettings )
{ {
@ -517,11 +507,11 @@ function _fnDraw( oSettings )
} }
} }
/*
* Function: _fnReDraw /**
* Purpose: Redraw the table - taking account of the various features which are enabled * Redraw the table - taking account of the various features which are enabled
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnReDraw( oSettings ) function _fnReDraw( oSettings )
{ {
@ -542,11 +532,12 @@ function _fnReDraw( oSettings )
} }
} }
/*
* Function: _fnAjaxUpdate /**
* Purpose: Update the table using an Ajax call * Update the table using an Ajax call
* Returns: bool: block the table drawing or not * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {boolean} Block the table drawing or not
* @private
*/ */
function _fnAjaxUpdate( oSettings ) function _fnAjaxUpdate( oSettings )
{ {
@ -570,11 +561,12 @@ function _fnAjaxUpdate( oSettings )
} }
} }
/*
* Function: _fnAjaxParameters /**
* Purpose: Build up the parameters in an object needed for a server-side processing request * Build up the parameters in an object needed for a server-side processing request
* Returns: bool: block the table drawing or not * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {bool} block the table drawing or not
* @private
*/ */
function _fnAjaxParameters( oSettings ) function _fnAjaxParameters( oSettings )
{ {
@ -635,12 +627,12 @@ function _fnAjaxParameters( oSettings )
return aoData; return aoData;
} }
/*
* Function: _fnServerParams /**
* Purpose: Add Ajax parameters from plugins * Add Ajax parameters from plugins
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param array {objects} aoData name/value pairs to send to the server
* array objects:aoData - name/value pairs to send to the server * @private
*/ */
function _fnServerParams( oSettings, aoData ) function _fnServerParams( oSettings, aoData )
{ {
@ -650,16 +642,17 @@ function _fnServerParams( oSettings, aoData )
} }
} }
/*
* Function: _fnAjaxUpdateDraw /**
* Purpose: Data the data from the server (nuking the old) and redraw the table * Data the data from the server (nuking the old) and redraw the table
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} json json data return from the server.
* object:json - json data return from the server. * @param {object} json.sEcho Tracking flag for DataTables to match requests
* The following must be defined: * @param {object} json.iTotalRecords Number of records in the data set, not accounting for filtering
* iTotalRecords, iTotalDisplayRecords, aaData * @param {object} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
* The following may be defined: * @param {object} json.aaData The data to display on this page
* sColumns * @param {object} [json.sColumns] Column ordering (sName, comma separated)
* @private
*/ */
function _fnAjaxUpdateDraw ( oSettings, json ) function _fnAjaxUpdateDraw ( oSettings, json )
{ {
@ -722,17 +715,10 @@ function _fnAjaxUpdateDraw ( oSettings, json )
} }
/**
* Add the options to the page HTML for the table
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @param {object} oSettings dataTables settings object
* Section - Options (features) HTML * @private
*/
/*
* Function: _fnAddOptionsHtml
* Purpose: Add the options to the page HTML for the table
* Returns: -
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnAddOptionsHtml ( oSettings ) function _fnAddOptionsHtml ( oSettings )
{ {
@ -893,16 +879,14 @@ function _fnAddOptionsHtml ( oSettings )
} }
/**
/* * Use the DOM source to create up an array of header cells. The idea here is to
* Function: _fnDetectHeader * create a layout grid (array) of rows x columns, which contains a reference
* Purpose: Use the DOM source to create up an array of header cells. The idea here is to * to the cell that that point in the grid (regardless of col/rowspan), such that
* create a layout grid (array) of rows x columns, which contains a reference * any column / row could be removed and the new grid constructed
* to the cell that that point in the grid (regardless of col/rowspan), such that * @param array {object} aLayout Array to store the calculated layout in
* any column / row could be removed and the new grid constructed * @param {node} nThead The header/footer element for the table
* Returns: void * @private
* Outputs: array object:aLayout - Array to store the calculated layout in
* Inputs: node:nThead - The header/footer element for the table
*/ */
function _fnDetectHeader ( aLayout, nThead ) function _fnDetectHeader ( aLayout, nThead )
{ {
@ -965,13 +949,14 @@ function _fnDetectHeader ( aLayout, nThead )
} }
} }
/*
* Function: _fnGetUniqueThs /**
* Purpose: Get an array of unique th elements, one for each column * Get an array of unique th elements, one for each column
* Returns: array node:aReturn - list of unique ths * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {node} nHeader automatically detect the layout from this node - optional
* node:nHeader - automatically detect the layout from this node - optional * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
* array object:aLayout - thead/tfoot layout from _fnDetectHeader - optional * @returns array {node} aReturn list of unique ths
* @private
*/ */
function _fnGetUniqueThs ( oSettings, nHeader, aLayout ) function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
{ {
@ -1000,3 +985,4 @@ function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
return aReturn; return aReturn;
} }

View File

@ -1,14 +1,10 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Section - Feature: Filtering * Generate the node required for filtering text
*/ * @returns {node} Filter control element
* @param {object} oSettings dataTables settings object
/* * @private
* Function: _fnFeatureHtmlFilter
* Purpose: Generate the node required for filtering text
* Returns: node
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnFeatureHtmlFilter ( oSettings ) function _fnFeatureHtmlFilter ( oSettings )
{ {
@ -60,13 +56,13 @@ function _fnFeatureHtmlFilter ( oSettings )
return nFilter; return nFilter;
} }
/*
* Function: _fnFilterComplete /**
* Purpose: Filter the table using both the global filter and column based filtering * Filter the table using both the global filter and column based filtering
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} oSearch search information
* object:oSearch: search information * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
* int:iForce - optional - force a research of the master array (1) or not (undefined or 0) * @private
*/ */
function _fnFilterComplete ( oSettings, oInput, iForce ) function _fnFilterComplete ( oSettings, oInput, iForce )
{ {
@ -99,11 +95,11 @@ function _fnFilterComplete ( oSettings, oInput, iForce )
_fnBuildSearchArray( oSettings, 0 ); _fnBuildSearchArray( oSettings, 0 );
} }
/*
* Function: _fnFilterCustom /**
* Purpose: Apply custom filtering functions * Apply custom filtering functions
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFilterCustom( oSettings ) function _fnFilterCustom( oSettings )
{ {
@ -125,15 +121,15 @@ function _fnFilterCustom( oSettings )
} }
} }
/*
* Function: _fnFilterColumn /**
* Purpose: Filter the table on a per-column basis * Filter the table on a per-column basis
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {string} sInput string to filter on
* string:sInput - string to filter on * @param {int} iColumn column to filter
* int:iColumn - column to filter * @param {bool} bRegex treat search string as a regular expression or not
* bool:bRegex - treat search string as a regular expression or not * @param {bool} bSmart use smart filtering or not
* bool:bSmart - use smart filtering or not * @private
*/ */
function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart ) function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart )
{ {
@ -157,15 +153,15 @@ function _fnFilterColumn ( oSettings, sInput, iColumn, bRegex, bSmart )
} }
} }
/*
* Function: _fnFilter /**
* Purpose: Filter the data table based on user input and draw the table * Filter the data table based on user input and draw the table
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {string} sInput string to filter on
* string:sInput - string to filter on * @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0)
* 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
* bool:bRegex - treat as a regular expression or not * @param {bool} bSmart perform smart filtering or not
* bool:bSmart - perform smart filtering or not * @private
*/ */
function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart ) function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart )
{ {
@ -243,12 +239,12 @@ function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart )
oSettings.oPreviousSearch.bSmart = bSmart; oSettings.oPreviousSearch.bSmart = bSmart;
} }
/*
* Function: _fnBuildSearchArray /**
* Purpose: Create an array which can be quickly search through * Create an array which can be quickly search through
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iMaster use the master data array - optional
* int:iMaster - use the master data array - optional * @private
*/ */
function _fnBuildSearchArray ( oSettings, iMaster ) function _fnBuildSearchArray ( oSettings, iMaster )
{ {
@ -268,12 +264,12 @@ function _fnBuildSearchArray ( oSettings, iMaster )
} }
} }
/*
* Function: _fnBuildSearchRow /**
* Purpose: Create a searchable string from a single data row * Create a searchable string from a single data row
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {array} aData Row data array to use for the data to search
* array:aData - Row data array to use for the data to search * @private
*/ */
function _fnBuildSearchRow( oSettings, aData ) function _fnBuildSearchRow( oSettings, aData )
{ {
@ -305,13 +301,13 @@ function _fnBuildSearchRow( oSettings, aData )
return sSearch; return sSearch;
} }
/* /**
* Function: _fnFilterCreateSearch * Build a regular expression object suitable for searching a table
* Purpose: Build a regular expression object suitable for searching a table * @param {string} sSearch string to search for
* Returns: RegExp: - constructed object * @param {bool} bRegex treat as a regular expression or not
* Inputs: string:sSearch - string to search for * @param {bool} bSmart perform smart filtering or not
* bool:bRegex - treat as a regular expression or not * @returns {RegExp} constructed object
* bool:bSmart - perform smart filtering or not * @private
*/ */
function _fnFilterCreateSearch( sSearch, bRegex, bSmart ) function _fnFilterCreateSearch( sSearch, bRegex, bSmart )
{ {
@ -333,12 +329,13 @@ function _fnFilterCreateSearch( sSearch, bRegex, bSmart )
} }
} }
/*
* Function: _fnDataToSearch /**
* Purpose: Convert raw data into something that the user can search on * Convert raw data into something that the user can search on
* Returns: string: - search string * @param {string} sData data to be modified
* Inputs: string:sData - data to be modified * @param {string} sType data type
* string:sType - data type * @returns {string} search string
* @private
*/ */
function _fnDataToSearch ( sData, sType ) function _fnDataToSearch ( sData, sType )
{ {
@ -362,11 +359,11 @@ function _fnDataToSearch ( sData, sType )
} }
/* /**
* Function: _fnEscapeRegex * scape a string stuch that it can be used in a regular expression
* Purpose: scape a string stuch that it can be used in a regular expression * @param {string} sVal string to escape
* Returns: string: - escaped string * @returns {string} escaped string
* Inputs: string:sVal - string to escape * @private
*/ */
function _fnEscapeRegex ( sVal ) function _fnEscapeRegex ( sVal )
{ {
@ -374,3 +371,4 @@ function _fnEscapeRegex ( sVal )
var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' ); var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
return sVal.replace(reReplace, '\\$1'); return sVal.replace(reReplace, '\\$1');
} }

View File

@ -1,14 +1,10 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Section - Feature: HTML info * Generate the node required for the info display
*/ * @param {object} oSettings dataTables settings object
* @returns {node} Information element
/* * @private
* Function: _fnFeatureHtmlInfo
* Purpose: Generate the node required for the info display
* Returns: node
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnFeatureHtmlInfo ( oSettings ) function _fnFeatureHtmlInfo ( oSettings )
{ {
@ -34,11 +30,11 @@ function _fnFeatureHtmlInfo ( oSettings )
return nInfo; return nInfo;
} }
/*
* Function: _fnUpdateInfo /**
* Purpose: Update the information elements in the display * Update the information elements in the display
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnUpdateInfo ( oSettings ) function _fnUpdateInfo ( oSettings )
{ {
@ -108,3 +104,4 @@ function _fnUpdateInfo ( oSettings )
$(n[i]).html( sOut ); $(n[i]).html( sOut );
} }
} }

View File

@ -1,13 +1,9 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Initialisation
*/
/* /**
* Function: _fnInitialise * Draw the table for the first time, adding all required features
* Purpose: Draw the table for the first time, adding all required features * @param {object} oSettings dataTables settings object
* Returns: - * @private
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnInitialise ( oSettings ) function _fnInitialise ( oSettings )
{ {
@ -112,11 +108,11 @@ function _fnInitialise ( oSettings )
} }
} }
/*
* Function: _fnInitComplete /**
* Purpose: Draw the table for the first time, adding all required features * Draw the table for the first time, adding all required features
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnInitComplete ( oSettings, json ) function _fnInitComplete ( oSettings, json )
{ {
@ -134,13 +130,13 @@ function _fnInitComplete ( oSettings, json )
} }
} }
/*
* Function: _fnLanguageProcess /**
* Purpose: Copy language variables from remote object to a local one * Copy language variables from remote object to a local one
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} oLanguage Language information
* object:oLanguage - Language information * @param {bool} bInit init once complete
* bool:bInit - init once complete * @private
*/ */
function _fnLanguageProcess( oSettings, oLanguage, bInit ) function _fnLanguageProcess( oSettings, oLanguage, bInit )
{ {
@ -167,3 +163,4 @@ function _fnLanguageProcess( oSettings, oLanguage, bInit )
_fnInitialise( oSettings ); _fnInitialise( oSettings );
} }
} }

View File

@ -1,13 +1,10 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Length change
*/
/* /**
* Function: _fnFeatureHtmlLength * Generate the node required for user display length changing
* Purpose: Generate the node required for user display length changing * @param {object} oSettings dataTables settings object
* Returns: node * @returns {node} Display length feature node
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFeatureHtmlLength ( oSettings ) function _fnFeatureHtmlLength ( oSettings )
{ {
@ -93,11 +90,10 @@ function _fnFeatureHtmlLength ( oSettings )
} }
/* /**
* Function: _fnCalculateEnd * Rcalculate the end point based on the start point
* Purpose: Rcalculate the end point based on the start point * @param {object} oSettings dataTables settings object
* Returns: - * @private
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnCalculateEnd( oSettings ) function _fnCalculateEnd( oSettings )
{ {
@ -121,3 +117,4 @@ function _fnCalculateEnd( oSettings )
} }
} }
} }

View File

@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Section - Feature: Pagination. Note that most of the paging logic is done in * Note that most of the paging logic is done in
* _oExt.oPagination * _oExt.oPagination
*/ */
/* /**
* Function: _fnFeatureHtmlPaginate * Generate the node required for default pagination
* Purpose: Generate the node required for default pagination * @param {object} oSettings dataTables settings object
* Returns: node * @returns {node} Pagination feature node
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnFeatureHtmlPaginate ( oSettings ) function _fnFeatureHtmlPaginate ( oSettings )
{ {
@ -44,12 +44,13 @@ function _fnFeatureHtmlPaginate ( oSettings )
return nPaginate; return nPaginate;
} }
/*
* Function: _fnPageChange /**
* Purpose: Alter the display settings to change the page * Alter the display settings to change the page
* Returns: bool:true - page has changed, false - no change (no effect) eg 'first' on page 1 * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {string} sAction paging action to take: "first", "previous", "next" or "last"
* 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 ) function _fnPageChange ( oSettings, sAction )
{ {
@ -106,3 +107,4 @@ function _fnPageChange ( oSettings, sAction )
return iOldStart != oSettings._iDisplayStart; return iOldStart != oSettings._iDisplayStart;
} }

View File

@ -1,14 +1,10 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Section - Feature: Processing incidator * Generate the node required for the processing node
*/ * @param {object} oSettings dataTables settings object
* @returns {node} Processing element
/* * @private
* Function: _fnFeatureHtmlProcessing
* Purpose: Generate the node required for the processing node
* Returns: node
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnFeatureHtmlProcessing ( oSettings ) function _fnFeatureHtmlProcessing ( oSettings )
{ {
@ -25,14 +21,12 @@ function _fnFeatureHtmlProcessing ( oSettings )
return nProcessing; return nProcessing;
} }
/*
* Function: _fnProcessingDisplay /**
* Purpose: Display or hide the processing indicator * Display or hide the processing indicator
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {bool} bShow Show the processing indicator (true) or not (false)
* bool: * @private
* true - show the processing indicator
* false - don't show
*/ */
function _fnProcessingDisplay ( oSettings, bShow ) function _fnProcessingDisplay ( oSettings, bShow )
{ {
@ -45,3 +39,4 @@ function _fnProcessingDisplay ( oSettings, bShow )
} }
} }
} }

View File

@ -1,18 +1,14 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Section - Feature: Filtering * Add any control elements for the table - specifically scrolling
*/ * @param {object} oSettings dataTables settings object
* @returns {node} Node to add to the DOM
/* * @private
* Function: _fnFeatureHtmlTable
* Purpose: Add any control elements for the table - specifically scrolling
* Returns: node: - Node to add to the DOM
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnFeatureHtmlTable ( oSettings ) function _fnFeatureHtmlTable ( oSettings )
{ {
/* Chack if scrolling is enabled or not - if not then leave the DOM unaltered */ /* Check if scrolling is enabled or not - if not then leave the DOM unaltered */
if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY === "" ) if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY === "" )
{ {
return oSettings.nTable; return oSettings.nTable;
@ -166,16 +162,17 @@ function _fnFeatureHtmlTable ( oSettings )
return nScroller; return nScroller;
} }
/*
* Function: _fnScrollDraw /**
* Purpose: Update the various tables for resizing * Update the various tables for resizing. It's a bit of a pig this function, but
* Returns: node: - Node to add to the DOM * basically the idea to:
* Inputs: object:o - dataTables settings object
* Notes: It's a bit of a pig this function, but basically the idea to:
* 1. Re-create the table inside the scrolling div * 1. Re-create the table inside the scrolling div
* 2. Take live measurements from the DOM * 2. Take live measurements from the DOM
* 3. Apply the measurements * 3. Apply the measurements
* 4. Clean up * 4. Clean up
* @param {object} o dataTables settings object
* @returns {node} Node to add to the DOM
* @private
*/ */
function _fnScrollDraw ( o ) function _fnScrollDraw ( o )
{ {
@ -447,7 +444,7 @@ function _fnScrollDraw ( o )
nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth ); nScrollFootTable.style.width = _fnStringToCss( o.nTable.offsetWidth );
} }
/* If sorting or filtering has occured, jump the scrolling back to the top */ /* If sorting or filtering has occurred, jump the scrolling back to the top */
if ( o.bSorted || o.bFiltered ) if ( o.bSorted || o.bFiltered )
{ {
nScrollBody.scrollTop = 0; nScrollBody.scrollTop = 0;
@ -455,15 +452,13 @@ function _fnScrollDraw ( o )
} }
/**
/* * Apply a given function to the display child nodes of an element array (typically
* Function: _fnApplyToChildren * TD children of TR rows
* Purpose: Apply a given function to the display child nodes of an element array (typically * @param {function} fn Method to apply to the objects
* TD children of TR rows * @param array {nodes} an1 List of elements to look through for display children
* Returns: - (done by reference) * @param array {nodes} an2 Another list (identical structure to the first) - optional
* Inputs: function:fn - Method to apply to the objects * @private
* array nodes:an1 - List of elements to look through for display children
* array nodes:an2 - Another list (identical structure to the first) - optional
*/ */
function _fnApplyToChildren( fn, an1, an2 ) function _fnApplyToChildren( fn, an1, an2 )
{ {
@ -485,3 +480,4 @@ function _fnApplyToChildren( fn, an1, an2 )
} }
} }
} }

View File

@ -1,13 +1,11 @@
/**
/* * Convert a CSS unit width to pixels (e.g. 2em)
* Function: _fnConvertToWidth * @param {string} sWidth width to be converted
* Purpose: Convert a CSS unit width to pixels (e.g. 2em) * @param {node} nParent parent to get the with for (required for relative widths) - optional
* Returns: int:iWidth - width in pixels * @returns {int} iWidth width in pixels
* Inputs: string:sWidth - width to be converted * @private
* node:nParent - parent to get the with for (required for
* relative widths) - optional
*/ */
function _fnConvertToWidth ( sWidth, nParent ) function _fnConvertToWidth ( sWidth, nParent )
{ {
@ -32,11 +30,11 @@ function _fnConvertToWidth ( sWidth, nParent )
return ( iWidth ); return ( iWidth );
} }
/*
* Function: _fnCalculateColumnWidths /**
* Purpose: Calculate the width of columns for the table * Calculate the width of columns for the table
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @private
*/ */
function _fnCalculateColumnWidths ( oSettings ) function _fnCalculateColumnWidths ( oSettings )
{ {
@ -247,12 +245,12 @@ function _fnCalculateColumnWidths ( oSettings )
} }
} }
/*
* Function: _fnScrollingWidthAdjust /**
* Purpose: Adjust a table's width to take account of scrolling * Adjust a table's width to take account of scrolling
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {node} n table node
* node:n - table node * @private
*/ */
function _fnScrollingWidthAdjust ( oSettings, n ) function _fnScrollingWidthAdjust ( oSettings, n )
{ {
@ -271,12 +269,13 @@ function _fnScrollingWidthAdjust ( oSettings, n )
} }
} }
/*
* Function: _fnGetWidestNode /**
* Purpose: Get the widest node * Get the widest node
* Returns: string: - max strlens for each column * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iCol column of interest
* int:iCol - column of interest * @returns {string} max strlens for each column
* @private
*/ */
function _fnGetWidestNode( oSettings, iCol ) function _fnGetWidestNode( oSettings, iCol )
{ {
@ -295,12 +294,13 @@ function _fnGetWidestNode( oSettings, iCol )
return _fnGetTdNodes(oSettings, iMaxIndex)[iCol]; return _fnGetTdNodes(oSettings, iMaxIndex)[iCol];
} }
/*
* Function: _fnGetMaxLenString /**
* Purpose: Get the maximum strlen for each data column * Get the maximum strlen for each data column
* Returns: string: - max strlens for each column * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} iCol column of interest
* int:iCol - column of interest * @returns {string} max strlens for each column
* @private
*/ */
function _fnGetMaxLenString( oSettings, iCol ) function _fnGetMaxLenString( oSettings, iCol )
{ {
@ -321,12 +321,13 @@ function _fnGetMaxLenString( oSettings, iCol )
return iMaxIndex; return iMaxIndex;
} }
/*
* Function: _fnStringToCss /**
* Purpose: Append a CSS unit (only if required) to a string * Append a CSS unit (only if required) to a string
* Returns: 0 if match, 1 if length is different, 2 if no match * @param {array} aArray1 first array
* Inputs: array:aArray1 - first array * @param {array} aArray2 second array
* array:aArray2 - second array * @returns {int} 0 if match, 1 if length is different, 2 if no match
* @private
*/ */
function _fnStringToCss( s ) function _fnStringToCss( s )
{ {
@ -354,14 +355,10 @@ function _fnStringToCss( s )
} }
/**
/* * Get the width of a scroll bar in this browser being used
* Function: _fnScrollBarWidth * @returns {int} width in pixels
* Purpose: Get the width of a scroll bar in this browser being used * @private
* Returns: int: - width in pixels
* Inputs: -
* Notes: All credit for this function belongs to Alexandre Gomes. Thanks for sharing!
* http://www.alexandre-gomes.com/?p=115
*/ */
function _fnScrollBarWidth () function _fnScrollBarWidth ()
{ {
@ -395,3 +392,4 @@ function _fnScrollBarWidth ()
document.body.removeChild(outer); document.body.removeChild(outer);
return (w1 - w2); return (w1 - w2);
} }

View File

@ -1,19 +1,10 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Section - Feature: Sorting * 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
* Purpose: Change the order of the table
* Returns: -
* Inputs: object:oSettings - dataTables settings object
* bool:bApplyClasses - optional - should we apply classes or not
* Notes: We always sort the master array and then apply a filter again
* if it is needed. This probably isn't optimal - but atm I can't think
* of any other way which is (each has disadvantages). we want to sort aiDisplayMaster -
* but according to aoData[]._aData
*/ */
function _fnSort ( oSettings, bApplyClasses ) function _fnSort ( oSettings, bApplyClasses )
{ {
@ -156,14 +147,14 @@ function _fnSort ( oSettings, bApplyClasses )
} }
} }
/*
* Function: _fnSortAttachListener /**
* Purpose: Attach a sort handler (click) to a node * Attach a sort handler (click) to a node
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {node} nNode node to attach the handler to
* node:nNode - node to attach the handler to * @param {int} iDataIndex column sorting index
* int:iDataIndex - column sorting index * @param {function} [fnCallback] callback function
* function:fnCallback - callback function - optional * @private
*/ */
function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback ) function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback )
{ {
@ -275,12 +266,12 @@ function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback )
} ); } );
} }
/*
* Function: _fnSortingClasses /**
* Purpose: Set the sortting classes on the header * Set the sorting classes on the header, Note: it is safe to call this function
* Returns: - * when bSort and bSortClasses are false
* Inputs: object:oSettings - dataTables settings object * @param {object} oSettings dataTables settings object
* Notes: It is safe to call this function when bSort and bSortClasses are false * @private
*/ */
function _fnSortingClasses( oSettings ) function _fnSortingClasses( oSettings )
{ {
@ -429,3 +420,4 @@ function _fnSortingClasses( oSettings )
} }
} }
} }

View File

@ -1,10 +1,9 @@
/* /**
* Function: _fnSaveState * Save the state of a table in a cookie such that the page can be reloaded
* Purpose: Save the state of a table in a cookie such that the page can be reloaded * @param {object} oSettings dataTables settings object
* Returns: - * @private
* Inputs: object:oSettings - dataTables settings object
*/ */
function _fnSaveState ( oSettings ) function _fnSaveState ( oSettings )
{ {
@ -64,12 +63,12 @@ function _fnSaveState ( oSettings )
oSettings.iCookieDuration, oSettings.sCookiePrefix, oSettings.fnCookieCallback ); oSettings.iCookieDuration, oSettings.sCookiePrefix, oSettings.fnCookieCallback );
} }
/*
* Function: _fnLoadState /**
* Purpose: Attempt to load a saved table state from a cookie * Attempt to load a saved table state from a cookie
* Returns: - * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {object} oInit DataTables init object so we can override settings
* object:oInit - DataTables init object so we can override settings * @private
*/ */
function _fnLoadState ( oSettings, oInit ) function _fnLoadState ( oSettings, oInit )
{ {
@ -156,15 +155,15 @@ function _fnLoadState ( oSettings, oInit )
} }
} }
/*
* Function: _fnCreateCookie /**
* Purpose: Create a new cookie with a value to store the state of a table * Create a new cookie with a value to store the state of a table
* Returns: - * @param {string} sName name of the cookie to create
* Inputs: string:sName - name of the cookie to create * @param {string} sValue the value the cookie should take
* string:sValue - the value the cookie should take * @param {int} iSecs duration of the cookie
* int:iSecs - duration of the cookie * @param {string} sBaseName sName is made up of the base + file name - this is the base
* string:sBaseName - sName is made up of the base + file name - this is the base * @param {function} fnCallback User definable function to modify the cookie
* function:fnCallback - User definable function to modify the cookie * @private
*/ */
function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback ) function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback )
{ {
@ -231,11 +230,12 @@ function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback )
document.cookie = sFullCookie; document.cookie = sFullCookie;
} }
/*
* Function: _fnReadCookie /**
* Purpose: Read an old cookie to get a cookie with an old table state * Read an old cookie to get a cookie with an old table state
* Returns: string: - contents of the cookie - or null if no cookie with that name found * @param {string} sName name of the cookie to read
* Inputs: string:sName - name of the cookie to read * @returns {string} contents of the cookie - or null if no cookie with that name found
* @private
*/ */
function _fnReadCookie ( sName ) function _fnReadCookie ( sName )
{ {
@ -260,3 +260,4 @@ function _fnReadCookie ( sName )
} }
return null; return null;
} }

View File

@ -1,11 +1,11 @@
/* /**
* Function: _fnArrayCmp * Compare two arrays
* Purpose: Compare two arrays * @param {array} aArray1 first array
* Returns: 0 if match, 1 if length is different, 2 if no match * @param {array} aArray2 second array
* Inputs: array:aArray1 - first array * @returns {int} 0 if match, 1 if length is different, 2 if no match
* array:aArray2 - second array * @private
*/ */
function _fnArrayCmp( aArray1, aArray2 ) function _fnArrayCmp( aArray1, aArray2 )
{ {
@ -25,11 +25,12 @@ function _fnArrayCmp( aArray1, aArray2 )
return 0; return 0;
} }
/*
* Function: _fnSettingsFromNode /**
* Purpose: Return the settings object for a particular table * Return the settings object for a particular table
* Returns: object: Settings object - or null if not found * @param {node} nTable table we are using as a dataTable
* Inputs: node:nTable - table we are using as a dataTable * @returns {object} Settings object - or null if not found
* @private
*/ */
function _fnSettingsFromNode ( nTable ) function _fnSettingsFromNode ( nTable )
{ {
@ -44,11 +45,12 @@ function _fnSettingsFromNode ( nTable )
return null; return null;
} }
/*
* Function: _fnGetTrNodes /**
* Purpose: Return an array with the TR nodes for the table * Return an array with the TR nodes for the table
* Returns: array: - TR array * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @returns {array} TR array
* @private
*/ */
function _fnGetTrNodes ( oSettings ) function _fnGetTrNodes ( oSettings )
{ {
@ -63,13 +65,14 @@ function _fnGetTrNodes ( oSettings )
return aNodes; return aNodes;
} }
/*
* Function: _fnGetTdNodes /**
* Purpose: Return an flat array with all TD nodes for the table, or row * Return an flat array with all TD nodes for the table, or row
* Returns: array: - TD array * @param {object} oSettings dataTables settings object
* Inputs: object:oSettings - dataTables settings object * @param {int} [iIndividualRow] aoData index to get the nodes for - optional
* int:iIndividualRow - aoData index to get the nodes for - optional if not * if not given then the return array will contain all nodes for the table
* given then the return array will contain all nodes for the table * @returns {array} TD array
* @private
*/ */
function _fnGetTdNodes ( oSettings, iIndividualRow ) function _fnGetTdNodes ( oSettings, iIndividualRow )
{ {
@ -121,12 +124,12 @@ function _fnGetTdNodes ( oSettings, iIndividualRow )
return anReturn; return anReturn;
} }
/*
* Function: _fnLog /**
* Purpose: Log an error message * Log an error message
* Returns: - * @param {int} iLevel log error messages, or display them to the user
* Inputs: int:iLevel - log error messages, or display them to the user * @param {string} sMesg error message
* string:sMesg - error message * @private
*/ */
function _fnLog( oSettings, iLevel, sMesg ) function _fnLog( oSettings, iLevel, sMesg )
{ {
@ -152,14 +155,14 @@ function _fnLog( oSettings, iLevel, sMesg )
} }
} }
/*
* Function: _fnMap /**
* Purpose: See if a property is defined on one object, if so assign it to the other object * See if a property is defined on one object, if so assign it to the other object
* Returns: - (done by reference) * @param {object} oRet target object
* Inputs: object:oRet - target object * @param {object} oSrc source object
* object:oSrc - source object * @param {string} sName property
* string:sName - property * @param {string} [sMappedName] name to map too - optional, sName used if not given
* string:sMappedName - name to map too - optional, sName used if not given * @private
*/ */
function _fnMap( oRet, oSrc, sName, sMappedName ) function _fnMap( oRet, oSrc, sName, sMappedName )
{ {
@ -172,3 +175,4 @@ function _fnMap( oRet, oSrc, sName, sMappedName )
oRet[sMappedName] = oSrc[sName]; oRet[sMappedName] = oSrc[sName];
} }
} }