effective_datatables 4.17.4 → 4.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '06189b222bdbaf62e5b823c4f2a86fad63f0864590edde7dad41e1d8c72b7eac'
4
- data.tar.gz: 352172976389234dd13d08e6822ef18438683e08dbda77f0f30f57288c173090
3
+ metadata.gz: 98b8b128f779a12a5f4bf7618a4c62ba9177a7c6da54b875b1fb74713a2ae1b7
4
+ data.tar.gz: 654dd180969300fbb4f0d9c61e0f81c47bc24e577d615585d2ca7c9194fca864
5
5
  SHA512:
6
- metadata.gz: 953eb5f1cba86efab0fdcd8ba34de7253a8095dd9481e694eee5399931020b9d026a45066bd9497d07f665db48ae95df67e6859184af557d8fdc4341bd3ca27a
7
- data.tar.gz: bf80a017f52a9073f755256bfaf88ba80ce8907a71377625021e16400d2cac1ff3cc1bdc85007ca7678e039506a5b59c168b36df6d377487bd89c61e132e6fd8
6
+ metadata.gz: cec0f5d9a28e18853014d058818dd16c6c8c668269c6cc970ebd3ac17928a591cb0c2d49b6bbd962f473e6f68f69739c642f936ede01d3a79fd356e03db7ccff
7
+ data.tar.gz: c65bbcfaae3d8efb553bd2a548fa1b3f843ac44eefd2ed6171e488d8740eb6d368676414ee1747ed7bb4a81050b1c36e38253da5710502ad3a1780924fa67981
@@ -0,0 +1,17 @@
1
+ # Upgrade
2
+
3
+ To upgrade the datatables.net source code:
4
+
5
+ Visit https://datatables.net/download/
6
+
7
+ Step 1: Choose Bootstrap4
8
+ Step 2:
9
+ Packages: Just DataTables
10
+ Extensions: Buttons, Column visibility, HTML5 export, Print view, Responsive, RowReorder
11
+ Step 3: Download do not minify or concatenate
12
+ Step 4: Replace existing javascript and css with downloaded
13
+
14
+ After replacing the existing JS/CSS:
15
+
16
+ - Consider the buttons.colVis.js and add back the custom sorted functionality
17
+ - Consider the stylesheets/effective_datatables/overrides.bootstrap4.scss
@@ -1,5 +1,5 @@
1
1
  /*! Bootstrap integration for DataTables' Buttons
2
- * ©2016 SpryMedia Ltd - datatables.net/license
2
+ * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
5
5
  (function( factory ){
@@ -11,21 +11,37 @@
11
11
  }
12
12
  else if ( typeof exports === 'object' ) {
13
13
  // CommonJS
14
- module.exports = function (root, $) {
15
- if ( ! root ) {
16
- root = window;
17
- }
18
-
19
- if ( ! $ || ! $.fn.dataTable ) {
20
- $ = require('datatables.net-bs4')(root, $).$;
14
+ var jq = require('jquery');
15
+ var cjsRequires = function (root, $) {
16
+ if ( ! $.fn.dataTable ) {
17
+ require('datatables.net-bs4')(root, $);
21
18
  }
22
19
 
23
20
  if ( ! $.fn.dataTable.Buttons ) {
24
21
  require('datatables.net-buttons')(root, $);
25
22
  }
26
-
27
- return factory( $, root, root.document );
28
23
  };
24
+
25
+ if (typeof window === 'undefined') {
26
+ module.exports = function (root, $) {
27
+ if ( ! root ) {
28
+ // CommonJS environments without a window global must pass a
29
+ // root. This will give an error otherwise
30
+ root = window;
31
+ }
32
+
33
+ if ( ! $ ) {
34
+ $ = jq( root );
35
+ }
36
+
37
+ cjsRequires( root, $ );
38
+ return factory( $, root, root.document );
39
+ };
40
+ }
41
+ else {
42
+ cjsRequires( window, jq );
43
+ module.exports = factory( jq, window, window.document );
44
+ }
29
45
  }
30
46
  else {
31
47
  // Browser
@@ -35,29 +51,67 @@
35
51
  'use strict';
36
52
  var DataTable = $.fn.dataTable;
37
53
 
38
- $.extend( true, DataTable.Buttons.defaults, {
54
+
55
+
56
+ $.extend(true, DataTable.Buttons.defaults, {
39
57
  dom: {
40
58
  container: {
41
- className: 'dt-buttons btn-group'
59
+ className: 'dt-buttons btn-group flex-wrap'
42
60
  },
43
61
  button: {
44
- className: 'btn btn-secondary'
62
+ className: 'btn btn-secondary',
63
+ active: 'active'
45
64
  },
46
65
  collection: {
47
- tag: 'div',
48
- className: 'dt-button-collection dropdown-menu',
66
+ action: {
67
+ dropHtml: ''
68
+ },
69
+ container: {
70
+ tag: 'div',
71
+ className: 'dropdown-menu dt-button-collection'
72
+ },
73
+ closeButton: false,
49
74
  button: {
50
75
  tag: 'a',
51
76
  className: 'dt-button dropdown-item',
52
- active: 'active',
53
- disabled: 'disabled'
77
+ active: 'dt-button-active',
78
+ disabled: 'disabled',
79
+ spacer: {
80
+ className: 'dropdown-divider',
81
+ tag: 'hr'
82
+ }
83
+ }
84
+ },
85
+ split: {
86
+ action: {
87
+ tag: 'a',
88
+ className: 'btn btn-secondary dt-button-split-drop-button',
89
+ closeButton: false
90
+ },
91
+ dropdown: {
92
+ tag: 'button',
93
+ dropHtml: '',
94
+ className:
95
+ 'btn btn-secondary dt-button-split-drop dropdown-toggle dropdown-toggle-split',
96
+ closeButton: false,
97
+ align: 'split-left',
98
+ splitAlignClass: 'dt-button-split-left'
99
+ },
100
+ wrapper: {
101
+ tag: 'div',
102
+ className: 'dt-button-split btn-group',
103
+ closeButton: false
54
104
  }
55
105
  }
106
+ },
107
+ buttonCreated: function (config, button) {
108
+ return config.buttons ? $('<div class="btn-group"/>').append(button) : button;
56
109
  }
57
- } );
110
+ });
58
111
 
59
112
  DataTable.ext.buttons.collection.className += ' dropdown-toggle';
60
113
  DataTable.ext.buttons.collection.rightAlignClassName = 'dropdown-menu-right';
61
114
 
62
- return DataTable.Buttons;
115
+
116
+ return DataTable;
63
117
  }));
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Column visibility buttons for Buttons and DataTables.
3
- * 2016 SpryMedia Ltd - datatables.net/license
3
+ * © SpryMedia Ltd - datatables.net/license
4
4
  */
