MCPcopy Create free account
hub / github.com/breck7/scroll / _fnImplementState

Function _fnImplementState

external/.datatables.js:5688–5798  ·  view source on GitHub ↗
(settings, s, callback)

Source from the content-addressed store, hash-verified

5686 }
5687
5688 function _fnImplementState(settings, s, callback) {
5689 var i, ien
5690 var columns = settings.aoColumns
5691 settings._bLoadingState = true
5692
5693 // When StateRestore was introduced the state could now be implemented at any time
5694 // Not just initialisation. To do this an api instance is required in some places
5695 var api = settings._bInitComplete ? new DataTable.Api(settings) : null
5696
5697 if (!s || !s.time) {
5698 settings._bLoadingState = false
5699 callback()
5700 return
5701 }
5702
5703 // Reject old data
5704 var duration = settings.iStateDuration
5705 if (duration > 0 && s.time < +new Date() - duration * 1000) {
5706 settings._bLoadingState = false
5707 callback()
5708 return
5709 }
5710
5711 // Allow custom and plug-in manipulation functions to alter the saved data set and
5712 // cancelling of loading by returning false
5713 var abStateLoad = _fnCallbackFire(settings, "aoStateLoadParams", "stateLoadParams", [settings, s])
5714 if (abStateLoad.indexOf(false) !== -1) {
5715 settings._bLoadingState = false
5716 callback()
5717 return
5718 }
5719
5720 // Number of columns have changed - all bets are off, no restore of settings
5721 if (s.columns && columns.length !== s.columns.length) {
5722 settings._bLoadingState = false
5723 callback()
5724 return
5725 }
5726
5727 // Store the saved state so it might be accessed at any time
5728 settings.oLoadedState = $.extend(true, {}, s)
5729
5730 // This is needed for ColReorder, which has to happen first to allow all
5731 // the stored indexes to be usable. It is not publicly documented.
5732 _fnCallbackFire(settings, null, "stateLoadInit", [settings, s], true)
5733
5734 // Page Length
5735 if (s.length !== undefined) {
5736 // If already initialised just set the value directly so that the select element is also updated
5737 if (api) {
5738 api.page.len(s.length)
5739 } else {
5740 settings._iDisplayLength = s.length
5741 }
5742 }
5743
5744 // Restore key features
5745 if (s.start !== undefined) {

Callers 3

loadedFunction · 0.85
_fnLoadStateFunction · 0.85
.datatables.jsFile · 0.85

Calls 6

callbackFunction · 0.85
_fnCallbackFireFunction · 0.85
_fnPageChangeFunction · 0.85
indexOfMethod · 0.80
extendMethod · 0.80
eachMethod · 0.80

Tested by

no test coverage detected