@ntlab/ntjs-assets 2.0.13 → 2.0.14

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.
@@ -1,11 +1,11 @@
1
- /*! DataTables 2.0.3
1
+ /*! DataTables 2.0.4
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.4
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
 
@@ -3887,7 +3902,7 @@
3887
3902
  }
3888
3903
 
3889
3904
  if (! columnDef.sTitle && unique) {
3890
- columnDef.sTitle = cell.innerHTML.replace( /<.*?>/g, "" );
3905
+ columnDef.sTitle = _stripHtml(cell.innerHTML);
3891
3906
  columnDef.autoTitle = true;
3892
3907
  }
3893
3908
  }
@@ -4508,7 +4523,7 @@
4508
4523
  word = '';
4509
4524
  }
4510
4525
 
4511
- return word.replace('"', '');
4526
+ return word.replace(/"/g, '');
4512
4527
  } );
4513
4528
 
4514
4529
  var match = not.length
@@ -5040,20 +5055,27 @@
5040
5055
  // uses a cell which has a longer string, but isn't the widest! For example
5041
5056
  // "Chief Executive Officer (CEO)" is the longest string in the demo, but
5042
5057
  // "Systems Administrator" is actually the widest string since it doesn't collapse.
5058
+ // Note the use of translating into a column index to get the `col` element. This
5059
+ // is because of Responsive which might remove `col` elements, knocking the alignment
5060
+ // of the indexes out.
5043
5061
  if (settings.aiDisplay.length) {
5044
5062
  // 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();
5063
+ var colSizes = table.find('tbody tr').eq(0).find('th, td').map(function (vis) {
5064
+ return {
5065
+ idx: _fnVisibleToColumnIndex(settings, vis),
5066
+ width: $(this).outerWidth()
5067
+ }
5047
5068
  });
5048
5069
 
5049
5070
  // 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', '');
5071
+ for (var i=0 ; i<colSizes.length ; i++) {
5072
+ var colEl = settings.aoColumns[ colSizes[i].idx ].colEl[0];
5073
+ var colWidth = colEl.style.width.replace('px', '');
5052
5074
 
5053
- if (colWidth !== colSizes[i]) {
5054
- this.style.width = colSizes[i] + 'px';
5075
+ if (colWidth !== colSizes[i].width) {
5076
+ colEl.style.width = colSizes[i].width + 'px';
5055
5077
  }
5056
- });
5078
+ }
5057
5079
  }
5058
5080
 
5059
5081
  // 3. Copy the colgroup over to the header and footer
@@ -6849,6 +6871,10 @@
6849
6871
  for ( i=0, ien=ext.length ; i<ien ; i++ ) {
6850
6872
  struct = ext[i];
6851
6873
 
6874
+ if (struct.name === '__proto__') {
6875
+ continue;
6876
+ }
6877
+
6852
6878
  // Value
6853
6879
  obj[ struct.name ] = struct.type === 'function' ?
6854
6880
  _api_scope( scope, struct.val, struct ) :
@@ -7511,16 +7537,7 @@
7511
7537
  order = opts.order, // applied, current, index (original - compatibility with 1.9)
7512
7538
  page = opts.page; // all, current
7513
7539
 
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' ) {
7540
+ if ( page == 'current' ) {
7524
7541
  // Current page implies that order=current and filter=applied, since it is
7525
7542
  // fairly senseless otherwise, regardless of what order and search actually
7526
7543
  // are
@@ -7943,8 +7960,9 @@
7943
7960
  {
7944
7961
  if ( state && state.childRows ) {
7945
7962
  api
7946
- .rows( state.childRows.map(function (id){
7947
- return id.replace(/:/g, '\\:')
7963
+ .rows( state.childRows.map(function (id) {
7964
+ // Escape any `:` characters from the row id, unless previously escaped
7965
+ return id.replace(/(?<!\\):/g, '\\:');
7948
7966
  }) )
7949
7967
  .every( function () {
7950
7968
  _fnCallbackFire( api.settings()[0], null, 'requestChild', [ this ] )
@@ -8225,6 +8243,17 @@
8225
8243
  };
8226
8244
 
8227
8245
 
8246
+ var __column_header = function ( settings, column, row ) {
8247
+ var header = settings.aoHeader;
8248
+ var target = row !== undefined
8249
+ ? row
8250
+ : settings.bSortCellsTop // legacy support
8251
+ ? 0
8252
+ : header.length - 1;
8253
+
8254
+ return header[target][column].cell;
8255
+ };
8256
+
8228
8257
  var __column_selector = function ( settings, selector, opts )
8229
8258
  {
8230
8259
  var
@@ -8257,7 +8286,8 @@
8257
8286
  return columns.map(function (col, idx) {
8258
8287
  return s(
8259
8288
  idx,
8260
- __columnData( settings, idx, 0, 0, rows )
8289
+ __columnData( settings, idx, 0, 0, rows ),
8290
+ __column_header( settings, idx )
8261
8291
  ) ? idx : null;
8262
8292
  });
8263
8293
  }
@@ -8402,15 +8432,8 @@
8402
8432
  } );
8403
8433
 
8404
8434
  _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;
8435
+ return this.iterator( 'column', function (settings, column) {
8436
+ return __column_header(settings, column, row);
8414
8437
  }, 1 );
8415
8438
  } );
8416
8439
 
@@ -9563,7 +9586,7 @@
9563
9586
  * @type string
9564
9587
  * @default Version number
9565
9588
  */
