diff --git a/make.sh b/make.sh new file mode 100755 index 00000000..112a7d9f --- /dev/null +++ b/make.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +cd media/src + +cp DataTables.js DataTables.js.build + +IFS='%' + +grep "require(" DataTables.js.build > /dev/null +while [ $? -eq 0 ]; do + REQUIRE=$(grep "require(" DataTables.js.build | head -n 1) + + SPACER=$(echo ${REQUIRE} | cut -d r -f 1) + FILE=$(echo ${REQUIRE} | sed -e "s#^.*require('##g" -e "s#');##") + DIR=$(echo ${FILE} | cut -d \. -f 1) + + echo " $FILE" + + sed "s#^#${SPACER}#" < ${DIR}/${FILE} > ${DIR}/${FILE}.build + + sed -e "/${REQUIRE}/r ${DIR}/${FILE}.build" -e "/${REQUIRE}/d" < DataTables.js.build > DataTables.js.out + mv DataTables.js.out DataTables.js.build + + rm ${DIR}/${FILE}.build + + grep "require(" DataTables.js.build > /dev/null +done + +mv DataTables.js.build ../js/jquery.dataTables.js diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index be4fdd28..7b8a827e 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -28,25 +28,704 @@ /*globals $, jQuery,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageProcess,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnArrayCmp,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn*/ (function($, window, document) { - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Section - DataTables variables - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + var oModels = {}; + var modelInit = { + "a": 1 + }; /* * Variable: dataTableSettings * Purpose: Store the settings for each dataTables instance * Scope: jQuery.fn */ - $.fn.dataTableSettings = []; - var _aoSettings = $.fn.dataTableSettings; /* Short reference for fast internal lookup */ + var _aoSettings = []; /* - * Variable: dataTableExt - * Purpose: Container for customisable parts of DataTables - * Scope: jQuery.fn + * Function: classSettings + * Purpose: Settings container function for all 'class' properties which are required + * by dataTables + * Returns: - + * Inputs: - */ - $.fn.dataTableExt = {}; - var _oExt = $.fn.dataTableExt; + var classSettings = { + + /* + * Variable: oFeatures + * Purpose: Indicate the enablement of key dataTable features + * Scope: jQuery.dataTable.classSettings + */ + oFeatures: { + "bPaginate": true, + "bLengthChange": true, + "bFilter": true, + "bSort": true, + "bInfo": true, + "bAutoWidth": true, + "bProcessing": false, + "bSortClasses": true, + "bStateSave": false, + "bServerSide": false, + "bDeferRender": false + }, + + /* + * Variable: oScroll + * Purpose: Container for scrolling options + * Scope: jQuery.dataTable.classSettings + */ + oScroll: { + "sX": "", + "sXInner": "", + "sY": "", + "bCollapse": false, + "bInfinite": false, + "iLoadGap": 100, + "iBarWidth": 0, + "bAutoCss": true + }, + + /* + * Variable: aanFeatures + * Purpose: Array referencing the nodes which are used for the features + * Scope: jQuery.dataTable.classSettings + * Notes: The parameters of this object match what is allowed by sDom - i.e. + * 'l' - Length changing + * 'f' - Filtering input + * 't' - The table! + * 'i' - Information + * 'p' - Pagination + * 'r' - pRocessing + */ + aanFeatures: [], + + /* + * Variable: oLanguage + * Purpose: Store the language strings used by dataTables + * Scope: jQuery.dataTable.classSettings + * Notes: The words in the format _VAR_ are variables which are dynamically replaced + * by javascript + */ + oLanguage: { + "sProcessing": "Processing...", + "sLengthMenu": "Show _MENU_ entries", + "sZeroRecords": "No matching records found", + "sEmptyTable": "No data available in table", + "sLoadingRecords": "Loading...", + "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries", + "sInfoEmpty": "Showing 0 to 0 of 0 entries", + "sInfoFiltered": "(filtered from _MAX_ total entries)", + "sInfoPostFix": "", + "sInfoThousands": ",", + "sSearch": "Search:", + "sUrl": "", + "oPaginate": { + "sFirst": "First", + "sPrevious": "Previous", + "sNext": "Next", + "sLast": "Last" + }, + "fnInfoCallback": null + }, + + /* + * Variable: aoData + * Purpose: Store data information + * Scope: jQuery.dataTable.classSettings + * Notes: This is an array of objects with the following parameters: + * int: _iId - internal id for tracking + * array: _aData - internal data - used for sorting / filtering etc + * node: nTr - display node + * array node: _anHidden - hidden TD nodes + * string: _sRowStripe + */ + aoData: [], + + /* + * Variable: aiDisplay + * Purpose: Array of indexes which are in the current display (after filtering etc) + * Scope: jQuery.dataTable.classSettings + */ + aiDisplay: [], + + /* + * Variable: aiDisplayMaster + * Purpose: Array of indexes for display - no filtering + * Scope: jQuery.dataTable.classSettings + */ + aiDisplayMaster: [], + + /* + * Variable: aoColumns + * Purpose: Store information about each column that is in use + * Scope: jQuery.dataTable.classSettings + */ + aoColumns: [], + + /* + * Variable: aoHeader + * Purpose: Store information about the table's header + * Scope: jQuery.dataTable.classSettings + */ + aoHeader: [], + + /* + * Variable: aoFooter + * Purpose: Store information about the table's footer + * Scope: jQuery.dataTable.classSettings + */ + aoFooter: [], + + /* + * Variable: iNextId + * Purpose: Store the next unique id to be used for a new row + * Scope: jQuery.dataTable.classSettings + */ + iNextId: 0, + + /* + * Variable: asDataSearch + * Purpose: Search data array for regular expression searching + * Scope: jQuery.dataTable.classSettings + */ + asDataSearch: [], + + /* + * Variable: oPreviousSearch + * Purpose: Store the previous search incase we want to force a re-search + * or compare the old search to a new one + * Scope: jQuery.dataTable.classSettings + */ + oPreviousSearch: { + "sSearch": "", + "bRegex": false, + "bSmart": true + }, + + /* + * Variable: aoPreSearchCols + * Purpose: Store the previous search for each column + * Scope: jQuery.dataTable.classSettings + */ + aoPreSearchCols: [], + + /* + * Variable: aaSorting + * Purpose: Sorting information + * Scope: jQuery.dataTable.classSettings + * Notes: Index 0 - column number + * Index 1 - current sorting direction + * Index 2 - index of asSorting for this column + */ + aaSorting: [ [0, 'asc', 0] ], + + /* + * Variable: aaSortingFixed + * Purpose: Sorting information that is always applied + * Scope: jQuery.dataTable.classSettings + */ + aaSortingFixed: null, + + /* + * Variable: asStripeClasses + * Purpose: Classes to use for the striping of a table + * Scope: jQuery.dataTable.classSettings + */ + asStripeClasses: [], + + /* + * Variable: asDestroyStripes + * Purpose: If restoring a table - we should restore its striping classes as well + * Scope: jQuery.dataTable.classSettings + */ + asDestroyStripes: [], + + /* + * Variable: sDestroyWidth + * Purpose: If restoring a table - we should restore its width + * Scope: jQuery.dataTable.classSettings + */ + sDestroyWidth: 0, + + /* + * Variable: fnRowCallback + * Purpose: Call this function every time a row is inserted (draw) + * Scope: jQuery.dataTable.classSettings + */ + fnRowCallback: null, + + /* + * Variable: fnHeaderCallback + * Purpose: Callback function for the header on each draw + * Scope: jQuery.dataTable.classSettings + */ + fnHeaderCallback: null, + + /* + * Variable: fnFooterCallback + * Purpose: Callback function for the footer on each draw + * Scope: jQuery.dataTable.classSettings + */ + fnFooterCallback: null, + + /* + * Variable: aoDrawCallback + * Purpose: Array of callback functions for draw callback functions + * Scope: jQuery.dataTable.classSettings + * Notes: Each array element is an object with the following parameters: + * function:fn - function to call + * string:sName - name callback (feature). useful for arranging array + */ + aoDrawCallback: [], + + /* + * Variable: fnPreDrawCallback + * Purpose: Callback function for just before the table is redrawn. A return of false + * will be used to cancel the draw. + * Scope: jQuery.dataTable.classSettings + */ + fnPreDrawCallback: null, + + /* + * Variable: fnInitComplete + * Purpose: Callback function for when the table has been initialised + * Scope: jQuery.dataTable.classSettings + */ + fnInitComplete: null, + + /* + * Variable: sTableId + * Purpose: Cache the table ID for quick access + * Scope: jQuery.dataTable.classSettings + */ + sTableId: "", + + /* + * Variable: nTable + * Purpose: Cache the table node for quick access + * Scope: jQuery.dataTable.classSettings + */ + nTable: null, + + /* + * Variable: nTHead + * Purpose: Permanent ref to the thead element + * Scope: jQuery.dataTable.classSettings + */ + nTHead: null, + + /* + * Variable: nTFoot + * Purpose: Permanent ref to the tfoot element - if it exists + * Scope: jQuery.dataTable.classSettings + */ + nTFoot: null, + + /* + * Variable: nTBody + * Purpose: Permanent ref to the tbody element + * Scope: jQuery.dataTable.classSettings + */ + nTBody: null, + + /* + * Variable: nTableWrapper + * Purpose: Cache the wrapper node (contains all DataTables controlled elements) + * Scope: jQuery.dataTable.classSettings + */ + nTableWrapper: null, + + /* + * Variable: bDeferLoading + * Purpose: Indicate if when using server-side processing the loading of data + * should be deferred until the second draw + * Scope: jQuery.dataTable.classSettings + */ + bDeferLoading: false, + + /* + * Variable: bInitialised + * Purpose: Indicate if all required information has been read in + * Scope: jQuery.dataTable.classSettings + */ + bInitialised: false, + + /* + * Variable: aoOpenRows + * Purpose: Information about open rows + * Scope: jQuery.dataTable.classSettings + * Notes: Has the parameters 'nTr' and 'nParent' + */ + aoOpenRows: [], + + /* + * Variable: sDom + * Purpose: Dictate the positioning that the created elements will take + * Scope: jQuery.dataTable.classSettings + * Notes: + * The following options are allowed: + * 'l' - Length changing + * 'f' - Filtering input + * 't' - The table! + * 'i' - Information + * 'p' - Pagination + * 'r' - pRocessing + * The following constants are allowed: + * 'H' - jQueryUI theme "header" classes + * 'F' - jQueryUI theme "footer" classes + * The following syntax is expected: + * '<' and '>' - div elements + * '<"class" and '>' - div with a class + * Examples: + * '<"wrapper"flipt>', 'ip>' + */ + sDom: 'lfrtip', + + /* + * Variable: sPaginationType + * Purpose: Note which type of sorting should be used + * Scope: jQuery.dataTable.classSettings + */ + sPaginationType: "two_button", + + /* + * Variable: iCookieDuration + * Purpose: The cookie duration (for bStateSave) in seconds - default 2 hours + * Scope: jQuery.dataTable.classSettings + */ + iCookieDuration: 60 * 60 * 2, + + /* + * Variable: sCookiePrefix + * Purpose: The cookie name prefix + * Scope: jQuery.dataTable.classSettings + */ + sCookiePrefix: "SpryMedia_DataTables_", + + /* + * Variable: fnCookieCallback + * Purpose: Callback function for cookie creation + * Scope: jQuery.dataTable.classSettings + */ + fnCookieCallback: null, + + /* + * Variable: aoStateSave + * Purpose: Array of callback functions for state saving + * Scope: jQuery.dataTable.classSettings + * Notes: Each array element is an object with the following parameters: + * function:fn - function to call. Takes two parameters, oSettings and the JSON string to + * save that has been thus far created. Returns a JSON string to be inserted into a + * json object (i.e. '"param": [ 0, 1, 2]') + * string:sName - name of callback + */ + aoStateSave: [], + + /* + * Variable: aoStateLoad + * Purpose: Array of callback functions for state loading + * Scope: jQuery.dataTable.classSettings + * Notes: Each array element is an object with the following parameters: + * function:fn - function to call. Takes two parameters, oSettings and the object stored. + * May return false to cancel state loading. + * string:sName - name of callback + */ + aoStateLoad: [], + + /* + * Variable: oLoadedState + * Purpose: State that was loaded from the cookie. Useful for back reference + * Scope: jQuery.dataTable.classSettings + */ + oLoadedState: null, + + /* + * Variable: sAjaxSource + * Purpose: Source url for AJAX data for the table + * Scope: jQuery.dataTable.classSettings + */ + sAjaxSource: null, + + /* + * Variable: sAjaxDataProp + * Purpose: Property from a given object from which to read the table data from. This can + * be an empty string (when not server-side processing), in which case it is + * assumed an an array is given directly. + * Scope: jQuery.dataTable.classSettings + */ + sAjaxDataProp: 'aaData', + + /* + * Variable: bAjaxDataGet + * Purpose: Note if draw should be blocked while getting data + * Scope: jQuery.dataTable.classSettings + */ + bAjaxDataGet: true, + + /* + * Variable: jqXHR + * Purpose: The last jQuery XHR object that was used for server-side data gathering. + * This can be used for working with the XHR information in one of the callbacks + * Scope: jQuery.dataTable.classSettings + */ + jqXHR: null, + + /* + * Variable: fnServerData + * Purpose: Function to get the server-side data - can be overruled by the developer + * Scope: jQuery.dataTable.classSettings + */ + fnServerData: function ( url, data, callback, settings ) { + settings.jqXHR = $.ajax( { + "url": url, + "data": data, + "success": function (json) { + $(settings.oInstance).trigger('xhr', settings); + callback( json ); + }, + "dataType": "json", + "cache": false, + "type": settings.sServerMethod, + "error": function (xhr, error, thrown) { + if ( error == "parsererror" ) { + alert( "DataTables warning: JSON data from server could not be parsed. "+ + "This is caused by a JSON formatting error." ); + } + } + } ); + }, + + /* + * Variable: aoServerParams + * Purpose: Functions which are called prior to sending an Ajax request so extra parameters + * can easily be sent to the server + * Scope: jQuery.dataTable.classSettings + * Notes: Each array element is an object with the following parameters: + * function:fn - function to call + * string:sName - name callback - useful for knowing where it came from (plugin etc) + */ + aoServerParams: [], + + /* + * Variable: sServerType + * Purpose: Send the XHR HTTP method - GET or POST (could be PUT or DELETE if required) + * Scope: jQuery.dataTable.classSettings + */ + sServerMethod: "GET", + + /* + * Variable: fnFormatNumber + * Purpose: Format numbers for display + * Scope: jQuery.dataTable.classSettings + */ + fnFormatNumber: function ( iIn ) + { + if ( iIn < 1000 ) + { + /* A small optimisation for what is likely to be the vast majority of use cases */ + return iIn; + } + else + { + var s=(iIn+""), a=s.split(""), out="", iLen=s.length; + + for ( var i=0 ; i= parseInt(sThat, 10); + }; + + /* + * Variable: _oExternConfig + * Purpose: Store information for DataTables to access globally about other instances + * Scope: jQuery.fn.dataTableExt + */ + _oExt._oExternConfig = { + /* int:iNextUnique - next unique number for an instance */ + "iNextUnique": 0 + }; + + /* * Variable: oStdClasses * Purpose: Storage for the various classes that DataTables uses @@ -586,7 +1312,7 @@ if ( typeof a != 'string' ) { a = ''; } return a.toLowerCase(); }, - + "string-asc": function ( x, y ) { return ((x < y) ? -1 : ((x > y) ? 1 : 0)); @@ -630,7 +1356,7 @@ } return x; }, - + "date-asc": function ( x, y ) { return x - y; @@ -649,7 +1375,7 @@ { return (a=="-" || a==="") ? 0 : a*1; }, - + "numeric-asc": function ( x, y ) { return x - y; @@ -760,1747 +1486,10 @@ return null; } ]; - - /* - * 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 - */ - _oExt.fnVersionCheck = function( sVersion ) + + var DataTable = function( oInit ) { - /* This is cheap, but very effective */ - var fnZPad = function (Zpad, count) - { - while(Zpad.length < count) { - Zpad += '0'; - } - return Zpad; - }; - var aThis = _oExt.sVersion.split('.'); - var aThat = sVersion.split('.'); - var sThis = '', sThat = ''; - for ( var i=0, iLen=aThat.length ; i= parseInt(sThat, 10); - }; - - /* - * Variable: _oExternConfig - * Purpose: Store information for DataTables to access globally about other instances - * Scope: jQuery.fn.dataTableExt - */ - _oExt._oExternConfig = { - /* int:iNextUnique - next unique number for an instance */ - "iNextUnique": 0 - }; - - - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Section - DataTables prototype - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - /* - * Function: dataTable - * Purpose: DataTables information - * Returns: - - * Inputs: object:oInit - initialisation options for the table - */ - $.fn.dataTable = function( oInit ) - { - /* - * Function: classSettings - * Purpose: Settings container function for all 'class' properties which are required - * by dataTables - * Returns: - - * Inputs: - - */ - function classSettings () - { - this.fnRecordsTotal = function () - { - if ( this.oFeatures.bServerSide ) { - return parseInt(this._iRecordsTotal, 10); - } else { - return this.aiDisplayMaster.length; - } - }; - - this.fnRecordsDisplay = function () - { - if ( this.oFeatures.bServerSide ) { - return parseInt(this._iRecordsDisplay, 10); - } else { - return this.aiDisplay.length; - } - }; - - this.fnDisplayEnd = function () - { - if ( this.oFeatures.bServerSide ) { - if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) { - return this._iDisplayStart+this.aiDisplay.length; - } else { - return Math.min( this._iDisplayStart+this._iDisplayLength, - this._iRecordsDisplay ); - } - } else { - return this._iDisplayEnd; - } - }; - - /* - * Variable: oInstance - * Purpose: The DataTables object for this table - * Scope: jQuery.dataTable.classSettings - */ - this.oInstance = null; - - /* - * Variable: sInstance - * Purpose: Unique idendifier for each instance of the DataTables object - * Scope: jQuery.dataTable.classSettings - */ - this.sInstance = null; - - /* - * Variable: oFeatures - * Purpose: Indicate the enablement of key dataTable features - * Scope: jQuery.dataTable.classSettings - */ - this.oFeatures = { - "bPaginate": true, - "bLengthChange": true, - "bFilter": true, - "bSort": true, - "bInfo": true, - "bAutoWidth": true, - "bProcessing": false, - "bSortClasses": true, - "bStateSave": false, - "bServerSide": false, - "bDeferRender": false - }; - - /* - * Variable: oScroll - * Purpose: Container for scrolling options - * Scope: jQuery.dataTable.classSettings - */ - this.oScroll = { - "sX": "", - "sXInner": "", - "sY": "", - "bCollapse": false, - "bInfinite": false, - "iLoadGap": 100, - "iBarWidth": 0, - "bAutoCss": true - }; - - /* - * Variable: aanFeatures - * Purpose: Array referencing the nodes which are used for the features - * Scope: jQuery.dataTable.classSettings - * Notes: The parameters of this object match what is allowed by sDom - i.e. - * 'l' - Length changing - * 'f' - Filtering input - * 't' - The table! - * 'i' - Information - * 'p' - Pagination - * 'r' - pRocessing - */ - this.aanFeatures = []; - - /* - * Variable: oLanguage - * Purpose: Store the language strings used by dataTables - * Scope: jQuery.dataTable.classSettings - * Notes: The words in the format _VAR_ are variables which are dynamically replaced - * by javascript - */ - this.oLanguage = { - "sProcessing": "Processing...", - "sLengthMenu": "Show _MENU_ entries", - "sZeroRecords": "No matching records found", - "sEmptyTable": "No data available in table", - "sLoadingRecords": "Loading...", - "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries", - "sInfoEmpty": "Showing 0 to 0 of 0 entries", - "sInfoFiltered": "(filtered from _MAX_ total entries)", - "sInfoPostFix": "", - "sInfoThousands": ",", - "sSearch": "Search:", - "sUrl": "", - "oPaginate": { - "sFirst": "First", - "sPrevious": "Previous", - "sNext": "Next", - "sLast": "Last" - }, - "fnInfoCallback": null - }; - - /* - * Variable: aoData - * Purpose: Store data information - * Scope: jQuery.dataTable.classSettings - * Notes: This is an array of objects with the following parameters: - * int: _iId - internal id for tracking - * array: _aData - internal data - used for sorting / filtering etc - * node: nTr - display node - * array node: _anHidden - hidden TD nodes - * string: _sRowStripe - */ - this.aoData = []; - - /* - * Variable: aiDisplay - * Purpose: Array of indexes which are in the current display (after filtering etc) - * Scope: jQuery.dataTable.classSettings - */ - this.aiDisplay = []; - - /* - * Variable: aiDisplayMaster - * Purpose: Array of indexes for display - no filtering - * Scope: jQuery.dataTable.classSettings - */ - this.aiDisplayMaster = []; - - /* - * Variable: aoColumns - * Purpose: Store information about each column that is in use - * Scope: jQuery.dataTable.classSettings - */ - this.aoColumns = []; - - /* - * Variable: aoHeader - * Purpose: Store information about the table's header - * Scope: jQuery.dataTable.classSettings - */ - this.aoHeader = []; - - /* - * Variable: aoFooter - * Purpose: Store information about the table's footer - * Scope: jQuery.dataTable.classSettings - */ - this.aoFooter = []; - - /* - * Variable: iNextId - * Purpose: Store the next unique id to be used for a new row - * Scope: jQuery.dataTable.classSettings - */ - this.iNextId = 0; - - /* - * Variable: asDataSearch - * Purpose: Search data array for regular expression searching - * Scope: jQuery.dataTable.classSettings - */ - this.asDataSearch = []; - - /* - * Variable: oPreviousSearch - * Purpose: Store the previous search incase we want to force a re-search - * or compare the old search to a new one - * Scope: jQuery.dataTable.classSettings - */ - this.oPreviousSearch = { - "sSearch": "", - "bRegex": false, - "bSmart": true - }; - - /* - * Variable: aoPreSearchCols - * Purpose: Store the previous search for each column - * Scope: jQuery.dataTable.classSettings - */ - this.aoPreSearchCols = []; - - /* - * Variable: aaSorting - * Purpose: Sorting information - * Scope: jQuery.dataTable.classSettings - * Notes: Index 0 - column number - * Index 1 - current sorting direction - * Index 2 - index of asSorting for this column - */ - this.aaSorting = [ [0, 'asc', 0] ]; - - /* - * Variable: aaSortingFixed - * Purpose: Sorting information that is always applied - * Scope: jQuery.dataTable.classSettings - */ - this.aaSortingFixed = null; - - /* - * Variable: asStripeClasses - * Purpose: Classes to use for the striping of a table - * Scope: jQuery.dataTable.classSettings - */ - this.asStripeClasses = []; - - /* - * Variable: asDestroyStripes - * Purpose: If restoring a table - we should restore its striping classes as well - * Scope: jQuery.dataTable.classSettings - */ - this.asDestroyStripes = []; - - /* - * Variable: sDestroyWidth - * Purpose: If restoring a table - we should restore its width - * Scope: jQuery.dataTable.classSettings - */ - this.sDestroyWidth = 0; - - /* - * Variable: fnRowCallback - * Purpose: Call this function every time a row is inserted (draw) - * Scope: jQuery.dataTable.classSettings - */ - this.fnRowCallback = null; - - /* - * Variable: fnHeaderCallback - * Purpose: Callback function for the header on each draw - * Scope: jQuery.dataTable.classSettings - */ - this.fnHeaderCallback = null; - - /* - * Variable: fnFooterCallback - * Purpose: Callback function for the footer on each draw - * Scope: jQuery.dataTable.classSettings - */ - this.fnFooterCallback = null; - - /* - * Variable: aoDrawCallback - * Purpose: Array of callback functions for draw callback functions - * Scope: jQuery.dataTable.classSettings - * Notes: Each array element is an object with the following parameters: - * function:fn - function to call - * string:sName - name callback (feature). useful for arranging array - */ - this.aoDrawCallback = []; - - /* - * Variable: fnPreDrawCallback - * Purpose: Callback function for just before the table is redrawn. A return of false - * will be used to cancel the draw. - * Scope: jQuery.dataTable.classSettings - */ - this.fnPreDrawCallback = null; - - /* - * Variable: fnInitComplete - * Purpose: Callback function for when the table has been initialised - * Scope: jQuery.dataTable.classSettings - */ - this.fnInitComplete = null; - - /* - * Variable: sTableId - * Purpose: Cache the table ID for quick access - * Scope: jQuery.dataTable.classSettings - */ - this.sTableId = ""; - - /* - * Variable: nTable - * Purpose: Cache the table node for quick access - * Scope: jQuery.dataTable.classSettings - */ - this.nTable = null; - - /* - * Variable: nTHead - * Purpose: Permanent ref to the thead element - * Scope: jQuery.dataTable.classSettings - */ - this.nTHead = null; - - /* - * Variable: nTFoot - * Purpose: Permanent ref to the tfoot element - if it exists - * Scope: jQuery.dataTable.classSettings - */ - this.nTFoot = null; - - /* - * Variable: nTBody - * Purpose: Permanent ref to the tbody element - * Scope: jQuery.dataTable.classSettings - */ - this.nTBody = null; - - /* - * Variable: nTableWrapper - * Purpose: Cache the wrapper node (contains all DataTables controlled elements) - * Scope: jQuery.dataTable.classSettings - */ - this.nTableWrapper = null; - - /* - * Variable: bDeferLoading - * Purpose: Indicate if when using server-side processing the loading of data - * should be deferred until the second draw - * Scope: jQuery.dataTable.classSettings - */ - this.bDeferLoading = false; - - /* - * Variable: bInitialised - * Purpose: Indicate if all required information has been read in - * Scope: jQuery.dataTable.classSettings - */ - this.bInitialised = false; - - /* - * Variable: aoOpenRows - * Purpose: Information about open rows - * Scope: jQuery.dataTable.classSettings - * Notes: Has the parameters 'nTr' and 'nParent' - */ - this.aoOpenRows = []; - - /* - * Variable: sDom - * Purpose: Dictate the positioning that the created elements will take - * Scope: jQuery.dataTable.classSettings - * Notes: - * The following options are allowed: - * 'l' - Length changing - * 'f' - Filtering input - * 't' - The table! - * 'i' - Information - * 'p' - Pagination - * 'r' - pRocessing - * The following constants are allowed: - * 'H' - jQueryUI theme "header" classes - * 'F' - jQueryUI theme "footer" classes - * The following syntax is expected: - * '<' and '>' - div elements - * '<"class" and '>' - div with a class - * Examples: - * '<"wrapper"flipt>', 'ip>' - */ - this.sDom = 'lfrtip'; - - /* - * Variable: sPaginationType - * Purpose: Note which type of sorting should be used - * Scope: jQuery.dataTable.classSettings - */ - this.sPaginationType = "two_button"; - - /* - * Variable: iCookieDuration - * Purpose: The cookie duration (for bStateSave) in seconds - default 2 hours - * Scope: jQuery.dataTable.classSettings - */ - this.iCookieDuration = 60 * 60 * 2; - - /* - * Variable: sCookiePrefix - * Purpose: The cookie name prefix - * Scope: jQuery.dataTable.classSettings - */ - this.sCookiePrefix = "SpryMedia_DataTables_"; - - /* - * Variable: fnCookieCallback - * Purpose: Callback function for cookie creation - * Scope: jQuery.dataTable.classSettings - */ - this.fnCookieCallback = null; - - /* - * Variable: aoStateSave - * Purpose: Array of callback functions for state saving - * Scope: jQuery.dataTable.classSettings - * Notes: Each array element is an object with the following parameters: - * function:fn - function to call. Takes two parameters, oSettings and the JSON string to - * save that has been thus far created. Returns a JSON string to be inserted into a - * json object (i.e. '"param": [ 0, 1, 2]') - * string:sName - name of callback - */ - this.aoStateSave = []; - - /* - * Variable: aoStateLoad - * Purpose: Array of callback functions for state loading - * Scope: jQuery.dataTable.classSettings - * Notes: Each array element is an object with the following parameters: - * function:fn - function to call. Takes two parameters, oSettings and the object stored. - * May return false to cancel state loading. - * string:sName - name of callback - */ - this.aoStateLoad = []; - - /* - * Variable: oLoadedState - * Purpose: State that was loaded from the cookie. Useful for back reference - * Scope: jQuery.dataTable.classSettings - */ - this.oLoadedState = null; - - /* - * Variable: sAjaxSource - * Purpose: Source url for AJAX data for the table - * Scope: jQuery.dataTable.classSettings - */ - this.sAjaxSource = null; - - /* - * Variable: sAjaxDataProp - * Purpose: Property from a given object from which to read the table data from. This can - * be an empty string (when not server-side processing), in which case it is - * assumed an an array is given directly. - * Scope: jQuery.dataTable.classSettings - */ - this.sAjaxDataProp = 'aaData'; - - /* - * Variable: bAjaxDataGet - * Purpose: Note if draw should be blocked while getting data - * Scope: jQuery.dataTable.classSettings - */ - this.bAjaxDataGet = true; - - /* - * Variable: jqXHR - * Purpose: The last jQuery XHR object that was used for server-side data gathering. - * This can be used for working with the XHR information in one of the callbacks - * Scope: jQuery.dataTable.classSettings - */ - this.jqXHR = null; - - /* - * Variable: fnServerData - * Purpose: Function to get the server-side data - can be overruled by the developer - * Scope: jQuery.dataTable.classSettings - */ - this.fnServerData = function ( url, data, callback, settings ) { - settings.jqXHR = $.ajax( { - "url": url, - "data": data, - "success": function (json) { - $(settings.oInstance).trigger('xhr', settings); - callback( json ); - }, - "dataType": "json", - "cache": false, - "type": settings.sServerMethod, - "error": function (xhr, error, thrown) { - if ( error == "parsererror" ) { - alert( "DataTables warning: JSON data from server could not be parsed. "+ - "This is caused by a JSON formatting error." ); - } - } - } ); - }; - - /* - * Variable: aoServerParams - * Purpose: Functions which are called prior to sending an Ajax request so extra parameters - * can easily be sent to the server - * Scope: jQuery.dataTable.classSettings - * Notes: Each array element is an object with the following parameters: - * function:fn - function to call - * string:sName - name callback - useful for knowing where it came from (plugin etc) - */ - this.aoServerParams = []; - - /* - * Variable: sServerType - * Purpose: Send the XHR HTTP method - GET or POST (could be PUT or DELETE if required) - * Scope: jQuery.dataTable.classSettings - */ - this.sServerMethod = "GET"; - - /* - * Variable: fnFormatNumber - * Purpose: Format numbers for display - * Scope: jQuery.dataTable.classSettings - */ - this.fnFormatNumber = function ( iIn ) - { - if ( iIn < 1000 ) - { - /* A small optimisation for what is likely to be the vast majority of use cases */ - return iIn; - } - else - { - var s=(iIn+""), a=s.split(""), out="", iLen=s.length; - - for ( var i=0 ; i