From 94f06473c6ae9a004f4e1c9cfe903ea195a0e736 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Wed, 31 Oct 2012 18:09:41 +0000 Subject: [PATCH] New: DataTables now uses HTML5 `localStorage` by default for state saving. This has a number of advantages over cookies, the first of which is that we are no longer limited to 4KiB in size. It also makes HTTP requests faster since they aren't included in the HTTP transport. Better yet, the removal of the cookie code reduces the DataTables minified size by 1.5K (1573 bytes). It must be noted that this does mean that IE6/7 don't, by default, work with state saving in DataTables. If support for those browsers is required, then fnStateSaveCallback and fnStateLoadCallback must be used by the developer to define their own state saving methods. Removed: fnCookieCallback (cookieCallback) - This is now irrelevant since DataTables does not state save in cookies by default. Removed: sCookiePrefix (cookiePrefix) - This is now irrelevant since DataTables does not state save in cookies by default. Depreciated: iCookieDuration (cookieDuration) - Since DataTables does not use cookies for state saving by default the name of this parameter is now incorrect. The new parameter `stateDuration` should be used instead, although the old parameter is still supported. It will be removed in the next major version of DataTables. --- media/js/jquery.dataTables.js | 330 ++++------------------------- media/src/DataTables.js | 2 +- media/src/api/api.internal.js | 3 - media/src/core/core.constructor.js | 11 +- media/src/core/core.state.js | 133 +----------- media/src/core/core.support.js | 52 ----- media/src/model/model.defaults.js | 105 +++------ media/src/model/model.settings.js | 24 +-- 8 files changed, 90 insertions(+), 570 deletions(-) diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index e157fb39..53115666 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -21,7 +21,7 @@ */ /*jslint evil: true, undef: true, browser: true */ -/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns,_fnHungarianMap,_fnCamelToHungarian*/ +/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns,_fnHungarianMap,_fnCamelToHungarian*/ (/** @lends */function( window, document, undefined ) { @@ -4286,7 +4286,7 @@ /** - * Save the state of a table in a cookie such that the page can be reloaded + * Save the state of a table * @param {object} oSettings dataTables settings object * @memberof DataTable#oApi */ @@ -4317,12 +4317,12 @@ _fnCallbackFire( oSettings, "aoStateSaveParams", 'stateSaveParams', [oSettings, oState] ); - oSettings.fnStateSave.call( oSettings.oInstance, oSettings, oState ); + oSettings.fnStateSaveCallback.call( oSettings.oInstance, oSettings, oState ); } /** - * Attempt to load a saved table state from a cookie + * Attempt to load a saved table state * @param {object} oSettings dataTables settings object * @param {object} oInit DataTables init object so we can override settings * @memberof DataTable#oApi @@ -4334,7 +4334,7 @@ return; } - var oData = oSettings.fnStateLoad.call( oSettings.oInstance, oSettings ); + var oData = oSettings.fnStateLoadCallback.call( oSettings.oInstance, oSettings ); if ( !oData ) { return; @@ -4348,6 +4348,11 @@ { return; } + + /* Reject old data */ + if ( oData.iCreate < new Date().getTime() - (oSettings.iStateDuration*1000) ) { + return; + } /* Store the saved state so it might be accessed at any time */ oSettings.oLoadedState = $.extend( true, {}, oData ); @@ -4379,126 +4384,6 @@ } - /** - * Create a new cookie with a value to store the state of a table - * @param {string} sName name of the cookie to create - * @param {string} sValue the value the cookie should take - * @param {int} iSecs duration of the cookie - * @param {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 - * @memberof DataTable#oApi - */ - function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback ) - { - var date = new Date(); - date.setTime( date.getTime()+(iSecs*1000) ); - - /* - * Shocking but true - it would appear IE has major issues with having the path not having - * a trailing slash on it. We need the cookie to be available based on the path, so we - * have to append the file name to the cookie name. Appalling. Thanks to vex for adding the - * patch to use at least some of the path - */ - var aParts = window.location.pathname.split('/'); - var sNameFile = sName + '_' + aParts.pop().replace(/[\/:]/g,"").toLowerCase(); - var sFullCookie, oData; - - if ( fnCallback !== null ) - { - oData = (typeof $.parseJSON === 'function') ? - $.parseJSON( sValue ) : eval( '('+sValue+')' ); - sFullCookie = fnCallback( sNameFile, oData, date.toGMTString(), - aParts.join('/')+"/" ); - } - else - { - sFullCookie = sNameFile + "=" + encodeURIComponent(sValue) + - "; expires=" + date.toGMTString() +"; path=" + aParts.join('/')+"/"; - } - - /* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies - * belonging to DataTables. - */ - var - aCookies =document.cookie.split(';'), - iNewCookieLen = sFullCookie.split(';')[0].length, - aOldCookies = []; - - if ( iNewCookieLen+document.cookie.length+10 > 4096 ) /* Magic 10 for padding */ - { - for ( var i=0, iLen=aCookies.length ; i 4096 ) { - if ( aOldCookies.length === 0 ) { - // Deleted all DT cookies and still not enough space. Can't state save - return; - } - - var old = aOldCookies.pop(); - document.cookie = old.name+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+ - aParts.join('/') + "/"; - } - } - - document.cookie = sFullCookie; - } - - - /** - * Read an old cookie to get a cookie with an old table state - * @param {string} sName name of the cookie to read - * @returns {string} contents of the cookie - or null if no cookie with that name found - * @memberof DataTable#oApi - */ - function _fnReadCookie ( sName ) - { - var - aParts = window.location.pathname.split('/'), - sNameEQ = sName + '_' + aParts[aParts.length-1].replace(/[\/:]/g,"").toLowerCase() + '=', - sCookieContents = document.cookie.split(';'); - - for( var i=0 ; i(2 hours) * * @dtopt Options - * @name DataTable.defaults.cookieDuration + * @name DataTable.defaults.stateDuration * * @example * $(document).ready( function() { * $('#example').dataTable( { - * "cookieDuration": 60*60*24; // 1 day + * "stateDuration": 60*60*24; // 1 day * } ); * } ) */ - "fnCookieDuration": 7200, + "iStateDuration": 7200, /** @@ -9620,25 +9417,6 @@ "sAjaxSource": null, - /** - * This parameter can be used to override the default prefix that DataTables - * assigns to a cookie when state saving is enabled. - * @type string - * @default SpryMedia_DataTables_ - * - * @dtopt Options - * @name DataTable.defaults.cookiePrefix - * - * @example - * $(document).ready( function() { - * $('#example').dataTable( { - * "cookiePrefix": "my_datatable_", - * } ); - * } ); - */ - "sCookiePrefix": "SpryMedia_DataTables_", - - /** * This initialisation variable allows you to specify exactly where in the * DOM you want DataTables to inject the various controls it adds to the page @@ -11104,31 +10882,13 @@ "sPaginationType": "two_button", /** - * The cookie duration (for bStateSave) in seconds. + * The state duration (for `stateSave`) in seconds. * Note that this parameter will be set by the initialisation routine. To * set a default use {@link DataTable.defaults}. * @type int * @default 0 */ - "iCookieDuration": 0, - - /** - * The cookie name prefix. - * Note that this parameter will be set by the initialisation routine. To - * set a default use {@link DataTable.defaults}. - * @type string - * @default Empty string - */ - "sCookiePrefix": "", - - /** - * Callback function for cookie creation. - * Note that this parameter will be set by the initialisation routine. To - * set a default use {@link DataTable.defaults}. - * @type function - * @default null - */ - "fnCookieCallback": null, + "iStateDuration": 0, /** * Array of callback functions for state saving. Each array element is an @@ -11159,7 +10919,7 @@ "aoStateLoad": [], /** - * State that was loaded from the cookie. Useful for back reference + * State that was loaded. Useful for back reference * @type object * @default null */ diff --git a/media/src/DataTables.js b/media/src/DataTables.js index c4db920a..7597c7c8 100644 --- a/media/src/DataTables.js +++ b/media/src/DataTables.js @@ -21,7 +21,7 @@ */ /*jslint evil: true, undef: true, browser: true */ -/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns,_fnHungarianMap,_fnCamelToHungarian*/ +/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns,_fnHungarianMap,_fnCamelToHungarian*/ (/** @lends */function( window, document, undefined ) { diff --git a/media/src/api/api.internal.js b/media/src/api/api.internal.js index 3f9a0e29..99a9f421 100644 --- a/media/src/api/api.internal.js +++ b/media/src/api/api.internal.js @@ -92,8 +92,6 @@ this.oApi = { "_fnClearTable": _fnClearTable, "_fnSaveState": _fnSaveState, "_fnLoadState": _fnLoadState, - "_fnCreateCookie": _fnCreateCookie, - "_fnReadCookie": _fnReadCookie, "_fnDetectHeader": _fnDetectHeader, "_fnGetUniqueThs": _fnGetUniqueThs, "_fnScrollBarWidth": _fnScrollBarWidth, @@ -109,7 +107,6 @@ this.oApi = { "_fnExtend": _fnExtend, "_fnCallbackReg": _fnCallbackReg, "_fnCallbackFire": _fnCallbackFire, - "_fnJsonString": _fnJsonString, "_fnNodeToColumnIndex": _fnNodeToColumnIndex, "_fnInfoMacros": _fnInfoMacros, "_fnBrowserDetect": _fnBrowserDetect, diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js index 5efe90a7..0aea5a6b 100644 --- a/media/src/core/core.constructor.js +++ b/media/src/core/core.constructor.js @@ -118,8 +118,8 @@ _fnMap( oSettings, oInit, "aLengthMenu" ); _fnMap( oSettings, oInit, "sPaginationType" ); _fnMap( oSettings, oInit, "sAjaxSource" ); _fnMap( oSettings, oInit, "sAjaxDataProp" ); -_fnMap( oSettings, oInit, "iCookieDuration" ); -_fnMap( oSettings, oInit, "sCookiePrefix" ); +_fnMap( oSettings, oInit, "iCookieDuration", "iStateDuration" ); // backwards compat +_fnMap( oSettings, oInit, "iStateDuration" ); _fnMap( oSettings, oInit, "sDom" ); _fnMap( oSettings, oInit, "bSortCellsTop" ); _fnMap( oSettings, oInit, "iTabIndex" ); @@ -127,9 +127,8 @@ _fnMap( oSettings, oInit, "oSearch", "oPreviousSearch" ); _fnMap( oSettings, oInit, "aoSearchCols", "aoPreSearchCols" ); _fnMap( oSettings, oInit, "iDisplayLength", "_iDisplayLength" ); _fnMap( oSettings, oInit, "bJQueryUI", "bJUI" ); -_fnMap( oSettings, oInit, "fnCookieCallback" ); -_fnMap( oSettings, oInit, "fnStateLoad" ); -_fnMap( oSettings, oInit, "fnStateSave" ); +_fnMap( oSettings, oInit, "fnStateLoadCallback" ); +_fnMap( oSettings, oInit, "fnStateSaveCallback" ); _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" ); /* Callback functions which are array driven */ @@ -190,7 +189,7 @@ if ( oSettings.iInitDisplayStart === undefined ) oSettings._iDisplayStart = oInit.iDisplayStart; } -/* Must be done after everything which can be overridden by a cookie! */ +/* Must be done after everything which can be overridden by the state saving! */ if ( oInit.bStateSave ) { oSettings.oFeatures.bStateSave = true; diff --git a/media/src/core/core.state.js b/media/src/core/core.state.js index 300b7d47..f97b01bc 100644 --- a/media/src/core/core.state.js +++ b/media/src/core/core.state.js @@ -1,7 +1,7 @@ /** - * Save the state of a table in a cookie such that the page can be reloaded + * Save the state of a table * @param {object} oSettings dataTables settings object * @memberof DataTable#oApi */ @@ -32,12 +32,12 @@ function _fnSaveState ( oSettings ) _fnCallbackFire( oSettings, "aoStateSaveParams", 'stateSaveParams', [oSettings, oState] ); - oSettings.fnStateSave.call( oSettings.oInstance, oSettings, oState ); + oSettings.fnStateSaveCallback.call( oSettings.oInstance, oSettings, oState ); } /** - * Attempt to load a saved table state from a cookie + * Attempt to load a saved table state * @param {object} oSettings dataTables settings object * @param {object} oInit DataTables init object so we can override settings * @memberof DataTable#oApi @@ -49,7 +49,7 @@ function _fnLoadState ( oSettings, oInit ) return; } - var oData = oSettings.fnStateLoad.call( oSettings.oInstance, oSettings ); + var oData = oSettings.fnStateLoadCallback.call( oSettings.oInstance, oSettings ); if ( !oData ) { return; @@ -63,6 +63,11 @@ function _fnLoadState ( oSettings, oInit ) { return; } + + /* Reject old data */ + if ( oData.iCreate < new Date().getTime() - (oSettings.iStateDuration*1000) ) { + return; + } /* Store the saved state so it might be accessed at any time */ oSettings.oLoadedState = $.extend( true, {}, oData ); @@ -94,123 +99,3 @@ function _fnLoadState ( oSettings, oInit ) } -/** - * Create a new cookie with a value to store the state of a table - * @param {string} sName name of the cookie to create - * @param {string} sValue the value the cookie should take - * @param {int} iSecs duration of the cookie - * @param {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 - * @memberof DataTable#oApi - */ -function _fnCreateCookie ( sName, sValue, iSecs, sBaseName, fnCallback ) -{ - var date = new Date(); - date.setTime( date.getTime()+(iSecs*1000) ); - - /* - * Shocking but true - it would appear IE has major issues with having the path not having - * a trailing slash on it. We need the cookie to be available based on the path, so we - * have to append the file name to the cookie name. Appalling. Thanks to vex for adding the - * patch to use at least some of the path - */ - var aParts = window.location.pathname.split('/'); - var sNameFile = sName + '_' + aParts.pop().replace(/[\/:]/g,"").toLowerCase(); - var sFullCookie, oData; - - if ( fnCallback !== null ) - { - oData = (typeof $.parseJSON === 'function') ? - $.parseJSON( sValue ) : eval( '('+sValue+')' ); - sFullCookie = fnCallback( sNameFile, oData, date.toGMTString(), - aParts.join('/')+"/" ); - } - else - { - sFullCookie = sNameFile + "=" + encodeURIComponent(sValue) + - "; expires=" + date.toGMTString() +"; path=" + aParts.join('/')+"/"; - } - - /* Are we going to go over the cookie limit of 4KiB? If so, try to delete a cookies - * belonging to DataTables. - */ - var - aCookies =document.cookie.split(';'), - iNewCookieLen = sFullCookie.split(';')[0].length, - aOldCookies = []; - - if ( iNewCookieLen+document.cookie.length+10 > 4096 ) /* Magic 10 for padding */ - { - for ( var i=0, iLen=aCookies.length ; i 4096 ) { - if ( aOldCookies.length === 0 ) { - // Deleted all DT cookies and still not enough space. Can't state save - return; - } - - var old = aOldCookies.pop(); - document.cookie = old.name+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+ - aParts.join('/') + "/"; - } - } - - document.cookie = sFullCookie; -} - - -/** - * Read an old cookie to get a cookie with an old table state - * @param {string} sName name of the cookie to read - * @returns {string} contents of the cookie - or null if no cookie with that name found - * @memberof DataTable#oApi - */ -function _fnReadCookie ( sName ) -{ - var - aParts = window.location.pathname.split('/'), - sNameEQ = sName + '_' + aParts[aParts.length-1].replace(/[\/:]/g,"").toLowerCase() + '=', - sCookieContents = document.cookie.split(';'); - - for( var i=0 ; i(2 hours) * * @dtopt Options - * @name DataTable.defaults.cookieDuration + * @name DataTable.defaults.stateDuration * * @example * $(document).ready( function() { * $('#example').dataTable( { - * "cookieDuration": 60*60*24; // 1 day + * "stateDuration": 60*60*24; // 1 day * } ); * } ) */ - "fnCookieDuration": 7200, + "iStateDuration": 7200, /** @@ -1937,25 +1905,6 @@ DataTable.defaults = { "sAjaxSource": null, - /** - * This parameter can be used to override the default prefix that DataTables - * assigns to a cookie when state saving is enabled. - * @type string - * @default SpryMedia_DataTables_ - * - * @dtopt Options - * @name DataTable.defaults.cookiePrefix - * - * @example - * $(document).ready( function() { - * $('#example').dataTable( { - * "cookiePrefix": "my_datatable_", - * } ); - * } ); - */ - "sCookiePrefix": "SpryMedia_DataTables_", - - /** * This initialisation variable allows you to specify exactly where in the * DOM you want DataTables to inject the various controls it adds to the page diff --git a/media/src/model/model.settings.js b/media/src/model/model.settings.js index 27254799..00c420f7 100644 --- a/media/src/model/model.settings.js +++ b/media/src/model/model.settings.js @@ -537,31 +537,13 @@ DataTable.models.oSettings = { "sPaginationType": "two_button", /** - * The cookie duration (for bStateSave) in seconds. + * The state duration (for `stateSave`) in seconds. * Note that this parameter will be set by the initialisation routine. To * set a default use {@link DataTable.defaults}. * @type int * @default 0 */ - "iCookieDuration": 0, - - /** - * The cookie name prefix. - * Note that this parameter will be set by the initialisation routine. To - * set a default use {@link DataTable.defaults}. - * @type string - * @default Empty string - */ - "sCookiePrefix": "", - - /** - * Callback function for cookie creation. - * Note that this parameter will be set by the initialisation routine. To - * set a default use {@link DataTable.defaults}. - * @type function - * @default null - */ - "fnCookieCallback": null, + "iStateDuration": 0, /** * Array of callback functions for state saving. Each array element is an @@ -592,7 +574,7 @@ DataTable.models.oSettings = { "aoStateLoad": [], /** - * State that was loaded from the cookie. Useful for back reference + * State that was loaded. Useful for back reference * @type object * @default null */