mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-27 00:54:15 +01:00
API: Update to extension API for camelCase support and tidy up
- This is a fairly far reaching commit in that the DataTables.ext object is updated to primarily use camelCase, just like the rest of the 1.10 API. The old notation is still available for compatiblity, but deprecated. - While working in this area, I've made a number of updates: - .model.ext has been removed - that was redundant and not useful. DataTables.ext is where the plug-ins for DataTables will live and will be correctly publically documented as such. - Type based actions (detection, sorting and filter) now live in a `type` namespace to make it clear that they are type based. - Internal references to .ext updated to use the new parameters. We could use the old ones since they are fully backwards compatible, but I'd rather set the standard by using the modern ones. - JSDoc comments for .ext updated - Extension examples updated
This commit is contained in:
parent
379a746034
commit
b7c6c98031
@ -1 +1 @@
|
||||
82f616457909106b568ee41e6a3daf378fc53450
|
||||
485ee7693dda3db904d3a1939e676981add06e04
|
||||
|
950
media/js/jquery.dataTables.js
vendored
950
media/js/jquery.dataTables.js
vendored
@ -456,7 +456,7 @@
|
||||
*/
|
||||
function _fnDetectType( sData )
|
||||
{
|
||||
var aTypes = DataTable.ext.aTypes;
|
||||
var aTypes = DataTable.ext.type.detect;
|
||||
var iLen = aTypes.length;
|
||||
|
||||
for ( var i=0 ; i<iLen ; i++ )
|
||||
@ -1749,10 +1749,10 @@
|
||||
nTmp = _fnFeatureHtmlPaginate( oSettings );
|
||||
iPushFeature = 1;
|
||||
}
|
||||
else if ( DataTable.ext.aoFeatures.length !== 0 )
|
||||
else if ( DataTable.ext.feature.length !== 0 )
|
||||
{
|
||||
/* Plug-in features */
|
||||
var aoFeatures = DataTable.ext.aoFeatures;
|
||||
var aoFeatures = DataTable.ext.feature;
|
||||
for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
|
||||
{
|
||||
if ( cOption == aoFeatures[k].cFeature )
|
||||
@ -2298,7 +2298,7 @@
|
||||
*/
|
||||
function _fnFilterCustom( oSettings )
|
||||
{
|
||||
var afnFilters = DataTable.ext.afnFiltering;
|
||||
var afnFilters = DataTable.ext.filter;
|
||||
var aiFilterColumns = _fnGetColumns( oSettings, 'bSearchable' );
|
||||
|
||||
for ( var i=0, iLen=afnFilters.length ; i<iLen ; i++ )
|
||||
@ -2372,7 +2372,7 @@
|
||||
var display, invalidated, i;
|
||||
|
||||
// Need to take account of custom filtering functions - always filter
|
||||
if ( DataTable.ext.afnFiltering.length !== 0 ) {
|
||||
if ( DataTable.ext.filter.length !== 0 ) {
|
||||
force = true;
|
||||
}
|
||||
|
||||
@ -2455,7 +2455,7 @@
|
||||
var columns = settings.aoColumns;
|
||||
var column;
|
||||
var i, j, ien, jen, filterData, cellData, row;
|
||||
var fomatters = DataTable.ext.ofnSearch;
|
||||
var fomatters = DataTable.ext.type.filter;
|
||||
var wasInvalidated = false;
|
||||
|
||||
for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
|
||||
@ -2762,7 +2762,7 @@
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Note that most of the paging logic is done in
|
||||
* DataTable.ext.oPagination
|
||||
* DataTable.ext.pager
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -2780,7 +2780,7 @@
|
||||
|
||||
var
|
||||
type = settings.sPaginationType,
|
||||
plugin = DataTable.ext.oPagination[ type ],
|
||||
plugin = DataTable.ext.pager[ type ],
|
||||
modern = typeof plugin === 'function',
|
||||
redraw = function( settings ) {
|
||||
_fnDraw( settings );
|
||||
@ -2811,7 +2811,7 @@
|
||||
i, ien;
|
||||
|
||||
for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
|
||||
_fnRenderer( settings, 'paging' )(
|
||||
_fnRenderer( settings, 'pageButton' )(
|
||||
settings, features.p[i], i, buttons, page, pages
|
||||
);
|
||||
}
|
||||
@ -3882,7 +3882,7 @@
|
||||
dir: nestedSort[i][1],
|
||||
index: nestedSort[i][2],
|
||||
type: sType,
|
||||
formatter: DataTable.ext.oSort[ sType+"-pre" ]
|
||||
formatter: DataTable.ext.type.sort[ sType+"-pre" ]
|
||||
} );
|
||||
}
|
||||
}
|
||||
@ -3903,7 +3903,7 @@
|
||||
sDataType, nTh,
|
||||
aSort = [],
|
||||
aiOrig = [],
|
||||
oExtSort = DataTable.ext.oSort,
|
||||
oExtSort = DataTable.ext.type.sort,
|
||||
aoData = oSettings.aoData,
|
||||
aoColumns = oSettings.aoColumns,
|
||||
aDataSort, data, iCol, sType, oSort,
|
||||
@ -4197,7 +4197,7 @@
|
||||
{
|
||||
// Custom sorting function - provided by the sort data type
|
||||
var column = settings.aoColumns[ idx ];
|
||||
var customSort = DataTable.ext.afnSortData[ column.sSortDataType ];
|
||||
var customSort = DataTable.ext.sort[ column.sSortDataType ];
|
||||
var customData;
|
||||
|
||||
if ( customSort ) {
|
||||
@ -4208,7 +4208,7 @@
|
||||
|
||||
// Use / populate cache
|
||||
var row, cellData;
|
||||
var formatter = DataTable.ext.oSort[ column.sType+"-pre" ];
|
||||
var formatter = DataTable.ext.type.sort[ column.sType+"-pre" ];
|
||||
|
||||
for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
|
||||
row = settings.aoData[i];
|
||||
@ -4368,7 +4368,11 @@
|
||||
}
|
||||
|
||||
if ( ! level ) {
|
||||
if ( DataTable.ext.sErrMode == 'alert' ) {
|
||||
// Backwards compatibility pre 1.10
|
||||
var ext = DataTable.ext;
|
||||
var type = ext.sErrMode || ext.errMode;
|
||||
|
||||
if ( type == 'alert' ) {
|
||||
alert( msg );
|
||||
}
|
||||
else {
|
||||
@ -5337,14 +5341,14 @@
|
||||
* Create a wrapper function for exporting an internal functions to an external API.
|
||||
* @param {string} sFunc API function name
|
||||
* @returns {function} wrapped function
|
||||
* @memberof DataTable#oApi
|
||||
* @memberof DataTable#internal
|
||||
*/
|
||||
function _fnExternApiFunc (sFunc)
|
||||
{
|
||||
return function() {
|
||||
var aArgs = [_fnSettingsFromNode(this[DataTable.ext.iApiIndex])].concat(
|
||||
Array.prototype.slice.call(arguments) );
|
||||
return DataTable.ext.oApi[sFunc].apply( this, aArgs );
|
||||
return DataTable.ext.internal[sFunc].apply( this, aArgs );
|
||||
};
|
||||
}
|
||||
|
||||
@ -5356,7 +5360,7 @@
|
||||
* (check the upgrade notes).
|
||||
* @namespace
|
||||
*/
|
||||
this.oApi = {
|
||||
this.internal = {
|
||||
"_fnExternApiFunc": _fnExternApiFunc,
|
||||
"_fnInitialise": _fnInitialise,
|
||||
"_fnInitComplete": _fnInitComplete,
|
||||
@ -5438,9 +5442,9 @@
|
||||
"_fnAjaxDataSrc": _fnAjaxDataSrc
|
||||
};
|
||||
|
||||
$.extend( DataTable.ext.oApi, this.oApi );
|
||||
$.extend( DataTable.ext.internal, this.internal );
|
||||
|
||||
for ( var sFunc in DataTable.ext.oApi )
|
||||
for ( var sFunc in DataTable.ext.internal )
|
||||
{
|
||||
if ( sFunc )
|
||||
{
|
||||
@ -5518,7 +5522,7 @@
|
||||
/* Ensure the table has an ID - required for accessibility */
|
||||
if ( sId === null || sId === "" )
|
||||
{
|
||||
sId = "DataTables_Table_"+(DataTable.ext._oExternConfig.iNextUnique++);
|
||||
sId = "DataTables_Table_"+(DataTable.ext._unique++);
|
||||
this.id = sId;
|
||||
}
|
||||
|
||||
@ -5637,7 +5641,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$.extend( oSettings.oClasses, DataTable.ext.oStdClasses, oInit.oClasses );
|
||||
$.extend( oSettings.oClasses, DataTable.ext.classes, oInit.oClasses );
|
||||
}
|
||||
$(this).addClass( oSettings.oClasses.sTable );
|
||||
|
||||
@ -8423,424 +8427,6 @@
|
||||
DataTable.models = {};
|
||||
|
||||
|
||||
/**
|
||||
* DataTables extension options and plug-ins. This namespace acts as a collection "area"
|
||||
* for plug-ins that can be used to extend the default DataTables behaviour - indeed many
|
||||
* of the build in methods use this method to provide their own capabilities (sorting methods
|
||||
* for example).
|
||||
*
|
||||
* Note that this namespace is aliased to jQuery.fn.dataTableExt so it can be readily accessed
|
||||
* and modified by plug-ins.
|
||||
* @namespace
|
||||
*/
|
||||
DataTable.models.ext = {
|
||||
/**
|
||||
* Plug-in filtering functions - this method of filtering is complimentary to the default
|
||||
* type based filtering, and a lot more comprehensive as it allows you complete control
|
||||
* over the filtering logic. Each element in this array is a function (parameters
|
||||
* described below) that is called for every row in the table, and your logic decides if
|
||||
* it should be included in the filtered data set or not.
|
||||
* <ul>
|
||||
* <li>
|
||||
* Function input parameters:
|
||||
* <ul>
|
||||
* <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
|
||||
* <li>{array|object} Data for the row to be processed (same as the original format
|
||||
* that was passed in as the data source, or an array from a DOM data source</li>
|
||||
* <li>{int} Row index in aoData ({@link DataTable.models.oSettings.aoData}), which can
|
||||
* be useful to retrieve the TR element if you need DOM interaction.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>
|
||||
* Function return:
|
||||
* <ul>
|
||||
* <li>{boolean} Include the row in the filtered result set (true) or not (false)</li>
|
||||
* </ul>
|
||||
* </il>
|
||||
* </ul>
|
||||
* @type array
|
||||
* @default []
|
||||
*
|
||||
* @example
|
||||
* // The following example shows custom filtering being applied to the fourth column (i.e.
|
||||
* // the aData[3] index) based on two input values from the end-user, matching the data in
|
||||
* // a certain range.
|
||||
* $.fn.dataTableExt.afnFiltering.push(
|
||||
* function( oSettings, aData, iDataIndex ) {
|
||||
* var iMin = document.getElementById('min').value * 1;
|
||||
* var iMax = document.getElementById('max').value * 1;
|
||||
* var iVersion = aData[3] == "-" ? 0 : aData[3]*1;
|
||||
* if ( iMin == "" && iMax == "" ) {
|
||||
* return true;
|
||||
* }
|
||||
* else if ( iMin == "" && iVersion < iMax ) {
|
||||
* return true;
|
||||
* }
|
||||
* else if ( iMin < iVersion && "" == iMax ) {
|
||||
* return true;
|
||||
* }
|
||||
* else if ( iMin < iVersion && iVersion < iMax ) {
|
||||
* return true;
|
||||
* }
|
||||
* return false;
|
||||
* }
|
||||
* );
|
||||
*/
|
||||
"afnFiltering": [],
|
||||
|
||||
|
||||
/**
|
||||
* Plug-in sorting functions - this method of sorting is complimentary to the default type
|
||||
* based sorting that DataTables does automatically, allowing much greater control over the
|
||||
* the data that is being used to sort a column. This is useful if you want to do sorting
|
||||
* based on live data (for example the contents of an 'input' element) rather than just the
|
||||
* static string that DataTables knows of. The way these plug-ins work is that you create
|
||||
* an array of the values you wish to be sorted for the column in question and then return
|
||||
* that array. Which pre-sorting function is run here depends on the sSortDataType parameter
|
||||
* that is used for the column (if any). This is the corollary of <i>ofnSearch</i> for sort
|
||||
* data.
|
||||
* <ul>
|
||||
* <li>
|
||||
* Function input parameters:
|
||||
* <ul>
|
||||
* <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
|
||||
* <li>{int} Target column index</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>
|
||||
* Function return:
|
||||
* <ul>
|
||||
* <li>{array} Data for the column to be sorted upon</li>
|
||||
* </ul>
|
||||
* </il>
|
||||
* </ul>
|
||||
*
|
||||
* Note that as of v1.9, it is typically preferable to use <i>mData</i> to prepare data for
|
||||
* the different uses that DataTables can put the data to. Specifically <i>mData</i> when
|
||||
* used as a function will give you a 'type' (sorting, filtering etc) that you can use to
|
||||
* prepare the data as required for the different types. As such, this method is deprecated.
|
||||
* @type array
|
||||
* @default []
|
||||
* @deprecated
|
||||
*
|
||||
* @example
|
||||
* // Updating the cached sorting information with user entered values in HTML input elements
|
||||
* jQuery.fn.dataTableExt.afnSortData['dom-text'] = function ( oSettings, iColumn )
|
||||
* {
|
||||
* var aData = [];
|
||||
* $( 'td:eq('+iColumn+') input', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
|
||||
* aData.push( this.value );
|
||||
* } );
|
||||
* return aData;
|
||||
* }
|
||||
*/
|
||||
"afnSortData": [],
|
||||
|
||||
|
||||
/**
|
||||
* Feature plug-ins - This is an array of objects which describe the feature plug-ins that are
|
||||
* available to DataTables. These feature plug-ins are accessible through the sDom initialisation
|
||||
* option. As such, each feature plug-in must describe a function that is used to initialise
|
||||
* itself (fnInit), a character so the feature can be enabled by sDom (cFeature) and the name
|
||||
* of the feature (sFeature). Thus the objects attached to this method must provide:
|
||||
* <ul>
|
||||
* <li>{function} fnInit Initialisation of the plug-in
|
||||
* <ul>
|
||||
* <li>
|
||||
* Function input parameters:
|
||||
* <ul>
|
||||
* <li>{object} DataTables settings object: see {@link DataTable.models.oSettings}.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>
|
||||
* Function return:
|
||||
* <ul>
|
||||
* <li>{node|null} The element which contains your feature. Note that the return
|
||||
* may also be void if your plug-in does not require to inject any DOM elements
|
||||
* into DataTables control (sDom) - for example this might be useful when
|
||||
* developing a plug-in which allows table control via keyboard entry.</li>
|
||||
* </ul>
|
||||
* </il>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>{character} cFeature Character that will be matched in sDom - case sensitive</li>
|
||||
* <li>{string} sFeature Feature name</li>
|
||||
* </ul>
|
||||
* @type array
|
||||
* @default []
|
||||
*
|
||||
* @example
|
||||
* // How TableTools initialises itself.
|
||||
* $.fn.dataTableExt.aoFeatures.push( {
|
||||
* "fnInit": function( oSettings ) {
|
||||
* return new TableTools( { "oDTSettings": oSettings } );
|
||||
* },
|
||||
* "cFeature": "T",
|
||||
* "sFeature": "TableTools"
|
||||
* } );
|
||||
*/
|
||||
"aoFeatures": [],
|
||||
|
||||
|
||||
/**
|
||||
* Type detection plug-in functions - DataTables utilises types to define how sorting and
|
||||
* filtering behave, and types can be either be defined by the developer (sType for the
|
||||
* column) or they can be automatically detected by the methods in this array. The functions
|
||||
* defined in the array are quite simple, taking a single parameter (the data to analyse)
|
||||
* and returning the type if it is a known type, or null otherwise.
|
||||
*
|
||||
* * Function input parameters:
|
||||
* * {*} Data from the column cell to be analysed
|
||||
* * Function return:
|
||||
* * {string|null} Data type detected, or null if unknown (and thus pass it
|
||||
* on to the other type detection functions.
|
||||
*
|
||||
* @type array
|
||||
* @default []
|
||||
*
|
||||
* @example
|
||||
* // Currency type detection plug-in:
|
||||
* jQuery.fn.dataTableExt.aTypes.push(
|
||||
* function ( data ) {
|
||||
* // Check the numeric part
|
||||
* if ( ! $.isNumeric( data.substring(1) ) ) {
|
||||
* return null;
|
||||
* }
|
||||
*
|
||||
* // Check prefixed by currency
|
||||
* if ( data.charAt(0) == '$' || data.charAt(0) == '£' ) {
|
||||
* return 'currency';
|
||||
* }
|
||||
* return null;
|
||||
* }
|
||||
* );
|
||||
*/
|
||||
"aTypes": [],
|
||||
|
||||
|
||||
/**
|
||||
* Provide a common method for plug-ins to check the version of DataTables being used,
|
||||
* in order to ensure compatibility.
|
||||
* @type function
|
||||
* @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note
|
||||
* that the formats "X" and "X.Y" are also acceptable.
|
||||
* @returns {boolean} true if this version of DataTables is greater or equal to the
|
||||
* required version, or false if this version of DataTales is not suitable
|
||||
*
|
||||
* @example
|
||||
* $(document).ready(function() {
|
||||
* var oTable = $('#example').dataTable();
|
||||
* alert( oTable.fnVersionCheck( '1.9.0' ) );
|
||||
* } );
|
||||
*/
|
||||
"fnVersionCheck": DataTable.fnVersionCheck,
|
||||
|
||||
|
||||
/**
|
||||
* Index for what 'this' index API functions should use
|
||||
* @type int
|
||||
* @default 0
|
||||
*/
|
||||
"iApiIndex": 0,
|
||||
|
||||
|
||||
/**
|
||||
* Pre-processing of filtering data plug-ins - When you assign the sType for a column
|
||||
* (or have it automatically detected for you by DataTables or a type detection plug-in),
|
||||
* you will typically be using this for custom sorting, but it can also be used to provide
|
||||
* custom filtering by allowing you to pre-processing the data and returning the data in
|
||||
* the format that should be filtered upon. This is done by adding functions this object
|
||||
* with a parameter name which matches the sType for that target column. This is the
|
||||
* corollary of <i>afnSortData</i> for filtering data.
|
||||
* <ul>
|
||||
* <li>
|
||||
* Function input parameters:
|
||||
* <ul>
|
||||
* <li>{*} Data from the column cell to be prepared for filtering</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>
|
||||
* Function return:
|
||||
* <ul>
|
||||
* <li>{string|null} Formatted string that will be used for the filtering.</li>
|
||||
* </ul>
|
||||
* </il>
|
||||
* </ul>
|
||||
*
|
||||
* Note that as of v1.9, it is typically preferable to use <i>mData</i> to prepare data for
|
||||
* the different uses that DataTables can put the data to. Specifically <i>mData</i> when
|
||||
* used as a function will give you a 'type' (sorting, filtering etc) that you can use to
|
||||
* prepare the data as required for the different types. As such, this method is deprecated.
|
||||
* @type object
|
||||
* @default {}
|
||||
* @deprecated
|
||||
*
|
||||
* @example
|
||||
* $.fn.dataTableExt.ofnSearch['title-numeric'] = function ( sData ) {
|
||||
* return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
|
||||
* }
|
||||
*/
|
||||
"ofnSearch": {},
|
||||
|
||||
|
||||
/**
|
||||
* Container for all private functions in DataTables so they can be exposed externally
|
||||
* @type object
|
||||
* @default {}
|
||||
*/
|
||||
"oApi": {},
|
||||
|
||||
|
||||
/**
|
||||
* Storage for the various classes that DataTables uses
|
||||
* @type object
|
||||
* @default {}
|
||||
*/
|
||||
"oStdClasses": {},
|
||||
|
||||
|
||||
/**
|
||||
* Storage for the various classes that DataTables uses - jQuery UI suitable
|
||||
* @type object
|
||||
* @default {}
|
||||
*/
|
||||
"oJUIClasses": {},
|
||||
|
||||
|
||||
/**
|
||||
* Pagination plug-in methods. Each entry in this object is a function
|
||||
* and defines which buttons should be shown by pagination rendering method
|
||||
* that is used for the table: {@link DataTable.ext.renderer.paging}. The
|
||||
* renderer addresses how the buttons are displayed in the document, while
|
||||
* the functions here tell it what buttons to display, in order by returning
|
||||
* an array of button descriptions (what each button will down).
|
||||
*
|
||||
* Pagination types (the four built in options and any additional plug-in
|
||||
* options) and be used through the `paginationType` initialisation
|
||||
* parameter.
|
||||
*
|
||||
* The functions defined take two parameters:
|
||||
*
|
||||
* 1. `{int} page` The current page index
|
||||
* 2. `{int} pages` The number of pages in the table
|
||||
*
|
||||
* Each function is expected to return an array where each element of the
|
||||
* array can be one of:
|
||||
*
|
||||
* * `first` - Jump to first page when activated
|
||||
* * `last` - Jump to last page when activated
|
||||
* * `previous` - Show previous page when activated
|
||||
* * `next` - Show next page when activated
|
||||
* * `{int}` - Show page of the index given
|
||||
* * `{array}` - A nested array containing the above elements to add a
|
||||
* containing 'DIV' element (might be useful for styling).
|
||||
*
|
||||
* Note that DataTables v1.9- used this object slightly differently whereby
|
||||
* an object with two functions would be defined for each plug-in. That
|
||||
* ability is still supported by DataTables 1.10+ to provide backwards
|
||||
* compatibility, but this option of use is now decremented and no longer
|
||||
* documented in DataTables 1.10+.
|
||||
*
|
||||
* @type object
|
||||
* @default {}
|
||||
*
|
||||
* @example
|
||||
* // Show previous, next and current page buttons only
|
||||
* $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
|
||||
* return [ 'previous', page, 'next' ];
|
||||
* };
|
||||
*/
|
||||
"oPagination": {},
|
||||
|
||||
|
||||
/**
|
||||
* Sorting plug-in methods - Sorting in DataTables is based on the detected type of the
|
||||
* data column (you can add your own type detection functions, or override automatic
|
||||
* detection using sType). With this specific type given to the column, DataTables will
|
||||
* apply the required sort from the functions in the object. Each sort type must provide
|
||||
* two mandatory methods, one each for ascending and descending sorting, and can optionally
|
||||
* provide a pre-formatting method that will help speed up sorting by allowing DataTables
|
||||
* to pre-format the sort data only once (rather than every time the actual sort functions
|
||||
* are run). The two sorting functions are typical Javascript sort methods:
|
||||
* <ul>
|
||||
* <li>
|
||||
* Function input parameters:
|
||||
* <ul>
|
||||
* <li>{*} Data to compare to the second parameter</li>
|
||||
* <li>{*} Data to compare to the first parameter</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>
|
||||
* Function return:
|
||||
* <ul>
|
||||
* <li>{int} Sorting match: <0 if first parameter should be sorted lower than
|
||||
* the second parameter, ===0 if the two parameters are equal and >0 if
|
||||
* the first parameter should be sorted height than the second parameter.</li>
|
||||
* </ul>
|
||||
* </il>
|
||||
* </ul>
|
||||
* @type object
|
||||
* @default {}
|
||||
*
|
||||
* @example
|
||||
* // Case-sensitive string sorting, with no pre-formatting method
|
||||
* $.extend( $.fn.dataTableExt.oSort, {
|
||||
* "string-case-asc": function(x,y) {
|
||||
* return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
* },
|
||||
* "string-case-desc": function(x,y) {
|
||||
* return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
* }
|
||||
* } );
|
||||
*
|
||||
* @example
|
||||
* // Case-insensitive string sorting, with pre-formatting
|
||||
* $.extend( $.fn.dataTableExt.oSort, {
|
||||
* "string-pre": function(x) {
|
||||
* return x.toLowerCase();
|
||||
* },
|
||||
* "string-asc": function(x,y) {
|
||||
* return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
* },
|
||||
* "string-desc": function(x,y) {
|
||||
* return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
* }
|
||||
* } );
|
||||
*/
|
||||
"oSort": {},
|
||||
|
||||
|
||||
/**
|
||||
* Version string for plug-ins to check compatibility. Allowed format is
|
||||
* a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and
|
||||
* e are optional
|
||||
* @type string
|
||||
* @default Version number
|
||||
*/
|
||||
"sVersion": DataTable.version,
|
||||
|
||||
|
||||
/**
|
||||
* How should DataTables report an error. Can take the value 'alert' or 'throw'
|
||||
* @type string
|
||||
* @default alert
|
||||
*/
|
||||
"sErrMode": "alert",
|
||||
|
||||
|
||||
/**
|
||||
* Store information for DataTables to access globally about other instances
|
||||
* @namespace
|
||||
* @private
|
||||
*/
|
||||
"_oExternConfig": {
|
||||
/* int:iNextUnique - next unique number for an instance */
|
||||
"iNextUnique": 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Template object for the way in which DataTables holds information about
|
||||
@ -13197,10 +12783,478 @@
|
||||
* @namespace
|
||||
* @extends DataTable.models.ext
|
||||
*/
|
||||
DataTable.ext = $.extend( true, {}, DataTable.models.ext );
|
||||
DataTable.ext.renderer = {};
|
||||
|
||||
$.extend( DataTable.ext.oStdClasses, {
|
||||
|
||||
/**
|
||||
* DataTables extensions
|
||||
*
|
||||
* This namespace acts as a collection area for plug-ins that can be used to
|
||||
* extend DataTables capabilities. Indeed many of the build in methods
|
||||
* use this method to provide their own capabilities (sorting methods for
|
||||
* example).
|
||||
*
|
||||
* Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
|
||||
* reasons
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
DataTable.ext = {
|
||||
/**
|
||||
* Element class names
|
||||
*
|
||||
* @type object
|
||||
* @default {}
|
||||
*/
|
||||
classes: {},
|
||||
|
||||
|
||||
/**
|
||||
* Error reporting.
|
||||
*
|
||||
* How should DataTables report an error. Can take the value 'alert' or
|
||||
* 'throw'
|
||||
*
|
||||
* @type string
|
||||
* @default alert
|
||||
*/
|
||||
errMode: "alert",
|
||||
|
||||
|
||||
/**
|
||||
* Feature plug-ins.
|
||||
*
|
||||
* This is an array of objects which describe the feature plug-ins that are
|
||||
* available to DataTables. These feature plug-ins are then available for
|
||||
* use through the `dom` initialisation option.
|
||||
*
|
||||
* Each feature plug-in is described by an object which must have the
|
||||
* following properties:
|
||||
*
|
||||
* * `fnInit` - function that is used to initialise the plug-in,
|
||||
* * `cFeature` - a character so the feature can be enabled by the `dom`
|
||||
* instillation option. This is case sensitive.
|
||||
*
|
||||
* The `fnInit` function has the following input parameters:
|
||||
*
|
||||
* 1. `{object}` DataTables settings object: see
|
||||
* {@link DataTable.models.oSettings}
|
||||
*
|
||||
* And the following return is expected:
|
||||
*
|
||||
* * {node|null} The element which contains your feature. Note that the
|
||||
* return may also be void if your plug-in does not require to inject any
|
||||
* DOM elements into DataTables control (`dom`) - for example this might
|
||||
* be useful when developing a plug-in which allows table control via
|
||||
* keyboard entry
|
||||
*
|
||||
* @type array
|
||||
*
|
||||
* @example
|
||||
* $.fn.dataTable.ext.features.push( {
|
||||
* "fnInit": function( oSettings ) {
|
||||
* return new TableTools( { "oDTSettings": oSettings } );
|
||||
* },
|
||||
* "cFeature": "T"
|
||||
* } );
|
||||
*/
|
||||
feature: [],
|
||||
|
||||
|
||||
/**
|
||||
* Row filtering.
|
||||
*
|
||||
* This method of filtering is complimentary to the default type based
|
||||
* filtering, and a lot more comprehensive as it allows you complete control
|
||||
* over the filtering logic. Each element in this array is a function
|
||||
* (parameters described below) that is called for every row in the table,
|
||||
* and your logic decides if it should be included in the filtered data set
|
||||
* or not.
|
||||
*
|
||||
* Filtering functions have the following input parameters:
|
||||
*
|
||||
* 1. `{object}` DataTables settings object: see
|
||||
* {@link DataTable.models.oSettings}
|
||||
* 2. `{array|object}` Data for the row to be processed (same as the
|
||||
* original format that was passed in as the data source, or an array
|
||||
* from a DOM data source
|
||||
* 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
|
||||
* can be useful to retrieve the `TR` element if you need DOM interaction.
|
||||
*
|
||||
* And the following return is expected:
|
||||
*
|
||||
* * {boolean} Include the row in the filtered result set (true) or not
|
||||
* (false)
|
||||
*
|
||||
* @type array
|
||||
* @default []
|
||||
*
|
||||
* @example
|
||||
* // The following example shows custom filtering being applied to the
|
||||
* // fourth column (i.e. the data[3] index) based on two input values
|
||||
* // from the end-user, matching the data in a certain range.
|
||||
* $.fn.dataTable.ext.filter.push(
|
||||
* function( settings, data, dataIndex ) {
|
||||
* var min = document.getElementById('min').value * 1;
|
||||
* var max = document.getElementById('max').value * 1;
|
||||
* var version = data[3] == "-" ? 0 : data[3]*1;
|
||||
*
|
||||
* if ( min == "" && max == "" ) {
|
||||
* return true;
|
||||
* }
|
||||
* else if ( min == "" && version < max ) {
|
||||
* return true;
|
||||
* }
|
||||
* else if ( min < version && "" == max ) {
|
||||
* return true;
|
||||
* }
|
||||
* else if ( min < version && version < max ) {
|
||||
* return true;
|
||||
* }
|
||||
* return false;
|
||||
* }
|
||||
* );
|
||||
*/
|
||||
filter: [],
|
||||
|
||||
|
||||
/**
|
||||
* Internal functions, exposed for used in plug-ins.
|
||||
*
|
||||
* Please note that you should not need to use the internal methods for
|
||||
* anything other than a plug-in (and even then, try to avoid if possible).
|
||||
* The internal function may change between releases.
|
||||
*
|
||||
* externally
|
||||
* @type object
|
||||
* @default {}
|
||||
*/
|
||||
internal: {},
|
||||
|
||||
|
||||
/**
|
||||
* Pagination plug-in methods.
|
||||
*
|
||||
* Each entry in this object is a function and defines which buttons should
|
||||
* be shown by the pagination rendering method that is used for the table:
|
||||
* {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
|
||||
* buttons are displayed in the document, while the functions here tell it
|
||||
* what buttons to display. This is done by returning an array of button
|
||||
* descriptions (what each button will do).
|
||||
*
|
||||
* Pagination types (the four built in options and any additional plug-in
|
||||
* options defined here) can be used through the `paginationType`
|
||||
* initialisation parameter.
|
||||
*
|
||||
* The functions defined take two parameters:
|
||||
*
|
||||
* 1. `{int} page` The current page index
|
||||
* 2. `{int} pages` The number of pages in the table
|
||||
*
|
||||
* Each function is expected to return an array where each element of the
|
||||
* array can be one of:
|
||||
*
|
||||
* * `first` - Jump to first page when activated
|
||||
* * `last` - Jump to last page when activated
|
||||
* * `previous` - Show previous page when activated
|
||||
* * `next` - Show next page when activated
|
||||
* * `{int}` - Show page of the index given
|
||||
* * `{array}` - A nested array containing the above elements to add a
|
||||
* containing 'DIV' element (might be useful for styling).
|
||||
*
|
||||
* Note that DataTables v1.9- used this object slightly differently whereby
|
||||
* an object with two functions would be defined for each plug-in. That
|
||||
* ability is still supported by DataTables 1.10+ to provide backwards
|
||||
* compatibility, but this option of use is now decremented and no longer
|
||||
* documented in DataTables 1.10+.
|
||||
*
|
||||
* @type object
|
||||
* @default {}
|
||||
*
|
||||
* @example
|
||||
* // Show previous, next and current page buttons only
|
||||
* $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
|
||||
* return [ 'previous', page, 'next' ];
|
||||
* };
|
||||
*/
|
||||
pager: {},
|
||||
|
||||
|
||||
renderer: {
|
||||
pageButton: {},
|
||||
header: {}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Sorting plug-ins - custom data source
|
||||
*
|
||||
* The extension options for sorting of data available here is complimentary
|
||||
* to the default type based sorting that DataTables typically uses. It
|
||||
* allows much greater control over the the data that is being used to
|
||||
* sort a column, but is necessarily therefore more complex.
|
||||
*
|
||||
* This type of sorting is useful if you want to do sorting based on data
|
||||
* live from the DOM (for example the contents of an 'input' element) rather
|
||||
* than just the static string that DataTables knows of.
|
||||
*
|
||||
* The way these plug-ins work is that you create an array of the values you
|
||||
* wish to be sorted for the column in question and then return that array.
|
||||
* The data in the array much be in the index order of the rows in the table
|
||||
* (not the currently sorted order!). Which sort data gathering function is
|
||||
* run here depends on the `sortDataType` parameter that is used for the
|
||||
* column (if any).
|
||||
*
|
||||
* The functions defined take two parameters:
|
||||
*
|
||||
* 1. `{object}` DataTables settings object: see
|
||||
* {@link DataTable.models.oSettings}
|
||||
* 2. `{int}` Target column index
|
||||
*
|
||||
* Each function is expected to return an array:
|
||||
*
|
||||
* * `{array}` Data for the column to be sorted upon
|
||||
*
|
||||
* @type array
|
||||
*
|
||||
* @example
|
||||
* // Sort using `input` node values
|
||||
* $.fn.dataTable.ext.sort['dom-text'] = function ( settings, col )
|
||||
* {
|
||||
* return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
|
||||
* return $('input', td).val();
|
||||
* } );
|
||||
* }
|
||||
*/
|
||||
sort: [],
|
||||
|
||||
|
||||
/**
|
||||
* Type based plug-ins.
|
||||
*
|
||||
* Each column in DataTables has a type assigned to it, either by automatic
|
||||
* detection or by direct assignment using the `type` option for the column.
|
||||
* The type of a column will effect how it is sorted and filtered (plug-ins
|
||||
* can also make use of the column type if required).
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
type: {
|
||||
/**
|
||||
* Type detection functions.
|
||||
*
|
||||
* The functions defined in this object are used to automatically detect
|
||||
* a column's type, making initialisation of DataTables super easy, even
|
||||
* when complex data is in the table.
|
||||
*
|
||||
* The functions defined take a single parameter:
|
||||
*
|
||||
* 1. `{*}` Data from the column cell to be analysed
|
||||
*
|
||||
* Each function is expected to return:
|
||||
*
|
||||
* * `{string|null}` Data type detected, or null if unknown (and thus
|
||||
* pass it on to the other type detection functions.
|
||||
*
|
||||
* @type array
|
||||
*
|
||||
* @example
|
||||
* // Currency type detection plug-in:
|
||||
* $.fn.dataTable.ext.type.detect.push(
|
||||
* function ( data ) {
|
||||
* // Check the numeric part
|
||||
* if ( ! $.isNumeric( data.substring(1) ) ) {
|
||||
* return null;
|
||||
* }
|
||||
*
|
||||
* // Check prefixed by currency
|
||||
* if ( data.charAt(0) == '$' || data.charAt(0) == '£' ) {
|
||||
* return 'currency';
|
||||
* }
|
||||
* return null;
|
||||
* }
|
||||
* );
|
||||
*/
|
||||
detect: [],
|
||||
|
||||
|
||||
/**
|
||||
* Type based filter formatting.
|
||||
*
|
||||
* The type based filtering functions can be used to pre-format the
|
||||
* data to be filtered up. For example, it can be used to strip HTML
|
||||
* tags or to de-format telephone numbers for numeric only filtering.
|
||||
*
|
||||
* Note that is a filter is not defined for a column of a given type,
|
||||
* no filter formatting will be performed.
|
||||
*
|
||||
* Pre-processing of filtering data plug-ins - When you assign the sType
|
||||
* for a column (or have it automatically detected for you by DataTables
|
||||
* or a type detection plug-in), you will typically be using this for
|
||||
* custom sorting, but it can also be used to provide custom filtering
|
||||
* by allowing you to pre-processing the data and returning the data in
|
||||
* the format that should be filtered upon. This is done by adding
|
||||
* functions this object with a parameter name which matches the sType
|
||||
* for that target column. This is the corollary of <i>afnSortData</i>
|
||||
* for filtering data.
|
||||
*
|
||||
* The functions defined take a single parameter:
|
||||
*
|
||||
* 1. `{*}` Data from the column cell to be prepared for filtering
|
||||
*
|
||||
* Each function is expected to return:
|
||||
*
|
||||
* * `{string|null}` Formatted string that will be used for the filtering.
|
||||
*
|
||||
* @type object
|
||||
* @default {}
|
||||
*
|
||||
* @example
|
||||
* $.fn.dataTable.ext.type.filter['title-numeric'] = function ( d ) {
|
||||
* return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
|
||||
* }
|
||||
*/
|
||||
filter: {},
|
||||
|
||||
|
||||
/**
|
||||
* Type based sorting.
|
||||
*
|
||||
* The column type tells DataTables what sorting to apply to the table
|
||||
* when a column is sorted upon. The sort for each type that is defined,
|
||||
* is defined by the functions available in this object.
|
||||
*
|
||||
* Each sorting option can be described by three properties added to
|
||||
* this object:
|
||||
*
|
||||
* * `{type}-pre` - Pre-formatting function
|
||||
* * `{type}-asc` - Ascending sort function
|
||||
* * `{type}-desc` - Descending sort function
|
||||
*
|
||||
* All three can be used together, only `{type}-pre` or only
|
||||
* `{type}-asc` and `{type}-desc` together. It is generally recommended
|
||||
* that only `{type}-pre` is used, as this provides the optimal
|
||||
* implementation in terms of speed, although the others are provided
|
||||
* for compatibility with existing Javascript sort functions.
|
||||
*
|
||||
* `{type}-pre`: Functions defined take a single parameter:
|
||||
*
|
||||
* 1. `{*}` Data from the column cell to be prepared for sorting
|
||||
*
|
||||
* And return:
|
||||
*
|
||||
* * `{*}` Data to be sorted upon
|
||||
*
|
||||
* `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
|
||||
* functions, taking two parameters:
|
||||
*
|
||||
* 1. `{*}` Data to compare to the second parameter
|
||||
* 2. `{*}` Data to compare to the first parameter
|
||||
*
|
||||
* And returning:
|
||||
*
|
||||
* * `{*}` Sorting match: <0 if first parameter should be sorted lower
|
||||
* than the second parameter, ===0 if the two parameters are equal and
|
||||
* >0 if the first parameter should be sorted height than the second
|
||||
* parameter.
|
||||
*
|
||||
* @type object
|
||||
* @default {}
|
||||
*
|
||||
* @example
|
||||
* // Numeric sorting of formatted numbers with a pre-formatter
|
||||
* $.extend( $.fn.dataTable.ext.type.sort, {
|
||||
* "string-pre": function(x) {
|
||||
* a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
|
||||
* return parseFloat( a );
|
||||
* }
|
||||
* } );
|
||||
*
|
||||
* @example
|
||||
* // Case-sensitive string sorting, with no pre-formatting method
|
||||
* $.extend( $.fn.dataTable.ext.sort, {
|
||||
* "string-case-asc": function(x,y) {
|
||||
* return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
||||
* },
|
||||
* "string-case-desc": function(x,y) {
|
||||
* return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
||||
* }
|
||||
* } );
|
||||
*/
|
||||
sort: {}
|
||||
},
|
||||
|
||||
/**
|
||||
* Unique DataTables instance counter
|
||||
*
|
||||
* @type int
|
||||
* @private
|
||||
*/
|
||||
_unqiue: 0,
|
||||
|
||||
|
||||
//
|
||||
// Depreciated
|
||||
// The following properties are retained for backwards compatiblity only.
|
||||
// The should not be used in new projects and will be removed in a future
|
||||
// version
|
||||
//
|
||||
|
||||
/**
|
||||
* Version check function.
|
||||
* @type function
|
||||
* @depreciated Since 1.10
|
||||
*/
|
||||
fnVersionCheck: DataTable.fnVersionCheck,
|
||||
|
||||
|
||||
/**
|
||||
* Index for what 'this' index API functions should use
|
||||
* @type int
|
||||
* @deprecated Since v1.10
|
||||
*/
|
||||
iApiIndex: 0,
|
||||
|
||||
|
||||
/**
|
||||
* jQuery UI class container
|
||||
* @type object
|
||||
* @deprecated Since v1.10
|
||||
*/
|
||||
oJUIClasses: {},
|
||||
|
||||
|
||||
/**
|
||||
* Software version
|
||||
* @type string
|
||||
* @deprecated Since v1.10
|
||||
*/
|
||||
sVersion: DataTable.version
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
|
||||
//
|
||||
(function () {
|
||||
|
||||
var ext = DataTable.ext;
|
||||
|
||||
$.extend( ext, {
|
||||
afnFiltering: ext.filter,
|
||||
aTypes: ext.type.detect,
|
||||
ofnSearch: ext.type.filter,
|
||||
oSort: ext.type.sort,
|
||||
afnSortData: ext.sort,
|
||||
aoFeatures: ext.feature,
|
||||
oApi: ext.internal,
|
||||
oStdClasses: ext.classes,
|
||||
oPagination: ext.pager
|
||||
} );
|
||||
|
||||
}());
|
||||
|
||||
|
||||
$.extend( DataTable.ext.classes, {
|
||||
"sTable": "dataTable",
|
||||
|
||||
/* Paging buttons */
|
||||
@ -13272,7 +13326,7 @@
|
||||
var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
|
||||
var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
|
||||
|
||||
$.extend( DataTable.ext.oJUIClasses, DataTable.ext.oStdClasses, {
|
||||
$.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
|
||||
/* Full numbers paging buttons */
|
||||
"sPageButton": "fg-button ui-button "+_stateDefault,
|
||||
"sPageButtonActive": "ui-state-disabled",
|
||||
@ -13315,7 +13369,7 @@
|
||||
(function() {
|
||||
|
||||
|
||||
var extPagination = DataTable.ext.oPagination;
|
||||
var extPagination = DataTable.ext.pager;
|
||||
|
||||
function _numbers ( page, pages ) {
|
||||
var
|
||||
@ -13374,7 +13428,7 @@
|
||||
|
||||
|
||||
$.extend( true, DataTable.ext.renderer, {
|
||||
paging: {
|
||||
pageButton: {
|
||||
_: function ( settings, host, idx, buttons, page, pages ) {
|
||||
var classes = settings.oClasses;
|
||||
var lang = settings.oLanguage.oPaginate;
|
||||
@ -13462,7 +13516,7 @@
|
||||
|
||||
}());
|
||||
|
||||
$.extend( DataTable.ext.oSort, {
|
||||
$.extend( DataTable.ext.type.sort, {
|
||||
/*
|
||||
* text sorting
|
||||
*/
|
||||
@ -13527,7 +13581,7 @@
|
||||
|
||||
// Built in type detection. See model.ext.aTypes for information about
|
||||
// what is required from this methods.
|
||||
$.extend( DataTable.ext.aTypes, [
|
||||
$.extend( DataTable.ext.type.detect, [
|
||||
// Numeric data type
|
||||
function ( data )
|
||||
{
|
||||
@ -13559,7 +13613,7 @@
|
||||
var __filter_lines = /[\r\n]/g;
|
||||
var __filter_html = /[\r\n]/g;
|
||||
|
||||
$.extend( DataTable.ext.ofnSearch, {
|
||||
$.extend( DataTable.ext.type.filter, {
|
||||
html: function ( data ) {
|
||||
return data
|
||||
.replace( __filter_lines, " " )
|
||||
|
Loading…
x
Reference in New Issue
Block a user