5
5
 
6
6
  (function( factory ){
@@ -12,21 +12,37 @@
12
12
  }
13
13
  else if ( typeof exports === 'object' ) {
14
14
  // CommonJS
15
- module.exports = function (root, $) {
16
- if ( ! root ) {
17
- root = window;
18
- }
19
-
20
- if ( ! $ || ! $.fn.dataTable ) {
21
- $ = require('datatables.net')(root, $).$;
15
+ var jq = require('jquery');
16
+ var cjsRequires = function (root, $) {
17
+ if ( ! $.fn.dataTable ) {
18
+ require('datatables.net')(root, $);
22
19
  }
23
20
 
24
21
  if ( ! $.fn.dataTable.Buttons ) {
25
22
  require('datatables.net-buttons')(root, $);
26
23
  }
27
-
28
- return factory( $, root, root.document );
29
24
  };
25
+
26
+ if (typeof window === 'undefined') {
27
+ module.exports = function (root, $) {
28
+ if ( ! root ) {
29
+ // CommonJS environments without a window global must pass a
30
+ // root. This will give an error otherwise
31
+ root = window;
32
+ }
33
+
34
+ if ( ! $ ) {
35
+ $ = jq( root );
36
+ }
37
+
38
+ cjsRequires( root, $ );
39
+ return factory( $, root, root.document );
40
+ };
41
+ }
42
+ else {
43
+ cjsRequires( window, jq );
44
+ module.exports = factory( jq, window, window.document );
45
+ }
30
46
  }
31
47
  else {
32
48
  // Browser
@@ -37,44 +53,68 @@
37
53
  var DataTable = $.fn.dataTable;
38
54
 
39
55
 
40
- $.extend( DataTable.ext.buttons, {
56
+
57
+ $.extend(DataTable.ext.buttons, {
41
58
  // A collection of column visibility buttons
42
- colvis: function ( dt, conf ) {
43
- return {
59
+ colvis: function (dt, conf) {
60
+ var node = null;
61
+ var buttonConf = {
44
62
  extend: 'collection',
45
- text: function ( dt ) {
46
- return dt.i18n( 'buttons.colvis', 'Column visibility' );
63
+ init: function (dt, n) {
64
+ node = n;
65
+ },
66
+ text: function (dt) {
67
+ return dt.i18n('buttons.colvis', 'Column visibility');
47
68
  },
48
69
  className: 'buttons-colvis',
49
- buttons: [ {
50
- extend: 'columnsToggle',
51
- columns: conf.columns,
52
- columnText: conf.columnText
53
- } ]
70
+ closeButton: false,
71
+ buttons: [
72
+ {
73
+ extend: 'columnsToggle',
74
+ columns: conf.columns,
75
+ columnText: conf.columnText
76
+ }
77
+ ]
54
78
  };
79
+
80
+ // Rebuild the collection with the new column structure if columns are reordered
81
+ dt.on('column-reorder.dt' + conf.namespace, function (e, settings, details) {
82
+ dt.button(null, dt.button(null, node).node()).collectionRebuild([
83
+ {
84
+ extend: 'columnsToggle',
85
+ columns: conf.columns,
86
+ columnText: conf.columnText
87
+ }
88
+ ]);
89
+ });
90
+
91
+ return buttonConf;
55
92
  },
56
93
 
57
94
  // Selected columns with individual buttons - toggle column visibility
58
- columnsToggle: function ( dt, conf ) {
59
- var columns = dt.columns( conf.columns ).indexes().map( function ( idx ) {
60
- return {
61
- extend: 'columnToggle',
62
- columns: idx,
63
- columnText: conf.columnText
64
- };
65
- })
66
-
67
- var sorted = columns.sort(function (a, b) {
68
- var a = dt.settings()[0].aoColumns[a.columns].sTitle;
69
- var b = dt.settings()[0].aoColumns[b.columns].sTitle;
70
- return a.localeCompare(b)
71
- }).toArray();
72
-
73
- return sorted;
95
+ columnsToggle: function (dt, conf) {
96
+ var columns = dt
97
+ .columns(conf.columns)
98
+ .indexes()
99
+ .map(function (idx) {
100
+ return {
101
+ extend: 'columnToggle',
102
+ columns: idx,
103
+ columnText: conf.columnText
104
+ };
105
+ })
106
+
107
+ var sorted = columns.sort(function (a, b) {
108
+ var a = dt.settings()[0].aoColumns[a.columns].sTitle;
109
+ var b = dt.settings()[0].aoColumns[b.columns].sTitle;
110
+ return a.localeCompare(b)
111
+ }).toArray();
112
+
113
+ return sorted;
74
114
  },
75
115
 
76
116
  // Single button to toggle column visibility
77
- columnToggle: function ( dt, conf ) {
117
+ columnToggle: function (dt, conf) {
78
118
  return {
79
119
  extend: 'columnVisibility',
80
120
  columns: conf.columns,
@@ -83,15 +123,19 @@ $.extend( DataTable.ext.buttons, {
83
123
  },
84
124
 
85
125
  // Selected columns with individual buttons - set column visibility
86
- columnsVisibility: function ( dt, conf ) {
87
- var columns = dt.columns( conf.columns ).indexes().map( function ( idx ) {
88
- return {
89
- extend: 'columnVisibility',
90
- columns: idx,
91
- visibility: conf.visibility,
92
- columnText: conf.columnText
93
- };
94
- } ).toArray();
126
+ columnsVisibility: function (dt, conf) {
127
+ var columns = dt
128
+ .columns(conf.columns)
129
+ .indexes()
130
+ .map(function (idx) {
131
+ return {
132
+ extend: 'columnVisibility',
133
+ columns: idx,
134
+ visibility: conf.visibility,
135
+ columnText: conf.columnText
136
+ };
137
+ })
138
+ .toArray();
95
139
 
96
140
  return columns;
97
141
  },
@@ -99,111 +143,113 @@ $.extend( DataTable.ext.buttons, {
99
143
  // Single button to set column visibility
100
144
  columnVisibility: {
101
145
  columns: undefined, // column selector
102
- text: function ( dt, button, conf ) {
103
- return conf._columnText( dt, conf );
146
+ text: function (dt, button, conf) {
147
+ return conf._columnText(dt, conf);
104
148
  },
105
149
  className: 'buttons-columnVisibility',
106
- action: function ( e, dt, button, conf ) {
107
- var col = dt.columns( conf.columns );
150
+ action: function (e, dt, button, conf) {
151
+ var col = dt.columns(conf.columns);
108
152
  var curr = col.visible();
109
153
 
110
- col.visible( conf.visibility !== undefined ?
111
- conf.visibility :
112
- ! (curr.length ? curr[0] : false )
154
+ col.visible(
155
+ conf.visibility !== undefined ? conf.visibility : !(curr.length ? curr[0] : false)
113
156
  );
114
157
  },
115
- init: function ( dt, button, conf ) {
158
+ init: function (dt, button, conf) {
116
159
  var that = this;
117
- button.attr( 'data-cv-idx', conf.columns );
118
-
119
- dt
120
- .on( 'column-visibility.dt'+conf.namespace, function (e, settings) {
121
- if ( ! settings.bDestroying && settings.nTable == dt.settings()[0].nTable ) {
122
- that.active( dt.column( conf.columns ).visible() );
123
- }
124
- } )
125
- .on( 'column-reorder.dt'+conf.namespace, function (e, settings, details) {
126
- // Don't rename buttons based on column name if the button
127
- // controls more than one column!
128
- if ( dt.columns( conf.columns ).count() !== 1 ) {
129
- return;
130
- }
131
-
132
- conf.columns = $.inArray( conf.columns, details.mapping );
133
- button.attr( 'data-cv-idx', conf.columns );
134
-
135
- // Reorder buttons for new table order
136
- button
137
- .parent()
138
- .children('[data-cv-idx]')
139
- .sort( function (a, b) {
140
- return (a.getAttribute('data-cv-idx')*1) - (b.getAttribute('data-cv-idx')*1);
141
- } )
142
- .appendTo(button.parent());
143
- } );
144
-
145
- this.active( dt.column( conf.columns ).visible() );
160
+ button.attr('data-cv-idx', conf.columns);
161
+
162
+ dt.on('column-visibility.dt' + conf.namespace, function (e, settings) {
163
+ if (!settings.bDestroying && settings.nTable == dt.settings()[0].nTable) {
164
+ that.active(dt.column(conf.columns).visible());
165
+ }
166
+ }).on('column-reorder.dt' + conf.namespace, function (e, settings, details) {
167
+ // Button has been removed from the DOM
168
+ if (conf.destroying) {
169
+ return;
170
+ }
171
+
172
+ if (dt.columns(conf.columns).count() !== 1) {
173
+ return;
174
+ }
175
+
176
+ // This button controls the same column index but the text for the column has
177
+ // changed
178
+ that.text(conf._columnText(dt, conf));
179
+
180
+ // Since its a different column, we need to check its visibility
181
+ that.active(dt.column(conf.columns).visible());
182
+ });
183
+
184
+ this.active(dt.column(conf.columns).visible());
146
185
  },
147
- destroy: function ( dt, button, conf ) {
148
- dt
149
- .off( 'column-visibility.dt'+conf.namespace )
150
- .off( 'column-reorder.dt'+conf.namespace );
186
+ destroy: function (dt, button, conf) {
187
+ dt.off('column-visibility.dt' + conf.namespace).off(
188
+ 'column-reorder.dt' + conf.namespace
189
+ );
151
190
  },
152
191
 
153
- _columnText: function ( dt, conf ) {
192
+ _columnText: function (dt, conf) {
154
193
  // Use DataTables' internal data structure until this is presented
155
194
  // is a public API. The other option is to use
156
195
  // `$( column(col).node() ).text()` but the node might not have been
157
196
  // populated when Buttons is constructed.
158
- var idx = dt.column( conf.columns ).index();
159
- var title = dt.settings()[0].aoColumns[ idx ].sTitle
160
- .replace(/\n/g," ") // remove new lines
161
- .replace(/<br\s*\/?>/gi, " ") // replace line breaks with spaces
162
- .replace(/<select(.*?)<\/select>/g, "") // remove select tags, including options text
163
- .replace(/<!\-\-.*?\-\->/g, "") // strip HTML comments
164
- .replace(/<.*?>/g, "") // strip HTML
165
- .replace(/^\s+|\s+$/g,""); // trim
166
-
167
- return conf.columnText ?
168
- conf.columnText( dt, idx, title ) :
169
- title;
197
+ var idx = dt.column(conf.columns).index();
198
+ var title = dt.settings()[0].aoColumns[idx].sTitle;
199
+
200
+ if (!title) {
201
+ title = dt.column(idx).header().innerHTML;
202
+ }
203
+
204
+ title = title
205
+ .replace(/\n/g, ' ') // remove new lines
206
+ .replace(/<br\s*\/?>/gi, ' ') // replace line breaks with spaces
207
+ .replace(/<select(.*?)<\/select>/g, '') // remove select tags, including options text
208
+ .replace(/<!\-\-.*?\-\->/g, '') // strip HTML comments
209
+ .replace(/<.*?>/g, '') // strip HTML
210
+ .replace(/^\s+|\s+$/g, ''); // trim
211
+
212
+ return conf.columnText ? conf.columnText(dt, idx, title) : title;
170
213
  }
171
214
  },
172
215
 
173
-
174
216
  colvisRestore: {
175
217
  className: 'buttons-colvisRestore',
176
218
 
177
- text: function ( dt ) {
178
- return dt.i18n( 'buttons.colvisRestore', 'Restore visibility' );
219
+ text: function (dt) {
220
+ return dt.i18n('buttons.colvisRestore', 'Restore visibility');
179
221
  },
180
222
 
181
- init: function ( dt, button, conf ) {
182
- conf._visOriginal = dt.columns().indexes().map( function ( idx ) {
183
- return dt.column( idx ).visible();
184
- } ).toArray();
223
+ init: function (dt, button, conf) {
224
+ conf._visOriginal = dt
225
+ .columns()
226
+ .indexes()
227
+ .map(function (idx) {
228
+ return dt.column(idx).visible();
229
+ })
230
+ .toArray();
185
231
  },
186
232
 
187
- action: function ( e, dt, button, conf ) {
188
- dt.columns().every( function ( i ) {
233
+ action: function (e, dt, button, conf) {
234
+ dt.columns().every(function (i) {
189
235
  // Take into account that ColReorder might have disrupted our
190
236
  // indexes
191
- var idx = dt.colReorder && dt.colReorder.transpose ?
192
- dt.colReorder.transpose( i, 'toOriginal' ) :
193
- i;
237
+ var idx =
238
+ dt.colReorder && dt.colReorder.transpose
239
+ ? dt.colReorder.transpose(i, 'toOriginal')
240
+ : i;
194
241
 
195
- this.visible( conf._visOriginal[ idx ] );
196
- } );
242
+ this.visible(conf._visOriginal[idx]);
243
+ });
197
244
  }
198
245
  },
199
246
 
200
-
201
247
  colvisGroup: {
202
248
  className: 'buttons-colvisGroup',
203
249
 
204
- action: function ( e, dt, button, conf ) {
205
- dt.columns( conf.show ).visible( true, false );
206
- dt.columns( conf.hide ).visible( false, false );
250
+ action: function (e, dt, button, conf) {
251
+ dt.columns(conf.show).visible(true, false);
252
+ dt.columns(conf.hide).visible(false, false);
207
253
 
208
254
  dt.columns.adjust();
209
255
  },
@@ -212,8 +258,8 @@ $.extend( DataTable.ext.buttons, {
212
258
 
213
259
  hide: []
214
260
  }
215
- } );
261
+ });
216
262
 
217
263
 
218
- return DataTable.Buttons;
264
+ return DataTable;
219
265
  }));