jquery-datatables 1.10.13 → 1.10.15

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/Rakefile +1 -1
  4. data/app/assets/javascripts/datatables/dataTables.bootstrap2.js +162 -0
  5. data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +7 -7
  6. data/app/assets/javascripts/datatables/dataTables.semanticui.js +2 -2
  7. data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +104 -13
  8. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +17 -9
  9. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.flash.js +41 -15
  10. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +48 -18
  11. data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +29 -13
  12. data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +46 -5
  13. data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +37 -19
  14. data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +65 -37
  15. data/app/assets/javascripts/datatables/extensions/RowGroup/dataTables.rowGroup.js +386 -0
  16. data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +24 -14
  17. data/app/assets/javascripts/datatables/jquery.dataTables.js +48 -10
  18. data/app/assets/stylesheets/datatables/dataTables.bootstrap.css +7 -7
  19. data/app/assets/stylesheets/datatables/dataTables.bootstrap2.css +178 -0
  20. data/app/assets/stylesheets/datatables/dataTables.bootstrap4.css +1 -0
  21. data/app/assets/stylesheets/datatables/dataTables.foundation.css +8 -6
  22. data/app/assets/stylesheets/datatables/dataTables.jqueryui.css +6 -5
  23. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.css +56 -0
  24. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.css +56 -0
  25. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.css +56 -0
  26. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.css +60 -0
  27. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.css +56 -0
  28. data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.css +57 -0
  29. data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +47 -0
  30. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.bootstrap.css +4 -0
  31. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.bootstrap4.css +4 -0
  32. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.dataTables.css +4 -0
  33. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.foundation.css +4 -0
  34. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.jqueryui.css +4 -0
  35. data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.semanticui.css +4 -0
  36. data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap.css +7 -7
  37. data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap4.css +7 -7
  38. data/app/assets/stylesheets/datatables/extensions/Select/select.dataTables.css +7 -7
  39. data/app/assets/stylesheets/datatables/extensions/Select/select.foundation.css +7 -7
  40. data/app/assets/stylesheets/datatables/extensions/Select/select.jqueryui.css +7 -7
  41. data/app/assets/stylesheets/datatables/extensions/Select/select.semanticui.css +7 -7
  42. data/app/assets/stylesheets/datatables/jquery.dataTables.css +14 -11
  43. data/lib/generators/jquery/datatables/templates/bootstrap2.css.tt +15 -0
  44. data/lib/generators/jquery/datatables/templates/bootstrap2.js.tt +22 -0
  45. data/lib/jquery-datatables/version.rb +1 -1
  46. metadata +14 -3
@@ -1,11 +1,11 @@
1
- /*! ColReorder 1.3.2
1
+ /*! ColReorder 1.3.3
2
2
  * ©2010-2015 SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  /**
6
6
  * @summary ColReorder
7
7
  * @description Provide the ability to reorder columns in a DataTable
8
- * @version 1.3.2
8
+ * @version 1.3.3
9
9
  * @file dataTables.colReorder.js
10
10
  * @author SpryMedia Ltd (www.sprymedia.co.uk)
11
11
  * @contact www.sprymedia.co.uk/contact
@@ -887,10 +887,14 @@ $.extend( ColReorder.prototype, {
887
887
  "_fnMouseListener": function ( i, nTh )
888
888
  {
889
889
  var that = this;
890
- $(nTh).on( 'mousedown.ColReorder', function (e) {
891
- e.preventDefault();
892
- that._fnMouseDown.call( that, e, nTh );
893
- } );
890
+ $(nTh)
891
+ .on( 'mousedown.ColReorder', function (e) {
892
+ e.preventDefault();
893
+ that._fnMouseDown.call( that, e, nTh );
894
+ } )
895
+ .on( 'touchstart.ColReorder', function (e) {
896
+ that._fnMouseDown.call( that, e, nTh );
897
+ } );
894
898
  },
895
899
 
896
900
 
@@ -915,10 +919,10 @@ $.extend( ColReorder.prototype, {
915
919
  return;
916
920
  }
917
921
 
918
- this.s.mouse.startX = e.pageX;
919
- this.s.mouse.startY = e.pageY;
920
- this.s.mouse.offsetX = e.pageX - offset.left;
921
- this.s.mouse.offsetY = e.pageY - offset.top;
922
+ this.s.mouse.startX = this._fnCursorPosition( e, 'pageX' );
923
+ this.s.mouse.startY = this._fnCursorPosition( e, 'pageY' );
924
+ this.s.mouse.offsetX = this._fnCursorPosition( e, 'pageX' ) - offset.left;
925
+ this.s.mouse.offsetY = this._fnCursorPosition( e, 'pageY' ) - offset.top;
922
926
  this.s.mouse.target = this.s.dt.aoColumns[ idx ].nTh;//target[0];
923
927
  this.s.mouse.targetIndex = idx;
924
928
  this.s.mouse.fromIndex = idx;
@@ -927,10 +931,10 @@ $.extend( ColReorder.prototype, {
927
931
 
928
932
  /* Add event handlers to the document */
