From c491f8a37f6607cfee8c95b4f064d012ac7a9b22 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Thu, 1 Dec 2011 19:47:40 +0000 Subject: [PATCH] Add examples to API methods and tidy up the way oApi is generated a little --- media/js/jquery.dataTables.js | 1467 +++++++++++++++++++-------------- media/src/api/api.internal.js | 166 ++-- media/src/api/api.methods.js | 1281 ++++++++++++++++------------ media/src/ext/ext.js | 22 +- 4 files changed, 1691 insertions(+), 1245 deletions(-) diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index f975290b..2da027b7 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -117,15 +117,19 @@ - /* - * Function: fnVersionCheck - * Purpose: Check a version string against this version of DataTables. Useful for plug-ins - * Returns: bool:true -this version of DataTables is greater or equal to the required version - * false -this version of DataTales is not suitable - * Inputs: string:sVersion - the version to check against. May be in the following formats: - * "a", "a.b" or "a.b.c" - * Notes: This function will only check the first three parts of a version string. It is - * assumed that beta and dev versions will meet the requirements. This might change in future + /** + * Provide a common method for plug-ins to check the version of DataTables being used, in order + * to ensure compatibility. + * @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' ) ); + * } ); */ _oExt.fnVersionCheck = function( sVersion ) { @@ -5318,131 +5322,18 @@ - /* - * Variable: oApi - * Purpose: Container for publicly exposed 'private' functions - * Scope: jQuery.dataTable - */ - this.oApi = {}; - - - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Section - API functions - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /** - * Redraw the table - * @param {bool} [bComplete=true] Refilter and resort (if enabled) the table before the draw. + * Perform a jQuery selector action on the table's TR elements (from the tbody) and + * return the resulting expression + * @param {string} sSelector jQuery selector + * @returns {object} jQuery object */ - this.fnDraw = function( bComplete ) + this.$ = function ( sSelector ) { - var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] ); - if ( typeof bComplete != 'undefined' && bComplete === false ) - { - _fnCalculateEnd( oSettings ); - _fnDraw( oSettings ); - } - else - { - _fnReDraw( oSettings ); - } - }; - - /** - * Filter the input based on data - * @param {string} sInput string to filter the table on - * @param {int|null} [iColumn] column to limit filtering to - * @param {bool} [bRegex=false] treat as regular expression or not - * @param {bool} [bSmart=true] perform smart filtering or not - * @param {bool} [bShowGlobal=true] show the input global filter in it's input box(es) - */ - this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal ) - { - var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] ); - - if ( !oSettings.oFeatures.bFilter ) - { - return; - } - - if ( typeof bRegex == 'undefined' ) - { - bRegex = false; - } - - if ( typeof bSmart == 'undefined' ) - { - bSmart = true; - } - - if ( typeof bShowGlobal == 'undefined' ) - { - bShowGlobal = true; - } - - if ( typeof iColumn == "undefined" || iColumn === null ) - { - /* Global filter */ - _fnFilterComplete( oSettings, { - "sSearch":sInput, - "bRegex": bRegex, - "bSmart": bSmart - }, 1 ); - - if ( bShowGlobal && typeof oSettings.aanFeatures.f != 'undefined' ) - { - var n = oSettings.aanFeatures.f; - for ( var i=0, iLen=n.length ; i