datatables.net 2.0.3 → 2.0.5

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,11 +1,11 @@
1
- /*! DataTables 2.0.3
1
+ /*! DataTables 2.0.5
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  /**
6
6
  * @summary DataTables
7
7
  * @description Paginate, search and order HTML tables
8
- * @version 2.0.3
8
+ * @version 2.0.5
9
9
  * @author SpryMedia Ltd
10
10
  * @contact www.datatables.net
11
11
  * @copyright SpryMedia Ltd.
@@ -1096,7 +1096,8 @@
1096
1096
 
1097
1097
  var _re_dic = {};
1098
1098
  var _re_new_lines = /[\r\n\u2028]/g;
1099
- var _re_html = /<.*?>/g;
1099
+ var _re_html = /<([^>]*>)/g;
1100
+ var _max_str_len = Math.pow(2, 28);
1100
1101
 
1101
1102
  // This is not strict ISO8601 - Date.parse() is quite lax, although
1102
1103
  // implementations differ between browsers.
@@ -1284,10 +1285,24 @@
1284
1285
  };
1285
1286
 
1286
1287
  // Replaceable function in api.util
1287
- var _stripHtml = function ( d ) {
1288
- return d
1289
- .replace( _re_html, '' ) // Complete tags
1290
- .replace(/<script/i, ''); // Safety for incomplete script tag
1288
+ var _stripHtml = function (input) {
1289
+ // Irrelevant check to workaround CodeQL's false positive on the regex
1290
+ if (input.length > _max_str_len) {
1291
+ throw new Error('Exceeded max str len');
1292
+ }
1293
+
1294
+ var previous;
1295
+
1296
+ input = input.replace(_re_html, ''); // Complete tags
1297
+
1298
+ // Safety for incomplete script tag - use do / while to ensure that
1299
+ // we get all instances
1300
+ do {
1301
+ previous = input;
1302
+ input = input.replace(/<script/i, '');
1303
+ } while (input !== previous);
1304
+
1305
+ return previous;
1291
1306
  };
1292
1307
 
1293
1308
  // Replaceable function in api.util
@@ -2002,7 +2017,7 @@
2002
2017
  "mData": oDefaults.mData ? oDefaults.mData : iCol,
2003
2018
  idx: iCol,
2004
2019
  searchFixed: {},
2005
- colEl: $('<col>')
2020
+ colEl: $('<col>').attr('data-dt-column', iCol)
2006
2021
  } );
2007
2022
  oSettings.aoColumns.push( oCol );
2008
2023
 
@@ -2630,9 +2645,15 @@
2630
2645
  type = 'sort';
2631
2646
  }
2632
2647
 
2648
+ var row = settings.aoData[rowIdx];
2649
+
2650
+ if (! row) {
2651
+ return undefined;
2652
+ }
2653
+
2633
2654
  var draw = settings.iDraw;
2634
2655
  var col = settings.aoColumns[colIdx];
2635
- var rowData = settings.aoData[rowIdx]._aData;
2656
+ var rowData = row._aData;
2636
2657
  var defaultContent = col.sDefaultContent;
2637
2658
  var cellData = col.fnGetData( rowData, type, {
2638
2659
  settings: settings,
@@ -3887,7 +3908,7 @@
3887
3908
  }
3888
3909
 
3889
3910
  if (! columnDef.sTitle && unique) {
3890
- columnDef.sTitle = cell.innerHTML.replace( /<.*?>/g, "" );
3911
+ columnDef.sTitle = _stripHtml(cell.innerHTML);
3891
3912
  columnDef.autoTitle = true;
3892
3913
  }
3893
3914
  }
@@ -4508,7 +4529,7 @@
4508
4529
  word = '';
4509
4530
  }
4510
4531
 
4511
- return word.replace('"', '');
4532
+ return word.replace(/"/g, '');
4512
4533
  } );
4513
4534
 
4514
4535
  var match = not.length
@@ -5040,20 +5061,27 @@
5040
5061
  // uses a cell which has a longer string, but isn't the widest! For example
5041
5062
  // "Chief Executive Officer (CEO)" is the longest string in the demo, but
5042
5063
  // "Systems Administrator" is actually the widest string since it doesn't collapse.
5064
+ // Note the use of translating into a column index to get the `col` element. This
5065
+ // is because of Responsive which might remove `col` elements, knocking the alignment
5066
+ // of the indexes out.
5043
5067
  if (settings.aiDisplay.length) {
5044
5068
  // Get the column sizes from the first row in the table
5045
- var colSizes = table.find('tbody tr').eq(0).find('th, td').map(function () {
5046
- return $(this).outerWidth();
5069
+ var colSizes = table.find('tbody tr').eq(0).find('th, td').map(function (vis) {
5070
+ return {
5071
+ idx: _fnVisibleToColumnIndex(settings, vis),
5072
+ width: $(this).outerWidth()
5073
+ }
5047
5074
  });
5048
5075
 
5049
5076
  // Check against what the colgroup > col is set to and correct if needed
5050
- $('col', settings.colgroup).each(function (i) {
5051
- var colWidth = this.style.width.replace('px', '');
5077
+ for (var i=0 ; i<colSizes.length ; i++) {
5078
+ var colEl = settings.aoColumns[ colSizes[i].idx ].colEl[0];
5079
+ var colWidth = colEl.style.width.replace('px', '');
5052
5080
 
5053
- if (colWidth !== colSizes[i]) {
5054
- this.style.width = colSizes[i] + 'px';
5081
+ if (colWidth !== colSizes[i].width) {
5082
+ colEl.style.width = colSizes[i].width + 'px';
5055
5083
  }
5056
- });
5084
+ }
5057
5085
  }
5058
5086
 
5059
5087
  // 3. Copy the colgroup over to the header and footer
@@ -6849,6 +6877,10 @@
6849
6877
  for ( i=0, ien=ext.length ; i<ien ; i++ ) {
6850
6878
  struct = ext[i];
6851
6879
 
6880
+ if (struct.name === '__proto__') {
6881
+ continue;
6882
+ }
6883
+
6852
6884
  // Value
6853
6885
  obj[ struct.name ] = struct.type === 'function' ?
6854
6886
  _api_scope( scope, struct.val, struct ) :
@@ -7511,16 +7543,7 @@
7511
7543
  order = opts.order, // applied, current, index (original - compatibility with 1.9)
7512
7544
  page = opts.page; // all, current
7513
7545
 
7514
- if ( _fnDataSource( settings ) == 'ssp' ) {
7515
- // In server-side processing mode, most options are irrelevant since
7516
- // rows not shown don't exist and the index order is the applied order
7517
- // Removed is a special case - for consistency just return an empty
7518
- // array
7519
- return search === 'removed' ?
7520
- [] :
7521
- _range( 0, displayMaster.length );
7522
- }
7523
- else if ( page == 'current' ) {
7546
+ if ( page == 'current' ) {
7524
7547
  // Current page implies that order=current and filter=applied, since it is
7525
7548
  // fairly senseless otherwise, regardless of what order and search actually
7526
7549
  // are
@@ -7789,11 +7812,6 @@
7789
7812
  settings.aiDisplayMaster.splice(idx, 1);
7790
7813
  }
7791
7814
 
7792
- idx = settings.aiDisplay.indexOf(row);
7793
- if (idx !== -1) {
7794
- settings.aiDisplay.splice(idx, 1);
7795
- }
7796
-
7797
7815
  // For server-side processing tables - subtract the deleted row from the count
7798
7816
  if ( settings._iRecordsDisplay > 0 ) {
7799
7817
  settings._iRecordsDisplay--;
@@ -7943,8 +7961,9 @@
7943
7961
  {
7944
7962
  if ( state && state.childRows ) {
7945
7963
  api
7946
- .rows( state.childRows.map(function (id){
7947
- return id.replace(/:/g, '\\:')
7964
+ .rows( state.childRows.map(function (id) {
7965
+ // Escape any `:` characters from the row id, unless previously escaped
7966
+ return id.replace(/(?<!\\):/g, '\\:');
7948
7967
  }) )
7949
7968
  .every( function () {
7950
7969
  _fnCallbackFire( api.settings()[0], null, 'requestChild', [ this ] )
@@ -8225,6 +8244,17 @@
8225
8244
  };
8226
8245
 
8227
8246
 
8247
+ var __column_header = function ( settings, column, row ) {
8248
+ var header = settings.aoHeader;
8249
+ var target = row !== undefined
8250
+ ? row
8251
+ : settings.bSortCellsTop // legacy support
8252
+ ? 0
8253
+ : header.length - 1;
8254
+
8255
+ return header[target][column].cell;
8256
+ };
8257
+
8228
8258
  var __column_selector = function ( settings, selector, opts )
8229
8259
  {
8230
8260
  var
@@ -8257,7 +8287,8 @@
8257
8287
  return columns.map(function (col, idx) {
8258
8288
  return s(
8259
8289
  idx,
8260
- __columnData( settings, idx, 0, 0, rows )
8290
+ __columnData( settings, idx, 0, 0, rows ),
8291
+ __column_header( settings, idx )
8261
8292
  ) ? idx : null;
8262
8293
  });
8263
8294
  }
@@ -8402,15 +8433,8 @@
8402
8433
  } );
8403
8434
 
8404
8435
  _api_registerPlural( 'columns().header()', 'column().header()', function ( row ) {
8405
- return this.iterator( 'column', function ( settings, column ) {
8406
- var header = settings.aoHeader;
8407
- var target = row !== undefined
8408
- ? row
8409
- : settings.bSortCellsTop // legacy support
8410
- ? 0
8411
- : header.length - 1;
8412
-
8413
- return header[target][column].cell;
8436
+ return this.iterator( 'column', function (settings, column) {
8437
+ return __column_header(settings, column, row);
8414
8438
  }, 1 );
8415
8439
  } );
8416
8440
 
@@ -9563,7 +9587,7 @@
9563
9587
  * @type string
9564
9588
  * @default Version number
9565
9589
  */
