datatables.net 2.3.3 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/dataTables.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! DataTables 2.3.3
1
+ /*! DataTables 2.3.4
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -131,6 +131,9 @@ var DataTable = function ( selector, options )
131
131
  this.id = sId;
132
132
  }
133
133
 
134
+ // Replacing an existing colgroup with our own. Not ideal, but a merge could take a lot of code
135
+ $this.children('colgroup').remove();
136
+
134
137
  /* Create the settings object for this table and set some of the default parameters */
135
138
  var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
136
139
  "sDestroyWidth": $this[0].style.width,
@@ -4123,24 +4126,21 @@ function _fnStart( oSettings )
4123
4126
  * DataTables - may be augmented by developer callbacks
4124
4127
  * @param {function} fn Callback function to run when data is obtained
4125
4128
  */
4126
- function _fnBuildAjax( oSettings, data, fn )
4127
- {
4129
+ function _fnBuildAjax(oSettings, data, fn) {
4128
4130
  var ajaxData;
4129
4131
  var ajax = oSettings.ajax;
4130
4132
  var instance = oSettings.oInstance;
4131
- var callback = function ( json ) {
4132
- var status = oSettings.jqXHR
4133
- ? oSettings.jqXHR.status
4134
- : null;
4133
+ var callback = function (json) {
4134
+ var status = oSettings.jqXHR ? oSettings.jqXHR.status : null;
4135
4135
 
4136
- if ( json === null || (typeof status === 'number' && status == 204 ) ) {
4136
+ if (json === null || (typeof status === 'number' && status == 204)) {
4137
4137
  json = {};
4138
- _fnAjaxDataSrc( oSettings, json, [] );
4138
+ _fnAjaxDataSrc(oSettings, json, []);
4139
4139
  }
4140
4140
 
4141
4141
  var error = json.error || json.sError;
4142
- if ( error ) {
4143
- _fnLog( oSettings, 0, error );
4142
+ if (error) {
4143
+ _fnLog(oSettings, 0, error);
4144
4144
  }
4145
4145
 
4146
4146
  // Microsoft often wrap JSON as a string in another JSON object
@@ -4148,30 +4148,27 @@ function _fnBuildAjax( oSettings, data, fn )
4148
4148
  if (json.d && typeof json.d === 'string') {
4149
4149
  try {
4150
4150
  json = JSON.parse(json.d);
4151
- }
4152
- catch (e) {
4151
+ } catch (e) {
4153
4152
  // noop
4154
4153
  }
4155
4154
  }
4156
4155
 
4157
4156
  oSettings.json = json;
4158
4157
 
4159
- _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR], true );
4160
- fn( json );
4158
+ _fnCallbackFire(oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR], true);
4159
+ fn(json);
4161
4160
  };
4162
4161
 
4163
- if ( $.isPlainObject( ajax ) && ajax.data )
4164
- {
4162
+ if ($.isPlainObject(ajax) && ajax.data) {
4165
4163
  ajaxData = ajax.data;
4166
4164
 
4167
- var newData = typeof ajaxData === 'function' ?
4168
- ajaxData( data, oSettings ) : // fn can manipulate data or return
4169
- ajaxData; // an object or array to merge
4165
+ var newData =
4166
+ typeof ajaxData === 'function'
4167
+ ? ajaxData(data, oSettings) // fn can manipulate data or return
4168
+ : ajaxData; // an object or array to merge
4170
4169
 
4171
4170
  // If the function returned something, use that alone
4172
- data = typeof ajaxData === 'function' && newData ?
4173
- newData :
4174
- $.extend( true, data, newData );
4171
+ data = typeof ajaxData === 'function' && newData ? newData : $.extend(true, data, newData);
4175
4172
 
4176
4173
  // Remove the data property as we've resolved it already and don't want
4177
4174
  // jQuery to do it again (it is restored at the end of the function)
@@ -4179,50 +4176,53 @@ function _fnBuildAjax( oSettings, data, fn )
4179
4176
  }
4180
4177
 
4181
4178
  var baseAjax = {
4182
- "url": typeof ajax === 'string' ?
4183
- ajax :
4184
- '',
4185
- "data": data,
4186
- "success": callback,
4187
- "dataType": "json",
4188
- "cache": false,
4189
- "type": oSettings.sServerMethod,
4190
- "error": function (xhr, error) {
4191
- var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR], true );
4192
-
4193
- if ( ret.indexOf(true) === -1 ) {
4194
- if ( error == "parsererror" ) {
4195
- _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
4179
+ url: typeof ajax === 'string' ? ajax : '',
4180
+ data: data,
4181
+ success: callback,
4182
+ dataType: 'json',
4183
+ cache: false,
4184
+ type: oSettings.sServerMethod,
4185
+ error: function (xhr, error) {
4186
+ var ret = _fnCallbackFire(
4187
+ oSettings,
4188
+ null,
4189
+ 'xhr',
4190
+ [oSettings, null, oSettings.jqXHR],
4191
+ true
4192
+ );
4193
+
4194
+ if (ret.indexOf(true) === -1) {
4195
+ if (error == 'parsererror') {
4196
+ _fnLog(oSettings, 0, 'Invalid JSON response', 1);
4196
4197
  }
4197
- else if ( xhr.readyState === 4 ) {
4198
- _fnLog( oSettings, 0, 'Ajax error', 7 );
4198
+ else if (xhr.readyState === 4) {
4199
+ _fnLog(oSettings, 0, 'Ajax error', 7);
4199
4200
  }
4200
4201
  }
4201
4202
 
4202
- _fnProcessingDisplay( oSettings, false );
4203
+ _fnProcessingDisplay(oSettings, false);
4203
4204
  }
4204
4205
  };
4205
4206
 
4206
4207
  // If `ajax` option is an object, extend and override our default base
4207
- if ( $.isPlainObject( ajax ) ) {
4208
- $.extend( baseAjax, ajax )
4208
+ if ($.isPlainObject(ajax)) {
4209
+ $.extend(baseAjax, ajax);
4209
4210
  }
4210
4211
 
4211
4212
  // Store the data submitted for the API
4212
4213
  oSettings.oAjaxData = data;
4213
4214
 
4214
4215
  // Allow plug-ins and external processes to modify the data
4215
- _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data, baseAjax], true );
4216
+ _fnCallbackFire(oSettings, null, 'preXhr', [oSettings, data, baseAjax], true);
4216
4217
 
4217
4218
  // Custom Ajax option to submit the parameters as a JSON string
4218
4219
  if (baseAjax.submitAs === 'json' && typeof data === 'object') {
4219
4220
  baseAjax.data = JSON.stringify(data);
4220
4221
  }
4221
4222
 
4222
- if ( typeof ajax === 'function' )
4223
- {
4223
+ if (typeof ajax === 'function') {
4224
4224
  // Is a function - let the caller define what needs to be done
4225
- oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
4225
+ oSettings.jqXHR = ajax.call(instance, data, callback, oSettings);
4226
4226
  }
4227
4227
  else if (ajax.url === '') {
4228
4228
  // No url, so don't load any data. Just apply an empty data array
@@ -4234,37 +4234,30 @@ function _fnBuildAjax( oSettings, data, fn )
4234
4234
  }
4235
4235
  else {
4236
4236
  // Object to extend the base settings
4237
- oSettings.jqXHR = $.ajax( baseAjax );
4237
+ oSettings.jqXHR = $.ajax(baseAjax);
4238
4238
  }
4239
4239
 
4240
4240
  // Restore for next time around
4241
- if ( ajaxData ) {
4241
+ if (ajaxData) {
4242
4242
  ajax.data = ajaxData;
4243
4243
  }
4244
4244
  }
4245
4245
 
4246
-
4247
4246
  /**
4248
4247
  * Update the table using an Ajax call
4249
4248
  * @param {object} settings dataTables settings object
4250
4249
  * @returns {boolean} Block the table drawing or not
4251
4250
  * @memberof DataTable#oApi
4252
4251
  */
4253
- function _fnAjaxUpdate( settings )
4254
- {
4252
+ function _fnAjaxUpdate(settings) {
4255
4253
  settings.iDraw++;
4256
- _fnProcessingDisplay( settings, true );
4254
+ _fnProcessingDisplay(settings, true);
4257
4255
 
4258
- _fnBuildAjax(
4259
- settings,
4260
- _fnAjaxParameters( settings ),
4261
- function(json) {
4262
- _fnAjaxUpdateDraw( settings, json );
4263
- }
4264
- );
4256
+ _fnBuildAjax(settings, _fnAjaxParameters(settings), function (json) {
4257
+ _fnAjaxUpdateDraw(settings, json);
4258
+ });
4265
4259
  }
4266
4260
 
4267
-
4268
4261
  /**
4269
4262
  * Build up the parameters in an object needed for a server-side processing
4270
4263
  * request.
@@ -4272,22 +4265,18 @@ function _fnAjaxUpdate( settings )
4272
4265
  * @returns {bool} block the table drawing or not
4273
4266
  * @memberof DataTable#oApi
4274
4267
  */
4275
- function _fnAjaxParameters( settings )
4276
- {
4277
- var
4278
- columns = settings.aoColumns,
4268
+ function _fnAjaxParameters(settings) {
4269
+ var columns = settings.aoColumns,
4279
4270
  features = settings.oFeatures,
4280
4271
  preSearch = settings.oPreviousSearch,
4281
4272
  preColSearch = settings.aoPreSearchCols,
4282
- colData = function ( idx, prop ) {
4283
- return typeof columns[idx][prop] === 'function' ?
4284
- 'function' :
4285
- columns[idx][prop];
4273
+ colData = function (idx, prop) {
4274
+ return typeof columns[idx][prop] === 'function' ? 'function' : columns[idx][prop];
4286
4275
  };
4287
4276
 
4288
4277
  return {
4289
4278
  draw: settings.iDraw,
4290
- columns: columns.map( function ( column, i ) {
4279
+ columns: columns.map(function (column, i) {
4291
4280
  return {
4292
4281
  data: colData(i, 'mData'),
4293
4282
  name: column.sName,
@@ -4296,40 +4285,43 @@ function _fnAjaxParameters( settings )
4296
4285
  search: {
4297
4286
  value: preColSearch[i].search,
4298
4287
  regex: preColSearch[i].regex,
4299
- fixed: Object.keys(column.searchFixed).map( function(name) {
4300
- return {
4301
- name: name,
4302
- term: column.searchFixed[name].toString()
4303
- }
4304
- })
4288
+ fixed: Object.keys(column.searchFixed)
4289
+ .map(function (name) {
4290
+ return {
4291
+ name: name,
4292
+ term: typeof column.searchFixed[name] !== 'function'
4293
+ ? column.searchFixed[name].toString()
4294
+ : 'function'
4295
+ };
4296
+ })
4305
4297
  }
4306
4298
  };
4307
- } ),
4308
- order: _fnSortFlatten( settings ).map( function ( val ) {
4299
+ }),
4300
+ order: _fnSortFlatten(settings).map(function (val) {
4309
4301
  return {
4310
4302
  column: val.col,
4311
4303
  dir: val.dir,
4312
4304
  name: colData(val.col, 'sName')
4313
4305
  };
4314
- } ),
4306
+ }),
4315
4307
  start: settings._iDisplayStart,
4316
- length: features.bPaginate ?
4317
- settings._iDisplayLength :
4318
- -1,
4308
+ length: features.bPaginate ? settings._iDisplayLength : -1,
4319
4309
  search: {
4320
4310
  value: preSearch.search,
4321
4311
  regex: preSearch.regex,
4322
- fixed: Object.keys(settings.searchFixed).map( function(name) {
4323
- return {
4324
- name: name,
4325
- term: settings.searchFixed[name].toString()
4326
- }
4327
- })
4312
+ fixed: Object.keys(settings.searchFixed)
4313
+ .map(function (name) {
4314
+ return {
4315
+ name: name,
4316
+ term: typeof settings.searchFixed[name] !== 'function'
4317
+ ? settings.searchFixed[name].toString()
4318
+ : 'function'
4319
+ };
4320
+ })
4328
4321
  }
4329
4322
  };
4330
4323
  }
4331
4324
 
4332
-
4333
4325
  /**
4334
4326
  * Data the data from the server (nuking the old) and redraw the table
4335
4327
  * @param {object} oSettings dataTables settings object
@@ -4341,42 +4333,40 @@ function _fnAjaxParameters( settings )
4341
4333
  * @param {string} [json.sColumns] Column ordering (sName, comma separated)
4342
4334
  * @memberof DataTable#oApi
4343
4335
  */
4344
- function _fnAjaxUpdateDraw ( settings, json )
4345
- {
4336
+ function _fnAjaxUpdateDraw(settings, json) {
4346
4337
  var data = _fnAjaxDataSrc(settings, json);
4347
4338
  var draw = _fnAjaxDataSrcParam(settings, 'draw', json);
4348
4339
  var recordsTotal = _fnAjaxDataSrcParam(settings, 'recordsTotal', json);
4349
4340
  var recordsFiltered = _fnAjaxDataSrcParam(settings, 'recordsFiltered', json);
4350
4341
 
4351
- if ( draw !== undefined ) {
4342
+ if (draw !== undefined) {
4352
4343
  // Protect against out of sequence returns
4353
- if ( draw*1 < settings.iDraw ) {
4344
+ if (draw * 1 < settings.iDraw) {
4354
4345
  return;
4355
4346
  }
4356
4347
  settings.iDraw = draw * 1;
4357
4348
  }
4358
4349
 
4359
4350
  // No data in returned object, so rather than an array, we show an empty table
4360
- if ( ! data ) {
4351
+ if (!data) {
4361
4352
  data = [];
4362
4353
  }
4363
4354
 
4364
- _fnClearTable( settings );
4365
- settings._iRecordsTotal = parseInt(recordsTotal, 10);
4355
+ _fnClearTable(settings);
4356
+ settings._iRecordsTotal = parseInt(recordsTotal, 10);
4366
4357
  settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
4367
4358
 
4368
- for ( var i=0, iLen=data.length ; i<iLen ; i++ ) {
4369
- _fnAddData( settings, data[i] );
4359
+ for (var i = 0, iLen = data.length; i < iLen; i++) {
4360
+ _fnAddData(settings, data[i]);
4370
4361
  }
4371
4362
  settings.aiDisplay = settings.aiDisplayMaster.slice();
4372
4363
 
4373
4364
  _fnColumnTypes(settings);
4374
- _fnDraw( settings, true );
4375
- _fnInitComplete( settings );
4376
- _fnProcessingDisplay( settings, false );
4365
+ _fnDraw(settings, true);
4366
+ _fnInitComplete(settings);
4367
+ _fnProcessingDisplay(settings, false);
4377
4368
  }
4378
4369
 
4379
-
4380
4370
  /**
4381
4371
  * Get the data from the JSON data source to use for drawing a table. Using
4382
4372
  * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
@@ -4385,11 +4375,10 @@ function _fnAjaxUpdateDraw ( settings, json )
4385
4375
  * @param {object} json Data source object / array from the server
4386
4376
  * @return {array} Array of data to use
4387
4377
  */
4388
- function _fnAjaxDataSrc ( settings, json, write )
4389
- {
4378
+ function _fnAjaxDataSrc(settings, json, write) {
4390
4379
  var dataProp = 'data';
4391
4380
 
4392
- if ($.isPlainObject( settings.ajax ) && settings.ajax.dataSrc !== undefined) {
4381
+ if ($.isPlainObject(settings.ajax) && settings.ajax.dataSrc !== undefined) {
4393
4382
  // Could in inside a `dataSrc` object, or not!
4394
4383
  var dataSrc = settings.ajax.dataSrc;
4395
4384
 
@@ -4402,20 +4391,18 @@ function _fnAjaxDataSrc ( settings, json, write )
4402
4391
  }
4403
4392
  }
4404
4393
 
4405
- if ( ! write ) {
4406
- if ( dataProp === 'data' ) {
4394
+ if (!write) {
4395
+ if (dataProp === 'data') {
4407
4396
  // If the default, then we still want to support the old style, and safely ignore
4408
4397
  // it if possible
4409
4398
  return json.aaData || json[dataProp];
4410
4399
  }
4411
4400
 
4412
- return dataProp !== "" ?
4413
- _fnGetObjectDataFn( dataProp )( json ) :
4414
- json;
4401
+ return dataProp !== '' ? _fnGetObjectDataFn(dataProp)(json) : json;
4415
4402
  }
4416
-
4403
+
4417
4404
  // set
4418
- _fnSetObjectDataFn( dataProp )( json, write );
4405
+ _fnSetObjectDataFn(dataProp)(json, write);
4419
4406
  }
4420
4407
 
4421
4408
  /**
@@ -4425,14 +4412,12 @@ function _fnAjaxDataSrc ( settings, json, write )
4425
4412
  * @param {*} json JSON data
4426
4413
  * @returns Resolved value
4427
4414
  */
4428
- function _fnAjaxDataSrcParam (settings, param, json) {
4429
- var dataSrc = $.isPlainObject( settings.ajax )
4430
- ? settings.ajax.dataSrc
4431
- : null;
4415
+ function _fnAjaxDataSrcParam(settings, param, json) {
4416
+ var dataSrc = $.isPlainObject(settings.ajax) ? settings.ajax.dataSrc : null;
4432
4417
 
4433
4418
  if (dataSrc && dataSrc[param]) {
4434
4419
  // Get from custom location
4435
- return _fnGetObjectDataFn( dataSrc[param] )( json );
4420
+ return _fnGetObjectDataFn(dataSrc[param])(json);
4436
4421
  }
4437
4422
 
4438
4423
  // else - Default behaviour
@@ -4449,9 +4434,7 @@ function _fnAjaxDataSrcParam (settings, param, json) {
4449
4434
  old = 'iTotalDisplayRecords';
4450
4435
  }
4451
4436
 
4452
- return json[old] !== undefined
4453
- ? json[old]
4454
- : json[param];
4437
+ return json[old] !== undefined ? json[old] : json[param];
4455
4438
  }
4456
4439
 
4457
4440
 
@@ -6466,7 +6449,9 @@ function _fnImplementState ( settings, s, callback) {
6466
6449
 
6467
6450
  // If the api is defined then we need to adjust the columns once the visibility has been changed
6468
6451
  if (api) {
6469
- api.columns.adjust();
6452
+ api.one('draw', function () {
6453
+ api.columns.adjust();
6454
+ });
6470
6455
  }
6471
6456
  }
6472
6457
  }
@@ -10186,7 +10171,7 @@ function cleanHeader(node, className) {
10186
10171
  * @type string
10187
10172
  * @default Version number
10188
10173
  */
10189
- DataTable.version = "2.3.3";
10174
+ DataTable.version = "2.3.4";
10190
10175
 
10191
10176
  /**
10192
10177
  * Private data store, containing all of the settings objects that are
@@ -12603,7 +12588,10 @@ function __mlHelper (localeString) {
12603
12588
  }
12604
12589
 
12605
12590
  var formatted = to === null
12606
- ? __mld(dt, 'toDate', 'toJSDate', '')[localeString]()
12591
+ ? __mld(dt, 'toDate', 'toJSDate', '')[localeString](
12592
+ navigator.language,
12593
+ { timeZone: "UTC" }
12594
+ )
12607
12595
  : __mld(dt, 'format', 'toFormat', 'toISOString', to);
12608
12596
 
12609
12597
  // XSS protection
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/dataTables.js",
5
5
  "module": "js/dataTables.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "2.3.3",
7
+ "version": "2.3.4",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",