effective_datatables 4.17.4 → 4.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/app/assets/javascripts/dataTables/UPGRADE.md +17 -0
- data/app/assets/javascripts/dataTables/buttons/buttons.bootstrap4.js +73 -19
- data/app/assets/javascripts/dataTables/buttons/buttons.colVis.js +166 -120
- data/app/assets/javascripts/dataTables/buttons/buttons.html5.js +749 -667
- data/app/assets/javascripts/dataTables/buttons/buttons.print.js +96 -64
- data/app/assets/javascripts/dataTables/buttons/dataTables.buttons.js +1568 -909
- data/app/assets/javascripts/dataTables/dataTables.bootstrap4.js +172 -154
- data/app/assets/javascripts/dataTables/jquery.dataTables.js +3119 -2704
- data/app/assets/javascripts/dataTables/responsive/dataTables.responsive.js +707 -531
- data/app/assets/javascripts/dataTables/responsive/responsive.bootstrap4.js +61 -33
- data/app/assets/javascripts/dataTables/rowReorder/dataTables.rowReorder.js +961 -740
- data/app/assets/javascripts/dataTables/rowReorder/rowReorder.bootstrap4.js +50 -30
- data/app/assets/javascripts/effective_datatables/filters.js.coffee +88 -0
- data/app/assets/stylesheets/dataTables/buttons/buttons.bootstrap4.scss +178 -151
- data/app/assets/stylesheets/dataTables/dataTables.bootstrap4.scss +300 -81
- data/app/assets/stylesheets/dataTables/responsive/responsive.bootstrap4.scss +54 -71
- data/app/assets/stylesheets/dataTables/rowReorder/rowReorder.bootstrap4.scss +23 -4
- data/app/assets/stylesheets/effective_datatables/_overrides.bootstrap4.scss +81 -39
- data/app/views/effective/datatables/_filter_date_range.html.haml +37 -9
- data/app/views/effective/datatables/_filters.html.haml +1 -1
- data/lib/effective_datatables/version.rb +1 -1
- metadata +3 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* Print button for Buttons and DataTables.
|
3
|
-
*
|
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
|
-
|
16
|
-
|
17
|
-
|
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,7 +53,8 @@
|
|
37
53
|
var DataTable = $.fn.dataTable;
|
38
54
|
|
39
55
|
|
40
|
-
|
56
|
+
|
57
|
+
var _link = document.createElement('a');
|
41
58
|
|
42
59
|
/**
|
43
60
|
* Clone link and style tags, taking into account the need to change the source
|
@@ -45,13 +62,13 @@ var _link = document.createElement( 'a' );
|
|
45
62
|
*
|
46
63
|
* @param {node} el Element to convert
|
47
64
|
*/
|
48
|
-
var _styleToAbs = function(
|
65
|
+
var _styleToAbs = function (el) {
|
49
66
|
var url;
|
50
67
|
var clone = $(el).clone()[0];
|
51
68
|
var linkHost;
|
52
69
|
|
53
|
-
if (
|
54
|
-
clone.href = _relToAbs(
|
70
|
+
if (clone.nodeName.toLowerCase() === 'link') {
|
71
|
+
clone.href = _relToAbs(clone.href);
|
55
72
|
}
|
56
73
|
|
57
74
|
return clone.outerHTML;
|
@@ -63,7 +80,7 @@ var _styleToAbs = function( el ) {
|
|
63
80
|
*
|
64
81
|
* @param {string} href URL
|
65
82
|
*/
|
66
|
-
var _relToAbs = function(
|
83
|
+
var _relToAbs = function (href) {
|
67
84
|
// Assign to a link on the original page so the browser will do all the
|
68
85
|
// hard work of figuring out where the file actually is
|
69
86
|
_link.href = href;
|
@@ -71,120 +88,135 @@ var _relToAbs = function( href ) {
|
|
71
88
|
|
72
89
|
// IE doesn't have a trailing slash on the host
|
73
90
|
// Chrome has it on the pathname
|
74
|
-
if (
|
91
|
+
if (linkHost.indexOf('/') === -1 && _link.pathname.indexOf('/') !== 0) {
|
75
92
|
linkHost += '/';
|
76
93
|
}
|
77
94
|
|
78
|
-
return _link.protocol+
|
95
|
+
return _link.protocol + '//' + linkHost + _link.pathname + _link.search;
|
79
96
|
};
|
80
97
|
|
81
|
-
|
82
98
|
DataTable.ext.buttons.print = {
|
83
99
|
className: 'buttons-print',
|
84
100
|
|
85
|
-
text: function (
|
86
|
-
return dt.i18n(
|
101
|
+
text: function (dt) {
|
102
|
+
return dt.i18n('buttons.print', 'Print');
|
87
103
|
},
|
88
104
|
|
89
|
-
action: function (
|
105
|
+
action: function (e, dt, button, config) {
|
90
106
|
var data = dt.buttons.exportData(
|
91
|
-
$.extend(
|
107
|
+
$.extend({ decodeEntities: false }, config.exportOptions) // XSS protection
|
92
108
|
);
|
93
|
-
var exportInfo = dt.buttons.exportInfo(
|
109
|
+
var exportInfo = dt.buttons.exportInfo(config);
|
94
110
|
var columnClasses = dt
|
95
|
-
.columns(
|
111
|
+
.columns(config.exportOptions.columns)
|
96
112
|
.flatten()
|
97
|
-
.map(
|
113
|
+
.map(function (idx) {
|
98
114
|
return dt.settings()[0].aoColumns[dt.column(idx).index()].sClass;
|
99
|
-
}
|
115
|
+
})
|
100
116
|
.toArray();
|
101
117
|
|
102
|
-
var addRow = function (
|
118
|
+
var addRow = function (d, tag) {
|
103
119
|
var str = '<tr>';
|
104
120
|
|
105
|
-
for (
|
121
|
+
for (var i = 0, ien = d.length; i < ien; i++) {
|
106
122
|
// null and undefined aren't useful in the print output
|
107
|
-
var dataOut = d[i] === null || d[i] === undefined ?
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
'class="'+columnClasses[i]+'"' :
|
112
|
-
'';
|
113
|
-
|
114
|
-
str += '<'+tag+' '+classAttr+'>'+dataOut+'</'+tag+'>';
|
123
|
+
var dataOut = d[i] === null || d[i] === undefined ? '' : d[i];
|
124
|
+
var classAttr = columnClasses[i] ? 'class="' + columnClasses[i] + '"' : '';
|
125
|
+
|
126
|
+
str += '<' + tag + ' ' + classAttr + '>' + dataOut + '</' + tag + '>';
|
115
127
|
}
|
116
128
|
|
117
129
|
return str + '</tr>';
|
118
130
|
};
|
119
131
|
|
120
132
|
// Construct a table for printing
|
121
|
-
var html = '<table class="'+dt.table().node().className+'">';
|
133
|
+
var html = '<table class="' + dt.table().node().className + '">';
|
122
134
|
|
123
|
-
if (
|
124
|
-
html += '<thead>'+ addRow(
|
135
|
+
if (config.header) {
|
136
|
+
html += '<thead>' + addRow(data.header, 'th') + '</thead>';
|
125
137
|
}
|
126
138
|
|
127
139
|
html += '<tbody>';
|
128
|
-
for (
|
129
|
-
html += addRow(
|
140
|
+
for (var i = 0, ien = data.body.length; i < ien; i++) {
|
141
|
+
html += addRow(data.body[i], 'td');
|
130
142
|
}
|
131
143
|
html += '</tbody>';
|
132
144
|
|
133
|
-
if (
|
134
|
-
html += '<tfoot>'+ addRow(
|
145
|
+
if (config.footer && data.footer) {
|
146
|
+
html += '<tfoot>' + addRow(data.footer, 'th') + '</tfoot>';
|
135
147
|
}
|
136
148
|
html += '</table>';
|
137
149
|
|
138
150
|
// Open a new window for the printable table
|
139
|
-
var win = window.open(
|
151
|
+
var win = window.open('', '');
|
152
|
+
|
153
|
+
if (!win) {
|
154
|
+
dt.buttons.info(
|
155
|
+
dt.i18n('buttons.printErrorTitle', 'Unable to open print view'),
|
156
|
+
dt.i18n(
|
157
|
+
'buttons.printErrorMsg',
|
158
|
+
'Please allow popups in your browser for this site to be able to view the print view.'
|
159
|
+
),
|
160
|
+
5000
|
161
|
+
);
|
162
|
+
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
140
166
|
win.document.close();
|
141
167
|
|
142
168
|
// Inject the title and also a copy of the style and link tags from this
|
143
169
|
// document so the table can retain its base styling. Note that we have
|
144
170
|
// to use string manipulation as IE won't allow elements to be created
|
145
171
|
// in the host document and then appended to the new window.
|
146
|
-
var head = '<title>'+exportInfo.title+'</title>';
|
147
|
-
$('style, link').each(
|
148
|
-
head += _styleToAbs(
|
149
|
-
}
|
172
|
+
var head = '<title>' + exportInfo.title + '</title>';
|
173
|
+
$('style, link').each(function () {
|
174
|
+
head += _styleToAbs(this);
|
175
|
+
});
|
150
176
|
|
151
177
|
try {
|
152
178
|
win.document.head.innerHTML = head; // Work around for Edge
|
153
|
-
}
|
154
|
-
|
155
|
-
$(win.document.head).html( head ); // Old IE
|
179
|
+
} catch (e) {
|
180
|
+
$(win.document.head).html(head); // Old IE
|
156
181
|
}
|
157
182
|
|
158
183
|
// Inject the table and other surrounding information
|
159
184
|
win.document.body.innerHTML =
|
160
|
-
'<h1>'+
|
161
|
-
|
162
|
-
|
163
|
-
'<div>'
|
185
|
+
'<h1>' +
|
186
|
+
exportInfo.title +
|
187
|
+
'</h1>' +
|
188
|
+
'<div>' +
|
189
|
+
(exportInfo.messageTop || '') +
|
190
|
+
'</div>' +
|
191
|
+
html +
|
192
|
+
'<div>' +
|
193
|
+
(exportInfo.messageBottom || '') +
|
194
|
+
'</div>';
|
164
195
|
|
165
196
|
$(win.document.body).addClass('dt-print-view');
|
166
197
|
|
167
|
-
$('img', win.document.body).each(
|
168
|
-
img.setAttribute(
|
169
|
-
}
|
198
|
+
$('img', win.document.body).each(function (i, img) {
|
199
|
+
img.setAttribute('src', _relToAbs(img.getAttribute('src')));
|
200
|
+
});
|
170
201
|
|
171
|
-
if (
|
172
|
-
config.customize(
|
202
|
+
if (config.customize) {
|
203
|
+
config.customize(win, config, dt);
|
173
204
|
}
|
174
205
|
|
175
206
|
// Allow stylesheets time to load
|
176
207
|
var autoPrint = function () {
|
177
|
-
if (
|
208
|
+
if (config.autoPrint) {
|
178
209
|
win.print(); // blocking - so close will not
|
179
210
|
win.close(); // execute until this is done
|
180
211
|
}
|
181
212
|
};
|
182
213
|
|
183
|
-
if (
|
214
|
+
if (navigator.userAgent.match(/Trident\/\d.\d/)) {
|
215
|
+
// IE needs to call this without a setTimeout
|
184
216
|
autoPrint();
|
185
217
|
}
|
186
218
|
else {
|
187
|
-
win.setTimeout(
|
219
|
+
win.setTimeout(autoPrint, 1000);
|
188
220
|
}
|
189
221
|
},
|
190
222
|
|
@@ -206,5 +238,5 @@ DataTable.ext.buttons.print = {
|
|
206
238
|
};
|
207
239
|
|
208
240
|
|
209
|
-
return DataTable
|
241
|
+
return DataTable;
|
210
242
|
}));
|