9566
- DataTable.version = "2.0.3";
9590
+ DataTable.version = "2.0.5";
9567
9591
 
9568
9592
  /**
9569
9593
  * Private data store, containing all of the settings objects that are
@@ -10418,24 +10442,24 @@
10418
10442
  */
10419
10443
  "oPaginate": {
10420
10444
  /**
10421
- * Label and character for first page button
10445
+ * Label and character for first page button («)
10422
10446
  */
10423
- "sFirst": "«",
10447
+ "sFirst": "\u00AB",
10424
10448
 
10425
10449
  /**
10426
- * Last page button
10450
+ * Last page button (»)
10427
10451
  */
10428
- "sLast": "»",
10452
+ "sLast": "\u00BB",
10429
10453
 
10430
10454
  /**
10431
- * Next page button
10455
+ * Next page button (›)
10432
10456
  */
10433
- "sNext": "",
10457
+ "sNext": "\u203A",
10434
10458
 
10435
10459
  /**
10436
- * Previous page button
10460
+ * Previous page button (‹)
10437
10461
  */
10438
- "sPrevious": "",
10462
+ "sPrevious": "\u2039",
10439
10463
  },
10440
10464
 
10441
10465
  /**
@@ -11664,657 +11688,95 @@
11664
11688
  */
11665
11689
 