929
933
  $(document)
930
- .on( 'mousemove.ColReorder', function (e) {
934
+ .on( 'mousemove.ColReorder touchmove.ColReorder', function (e) {
931
935
  that._fnMouseMove.call( that, e );
932
936
  } )
933
- .on( 'mouseup.ColReorder', function (e) {
937
+ .on( 'mouseup.ColReorder touchend.ColReorder', function (e) {
934
938
  that._fnMouseUp.call( that, e );
935
939
  } );
936
940
  },
@@ -954,8 +958,8 @@ $.extend( ColReorder.prototype, {
954
958
  * possibly confusing drag element showing up
955
959
  */
956
960
  if ( Math.pow(
957
- Math.pow(e.pageX - this.s.mouse.startX, 2) +
958
- Math.pow(e.pageY - this.s.mouse.startY, 2), 0.5 ) < 5 )
961
+ Math.pow(this._fnCursorPosition( e, 'pageX') - this.s.mouse.startX, 2) +
962
+ Math.pow(this._fnCursorPosition( e, 'pageY') - this.s.mouse.startY, 2), 0.5 ) < 5 )
959
963
  {
960
964
  return;
961
965
  }
@@ -964,8 +968,8 @@ $.extend( ColReorder.prototype, {
964
968
 
965
969
  /* Position the element - we respect where in the element the click occured */
966
970
  this.dom.drag.css( {
967
- left: e.pageX - this.s.mouse.offsetX,
968
- top: e.pageY - this.s.mouse.offsetY
971
+ left: this._fnCursorPosition( e, 'pageX' ) - this.s.mouse.offsetX,
972
+ top: this._fnCursorPosition( e, 'pageY' ) - this.s.mouse.offsetY
969
973
  } );
970
974
 
971
975
  /* Based on the current mouse position, calculate where the insert should go */
@@ -974,7 +978,7 @@ $.extend( ColReorder.prototype, {
974
978
 
975
979
  for ( var i=1, iLen=this.s.aoTargets.length ; i<iLen ; i++ )
976
980
  {
977
- if ( e.pageX < this.s.aoTargets[i-1].x + ((this.s.aoTargets[i].x-this.s.aoTargets[i-1].x)/2) )
981
+ if ( this._fnCursorPosition(e, 'pageX') < this.s.aoTargets[i-1].x + ((this.s.aoTargets[i].x-this.s.aoTargets[i-1].x)/2) )
978
982
  {
979
983
  this.dom.pointer.css( 'left', this.s.aoTargets[i-1].x );
980
984
  this.s.mouse.toIndex = this.s.aoTargets[i-1].to;
@@ -1011,7 +1015,7 @@ $.extend( ColReorder.prototype, {
1011
1015
  {
1012
1016
  var that = this;
1013
1017
 
1014
- $(document).off( 'mousemove.ColReorder mouseup.ColReorder' );
1018
+ $(document).off( '.ColReorder' );
1015
1019
 
1016
1020
  if ( this.dom.drag !== null )
1017
1021
  {
@@ -1163,6 +1167,20 @@ $.extend( ColReorder.prototype, {
1163
1167
  $.each( this.s.dt.aoColumns, function (i, column) {
1164
1168
  $(column.nTh).attr('data-column-index', i);
1165
1169
  } );
1170
+ },
1171
+
1172
+
1173
+ /**
1174
+ * Get cursor position regardless of mouse or touch input
1175
+ * @param {Event} e jQuery Event
1176
+ * @param {string} prop Property to get
1177
+ * @return {number} Value
1178
+ */
1179
+ _fnCursorPosition: function ( e, prop ) {
1180
+ if ( e.type.indexOf('touch') !== -1 ) {
1181
+ return e.originalEvent.touches[0][ prop ];
1182
+ }
1183
+ return e[ prop ];
1166
1184
  }
1167
1185
  } );
1168
1186
 
@@ -1242,7 +1260,7 @@ ColReorder.defaults = {
1242
1260
  * @type String
1243
1261
  * @default As code
1244
1262
  */
1245
- ColReorder.version = "1.3.2";
1263
+ ColReorder.version = "1.3.3";
1246
1264
 
1247
1265
 
1248
1266
 
@@ -1,11 +1,11 @@
1
- /*! KeyTable 2.2.0
1
+ /*! KeyTable 2.2.1
2
2
  * ©2009-2016 SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  /**
6
6
  * @summary KeyTable
7
7
  * @description Spreadsheet like keyboard navigation for DataTables
8
- * @version 2.2.0
8
+ * @version 2.2.1
9
9
  * @file dataTables.keyTable.js
10
10
  * @author SpryMedia Ltd (www.sprymedia.co.uk)
11
11
  * @contact www.sprymedia.co.uk/contact
@@ -211,6 +211,11 @@ $.extend( KeyTable.prototype, {
211
211
  return;
212
212
  }
213
213
 
214
+ // Or an Editor date input
215
+ if ( $(e.target).parents('div.editor-datetime').length ) {
216
+ return;
217
+ }
218
+
214
219
  //If the click was inside the fixed columns container, don't blur
215
220
  if ( $(e.target).parents().filter('.DTFC_Cloned').length ) {
216
221
  return;
@@ -243,11 +248,15 @@ $.extend( KeyTable.prototype, {
243
248
 
244
249
  var lastFocus = that.s.lastFocus;
245
250
 
246
- if ( lastFocus ) {
251
+ if ( lastFocus && lastFocus.node && $(lastFocus.node).closest('body') === document.body ) {
247
252
  var relative = that.s.lastFocus.relative;
248
253
  var info = dt.page.info();
249
254
  var row = relative.row + info.start;
250
255
 
256
+ if ( info.recordsDisplay === 0 ) {
257
+ return;
258
+ }
259
+
251
260
  // Reverse if needed
252
261
  if ( row >= info.recordsDisplay ) {
253
262
  row = info.recordsDisplay - 1;
@@ -345,6 +354,7 @@ $.extend( KeyTable.prototype, {
345
354
  */
346
355
  _editor: function ( key, orig )
347
356
  {
357
+ var that = this;
348
358
  var dt = this.s.dt;
349
359
  var editor = this.c.editor;
350
360
 
@@ -361,26 +371,36 @@ $.extend( KeyTable.prototype, {
361
371
  orig.preventDefault();
362
372
  }
363
373
 
364
- editor.inline( this.s.lastFocus.cell.index() );
374
+ editor
375
+ .one( 'open.keyTable', function () {
376
+ // Remove cancel open
377
+ editor.off( 'cancelOpen.keyTable' );
365
378
 
366
- // Excel style - select all text
367
- $('div.DTE input, div.DTE textarea').select();
379
+ // Excel style - select all text
380
+ $('div.DTE input, div.DTE textarea').select();
368
381
 
369
- // Reduce the keys the Keys listens for
370
- dt.keys.enable( this.c.editorKeys );
382
+ // Reduce the keys the Keys listens for
383
+ dt.keys.enable( that.c.editorKeys );
371
384
 
372
- // On blur of the navigation submit
373
- dt.one( 'key-blur.editor', function () {
374
- if ( editor.displayed() ) {
375
- editor.submit();
376
- }
377
- } );
385
+ // On blur of the navigation submit
386
+ dt.one( 'key-blur.editor', function () {
387
+ if ( editor.displayed() ) {
388
+ editor.submit();
389
+ }
390
+ } );
378
391
 
379
- // Restore full key navigation on close
380
- editor.one( 'close', function () {
381
- dt.keys.enable( true );
382
- dt.off( 'key-blur.editor' );
383
- } );
392
+ // Restore full key navigation on close
393
+ editor.one( 'close', function () {
394
+ dt.keys.enable( true );
395
+ dt.off( 'key-blur.editor' );
396
+ } );
397
+ } )
398
+ .one( 'cancelOpen.keyTable', function () {
399
+ // `preOpen` can cancel the display of the form, so it
400
+ // might be that the open event handler isn't needed
401
+ editor.off( 'open.keyTable' );
402
+ } )
403
+ .inline( this.s.lastFocus.cell.index() );
384
404
  },
385
405
 
386
406
 
@@ -417,8 +437,10 @@ $.extend( KeyTable.prototype, {
417
437
  var dt = this.s.dt;
418
438
  var pageInfo = dt.page.info();
419
439
  var lastFocus = this.s.lastFocus;
420
- if( ! originalEvent)
440
+
441
+ if ( ! originalEvent) {
421
442
  originalEvent = null;
443
+ }
422
444
 
423
445
  if ( ! this.s.enable ) {
424
446
  return;
@@ -451,7 +473,7 @@ $.extend( KeyTable.prototype, {
451
473
  .one( 'draw', function () {
452
474
  that.s.focusDraw = false;
453
475
  that.s.waitingForDraw = false;
454
- that._focus( row, column );
476
+ that._focus( row, column, undefined, originalEvent );
455
477
  } )
456
478
  .page( Math.floor( row / pageInfo.length ) )
457
479
  .draw( false );
@@ -782,26 +804,32 @@ $.extend( KeyTable.prototype, {
782
804
  .insertBefore( dt.table().node() );
783
805
 
784
806
  div.children().on( 'focus', function (e) {
785
- that._focus( dt.cell(':eq(0)', '0:visible', {page: 'current'}), null, true, e );
807
+ if ( dt.cell(':eq(0)', {page: 'current'}).any() ) {
808
+ that._focus( dt.cell(':eq(0)', '0:visible', {page: 'current'}), null, true, e );
809
+ }
786
810
  } );
787
811
  },
812
+
788
813
  /**
789
- * Update fixed columns if they are enabled and if the cell we are focusing is inside a fixed column
790
- * @param {integer} column Index of the column being changed
791
- *
814
+ * Update fixed columns if they are enabled and if the cell we are
815
+ * focusing is inside a fixed column
816
+ * @param {integer} column Index of the column being changed
792
817
  * @private
793
818
  */
794
- _updateFixedColumns:function(column){
795
- var dt = this.s.dt;
796
- var settings = dt.settings()[0];
797
-
798
- if(settings._oFixedColumns){
799
- var leftCols = settings._oFixedColumns.s.iLeftColumns;
800
- var rightCols = settings.aoColumns.length - settings._oFixedColumns.s.iRightColumns;
801
- if (column < leftCols || column > rightCols)
802
- dt.fixedColumns().update();
803
- }
804
- }
819
+ _updateFixedColumns: function( column )
820
+ {
821
+ var dt = this.s.dt;
822
+ var settings = dt.settings()[0];
823
+
824
+ if ( settings._oFixedColumns ) {
825
+ var leftCols = settings._oFixedColumns.s.iLeftColumns;
826
+ var rightCols = settings.aoColumns.length - settings._oFixedColumns.s.iRightColumns;
827
+
828
+ if (column < leftCols || column >= rightCols) {
829
+ dt.fixedColumns().update();
830
+ }
831
+ }
832
+ }
805
833
  } );
806
834
 
807
835
 
@@ -867,7 +895,7 @@ KeyTable.defaults = {
867
895
 
868
896
 
869
897
 
870
- KeyTable.version = "2.2.0";
898
+ KeyTable.version = "2.2.1";
871
899
 
872
900
 
873
901
  $.fn.dataTable.KeyTable = KeyTable;
@@ -0,0 +1,386 @@
1
+ /*! RowGroup 1.0.0
2
+ * ©2017 SpryMedia Ltd - datatables.net/license
3
+ */
4
+
5
+ /**
6
+ * @summary RowGroup
7
+ * @description RowGrouping for DataTables
8
+ * @version 1.0.0
9
+ * @file dataTables.rowGroup.js
10
+ * @author SpryMedia Ltd (www.sprymedia.co.uk)
11
+ * @contact datatables.net
12
+ * @copyright Copyright 2017 SpryMedia Ltd.
13
+ *
14
+ * This source file is free software, available under the following license:
15
+ * MIT license - http://datatables.net/license/mit
16
+ *
17
+ * This source file is distributed in the hope that it will be useful, but
18
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
20
+ *
21
+ * For details please refer to: http://www.datatables.net
22
+ */
23
+
24
+ (function( factory ){
25
+ if ( typeof define === 'function' && define.amd ) {
26
+ // AMD
27
+ define( ['jquery', 'datatables.net'], function ( $ ) {
28
+ return factory( $, window, document );
29
+ } );
30
+ }
31
+ else if ( typeof exports === 'object' ) {
32
+ // CommonJS
33
+ module.exports = function (root, $) {
34
+ if ( ! root ) {
35
+ root = window;
36
+ }
37
+
38
+ if ( ! $ || ! $.fn.dataTable ) {
39
+ $ = require('datatables.net')(root, $).$;
40
+ }
41
+
42
+ return factory( $, root, root.document );
43
+ };
44
+ }
45
+ else {
46
+ // Browser
47
+ factory( jQuery, window, document );
48
+ }
49
+ }(function( $, window, document, undefined ) {
50
+ 'use strict';
51
+ var DataTable = $.fn.dataTable;
52
+
53
+
54
+ var RowGroup = function ( dt, opts ) {
55
+ // Sanity check that we are using DataTables 1.10 or newer
56
+ if ( ! DataTable.versionCheck || ! DataTable.versionCheck( '1.10.8' ) ) {
57
+ throw 'RowGroup requires DataTables 1.10.8 or newer';
58
+ }
59
+
60
+ // User and defaults configuration object
61
+ this.c = $.extend( true, {},
62
+ DataTable.defaults.rowGroup,
63
+ RowGroup.defaults,
64
+ opts
65
+ );
66
+
67
+ // Internal settings
68
+ this.s = {
69
+ dt: new DataTable.Api( dt ),
70
+
71
+ dataFn: DataTable.ext.oApi._fnGetObjectDataFn( this.c.dataSrc ),
72
+ };
73
+
74
+ // DOM items
75
+ this.dom = {
76
+
77
+ };
78
+
79
+ // Check if row grouping has already been initialised on this table
80
+ var settings = this.s.dt.settings()[0];
81
+ var existing = settings.rowGroup;
82
+ if ( existing ) {
83
+ return existing;
84
+ }
85
+
86
+ settings.rowGroup = this;
87
+ this._constructor();
88
+ };
89
+
90
+
91
+ $.extend( RowGroup.prototype, {
92
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
93
+ * API methods for DataTables API interface
94
+ */
95
+
96
+ /**
97
+ * Get/set the grouping data source - need to call draw after this is
98
+ * executed as a setter
99
+ * @returns string~RowGroup
100
+ */
101
+ dataSrc: function ( val )
102
+ {
103
+ if ( val === undefined ) {
104
+ return this.c.dataSrc;
105
+ }
106
+
107
+ var dt = this.s.dt;
108
+
109
+ this.c.dataSrc = val;
110
+ this.s.dataFn = DataTable.ext.oApi._fnGetObjectDataFn( this.c.dataSrc );
111
+
112
+ $(dt.table().node()).triggerHandler( 'rowgroup-datasrc.dt', [ dt, val ] );
113
+
114
+ return this;
115
+ },
116
+
117
+ /**
118
+ * Disable - need to call draw after this is executed
119
+ * @returns RowGroup
120
+ */
121
+ disable: function ()
122
+ {
123
+ this.c.enable = false;
124
+ return this;
125
+ },
126
+
127
+ /**
128
+ * Enable - need to call draw after this is executed
129
+ * @returns RowGroup
130
+ */
131
+ enable: function ( flag )
132
+ {
133
+ if ( flag === false ) {
134
+ return this.disable();
135
+ }
136
+
137
+ this.c.enable = true;
138
+ return this;
139
+ },
140
+
141
+
142
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
143
+ * Constructor
144
+ */
145
+ _constructor: function ()
146
+ {
147
+ var that = this;
148
+ var dt = this.s.dt;
149
+
150
+ dt.on( 'draw.dtrg', function () {
151
+ if ( that.c.enable ) {
152
+ that._draw();
153
+ }
154
+ } );
155
+
156
+ dt.on( 'column-visibility.dtrg', function () {
157
+ that._adjustColspan();
158
+ } );
159
+
160
+ dt.on( 'destroy', function () {
161
+ dt.off( '.dtrg' );
162
+ } );
163
+ },
164
+
165
+
166
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
167
+ * Private methods
168
+ */
169
+
170
+ /**
171
+ * Adjust column span when column visibility changes
172
+ * @private
173
+ */
174
+ _adjustColspan: function ()
175
+ {
176
+ $( 'tr.'+this.c.className, this.s.dt.table().body() )
177
+ .attr( 'colspan', this._colspan() );
178
+ },
179
+
180
+ /**
181
+ * Get the number of columns that a grouping row should span
182
+ * @private
183
+ */
184
+ _colspan: function ()
185
+ {
186
+ return $( this.s.dt.columns().header() ).filter(':visible').length;
187
+ },
188
+
189
+ /**
190
+ * Update function that is called whenever we need to draw the grouping rows
191
+ * @private
192
+ */
193
+ _draw: function ()
194
+ {
195
+ var that = this;
196
+ var dt = this.s.dt;
197
+ var rows = dt.rows( { page: 'current' } );
198
+ var groupedRows = [];
199
+ var last, display;
200
+
201
+ rows.every( function () {
202
+ var d = this.data();
203
+ var group = that.s.dataFn( d );
204
+
205
+ if ( last === undefined || group !== last ) {
206
+ groupedRows.push( [] );
207
+ last = group;
208
+ }
209
+
210
+ groupedRows[ groupedRows.length - 1 ].push( this.index() );
211
+ } );
212
+
213
+ for ( var i=0, ien=groupedRows.length ; i<ien ; i++ ) {
214
+ var group = groupedRows[i];
215
+ var firstRow = dt.row(group[0]);
216
+ var groupName = this.s.dataFn( firstRow.data() );
217
+
218
+ if ( this.c.startRender ) {
219
+ display = this.c.startRender.call( this, dt.rows(group), groupName );
220
+
221
+ this
222
+ ._rowWrap( display, this.c.startClassName )
223
+ .insertBefore( firstRow.node() );
224
+ }
225
+
226
+ if ( this.c.endRender ) {
227
+ display = this.c.endRender.call( this, dt.rows(group), groupName );
228
+
229
+ this
230
+ ._rowWrap( display, this.c.endClassName )
231
+ .insertAfter( dt.row( group[ group.length-1 ] ).node() );
232
+ }
233
+ }
234
+ },
235
+
236
+ /**
237
+ * Take a rendered value from an end user and make it suitable for display
238
+ * as a row, by wrapping it in a row, or detecting that it is a row.
239
+ * @param [node|jQuery|string] display Display value
240
+ * @param [string] className Class to add to the row
241
+ * @private
242
+ */
243
+ _rowWrap: function ( display, className )
244
+ {
245
+ var row;
246
+
247
+ if ( typeof display === 'object' && display.nodeName && display.nodeName.toLowerCase() === 'tr') {
248
+ row = $(display);
249
+ }
250
+ else if (display instanceof $ && display.length && display[0].nodeName.toLowerCase() === 'tr') {
251
+ row = display;
252
+ }
253
+ else {
254
+ row = $('<tr/>')
255
+ .append(
256
+ $('<td/>')
257
+ .attr( 'colspan', this._colspan() )
258
+ .append( display )
259
+ );
260
+ }
261
+
262
+ return row
263
+ .addClass( this.c.className )
264
+ .addClass( className );
265
+ }
266
+ } );
267
+
268
+
269
+ /**
270
+ * RowGroup default settings for initialisation
271
+ *
272
+ * @namespace
273
+ * @name RowGroup.defaults
274
+ * @static
275
+ */
276
+ RowGroup.defaults = {
277
+ /**
278
+ * Class to apply to grouping rows - applied to both the start and
279
+ * end grouping rows.
280
+ * @type string
281
+ */
282
+ className: 'group',
283
+
284
+ /**
285
+ * Data property from which to read the grouping information
286
+ * @type string|integer
287
+ */
288
+ dataSrc: 0,
289
+
290
+ /**
291
+ * Initial enablement state
292
+ * @boolean
293
+ */
294
+ enable: true,
295
+
296
+ /**
297
+ * Class name to give to the end grouping row
298
+ * @type string
299
+ */
300
+ endClassName: 'group-end',
301
+
302
+ /**
303
+ * End grouping label function
304
+ * @function
305
+ */
306
+ endRender: null,
307
+
308
+ /**
309
+ * Class name to give to the start grouping row
310
+ * @type string
311
+ */
312
+ startClassName: 'group-start',
313
+
314
+ /**
315
+ * Start grouping label function
316
+ * @function
317
+ */
318
+ startRender: function ( rows, group ) {
319
+ return group;
320
+ }
321
+ };
322
+
323
+
324
+ RowGroup.version = "1.0.0";
325
+
326
+
327
+ $.fn.dataTable.RowGroup = RowGroup;
328
+ $.fn.DataTable.RowGroup = RowGroup;
329
+
330
+
331
+ DataTable.Api.register( 'rowGroup()', function () {
332
+ return this;
333
+ } );
334
+
335
+ DataTable.Api.register( 'rowGroup().disable()', function () {
336
+ return this.iterator( 'table', function (ctx) {
337
+ if ( ctx.rowGroup ) {
338
+ ctx.rowGroup.enable( false );
339
+ }
340
+ } );
341
+ } );
342
+
343
+ DataTable.Api.register( 'rowGroup().enable()', function ( opts ) {
344
+ return this.iterator( 'table', function (ctx) {
345
+ if ( ctx.rowGroup ) {
346
+ ctx.rowGroup.enable( opts === undefined ? true : opts );
347
+ }
348
+ } );
349
+ } );
350
+
351
+ DataTable.Api.register( 'rowGroup().dataSrc()', function ( val ) {
352
+ if ( val === undefined ) {
353
+ return this.context[0].rowGroup.dataSrc();
354
+ }
355
+
356
+ return this.iterator( 'table', function (ctx) {
357
+ if ( ctx.rowGroup ) {
358
+ ctx.rowGroup.dataSrc( val );
359
+ }
360
+ } );
361
+ } );
362
+
363
+
364
+ // Attach a listener to the document which listens for DataTables initialisation
365
+ // events so we can automatically initialise
366
+ $(document).on( 'preInit.dt.dtrg', function (e, settings, json) {
367
+ if ( e.namespace !== 'dt' ) {
368
+ return;
369
+ }
370
+
371
+ var init = settings.oInit.rowGroup;
372
+ var defaults = DataTable.defaults.rowGroup;
373
+
374
+ if ( init || defaults ) {
375
+ var opts = $.extend( {}, defaults, init );
376
+
377
+ if ( init !== false ) {
378
+ new RowGroup( settings, opts );
379
+ }
380
+ }
381
+ } );
382
+
383
+
384
+ return RowGroup;
385
+
386
+ }));