9566
- DataTable.version = "2.0.3";
9589
+ DataTable.version = "2.0.4";
9567
9590
 
9568
9591
  /**
9569
9592
  * Private data store, containing all of the settings objects that are
@@ -10418,24 +10441,24 @@
10418
10441
  */
10419
10442
  "oPaginate": {
10420
10443
  /**
10421
- * Label and character for first page button
10444
+ * Label and character for first page button («)
10422
10445
  */
10423
- "sFirst": "«",
10446
+ "sFirst": "\u00AB",
10424
10447
 
10425
10448
  /**
10426
- * Last page button
10449
+ * Last page button (»)
10427
10450
  */
10428
- "sLast": "»",
10451
+ "sLast": "\u00BB",
10429
10452
 
10430
10453
  /**
10431
- * Next page button
10454
+ * Next page button (›)
10432
10455
  */
10433
- "sNext": "",
10456
+ "sNext": "\u203A",
10434
10457
 
10435
10458
  /**
10436
- * Previous page button
10459
+ * Previous page button (‹)
10437
10460
  */
10438
- "sPrevious": "",
10461
+ "sPrevious": "\u2039",
10439
10462
  },
10440
10463
 
10441
10464
  /**
@@ -11664,657 +11687,95 @@
11664
11687
  */
11665
11688
 
11666
11689
 
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: {},
11690
+ var extPagination = DataTable.ext.pager;
11690
11691
 
11692
+ // Paging buttons configuration
11693
+ $.extend( extPagination, {
11694
+ simple: function () {
11695
+ return [ 'previous', 'next' ];
11696
+ },
11691
11697
 
11692
- /**
11693
- * Element class names
11694
- *
11695
- * @type object
11696
- * @default {}
11697
- */
11698
- classes: {},
11698
+ full: function () {
11699
+ return [ 'first', 'previous', 'next', 'last' ];
11700
+ },
11699
11701
 
11702
+ numbers: function () {
11703
+ return [ 'numbers' ];
11704
+ },
11700
11705
 
11701
- /**
11702
- * DataTables build type (expanded by the download builder)
11703
- *
11704
- * @type string
11705
- */
11706
- builder: "-source-",
11706
+ simple_numbers: function () {
11707
+ return [ 'previous', 'numbers', 'next' ];
11708
+ },
11707
11709
 
11710
+ full_numbers: function () {
11711
+ return [ 'first', 'previous', 'numbers', 'next', 'last' ];
11712
+ },
11713
+
11714
+ first_last: function () {
11715
+ return ['first', 'last'];
11716
+ },
11717
+
11718
+ first_last_numbers: function () {
11719
+ return ['first', 'numbers', 'last'];
11720
+ },
11708
11721
 
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",
11722
+ // For testing and plug-ins to use
11723
+ _numbers: _pagingNumbers,
11719
11724
 
11725
+ // Number of number buttons - legacy, use `numbers` option for paging feature
11726
+ numbers_length: 7
11727
+ } );
11720
11728
 
11721
- /**
11722
- * Legacy so v1 plug-ins don't throw js errors on load
11723
- */
11724
- feature: [],
11725
11729
 
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: {},
11730
+ $.extend( true, DataTable.ext.renderer, {
11731
+ pagingButton: {
11732
+ _: function (settings, buttonType, content, active, disabled) {
11733
+ var classes = settings.oClasses.paging;
11734
+ var btnClasses = [classes.button];
11735
+ var btn;
11733
11736
 
11737
+ if (active) {
11738
+ btnClasses.push(classes.active);
11739
+ }
11734
11740
 
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: [],
11741
+ if (disabled) {
11742
+ btnClasses.push(classes.disabled)
11743
+ }
11794
11744
 
11745
+ if (buttonType === 'ellipsis') {
11746
+ btn = $('<span class="ellipsis"></span>').html(content)[0];
11747
+ }
11748
+ else {
11749
+ btn = $('<button>', {
11750
+ class: btnClasses.join(' '),
11751
+ role: 'link',
11752
+ type: 'button'
11753
+ }).html(content);
11754
+ }
11795
11755
 
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: []
11756
+ return {
11757
+ display: btn,
11758
+ clicker: btn
11759
+ }
11760
+ }
11824
11761
  },
11825
11762
 
11763
+ pagingContainer: {
11764
+ _: function (settings, buttons) {
11765
+ // No wrapping element - just append directly to the host
11766
+ return buttons;
11767
+ }
11768
+ }
11769
+ } );
11826
11770
 
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
- },
11771
+ // Common function to remove new lines, strip HTML and diacritic control
11772
+ var _filterString = function (stripHtml, normalize) {
11773
+ return function (str) {
11774
+ if (_empty(str) || typeof str !== 'string') {
11775
+ return str;
11776
+ }
11843
11777
 
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, " " );
11778
+ str = str.replace( _re_new_lines, " " );
12318
11779
 
12319
11780
  if (stripHtml) {
12320
11781
  str = _stripHtml(str);
@@ -13089,7 +12550,7 @@
13089
12550
  });
