datatables.net 2.3.5 → 2.3.7

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.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! DataTables 2.3.5
1
+ /*! DataTables 2.3.7
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -174,7 +174,7 @@
174
174
  "sDestroyWidth": $this[0].style.width,
175
175
  "sInstance": sId,
176
176
  "sTableId": sId,
177
- colgroup: $('<colgroup>').prependTo(this),
177
+ colgroup: $('<colgroup>'),
178
178
  fastData: function (row, column, type) {
179
179
  return _fnGetCellData(oSettings, row, column, type);
180
180
  }
@@ -247,6 +247,7 @@
247
247
  "orderHandler",
248
248
  "titleRow",
249
249
  "typeDetect",
250
+ "columnTitleTag",
250
251
  [ "iCookieDuration", "iStateDuration" ], // backwards compat
251
252
  [ "oSearch", "oPreviousSearch" ],
252
253
  [ "aoSearchCols", "aoPreSearchCols" ],
@@ -411,7 +412,7 @@
411
412
 
412
413
  if ( oSettings.caption ) {
413
414
  if ( caption.length === 0 ) {
414
- caption = $('<caption/>').appendTo( $this );
415
+ caption = $('<caption/>').prependTo( $this );
415
416
  }
416
417
 
417
418
  caption.html( oSettings.caption );
@@ -424,6 +425,14 @@
424
425
  oSettings.captionNode = caption[0];
425
426
  }
426
427
 
428
+ // Place the colgroup element in the correct location for the HTML structure
429
+ if (caption.length) {
430
+ oSettings.colgroup.insertAfter(caption);
431
+ }
432
+ else {
433
+ oSettings.colgroup.prependTo(oSettings.nTable);
434
+ }
435
+
427
436
  if ( thead.length === 0 ) {
428
437
  thead = $('<thead/>').appendTo($this);
429
438
  }
@@ -1280,7 +1289,7 @@
1280
1289
  };
1281
1290
 
1282
1291
  // Replaceable function in api.util
1283
- var _stripHtml = function (input) {
1292
+ var _stripHtml = function (input, replacement) {
1284
1293
  if (! input || typeof input !== 'string') {
1285
1294
  return input;
1286
1295
  }
@@ -1292,7 +1301,7 @@
1292
1301
 
1293
1302
  var previous;
1294
1303
 
1295
- input = input.replace(_re_html, ''); // Complete tags
1304
+ input = input.replace(_re_html, replacement || ''); // Complete tags
1296
1305
 
1297
1306
  // Safety for incomplete script tag - use do / while to ensure that
1298
1307
  // we get all instances
@@ -1757,7 +1766,7 @@
1757
1766
  }
1758
1767
  },
1759
1768
 
1760
- stripHtml: function (mixed) {
1769
+ stripHtml: function (mixed, replacement) {
1761
1770
  var type = typeof mixed;
1762
1771
 
1763
1772
  if (type === 'function') {
@@ -1765,7 +1774,7 @@
1765
1774
  return;
1766
1775
  }
1767
1776
  else if (type === 'string') {
1768
- return _stripHtml(mixed);
1777
+ return _stripHtml(mixed, replacement);
1769
1778
  }
1770
1779
  return mixed;
1771
1780
  },
@@ -3367,7 +3376,7 @@
3367
3376
  colspan++;
3368
3377
  }
3369
3378
 
3370
- var titleSpan = $('span.dt-column-title', cell);
3379
+ var titleSpan = $('.dt-column-title', cell);
3371
3380
 
3372
3381
  structure[row][column] = {
3373
3382
  cell: cell,
@@ -4081,8 +4090,8 @@
4081
4090
  }
4082
4091
 
4083
4092
  // Wrap the column title so we can write to it in future
4084
- if ( $('span.dt-column-title', cell).length === 0) {
4085
- $('<span>')
4093
+ if ( $('.dt-column-title', cell).length === 0) {
4094
+ $(document.createElement(settings.columnTitleTag))
4086
4095
  .addClass('dt-column-title')
4087
4096
  .append(cell.childNodes)
4088
4097
  .appendTo(cell);
@@ -4093,9 +4102,9 @@
4093
4102
  isHeader &&
4094
4103
  jqCell.filter(':not([data-dt-order=disable])').length !== 0 &&
4095
4104
  jqCell.parent(':not([data-dt-order=disable])').length !== 0 &&
4096
- $('span.dt-column-order', cell).length === 0
4105
+ $('.dt-column-order', cell).length === 0
4097
4106
  ) {
4098
- $('<span>')
4107
+ $(document.createElement(settings.columnTitleTag))
4099
4108
  .addClass('dt-column-order')
4100
4109
  .appendTo(cell);
4101
4110
  }
@@ -4104,7 +4113,7 @@
4104
4113
  // layout for those elements
4105
4114
  var headerFooter = isHeader ? 'header' : 'footer';
4106
4115
 
4107
- if ( $('span.dt-column-' + headerFooter, cell).length === 0) {
4116
+ if ( $('div.dt-column-' + headerFooter, cell).length === 0) {
4108
4117
  $('<div>')
4109
4118
  .addClass('dt-column-' + headerFooter)
4110
4119
  .append(cell.childNodes)
@@ -4261,6 +4270,10 @@
4261
4270
  // Custom Ajax option to submit the parameters as a JSON string
4262
4271
  if (baseAjax.submitAs === 'json' && typeof data === 'object') {
4263
4272
  baseAjax.data = JSON.stringify(data);
4273
+
4274
+ if (!baseAjax.contentType) {
4275
+ baseAjax.contentType = 'application/json; charset=utf-8';
4276
+ }
4264
4277
  }
4265
4278
 
4266
4279
  if (typeof ajax === 'function') {
@@ -5519,7 +5532,7 @@
5519
5532
  var autoClass = _ext.type.className[column.sType];
5520
5533
  var padding = column.sContentPadding || (scrollX ? '-' : '');
5521
5534
  var text = longest + padding;
5522
- var insert = longest.indexOf('<') === -1
5535
+ var insert = longest.indexOf('<') === -1 && longest.indexOf('&') === -1
5523
5536
  ? document.createTextNode(text)
5524
5537
  : text
5525
5538
 
@@ -5707,15 +5720,20 @@
5707
5720
  .replace(/id=".*?"/g, '')
5708
5721
  .replace(/name=".*?"/g, '');
5709
5722
 
5710
- var s = _stripHtml(cellString)
5723
+ // Don't want Javascript at all in these calculation cells.
5724
+ cellString = cellString.replace(/<script.*?<\/script>/gi, ' ');
5725
+
5726
+ var noHtml = _stripHtml(cellString, ' ')
5711
5727
  .replace( /&nbsp;/g, ' ' );
5712
5728
 
5729
+ // The length is calculated on the text only, but we keep the HTML
5730
+ // in the string so it can be used in the calculation table
5713
5731
  collection.push({
5714
- str: s,
5715
- len: s.length
5732
+ str: cellString,
5733
+ len: noHtml.length
5716
5734
  });
5717
5735
 
5718
- allStrings.push(s);
5736
+ allStrings.push(noHtml);
5719
5737
  }
5720
5738
 
5721
5739
  // Order and then cut down to the size we need
@@ -8770,7 +8788,7 @@
8770
8788
  // Automatic - find the _last_ unique cell from the top that is not empty (last for
8771
8789
  // backwards compatibility)
8772
8790
  for (var i=0 ; i<header.length ; i++) {
8773
- if (header[i][column].unique && $('span.dt-column-title', header[i][column].cell).text()) {
8791
+ if (header[i][column].unique && $('.dt-column-title', header[i][column].cell).text()) {
8774
8792
  target = i;
8775
8793
  }
8776
8794
  }
@@ -8866,6 +8884,10 @@
8866
8884
  return null;
8867
8885
  }
8868
8886
 
8887
+ if (col.responsiveVisible === false) {
8888
+ return null;
8889
+ }
8890
+
8869
8891
  // Selector
8870
8892
  if (match[1]) {
8871
8893
  return $(nodes[idx]).filter(match[1]).length > 0 ? idx : null;
@@ -9077,7 +9099,7 @@
9077
9099
  title = undefined;
9078
9100
  }
9079
9101
 
9080
- var span = $('span.dt-column-title', this.column(column).header(row));
9102
+ var span = $('.dt-column-title', this.column(column).header(row));
9081
9103
 
9082
9104
  if (title !== undefined) {
9083
9105
  span.html(title);
@@ -10251,8 +10273,8 @@
10251
10273
 
10252
10274
  // Needed for header and footer, so pulled into its own function
10253
10275
  function cleanHeader(node, className) {
10254
- $(node).find('span.dt-column-order').remove();
10255
- $(node).find('span.dt-column-title').each(function () {
10276
+ $(node).find('.dt-column-order').remove();
10277
+ $(node).find('.dt-column-title').each(function () {
10256
10278
  var title = $(this).html();
10257
10279
  $(this).parent().parent().append(title);
10258
10280
  $(this).remove();
@@ -10270,7 +10292,7 @@
10270
10292
  * @type string
10271
10293
  * @default Version number
10272
10294
  */
10273
- DataTable.version = "2.3.5";
10295
+ DataTable.version = "2.3.7";
10274
10296
 
10275
10297
  /**
10276
10298
  * Private data store, containing all of the settings objects that are
@@ -11438,7 +11460,10 @@
11438
11460
  iDeferLoading: null,
11439
11461
 
11440
11462
  /** Event listeners */
11441
- on: null
11463
+ on: null,
11464
+
11465
+ /** Title wrapper element type */
11466
+ columnTitleTag: 'span'
11442
11467
  };
11443
11468
 
11444
11469
  _fnHungarianMap( DataTable.defaults );
@@ -12402,7 +12427,10 @@
12402
12427
  orderHandler: true,
12403
12428
 
12404
12429
  /** Title row indicator */
12405
- titleRow: null
12430
+ titleRow: null,
12431
+
12432
+ /** Title wrapper element type */
12433
+ columnTitleTag: 'span'
12406
12434
  };
12407
12435
 
12408
12436
  /**