11666
11690
 
11667
- /**
11668
- * DataTables extensions
11669
- *
11670
- * This namespace acts as a collection area for plug-ins that can be used to
11671
- * extend DataTables capabilities. Indeed many of the build in methods
11672
- * use this method to provide their own capabilities (sorting methods for
11673
- * example).
11674
- *
11675
- * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
11676
- * reasons
11677
- *
11678
- * @namespace
11679
- */
11680
- DataTable.ext = _ext = {
11681
- /**
11682
- * Buttons. For use with the Buttons extension for DataTables. This is
11683
- * defined here so other extensions can define buttons regardless of load
11684
- * order. It is _not_ used by DataTables core.
11685
- *
11686
- * @type object
11687
- * @default {}
11688
- */
11689
- buttons: {},
11691
+ var extPagination = DataTable.ext.pager;
11690
11692
 
11693
+ // Paging buttons configuration
11694
+ $.extend( extPagination, {
11695
+ simple: function () {
11696
+ return [ 'previous', 'next' ];
11697
+ },
11691
11698
 
11692
- /**
11693
- * Element class names
11694
- *
11695
- * @type object
11696
- * @default {}
11697
- */
11698
- classes: {},
11699
+ full: function () {
11700
+ return [ 'first', 'previous', 'next', 'last' ];
11701
+ },
11699
11702
 
11703
+ numbers: function () {
11704
+ return [ 'numbers' ];
11705
+ },
11700
11706
 
11701
- /**
11702
- * DataTables build type (expanded by the download builder)
11703
- *
11704
- * @type string
11705
- */
11706
- builder: "-source-",
11707
+ simple_numbers: function () {
11708
+ return [ 'previous', 'numbers', 'next' ];
11709
+ },
11707
11710
 
11711
+ full_numbers: function () {
11712
+ return [ 'first', 'previous', 'numbers', 'next', 'last' ];
11713
+ },
11714
+
11715
+ first_last: function () {
11716
+ return ['first', 'last'];
11717
+ },
11718
+
11719
+ first_last_numbers: function () {
11720
+ return ['first', 'numbers', 'last'];
11721
+ },
11708
11722
 
11709
- /**
11710
- * Error reporting.
11711
- *
11712
- * How should DataTables report an error. Can take the value 'alert',
11713
- * 'throw', 'none' or a function.
11714
- *
11715
- * @type string|function
11716
- * @default alert
11717
- */
11718
- errMode: "alert",
11723
+ // For testing and plug-ins to use
11724
+ _numbers: _pagingNumbers,
11719
11725
 
11726
+ // Number of number buttons - legacy, use `numbers` option for paging feature
11727
+ numbers_length: 7
11728
+ } );
11720
11729
 
11721
- /**
11722
- * Legacy so v1 plug-ins don't throw js errors on load
11723
- */
11724
- feature: [],
11725
11730
 
11726
- /**
11727
- * Feature plug-ins.
11728
- *
11729
- * This is an object of callbacks which provide the features for DataTables
11730
- * to be initialised via the `layout` option.
11731
- */
11732
- features: {},
11731
+ $.extend( true, DataTable.ext.renderer, {
11732
+ pagingButton: {
11733
+ _: function (settings, buttonType, content, active, disabled) {
11734
+ var classes = settings.oClasses.paging;
11735
+ var btnClasses = [classes.button];
11736
+ var btn;
11733
11737
 
11738
+ if (active) {
11739
+ btnClasses.push(classes.active);
11740
+ }
11734
11741
 
11735
- /**
11736
- * Row searching.
11737
- *
11738
- * This method of searching is complimentary to the default type based
11739
- * searching, and a lot more comprehensive as it allows you complete control
11740
- * over the searching logic. Each element in this array is a function
11741
- * (parameters described below) that is called for every row in the table,
11742
- * and your logic decides if it should be included in the searching data set
11743
- * or not.
11744
- *
11745
- * Searching functions have the following input parameters:
11746
- *
11747
- * 1. `{object}` DataTables settings object: see
11748
- * {@link DataTable.models.oSettings}
11749
- * 2. `{array|object}` Data for the row to be processed (same as the
11750
- * original format that was passed in as the data source, or an array
11751
- * from a DOM data source
11752
- * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
11753
- * can be useful to retrieve the `TR` element if you need DOM interaction.
11754
- *
11755
- * And the following return is expected:
11756
- *
11757
- * * {boolean} Include the row in the searched result set (true) or not
11758
- * (false)
11759
- *
11760
- * Note that as with the main search ability in DataTables, technically this
11761
- * is "filtering", since it is subtractive. However, for consistency in
11762
- * naming we call it searching here.
11763
- *
11764
- * @type array
11765
- * @default []
11766
- *
11767
- * @example
11768
- * // The following example shows custom search being applied to the
11769
- * // fourth column (i.e. the data[3] index) based on two input values
11770
- * // from the end-user, matching the data in a certain range.
11771
- * $.fn.dataTable.ext.search.push(
11772
- * function( settings, data, dataIndex ) {
11773
- * var min = document.getElementById('min').value * 1;
11774
- * var max = document.getElementById('max').value * 1;
11775
- * var version = data[3] == "-" ? 0 : data[3]*1;
11776
- *
11777
- * if ( min == "" && max == "" ) {
11778
- * return true;
11779
- * }
11780
- * else if ( min == "" && version < max ) {
11781
- * return true;
11782
- * }
11783
- * else if ( min < version && "" == max ) {
11784
- * return true;
11785
- * }
11786
- * else if ( min < version && version < max ) {
11787
- * return true;
11788
- * }
11789
- * return false;
11790
- * }
11791
- * );
11792
- */
11793
- search: [],
11742
+ if (disabled) {
11743
+ btnClasses.push(classes.disabled)
11744
+ }
11794
11745
 
11746
+ if (buttonType === 'ellipsis') {
11747
+ btn = $('<span class="ellipsis"></span>').html(content)[0];
11748
+ }
11749
+ else {
11750
+ btn = $('<button>', {
11751
+ class: btnClasses.join(' '),
11752
+ role: 'link',
11753
+ type: 'button'
11754
+ }).html(content);
11755
+ }
11795
11756
 
11796
- /**
11797
- * Selector extensions
11798
- *
11799
- * The `selector` option can be used to extend the options available for the
11800
- * selector modifier options (`selector-modifier` object data type) that
11801
- * each of the three built in selector types offer (row, column and cell +
11802
- * their plural counterparts). For example the Select extension uses this
11803
- * mechanism to provide an option to select only rows, columns and cells
11804
- * that have been marked as selected by the end user (`{selected: true}`),
11805
- * which can be used in conjunction with the existing built in selector
11806
- * options.
11807
- *
11808
- * Each property is an array to which functions can be pushed. The functions
11809
- * take three attributes:
11810
- *
11811
- * * Settings object for the host table
11812
- * * Options object (`selector-modifier` object type)
11813
- * * Array of selected item indexes
11814
- *
11815
- * The return is an array of the resulting item indexes after the custom
11816
- * selector has been applied.
11817
- *
11818
- * @type object
11819
- */
11820
- selector: {
11821
- cell: [],
11822
- column: [],
11823
- row: []
11757
+ return {
11758
+ display: btn,
11759
+ clicker: btn
11760
+ }
11761
+ }
11824
11762
  },
11825
11763
 
11764
+ pagingContainer: {
11765
+ _: function (settings, buttons) {
11766
+ // No wrapping element - just append directly to the host
11767
+ return buttons;
11768
+ }
11769
+ }
11770
+ } );
11826
11771
 
11827
- /**
11828
- * Legacy configuration options. Enable and disable legacy options that
11829
- * are available in DataTables.
11830
- *
11831
- * @type object
11832
- */
11833
- legacy: {
11834
- /**
11835
- * Enable / disable DataTables 1.9 compatible server-side processing
11836
- * requests
11837
- *
11838
- * @type boolean
11839
- * @default null
11840
- */
11841
- ajax: null
11842
- },
11772
+ // Common function to remove new lines, strip HTML and diacritic control
11773
+ var _filterString = function (stripHtml, normalize) {
11774
+ return function (str) {
11775
+ if (_empty(str) || typeof str !== 'string') {
11776
+ return str;
11777
+ }
11843
11778
 
11844
-
11845
- /**
11846
- * Pagination plug-in methods.
11847
- *
11848
- * Each entry in this object is a function and defines which buttons should
11849
- * be shown by the pagination rendering method that is used for the table:
11850
- * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
11851
- * buttons are displayed in the document, while the functions here tell it
11852
- * what buttons to display. This is done by returning an array of button
11853
- * descriptions (what each button will do).
11854
- *
11855
- * Pagination types (the four built in options and any additional plug-in
11856
- * options defined here) can be used through the `paginationType`
11857
- * initialisation parameter.
11858
- *
11859
- * The functions defined take two parameters:
11860
- *
11861
- * 1. `{int} page` The current page index
11862
- * 2. `{int} pages` The number of pages in the table
11863
- *
11864
- * Each function is expected to return an array where each element of the
11865
- * array can be one of:
11866
- *
11867
- * * `first` - Jump to first page when activated
11868
- * * `last` - Jump to last page when activated
11869
- * * `previous` - Show previous page when activated
11870
- * * `next` - Show next page when activated
11871
- * * `{int}` - Show page of the index given
11872
- * * `{array}` - A nested array containing the above elements to add a
11873
- * containing 'DIV' element (might be useful for styling).
11874
- *
11875
- * Note that DataTables v1.9- used this object slightly differently whereby
11876
- * an object with two functions would be defined for each plug-in. That
11877
- * ability is still supported by DataTables 1.10+ to provide backwards
11878
- * compatibility, but this option of use is now decremented and no longer
11879
- * documented in DataTables 1.10+.
11880
- *
11881
- * @type object
11882
- * @default {}
11883
- *
11884
- * @example
11885
- * // Show previous, next and current page buttons only
11886
- * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
11887
- * return [ 'previous', page, 'next' ];
11888
- * };
11889
- */
11890
- pager: {},
11891
-
11892
-
11893
- renderer: {
11894
- pageButton: {},
11895
- header: {}
11896
- },
11897
-
11898
-
11899
- /**
11900
- * Ordering plug-ins - custom data source
11901
- *
11902
- * The extension options for ordering of data available here is complimentary
11903
- * to the default type based ordering that DataTables typically uses. It
11904
- * allows much greater control over the the data that is being used to
11905
- * order a column, but is necessarily therefore more complex.
11906
- *
11907
- * This type of ordering is useful if you want to do ordering based on data
11908
- * live from the DOM (for example the contents of an 'input' element) rather
11909
- * than just the static string that DataTables knows of.
11910
- *
11911
- * The way these plug-ins work is that you create an array of the values you
11912
- * wish to be ordering for the column in question and then return that
11913
- * array. The data in the array much be in the index order of the rows in
11914
- * the table (not the currently ordering order!). Which order data gathering
11915
- * function is run here depends on the `dt-init columns.orderDataType`
11916
- * parameter that is used for the column (if any).
11917
- *
11918
- * The functions defined take two parameters:
11919
- *
11920
- * 1. `{object}` DataTables settings object: see
11921
- * {@link DataTable.models.oSettings}
11922
- * 2. `{int}` Target column index
11923
- *
11924
- * Each function is expected to return an array:
11925
- *
11926
- * * `{array}` Data for the column to be ordering upon
11927
- *
11928
- * @type array
11929
- *
11930
- * @example
11931
- * // Ordering using `input` node values
11932
- * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
11933
- * {
11934
- * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
11935
- * return $('input', td).val();
11936
- * } );
11937
- * }
11938
- */
11939
- order: {},
11940
-
11941
-
11942
- /**
11943
- * Type based plug-ins.
11944
- *
11945
- * Each column in DataTables has a type assigned to it, either by automatic
11946
- * detection or by direct assignment using the `type` option for the column.
11947
- * The type of a column will effect how it is ordering and search (plug-ins
11948
- * can also make use of the column type if required).
11949
- *
11950
- * @namespace
11951
- */
11952
- type: {
11953
- /**
11954
- * Automatic column class assignment
11955
- */
11956
- className: {},
11957
-
11958
- /**
11959
- * Type detection functions.
11960
- *
11961
- * The functions defined in this object are used to automatically detect
11962
- * a column's type, making initialisation of DataTables super easy, even
11963
- * when complex data is in the table.
11964
- *
11965
- * The functions defined take two parameters:
11966
- *
11967
- * 1. `{*}` Data from the column cell to be analysed
11968
- * 2. `{settings}` DataTables settings object. This can be used to
11969
- * perform context specific type detection - for example detection
11970
- * based on language settings such as using a comma for a decimal
11971
- * place. Generally speaking the options from the settings will not
11972
- * be required
11973
- *
11974
- * Each function is expected to return:
11975
- *
11976
- * * `{string|null}` Data type detected, or null if unknown (and thus
11977
- * pass it on to the other type detection functions.
11978
- *
11979
- * @type array
11980
- *
11981
- * @example
11982
- * // Currency type detection plug-in:
11983
- * $.fn.dataTable.ext.type.detect.push(
11984
- * function ( data, settings ) {
11985
- * // Check the numeric part
11986
- * if ( ! data.substring(1).match(/[0-9]/) ) {
11987
- * return null;
11988
- * }
11989
- *
11990
- * // Check prefixed by currency
11991
- * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
11992
- * return 'currency';
11993
- * }
11994
- * return null;
11995
- * }
11996
- * );
11997
- */
11998
- detect: [],
11999
-
12000
- /**
12001
- * Automatic renderer assignment
12002
- */
12003
- render: {},
12004
-
12005
-
12006
- /**
12007
- * Type based search formatting.
12008
- *
12009
- * The type based searching functions can be used to pre-format the
12010
- * data to be search on. For example, it can be used to strip HTML
12011
- * tags or to de-format telephone numbers for numeric only searching.
12012
- *
12013
- * Note that is a search is not defined for a column of a given type,
12014
- * no search formatting will be performed.
12015
- *
12016
- * Pre-processing of searching data plug-ins - When you assign the sType
12017
- * for a column (or have it automatically detected for you by DataTables
12018
- * or a type detection plug-in), you will typically be using this for
12019
- * custom sorting, but it can also be used to provide custom searching
12020
- * by allowing you to pre-processing the data and returning the data in
12021
- * the format that should be searched upon. This is done by adding
12022
- * functions this object with a parameter name which matches the sType
12023
- * for that target column. This is the corollary of <i>afnSortData</i>
12024
- * for searching data.
12025
- *
12026
- * The functions defined take a single parameter:
12027
- *
12028
- * 1. `{*}` Data from the column cell to be prepared for searching
12029
- *
12030
- * Each function is expected to return:
12031
- *
12032
- * * `{string|null}` Formatted string that will be used for the searching.
12033
- *
12034
- * @type object
12035
- * @default {}
12036
- *
12037
- * @example
12038
- * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
12039
- * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
12040
- * }
12041
- */
12042
- search: {},
12043
-
12044
-
12045
- /**
12046
- * Type based ordering.
12047
- *
12048
- * The column type tells DataTables what ordering to apply to the table
12049
- * when a column is sorted upon. The order for each type that is defined,
12050
- * is defined by the functions available in this object.
12051
- *
12052
- * Each ordering option can be described by three properties added to
12053
- * this object:
12054
- *
12055
- * * `{type}-pre` - Pre-formatting function
12056
- * * `{type}-asc` - Ascending order function
12057
- * * `{type}-desc` - Descending order function
12058
- *
12059
- * All three can be used together, only `{type}-pre` or only
12060
- * `{type}-asc` and `{type}-desc` together. It is generally recommended
12061
- * that only `{type}-pre` is used, as this provides the optimal
12062
- * implementation in terms of speed, although the others are provided
12063
- * for compatibility with existing Javascript sort functions.
12064
- *
12065
- * `{type}-pre`: Functions defined take a single parameter:
12066
- *
12067
- * 1. `{*}` Data from the column cell to be prepared for ordering
12068
- *
12069
- * And return:
12070
- *
12071
- * * `{*}` Data to be sorted upon
12072
- *
12073
- * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
12074
- * functions, taking two parameters:
12075
- *
12076
- * 1. `{*}` Data to compare to the second parameter
12077
- * 2. `{*}` Data to compare to the first parameter
12078
- *
12079
- * And returning:
12080
- *
12081
- * * `{*}` Ordering match: <0 if first parameter should be sorted lower
12082
- * than the second parameter, ===0 if the two parameters are equal and
12083
- * >0 if the first parameter should be sorted height than the second
12084
- * parameter.
12085
- *
12086
- * @type object
12087
- * @default {}
12088
- *
12089
- * @example
12090
- * // Numeric ordering of formatted numbers with a pre-formatter
12091
- * $.extend( $.fn.dataTable.ext.type.order, {
12092
- * "string-pre": function(x) {
12093
- * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
12094
- * return parseFloat( a );
12095
- * }
12096
- * } );
12097
- *
12098
- * @example
12099
- * // Case-sensitive string ordering, with no pre-formatting method
12100
- * $.extend( $.fn.dataTable.ext.order, {
12101
- * "string-case-asc": function(x,y) {
12102
- * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
12103
- * },
12104
- * "string-case-desc": function(x,y) {
12105
- * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
12106
- * }
12107
- * } );
12108
- */
12109
- order: {}
12110
- },
12111
-
12112
- /**
12113
- * Unique DataTables instance counter
12114
- *
12115
- * @type int
12116
- * @private
12117
- */
12118
- _unique: 0,
12119
-
12120
-
12121
- //
12122
- // Depreciated
12123
- // The following properties are retained for backwards compatibility only.
12124
- // The should not be used in new projects and will be removed in a future
12125
- // version
12126
- //
12127
-
12128
- /**
12129
- * Version check function.
12130
- * @type function
12131
- * @depreciated Since 1.10
12132
- */
12133
- fnVersionCheck: DataTable.fnVersionCheck,
12134
-
12135
-
12136
- /**
12137
- * Index for what 'this' index API functions should use
12138
- * @type int
12139
- * @deprecated Since v1.10
12140
- */
12141
- iApiIndex: 0,
12142
-
12143
-
12144
- /**
12145
- * Software version
12146
- * @type string
12147
- * @deprecated Since v1.10
12148
- */
12149
- sVersion: DataTable.version
12150
- };
12151
-
12152
-
12153
- //
12154
- // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
12155
- //
12156
- $.extend( _ext, {
12157
- afnFiltering: _ext.search,
12158
- aTypes: _ext.type.detect,
12159
- ofnSearch: _ext.type.search,
12160
- oSort: _ext.type.order,
12161
- afnSortData: _ext.order,
12162
- aoFeatures: _ext.feature,
12163
- oStdClasses: _ext.classes,
12164
- oPagination: _ext.pager
12165
- } );
12166
-
12167
-
12168
- $.extend( DataTable.ext.classes, {
12169
- container: 'dt-container',
12170
- empty: {
12171
- row: 'dt-empty'
12172
- },
12173
- info: {
12174
- container: 'dt-info'
12175
- },
12176
- length: {
12177
- container: 'dt-length',
12178
- select: 'dt-input'
12179
- },
12180
- order: {
12181
- canAsc: 'dt-orderable-asc',
12182
- canDesc: 'dt-orderable-desc',
12183
- isAsc: 'dt-ordering-asc',
12184
- isDesc: 'dt-ordering-desc',
12185
- none: 'dt-orderable-none',
12186
- position: 'sorting_'
12187
- },
12188
- processing: {
12189
- container: 'dt-processing'
12190
- },
12191
- scrolling: {
12192
- body: 'dt-scroll-body',
12193
- container: 'dt-scroll',
12194
- footer: {
12195
- self: 'dt-scroll-foot',
12196
- inner: 'dt-scroll-footInner'
12197
- },
12198
- header: {
12199
- self: 'dt-scroll-head',
12200
- inner: 'dt-scroll-headInner'
12201
- }
12202
- },
12203
- search: {
12204
- container: 'dt-search',
12205
- input: 'dt-input'
12206
- },
12207
- table: 'dataTable',
12208
- tbody: {
12209
- cell: '',
12210
- row: ''
12211
- },
12212
- thead: {
12213
- cell: '',
12214
- row: ''
12215
- },
12216
- tfoot: {
12217
- cell: '',
12218
- row: ''
12219
- },
12220
- paging: {
12221
- active: 'current',
12222
- button: 'dt-paging-button',
12223
- container: 'dt-paging',
12224
- disabled: 'disabled'
12225
- }
12226
- } );
12227
-
12228
-
12229
- var extPagination = DataTable.ext.pager;
12230
-
12231
- // Paging buttons configuration
12232
- $.extend( extPagination, {
12233
- simple: function () {
12234
- return [ 'previous', 'next' ];
12235
- },
12236
-
12237
- full: function () {
12238
- return [ 'first', 'previous', 'next', 'last' ];
12239
- },
12240
-
12241
- numbers: function () {
12242
- return [ 'numbers' ];
12243
- },
12244
-
12245
- simple_numbers: function () {
12246
- return [ 'previous', 'numbers', 'next' ];
12247
- },
12248
-
12249
- full_numbers: function () {
12250
- return [ 'first', 'previous', 'numbers', 'next', 'last' ];
12251
- },
12252
-
12253
- first_last: function () {
12254
- return ['first', 'last'];
12255
- },
12256
-
12257
- first_last_numbers: function () {
12258
- return ['first', 'numbers', 'last'];
12259
- },
12260
-
12261
- // For testing and plug-ins to use
12262
- _numbers: _pagingNumbers,
12263
-
12264
- // Number of number buttons - legacy, use `numbers` option for paging feature
12265
- numbers_length: 7
12266
- } );
12267
-
12268
-
12269
- $.extend( true, DataTable.ext.renderer, {
12270
- pagingButton: {
12271
- _: function (settings, buttonType, content, active, disabled) {
12272
- var classes = settings.oClasses.paging;
12273
- var btnClasses = [classes.button];
12274
- var btn;
12275
-
12276
- if (active) {
12277
- btnClasses.push(classes.active);
12278
- }
12279
-
12280
- if (disabled) {
12281
- btnClasses.push(classes.disabled)
12282
- }
12283
-
12284
- if (buttonType === 'ellipsis') {
12285
- btn = $('<span class="ellipsis"></span>').html(content)[0];
12286
- }
12287
- else {
12288
- btn = $('<button>', {
12289
- class: btnClasses.join(' '),
12290
- role: 'link',
12291
- type: 'button'
12292
- }).html(content);
12293
- }
12294
-
12295
- return {
12296
- display: btn,
12297
- clicker: btn
12298
- }
12299
- }
12300
- },
12301
-
12302
- pagingContainer: {
12303
- _: function (settings, buttons) {
12304
- // No wrapping element - just append directly to the host
12305
- return buttons;
12306
- }
12307
- }
12308
- } );
12309
-
12310
- // Common function to remove new lines, strip HTML and diacritic control
12311
- var _filterString = function (stripHtml, normalize) {
12312
- return function (str) {
12313
- if (_empty(str) || typeof str !== 'string') {
12314
- return str;
12315
- }
12316
-
12317
- str = str.replace( _re_new_lines, " " );
11779
+ str = str.replace( _re_new_lines, " " );
12318
11780
 
12319
11781
  if (stripHtml) {
12320
11782
  str = _stripHtml(str);
@@ -13089,7 +12551,7 @@
13089
12551
  });
13090
12552
 
13091
12553
  // For the first info display in the table, we add a callback and aria information.
13092
- if (! $('#' + tid+'_info', settings.nWrapper).length) {
12554
+ if (! settings._infoEl) {
13093
12555
  n.attr({
13094
12556
  'aria-live': 'polite',
13095
12557
  id: tid+'_info',
@@ -13098,6 +12560,8 @@
13098
12560
 
13099
12561
  // Table is described by our info div
13100
12562
  $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
12563
+
12564
+ settings._infoEl = n;
13101
12565
  }
13102
12566
 
13103
12567
  return n;
@@ -13255,7 +12719,7 @@
13255
12719
 
13256
12720
  // opts
13257
12721
  // - type - button configuration
13258
- // - numbers - number of buttons to show - must be odd
12722
+ // - buttons - number of buttons to show - must be odd
13259
12723
  DataTable.feature.register( 'paging', function ( settings, opts ) {
13260
12724
  // Don't show the paging input if the table doesn't have paging enabled
13261
12725
  if (! settings.oFeatures.bPaginate) {
@@ -13263,9 +12727,15 @@
13263
12727
  }
13264
12728
 
13265
12729
  opts = $.extend({
13266
- numbers: DataTable.ext.pager.numbers_length,
13267
- type: settings.sPaginationType
13268
- }, opts)
12730
+ buttons: DataTable.ext.pager.numbers_length,
12731
+ type: settings.sPaginationType,
12732
+ boundaryNumbers: true
12733
+ }, opts);
12734
+
12735
+ // To be removed in 2.1
12736
+ if (opts.numbers) {
12737
+ opts.buttons = opts.numbers;
12738
+ }
13269
12739
 
13270
12740
  var host = $('<div/>').addClass( settings.oClasses.paging.container + ' paging_' + opts.type );
13271
12741
  var draw = function () {
@@ -13297,7 +12767,7 @@
13297
12767
  buttons = plugin()
13298
12768
  .map(function (val) {
13299
12769
  return val === 'numbers'
13300
- ? _pagingNumbers(page, pages, opts.numbers)
12770
+ ? _pagingNumbers(page, pages, opts.buttons, opts.boundaryNumbers)
13301
12771
  : val;
13302
12772
  })
13303
12773
  .flat();
@@ -13439,12 +12909,15 @@
13439
12909
  * @param {*} page Current page
13440
12910
  * @param {*} pages Total number of pages
13441
12911
  * @param {*} buttons Target number of number buttons
12912
+ * @param {boolean} addFirstLast Indicate if page 1 and end should be included
13442
12913
  * @returns Buttons to show
13443
12914
  */
13444
- function _pagingNumbers ( page, pages, buttons ) {
12915
+ function _pagingNumbers ( page, pages, buttons, addFirstLast ) {
13445
12916
  var
13446
12917
  numbers = [],
13447
- half = Math.floor(buttons / 2);
12918
+ half = Math.floor(buttons / 2),
12919
+ before = addFirstLast ? 2 : 1,
12920
+ after = addFirstLast ? 1 : 0;
13448
12921
 
13449
12922
  if ( pages <= buttons ) {
13450
12923
  numbers = _range(0, pages);
@@ -13467,17 +12940,30 @@
13467
12940
  }
13468
12941
  }
13469
12942
  else if ( page <= half ) {
13470
- numbers = _range(0, buttons-2);
13471
- numbers.push('ellipsis', pages-1);
12943
+ numbers = _range(0, buttons-before);
12944
+ numbers.push('ellipsis');
12945
+
12946
+ if (addFirstLast) {
12947
+ numbers.push(pages-1);
12948
+ }
13472
12949
  }
13473
12950
  else if ( page >= pages - 1 - half ) {
13474
- numbers = _range(pages-(buttons-2), pages);
13475
- numbers.unshift(0, 'ellipsis');
12951
+ numbers = _range(pages-(buttons-before), pages);
12952
+ numbers.unshift('ellipsis');
12953
+
12954
+ if (addFirstLast) {
12955
+ numbers.unshift(0);
12956
+ }
13476
12957
  }
13477
12958
  else {
13478
- numbers = _range(page-half+2, page+half-1);
13479
- numbers.push('ellipsis', pages-1);
13480
- numbers.unshift(0, 'ellipsis');
12959
+ numbers = _range(page-half+before, page+half-after);
12960
+ numbers.push('ellipsis');
12961
+ numbers.unshift('ellipsis');
12962
+
12963
+ if (addFirstLast) {
12964
+ numbers.push(pages-1);
12965
+ numbers.unshift(0);
12966
+ }
13481
12967
  }
13482
12968
 
13483
12969
  return numbers;