13090
12551
 
13091
12552
  // For the first info display in the table, we add a callback and aria information.
13092
- if (! $('#' + tid+'_info', settings.nWrapper).length) {
12553
+ if (! settings._infoEl) {
13093
12554
  n.attr({
13094
12555
  'aria-live': 'polite',
13095
12556
  id: tid+'_info',
@@ -13098,6 +12559,8 @@
13098
12559
 
13099
12560
  // Table is described by our info div
13100
12561
  $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
12562
+
12563
+ settings._infoEl = n;
13101
12564
  }
13102
12565
 
13103
12566
  return n;
@@ -13255,7 +12718,7 @@
13255
12718
 
13256
12719
  // opts
13257
12720
  // - type - button configuration
13258
- // - numbers - number of buttons to show - must be odd
12721
+ // - buttons - number of buttons to show - must be odd
13259
12722
  DataTable.feature.register( 'paging', function ( settings, opts ) {
13260
12723
  // Don't show the paging input if the table doesn't have paging enabled
13261
12724
  if (! settings.oFeatures.bPaginate) {
@@ -13263,9 +12726,15 @@
13263
12726
  }
13264
12727
 
13265
12728
  opts = $.extend({
13266
- numbers: DataTable.ext.pager.numbers_length,
13267
- type: settings.sPaginationType
13268
- }, opts)
12729
+ buttons: DataTable.ext.pager.numbers_length,
12730
+ type: settings.sPaginationType,
12731
+ boundaryNumbers: true
12732
+ }, opts);
12733
+
12734
+ // To be removed in 2.1
12735
+ if (opts.numbers) {
12736
+ opts.buttons = opts.numbers;
12737
+ }
13269
12738
 
13270
12739
  var host = $('<div/>').addClass( settings.oClasses.paging.container + ' paging_' + opts.type );
13271
12740
  var draw = function () {
@@ -13297,7 +12766,7 @@
13297
12766
  buttons = plugin()
13298
12767
  .map(function (val) {
13299
12768
  return val === 'numbers'
13300
- ? _pagingNumbers(page, pages, opts.numbers)
12769
+ ? _pagingNumbers(page, pages, opts.buttons, opts.boundaryNumbers)
13301
12770
  : val;
13302
12771
  })
13303
12772
  .flat();
@@ -13439,12 +12908,15 @@
13439
12908
  * @param {*} page Current page
13440
12909
  * @param {*} pages Total number of pages
13441
12910
  * @param {*} buttons Target number of number buttons
12911
+ * @param {boolean} addFirstLast Indicate if page 1 and end should be included
13442
12912
  * @returns Buttons to show
13443
12913
  */
13444
- function _pagingNumbers ( page, pages, buttons ) {
12914
+ function _pagingNumbers ( page, pages, buttons, addFirstLast ) {
13445
12915
  var
13446
12916
  numbers = [],
13447
- half = Math.floor(buttons / 2);
12917
+ half = Math.floor(buttons / 2),
12918
+ before = addFirstLast ? 2 : 1,
12919
+ after = addFirstLast ? 1 : 0;
13448
12920
 
13449
12921
  if ( pages <= buttons ) {
13450
12922
  numbers = _range(0, pages);
@@ -13467,17 +12939,30 @@
13467
12939
  }
13468
12940
  }
13469
12941
  else if ( page <= half ) {
13470
- numbers = _range(0, buttons-2);
13471
- numbers.push('ellipsis', pages-1);
12942
+ numbers = _range(0, buttons-before);
12943
+ numbers.push('ellipsis');
12944
+
12945
+ if (addFirstLast) {
12946
+ numbers.push(pages-1);
12947
+ }
13472
12948
  }
13473
12949
  else if ( page >= pages - 1 - half ) {
13474
- numbers = _range(pages-(buttons-2), pages);
13475
- numbers.unshift(0, 'ellipsis');
12950
+ numbers = _range(pages-(buttons-before), pages);
12951
+ numbers.unshift('ellipsis');
12952
+
12953
+ if (addFirstLast) {
12954
+ numbers.unshift(0);
12955
+ }
13476
12956
  }
13477
12957
  else {
13478
- numbers = _range(page-half+2, page+half-1);
13479
- numbers.push('ellipsis', pages-1);
13480
- numbers.unshift(0, 'ellipsis');
12958
+ numbers = _range(page-half+before, page+half-after);
12959
+ numbers.push('ellipsis');
12960
+ numbers.unshift('ellipsis');
12961
+
12962
+ if (addFirstLast) {
12963
+ numbers.push(pages-1);
12964
+ numbers.unshift(0);
12965
+ }
13481
12966
  }
13482
12967
 
13483
12968
  return numbers;