effective_datatables 4.17.4 → 4.19.0

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 (24) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/app/assets/javascripts/dataTables/UPGRADE.md +17 -0
  4. data/app/assets/javascripts/dataTables/buttons/buttons.bootstrap4.js +73 -19
  5. data/app/assets/javascripts/dataTables/buttons/buttons.colVis.js +166 -120
  6. data/app/assets/javascripts/dataTables/buttons/buttons.html5.js +749 -667
  7. data/app/assets/javascripts/dataTables/buttons/buttons.print.js +96 -64
  8. data/app/assets/javascripts/dataTables/buttons/dataTables.buttons.js +1568 -909
  9. data/app/assets/javascripts/dataTables/dataTables.bootstrap4.js +172 -154
  10. data/app/assets/javascripts/dataTables/jquery.dataTables.js +3119 -2704
  11. data/app/assets/javascripts/dataTables/responsive/dataTables.responsive.js +707 -531
  12. data/app/assets/javascripts/dataTables/responsive/responsive.bootstrap4.js +61 -33
  13. data/app/assets/javascripts/dataTables/rowReorder/dataTables.rowReorder.js +961 -740
  14. data/app/assets/javascripts/dataTables/rowReorder/rowReorder.bootstrap4.js +50 -30
  15. data/app/assets/javascripts/effective_datatables/filters.js.coffee +88 -0
  16. data/app/assets/stylesheets/dataTables/buttons/buttons.bootstrap4.scss +178 -151
  17. data/app/assets/stylesheets/dataTables/dataTables.bootstrap4.scss +300 -81
  18. data/app/assets/stylesheets/dataTables/responsive/responsive.bootstrap4.scss +54 -71
  19. data/app/assets/stylesheets/dataTables/rowReorder/rowReorder.bootstrap4.scss +23 -4
  20. data/app/assets/stylesheets/effective_datatables/_overrides.bootstrap4.scss +81 -39
  21. data/app/views/effective/datatables/_filter_date_range.html.haml +37 -9
  22. data/app/views/effective/datatables/_filters.html.haml +1 -1
  23. data/lib/effective_datatables/version.rb +1 -1
  24. metadata +3 -2
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * HTML5 export buttons for Buttons and DataTables.
3
- * 2016 SpryMedia Ltd - datatables.net/license
3
+ * © SpryMedia Ltd - datatables.net/license
4
4
  *
5
5
  * FileSaver.js (1.3.3) - MIT license
6
6
  * Copyright © 2016 Eli Grey - http://eligrey.com
@@ -15,21 +15,37 @@
15
15
  }
16
16
  else if ( typeof exports === 'object' ) {
17
17
  // CommonJS
18
- module.exports = function (root, $, jszip, pdfmake) {
19
- if ( ! root ) {
20
- root = window;
21
- }
22
-
23
- if ( ! $ || ! $.fn.dataTable ) {
24
- $ = require('datatables.net')(root, $).$;
18
+ var jq = require('jquery');
19
+ var cjsRequires = function (root, $) {
20
+ if ( ! $.fn.dataTable ) {
21
+ require('datatables.net')(root, $);
25
22
  }
26
23
 
27
24
  if ( ! $.fn.dataTable.Buttons ) {
28
25
  require('datatables.net-buttons')(root, $);
29
26
  }
30
-
31
- return factory( $, root, root.document, jszip, pdfmake );
32
27
  };
28
+
29
+ if (typeof window === 'undefined') {
30
+ module.exports = function (root, $, jszip, pdfmake) {
31
+ if ( ! root ) {
32
+ // CommonJS environments without a window global must pass a
33
+ // root. This will give an error otherwise
34
+ root = window;
35
+ }
36
+
37
+ if ( ! $ ) {
38
+ $ = jq( root );
39
+ }
40
+
41
+ cjsRequires( root, $ );
42
+ return factory( $, root, root.document, jszip, pdfmake );
43
+ };
44
+ }
45
+ else {
46
+ cjsRequires( window, jq );
47
+ module.exports = factory( jq, window, window.document );
48
+ }
33
49
  }
34
50
  else {
35
51
  // Browser
@@ -39,29 +55,33 @@
39
55
  'use strict';
40
56
  var DataTable = $.fn.dataTable;
41
57
 
58
+
59
+
42
60
  // Allow the constructor to pass in JSZip and PDFMake from external requires.
43
61
  // Otherwise, use globally defined variables, if they are available.
44
- function _jsZip () {
45
- return jszip || window.JSZip;
62
+ var useJszip;
63
+ var usePdfmake;
64
+
65
+ function _jsZip() {
66
+ return useJszip || window.JSZip;
46
67
  }
47
- function _pdfMake () {
48
- return pdfmake || window.pdfMake;
68
+ function _pdfMake() {
69
+ return usePdfmake || window.pdfMake;
49
70
  }
50
71
 
51
72
  DataTable.Buttons.pdfMake = function (_) {
52
- if ( ! _ ) {
73
+ if (!_) {
53
74
  return _pdfMake();
54
75
  }
55
- pdfmake = m_ake;
56
- }
76
+ usePdfmake = _;
77
+ };
57
78
 
58
79
  DataTable.Buttons.jszip = function (_) {
59
- if ( ! _ ) {
80
+ if (!_) {
60
81
  return _jsZip();
61
82
  }
62
- jszip = _;
63
- }
64
-
83
+ useJszip = _;
84
+ };
65
85
 
66
86
  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
67
87
  * FileSaver.js dependency
@@ -69,50 +89,55 @@ DataTable.Buttons.jszip = function (_) {
69
89
 
70
90
  /*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
71
91
 
72
- var _saveAs = (function(view) {
73
- "use strict";
92
+ var _saveAs = (function (view) {
93
+ 'use strict';
74
94
  // IE <10 is explicitly unsupported
75
- if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
95
+ if (
96
+ typeof view === 'undefined' ||
97
+ (typeof navigator !== 'undefined' && /MSIE [1-9]\./.test(navigator.userAgent))
98
+ ) {
76
99
  return;
77
100
  }
78
- var
79
- doc = view.document
80
- // only get URL when necessary in case Blob.js hasn't overridden it yet
81
- , get_URL = function() {
101
+ var doc = view.document,
102
+ // only get URL when necessary in case Blob.js hasn't overridden it yet
103
+ get_URL = function () {
82
104
  return view.URL || view.webkitURL || view;
83
- }
84
- , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
85
- , can_use_save_link = "download" in save_link
86
- , click = function(node) {
87
- var event = new MouseEvent("click");
105
+ },
106
+ save_link = doc.createElementNS('http://www.w3.org/1999/xhtml', 'a'),
107
+ can_use_save_link = 'download' in save_link,
108
+ click = function (node) {
109
+ var event = new MouseEvent('click');
88
110
  node.dispatchEvent(event);
89
- }
90
- , is_safari = /constructor/i.test(view.HTMLElement) || view.safari
91
- , is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
92
- , throw_outside = function(ex) {
93
- (view.setImmediate || view.setTimeout)(function() {
111
+ },
112
+ is_safari = /constructor/i.test(view.HTMLElement) || view.safari,
113
+ is_chrome_ios = /CriOS\/[\d]+/.test(navigator.userAgent),
114
+ throw_outside = function (ex) {
115
+ (view.setImmediate || view.setTimeout)(function () {
94
116
  throw ex;
95
117
  }, 0);
96
- }
97
- , force_saveable_type = "application/octet-stream"
118
+ },
119
+ force_saveable_type = 'application/octet-stream',
98
120
  // the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
99
- , arbitrary_revoke_timeout = 1000 * 40 // in ms
100
- , revoke = function(file) {
101
- var revoker = function() {
102
- if (typeof file === "string") { // file is an object URL
121
+ arbitrary_revoke_timeout = 1000 * 40, // in ms
122
+ revoke = function (file) {
123
+ var revoker = function () {
124
+ if (typeof file === 'string') {
125
+ // file is an object URL
103
126
  get_URL().revokeObjectURL(file);
104
- } else { // file is a File
127
+ }
128
+ else {
129
+ // file is a File
105
130
  file.remove();
106
131
  }
107
132
  };
108
133
  setTimeout(revoker, arbitrary_revoke_timeout);
109
- }
110
- , dispatch = function(filesaver, event_types, event) {
134
+ },
135
+ dispatch = function (filesaver, event_types, event) {
111
136
  event_types = [].concat(event_types);
112
137
  var i = event_types.length;
113
138
  while (i--) {
114
- var listener = filesaver["on" + event_types[i]];
115
- if (typeof listener === "function") {
139
+ var listener = filesaver['on' + event_types[i]];
140
+ if (typeof listener === 'function') {
116
141
  try {
117
142
  listener.call(filesaver, event || filesaver);
118
143
  } catch (ex) {
@@ -120,38 +145,43 @@ var _saveAs = (function(view) {
120
145
  }
121
146
  }
122
147
  }
123
- }
124
- , auto_bom = function(blob) {
148
+ },
149
+ auto_bom = function (blob) {
125
150
  // prepend BOM for UTF-8 XML and text/* types (including HTML)
126
151
  // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
127
- if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
128
- return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
152
+ if (
153
+ /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(
154
+ blob.type
155
+ )
156
+ ) {
157
+ return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type });
129
158
  }
130
159
  return blob;
131
- }
132
- , FileSaver = function(blob, name, no_auto_bom) {
160
+ },
161
+ FileSaver = function (blob, name, no_auto_bom) {
133
162
  if (!no_auto_bom) {
134
163
  blob = auto_bom(blob);
135
164
  }
136
165
  // First try a.download, then web filesystem, then object URLs
137
- var
138
- filesaver = this
139
- , type = blob.type
140
- , force = type === force_saveable_type
141
- , object_url
142
- , dispatch_all = function() {
143
- dispatch(filesaver, "writestart progress write writeend".split(" "));
144
- }
166
+ var filesaver = this,
167
+ type = blob.type,
168
+ force = type === force_saveable_type,
169
+ object_url,
170
+ dispatch_all = function () {
171
+ dispatch(filesaver, 'writestart progress write writeend'.split(' '));
172
+ },
145
173
  // on any filesys errors revert to saving with object URLs
146
- , fs_error = function() {
174
+ fs_error = function () {
147
175
  if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
148
176
  // Safari doesn't allow downloading of blob urls
149
177
  var reader = new FileReader();
150
- reader.onloadend = function() {
151
- var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
178
+ reader.onloadend = function () {
179
+ var url = is_chrome_ios
180
+ ? reader.result
181
+ : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
152
182
  var popup = view.open(url, '_blank');
153
- if(!popup) view.location.href = url;
154
- url=undefined; // release reference before dispatching
183
+ if (!popup) view.location.href = url;
184
+ url = undefined; // release reference before dispatching
155
185
  filesaver.readyState = filesaver.DONE;
156
186
  dispatch_all();
157
187
  };
@@ -165,8 +195,9 @@ var _saveAs = (function(view) {
165
195
  }
166
196
  if (force) {
167
197
  view.location.href = object_url;
168
- } else {
169
- var opened = view.open(object_url, "_blank");
198
+ }
199
+ else {
200
+ var opened = view.open(object_url, '_blank');
170
201
  if (!opened) {
171
202
  // Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
172
203
  view.location.href = object_url;
@@ -175,13 +206,12 @@ var _saveAs = (function(view) {
175
206
  filesaver.readyState = filesaver.DONE;
176
207
  dispatch_all();
177
208
  revoke(object_url);
178
- }
179
- ;
209
+ };
180
210
  filesaver.readyState = filesaver.INIT;
181
211
 
182
212
  if (can_use_save_link) {
183
213
  object_url = get_URL().createObjectURL(blob);
184
- setTimeout(function() {
214
+ setTimeout(function () {
185
215
  save_link.href = object_url;
186
216
  save_link.download = name;
187
217
  click(save_link);
@@ -193,16 +223,15 @@ var _saveAs = (function(view) {
193
223
  }
194
224
 
195
225
  fs_error();
196
- }
197
- , FS_proto = FileSaver.prototype
198
- , saveAs = function(blob, name, no_auto_bom) {
199
- return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
200
- }
201
- ;
226
+ },
227
+ FS_proto = FileSaver.prototype,
228
+ saveAs = function (blob, name, no_auto_bom) {
229
+ return new FileSaver(blob, name || blob.name || 'download', no_auto_bom);
230
+ };
202
231
  // IE 10+ (native saveAs)
203
- if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
204
- return function(blob, name, no_auto_bom) {
205
- name = name || blob.name || "download";
232
+ if (typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob) {
233
+ return function (blob, name, no_auto_bom) {
234
+ name = name || blob.name || 'download';
206
235
 
207
236
  if (!no_auto_bom) {
208
237
  blob = auto_bom(blob);
@@ -211,33 +240,31 @@ var _saveAs = (function(view) {
211
240
  };
212
241
  }
213
242
 
214
- FS_proto.abort = function(){};
243
+ FS_proto.abort = function () {};
215
244
  FS_proto.readyState = FS_proto.INIT = 0;
216
245
  FS_proto.WRITING = 1;
217
246
  FS_proto.DONE = 2;
218
247
 
219
248
  FS_proto.error =
220
- FS_proto.onwritestart =
221
- FS_proto.onprogress =
222
- FS_proto.onwrite =
223
- FS_proto.onabort =
224
- FS_proto.onerror =
225
- FS_proto.onwriteend =
226
- null;
249
+ FS_proto.onwritestart =
250
+ FS_proto.onprogress =
251
+ FS_proto.onwrite =
252
+ FS_proto.onabort =
253
+ FS_proto.onerror =
254
+ FS_proto.onwriteend =
255
+ null;
227
256
 
228
257
  return saveAs;
229
- }(
230
- typeof self !== "undefined" && self
231
- || typeof window !== "undefined" && window
232
- || this.content
233
- ));
234
-
258
+ })(
259
+ (typeof self !== 'undefined' && self) ||
260
+ (typeof window !== 'undefined' && window) ||
261
+ this.content
262
+ );
235
263
 
236
264
  // Expose file saver on the DataTables API. Can't attach to `DataTables.Buttons`
237
265
  // since this file can be loaded before Button's core!
238
266
  DataTable.fileSave = _saveAs;
239
267
 
240
-
241
268
  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
242
269
  * Local (private) functions
243
270
  */
@@ -247,11 +274,10 @@ DataTable.fileSave = _saveAs;
247
274
  *
248
275
  * @param {object} config Button configuration
249
276
  */
250
- var _sheetname = function ( config )
251
- {
277
+ var _sheetname = function (config) {
252
278
  var sheetName = 'Sheet1';
253
279
 
254
- if ( config.sheetName ) {
280
+ if (config.sheetName) {
255
281
  sheetName = config.sheetName.replace(/[\[\]\*\/\\\?\:]/g, '');
256
282
  }
257
283
 
@@ -264,13 +290,8 @@ var _sheetname = function ( config )
264
290
  * @param {object} config Button configuration
265
291
  * @return {string} Newline character
266
292
  */
267
- var _newLine = function ( config )
268
- {
269
- return config.newline ?
270
- config.newline :
271
- navigator.userAgent.match(/Windows/) ?
272
- '\r\n' :
273
- '\n';
293
+ var _newLine = function (config) {
294
+ return config.newline ? config.newline : navigator.userAgent.match(/Windows/) ? '\r\n' : '\n';
274
295
  };
275
296
 
276
297
  /**
@@ -281,44 +302,41 @@ var _newLine = function ( config )
281
302
  * @param {object} config Button configuration
282
303
  * @return {object} The data to export
283
304
  */
284
- var _exportData = function ( dt, config )
285
- {
286
- var newLine = _newLine( config );
287
- var data = dt.buttons.exportData( config.exportOptions );
305
+ var _exportData = function (dt, config) {
306
+ var newLine = _newLine(config);
307
+ var data = dt.buttons.exportData(config.exportOptions);
288
308
  var boundary = config.fieldBoundary;
289
309
  var separator = config.fieldSeparator;
290
- var reBoundary = new RegExp( boundary, 'g' );
291
- var escapeChar = config.escapeChar !== undefined ?
292
- config.escapeChar :
293
- '\\';
294
- var join = function ( a ) {
310
+ var reBoundary = new RegExp(boundary, 'g');
311
+ var escapeChar = config.escapeChar !== undefined ? config.escapeChar : '\\';
312
+ var join = function (a) {
295
313
  var s = '';
296
314
 
297
315
  // If there is a field boundary, then we might need to escape it in
298
316
  // the source data
299
- for ( var i=0, ien=a.length ; i<ien ; i++ ) {
300
- if ( i > 0 ) {
317
+ for (var i = 0, ien = a.length; i < ien; i++) {
318
+ if (i > 0) {
301
319
  s += separator;
302
320
  }
303
321
 
304
- s += boundary ?
305
- boundary + ('' + a[i]).replace( reBoundary, escapeChar+boundary ) + boundary :
306
- a[i];
322
+ s += boundary
323
+ ? boundary + ('' + a[i]).replace(reBoundary, escapeChar + boundary) + boundary
324
+ : a[i];
307
325
  }
308
326
 
309
327
  return s;
310
328
  };
311
329
 
312
- var header = config.header ? join( data.header )+newLine : '';
313
- var footer = config.footer && data.footer ? newLine+join( data.footer ) : '';
330
+ var header = config.header ? join(data.header) + newLine : '';
331
+ var footer = config.footer && data.footer ? newLine + join(data.footer) : '';
314
332
  var body = [];
315
333
 
316
- for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
317
- body.push( join( data.body[i] ) );
334
+ for (var i = 0, ien = data.body.length; i < ien; i++) {
335
+ body.push(join(data.body[i]));
318
336
  }
319
337
 
320
338
  return {
321
- str: header + body.join( newLine ) + footer,
339
+ str: header + body.join(newLine) + footer,
322
340
  rows: body.length
323
341
  };
324
342
  };
@@ -329,18 +347,18 @@ var _exportData = function ( dt, config )
329
347
  *
330
348
  * @return {Boolean} `true` if old Safari
331
349
  */
332
- var _isDuffSafari = function ()
333
- {
334
- var safari = navigator.userAgent.indexOf('Safari') !== -1 &&
350
+ var _isDuffSafari = function () {
351
+ var safari =
352
+ navigator.userAgent.indexOf('Safari') !== -1 &&
335
353
  navigator.userAgent.indexOf('Chrome') === -1 &&
336
354
  navigator.userAgent.indexOf('Opera') === -1;
337
355
 
338
- if ( ! safari ) {
356
+ if (!safari) {
339
357
  return false;
340
358
  }
341
359
 
342
- var version = navigator.userAgent.match( /AppleWebKit\/(\d+\.\d+)/ );
343
- if ( version && version.length > 1 && version[1]*1 < 603.1 ) {
360
+ var version = navigator.userAgent.match(/AppleWebKit\/(\d+\.\d+)/);
361
+ if (version && version.length > 1 && version[1] * 1 < 603.1) {
344
362
  return true;
345
363
  }
346
364
 
@@ -352,14 +370,14 @@ var _isDuffSafari = function ()
352
370
  * @param {int} n Column number
353
371
  * @return {string} Column letter(s) name
354
372
  */
355
- function createCellPos( n ){
373
+ function createCellPos(n) {
356
374
  var ordA = 'A'.charCodeAt(0);
357
375
  var ordZ = 'Z'.charCodeAt(0);
358
376
  var len = ordZ - ordA + 1;
359
- var s = "";
377
+ var s = '';
360
378
 
361
- while( n >= 0 ) {
362
- s = String.fromCharCode(n % len + ordA) + s;
379
+ while (n >= 0) {
380
+ s = String.fromCharCode((n % len) + ordA) + s;
363
381
  n = Math.floor(n / len) - 1;
364
382
  }
365
383
 
@@ -369,8 +387,7 @@ function createCellPos( n ){
369
387
  try {
370
388
  var _serialiser = new XMLSerializer();
371
389
  var _ieExcel;
372
- }
373
- catch (t) {}
390
+ } catch (t) {}
374
391
 
375
392
  /**
376
393
  * Recursively add XML files from an object's structure to a ZIP file. This
@@ -380,24 +397,28 @@ catch (t) {}
380
397
  * @param {JSZip} zip ZIP package
381
398
  * @param {object} obj Object to add (recursive)
382
399
  */
383
- function _addToZip( zip, obj ) {
384
- if ( _ieExcel === undefined ) {
400
+ function _addToZip(zip, obj) {
401
+ if (_ieExcel === undefined) {
385
402
  // Detect if we are dealing with IE's _awful_ serialiser by seeing if it
386
403
  // drop attributes
387
- _ieExcel = _serialiser
388
- .serializeToString(
389
- $.parseXML( excelStrings['xl/worksheets/sheet1.xml'] )
390
- )
391
- .indexOf( 'xmlns:r' ) === -1;
404
+ _ieExcel =
405
+ _serialiser
406
+ .serializeToString(
407
+ new window.DOMParser().parseFromString(
408
+ excelStrings['xl/worksheets/sheet1.xml'],
409
+ 'text/xml'
410
+ )
411
+ )
412
+ .indexOf('xmlns:r') === -1;
392
413
  }
393
414
 
394
- $.each( obj, function ( name, val ) {
395
- if ( $.isPlainObject( val ) ) {
396
- var newDir = zip.folder( name );
397
- _addToZip( newDir, val );
415
+ $.each(obj, function (name, val) {
416
+ if ($.isPlainObject(val)) {
417
+ var newDir = zip.folder(name);
418
+ _addToZip(newDir, val);
398
419
  }
399
420
  else {
400
- if ( _ieExcel ) {
421
+ if (_ieExcel) {
401
422
  // IE's XML serialiser will drop some name space attributes from
402
423
  // from the root node, so we need to save them. Do this by
403
424
  // replacing the namespace nodes with a regular attribute that
@@ -407,47 +428,49 @@ function _addToZip( zip, obj ) {
407
428
  var i, ien;
408
429
  var attrs = [];
409
430
 
410
- for ( i=worksheet.attributes.length-1 ; i>=0 ; i-- ) {
431
+ for (i = worksheet.attributes.length - 1; i >= 0; i--) {
411
432
  var attrName = worksheet.attributes[i].nodeName;
412
433
  var attrValue = worksheet.attributes[i].nodeValue;
413
434
 
414
- if ( attrName.indexOf( ':' ) !== -1 ) {
415
- attrs.push( { name: attrName, value: attrValue } );
435
+ if (attrName.indexOf(':') !== -1) {
436
+ attrs.push({ name: attrName, value: attrValue });
416
437
 
417
- worksheet.removeAttribute( attrName );
438
+ worksheet.removeAttribute(attrName);
418
439
  }
419
440
  }
420
441
 
421
- for ( i=0, ien=attrs.length ; i<ien ; i++ ) {
422
- var attr = val.createAttribute( attrs[i].name.replace( ':', '_dt_b_namespace_token_' ) );
442
+ for (i = 0, ien = attrs.length; i < ien; i++) {
443
+ var attr = val.createAttribute(
444
+ attrs[i].name.replace(':', '_dt_b_namespace_token_')
445
+ );
423
446
  attr.value = attrs[i].value;
424
- worksheet.setAttributeNode( attr );
447
+ worksheet.setAttributeNode(attr);
425
448
  }
426
449
  }
427
450
 
428
451
  var str = _serialiser.serializeToString(val);
429
452
 
430
453
  // Fix IE's XML
431
- if ( _ieExcel ) {
454
+ if (_ieExcel) {
432
455
  // IE doesn't include the XML declaration
433
- if ( str.indexOf( '<?xml' ) === -1 ) {
434
- str = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+str;
456
+ if (str.indexOf('<?xml') === -1) {
457
+ str = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + str;
435
458
  }
436
459
 
437
460
  // Return namespace attributes to being as such
438
- str = str.replace( /_dt_b_namespace_token_/g, ':' );
461
+ str = str.replace(/_dt_b_namespace_token_/g, ':');
439
462
 
440
463
  // Remove testing name space that IE puts into the space preserve attr
441
- str = str.replace( /xmlns:NS[\d]+="" NS[\d]+:/g, '' );
464
+ str = str.replace(/xmlns:NS[\d]+="" NS[\d]+:/g, '');
442
465
  }
443
466
 
444
467
  // Safari, IE and Edge will put empty name space attributes onto
445
468
  // various elements making them useless. This strips them out
446
- str = str.replace( /<([^<>]*?) xmlns=""([^<>]*?)>/g, '<$1 $2>' );
469
+ str = str.replace(/<([^<>]*?) xmlns=""([^<>]*?)>/g, '<$1 $2>');
447
470
 
448
- zip.file( name, str );
471
+ zip.file(name, str);
449
472
  }
450
- } );
473
+ });
451
474
  }
452
475
 
453
476
  /**
@@ -460,22 +483,22 @@ function _addToZip( zip, obj ) {
460
483
  * (child nodes) and `text` (text content)
461
484
  * @return {node} Created node
462
485
  */
463
- function _createNode( doc, nodeName, opts ) {
464
- var tempNode = doc.createElement( nodeName );
486
+ function _createNode(doc, nodeName, opts) {
487
+ var tempNode = doc.createElement(nodeName);
465
488
 
466
- if ( opts ) {
467
- if ( opts.attr ) {
468
- $(tempNode).attr( opts.attr );
489
+ if (opts) {
490
+ if (opts.attr) {
491
+ $(tempNode).attr(opts.attr);
469
492
  }
470
493
 
471
- if ( opts.children ) {
472
- $.each( opts.children, function ( key, value ) {
473
- tempNode.appendChild( value );
474
- } );
494
+ if (opts.children) {
495
+ $.each(opts.children, function (key, value) {
496
+ tempNode.appendChild(value);
497
+ });
475
498
  }
476
499
 
477
- if ( opts.text !== null && opts.text !== undefined ) {
478
- tempNode.appendChild( doc.createTextNode( opts.text ) );
500
+ if (opts.text !== null && opts.text !== undefined) {
501
+ tempNode.appendChild(doc.createTextNode(opts.text));
479
502
  }
480
503
  }
481
504
 
@@ -488,27 +511,25 @@ function _createNode( doc, nodeName, opts ) {
488
511
  * @param {int} col Column index
489
512
  * @return {int} Column width
490
513
  */
491
- function _excelColWidth( data, col ) {
514
+ function _excelColWidth(data, col) {
492
515
  var max = data.header[col].length;
493
516
  var len, lineSplit, str;
494
517
 
495
- if ( data.footer && data.footer[col].length > max ) {
518
+ if (data.footer && data.footer[col].length > max) {
496
519
  max = data.footer[col].length;
497
520
  }
498
521
 
499
- for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
522
+ for (var i = 0, ien = data.body.length; i < ien; i++) {
500
523
  var point = data.body[i][col];
501
- str = point !== null && point !== undefined ?
502
- point.toString() :
503
- '';
524
+ str = point !== null && point !== undefined ? point.toString() : '';
504
525
 
505
526
  // If there is a newline character, workout the width of the column
506
527
  // based on the longest line in the string
507
- if ( str.indexOf('\n') !== -1 ) {
528
+ if (str.indexOf('\n') !== -1) {
508
529
  lineSplit = str.split('\n');
509
- lineSplit.sort( function (a, b) {
530
+ lineSplit.sort(function (a, b) {
510
531
  return b.length - a.length;
511
- } );
532
+ });
512
533
 
513
534
  len = lineSplit[0].length;
514
535
  }
@@ -516,12 +537,12 @@ function _excelColWidth( data, col ) {
516
537
  len = str.length;
517
538
  }
518
539
 
519
- if ( len > max ) {
540
+ if (len > max) {
520
541
  max = len;
521
542
  }
522
543
 
523
544
  // Max width rather than having potentially massive column widths
524
- if ( max > 40 ) {
545
+ if (max > 40) {
525
546
  return 54; // 40 * 1.35
526
547
  }
527
548
  }
@@ -534,233 +555,234 @@ function _excelColWidth( data, col ) {
534
555
 
535
556
  // Excel - Pre-defined strings to build a basic XLSX file
536
557
  var excelStrings = {
537
- "_rels/.rels":
538
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
539
- '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
540
- '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'+
558
+ '_rels/.rels':
559
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
560
+ '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' +
561
+ '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>' +
541
562
  '</Relationships>',
542
563
 
543
- "xl/_rels/workbook.xml.rels":
544
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
545
- '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
546
- '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>'+
547
- '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+
564
+ 'xl/_rels/workbook.xml.rels':
565
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
566
+ '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' +
567
+ '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>' +
568
+ '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>' +
548
569
  '</Relationships>',
549
570
 
550
- "[Content_Types].xml":
551
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
552
- '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'+
553
- '<Default Extension="xml" ContentType="application/xml" />'+
554
- '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />'+
555
- '<Default Extension="jpeg" ContentType="image/jpeg" />'+
556
- '<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />'+
557
- '<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />'+
558
- '<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />'+
571
+ '[Content_Types].xml':
572
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
573
+ '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">' +
574
+ '<Default Extension="xml" ContentType="application/xml" />' +
575
+ '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />' +
576
+ '<Default Extension="jpeg" ContentType="image/jpeg" />' +
577
+ '<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />' +
578
+ '<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />' +
579
+ '<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />' +
559
580
  '</Types>',
560
581
 
561
- "xl/workbook.xml":
562
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
563
- '<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'+
564
- '<fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="24816"/>'+
565
- '<workbookPr showInkAnnotation="0" autoCompressPictures="0"/>'+
566
- '<bookViews>'+
567
- '<workbookView xWindow="0" yWindow="0" windowWidth="25600" windowHeight="19020" tabRatio="500"/>'+
568
- '</bookViews>'+
569
- '<sheets>'+
570
- '<sheet name="Sheet1" sheetId="1" r:id="rId1"/>'+
571
- '</sheets>'+
572
- '<definedNames/>'+
582
+ 'xl/workbook.xml':
583
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
584
+ '<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">' +
585
+ '<fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="24816"/>' +
586
+ '<workbookPr showInkAnnotation="0" autoCompressPictures="0"/>' +
587
+ '<bookViews>' +
588
+ '<workbookView xWindow="0" yWindow="0" windowWidth="25600" windowHeight="19020" tabRatio="500"/>' +
589
+ '</bookViews>' +
590
+ '<sheets>' +
591
+ '<sheet name="Sheet1" sheetId="1" r:id="rId1"/>' +
592
+ '</sheets>' +
593
+ '<definedNames/>' +
573
594
  '</workbook>',
574
595
 
575
- "xl/worksheets/sheet1.xml":
576
- '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
577
- '<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">'+
578
- '<sheetData/>'+
579
- '<mergeCells count="0"/>'+
596
+ 'xl/worksheets/sheet1.xml':
597
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
598
+ '<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">' +
599
+ '<sheetData/>' +
600
+ '<mergeCells count="0"/>' +
580
601
  '</worksheet>',
581
602
 
582
- "xl/styles.xml":
583
- '<?xml version="1.0" encoding="UTF-8"?>'+
584
- '<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">'+
585
- '<numFmts count="6">'+
586
- '<numFmt numFmtId="164" formatCode="#,##0.00_-\ [$$-45C]"/>'+
587
- '<numFmt numFmtId="165" formatCode="&quot;£&quot;#,##0.00"/>'+
588
- '<numFmt numFmtId="166" formatCode="[$€-2]\ #,##0.00"/>'+
589
- '<numFmt numFmtId="167" formatCode="0.0%"/>'+
590
- '<numFmt numFmtId="168" formatCode="#,##0;(#,##0)"/>'+
591
- '<numFmt numFmtId="169" formatCode="#,##0.00;(#,##0.00)"/>'+
592
- '</numFmts>'+
593
- '<fonts count="5" x14ac:knownFonts="1">'+
594
- '<font>'+
595
- '<sz val="11" />'+
596
- '<name val="Calibri" />'+
597
- '</font>'+
598
- '<font>'+
599
- '<sz val="11" />'+
600
- '<name val="Calibri" />'+
601
- '<color rgb="FFFFFFFF" />'+
602
- '</font>'+
603
- '<font>'+
604
- '<sz val="11" />'+
605
- '<name val="Calibri" />'+
606
- '<b />'+
607
- '</font>'+
608
- '<font>'+
609
- '<sz val="11" />'+
610
- '<name val="Calibri" />'+
611
- '<i />'+
612
- '</font>'+
613
- '<font>'+
614
- '<sz val="11" />'+
615
- '<name val="Calibri" />'+
616
- '<u />'+
617
- '</font>'+
618
- '</fonts>'+
619
- '<fills count="6">'+
620
- '<fill>'+
621
- '<patternFill patternType="none" />'+
622
- '</fill>'+
623
- '<fill>'+ // Excel appears to use this as a dotted background regardless of values but
624
- '<patternFill patternType="none" />'+ // to be valid to the schema, use a patternFill
625
- '</fill>'+
626
- '<fill>'+
627
- '<patternFill patternType="solid">'+
628
- '<fgColor rgb="FFD9D9D9" />'+
629
- '<bgColor indexed="64" />'+
630
- '</patternFill>'+
631
- '</fill>'+
632
- '<fill>'+
633
- '<patternFill patternType="solid">'+
634
- '<fgColor rgb="FFD99795" />'+
635
- '<bgColor indexed="64" />'+
636
- '</patternFill>'+
637
- '</fill>'+
638
- '<fill>'+
639
- '<patternFill patternType="solid">'+
640
- '<fgColor rgb="ffc6efce" />'+
641
- '<bgColor indexed="64" />'+
642
- '</patternFill>'+
643
- '</fill>'+
644
- '<fill>'+
645
- '<patternFill patternType="solid">'+
646
- '<fgColor rgb="ffc6cfef" />'+
647
- '<bgColor indexed="64" />'+
648
- '</patternFill>'+
649
- '</fill>'+
650
- '</fills>'+
651
- '<borders count="2">'+
652
- '<border>'+
653
- '<left />'+
654
- '<right />'+
655
- '<top />'+
656
- '<bottom />'+
657
- '<diagonal />'+
658
- '</border>'+
659
- '<border diagonalUp="false" diagonalDown="false">'+
660
- '<left style="thin">'+
661
- '<color auto="1" />'+
662
- '</left>'+
663
- '<right style="thin">'+
664
- '<color auto="1" />'+
665
- '</right>'+
666
- '<top style="thin">'+
667
- '<color auto="1" />'+
668
- '</top>'+
669
- '<bottom style="thin">'+
670
- '<color auto="1" />'+
671
- '</bottom>'+
672
- '<diagonal />'+
673
- '</border>'+
674
- '</borders>'+
675
- '<cellStyleXfs count="1">'+
676
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" />'+
677
- '</cellStyleXfs>'+
678
- '<cellXfs count="67">'+
679
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
680
- '<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
681
- '<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
682
- '<xf numFmtId="0" fontId="3" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
683
- '<xf numFmtId="0" fontId="4" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
684
- '<xf numFmtId="0" fontId="0" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
685
- '<xf numFmtId="0" fontId="1" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
686
- '<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
687
- '<xf numFmtId="0" fontId="3" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
688
- '<xf numFmtId="0" fontId="4" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
689
- '<xf numFmtId="0" fontId="0" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
690
- '<xf numFmtId="0" fontId="1" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
691
- '<xf numFmtId="0" fontId="2" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
692
- '<xf numFmtId="0" fontId="3" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
693
- '<xf numFmtId="0" fontId="4" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
694
- '<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
695
- '<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
696
- '<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
697
- '<xf numFmtId="0" fontId="3" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
698
- '<xf numFmtId="0" fontId="4" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
699
- '<xf numFmtId="0" fontId="0" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
700
- '<xf numFmtId="0" fontId="1" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
701
- '<xf numFmtId="0" fontId="2" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
702
- '<xf numFmtId="0" fontId="3" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
703
- '<xf numFmtId="0" fontId="4" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
704
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
705
- '<xf numFmtId="0" fontId="1" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
706
- '<xf numFmtId="0" fontId="2" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
707
- '<xf numFmtId="0" fontId="3" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
708
- '<xf numFmtId="0" fontId="4" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
709
- '<xf numFmtId="0" fontId="0" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
710
- '<xf numFmtId="0" fontId="1" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
711
- '<xf numFmtId="0" fontId="2" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
712
- '<xf numFmtId="0" fontId="3" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
713
- '<xf numFmtId="0" fontId="4" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
714
- '<xf numFmtId="0" fontId="0" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
715
- '<xf numFmtId="0" fontId="1" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
716
- '<xf numFmtId="0" fontId="2" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
717
- '<xf numFmtId="0" fontId="3" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
718
- '<xf numFmtId="0" fontId="4" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
719
- '<xf numFmtId="0" fontId="0" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
720
- '<xf numFmtId="0" fontId="1" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
721
- '<xf numFmtId="0" fontId="2" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
722
- '<xf numFmtId="0" fontId="3" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
723
- '<xf numFmtId="0" fontId="4" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
724
- '<xf numFmtId="0" fontId="0" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
725
- '<xf numFmtId="0" fontId="1" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
726
- '<xf numFmtId="0" fontId="2" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
727
- '<xf numFmtId="0" fontId="3" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
728
- '<xf numFmtId="0" fontId="4" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
729
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
730
- '<alignment horizontal="left"/>'+
731
- '</xf>'+
732
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
733
- '<alignment horizontal="center"/>'+
734
- '</xf>'+
735
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
736
- '<alignment horizontal="right"/>'+
737
- '</xf>'+
738
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
739
- '<alignment horizontal="fill"/>'+
740
- '</xf>'+
741
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
742
- '<alignment textRotation="90"/>'+
743
- '</xf>'+
744
- '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">'+
745
- '<alignment wrapText="1"/>'+
746
- '</xf>'+
747
- '<xf numFmtId="9" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
748
- '<xf numFmtId="164" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
749
- '<xf numFmtId="165" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
750
- '<xf numFmtId="166" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
751
- '<xf numFmtId="167" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
752
- '<xf numFmtId="168" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
753
- '<xf numFmtId="169" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
754
- '<xf numFmtId="3" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
755
- '<xf numFmtId="4" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
756
- '<xf numFmtId="1" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
757
- '<xf numFmtId="2" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
758
- '</cellXfs>'+
759
- '<cellStyles count="1">'+
760
- '<cellStyle name="Normal" xfId="0" builtinId="0" />'+
761
- '</cellStyles>'+
762
- '<dxfs count="0" />'+
763
- '<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4" />'+
603
+ 'xl/styles.xml':
604
+ '<?xml version="1.0" encoding="UTF-8"?>' +
605
+ '<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">' +
606
+ '<numFmts count="6">' +
607
+ '<numFmt numFmtId="164" formatCode="#,##0.00_- [$$-45C]"/>' +
608
+ '<numFmt numFmtId="165" formatCode="&quot;£&quot;#,##0.00"/>' +
609
+ '<numFmt numFmtId="166" formatCode="[$€-2] #,##0.00"/>' +
610
+ '<numFmt numFmtId="167" formatCode="0.0%"/>' +
611
+ '<numFmt numFmtId="168" formatCode="#,##0;(#,##0)"/>' +
612
+ '<numFmt numFmtId="169" formatCode="#,##0.00;(#,##0.00)"/>' +
613
+ '</numFmts>' +
614
+ '<fonts count="5" x14ac:knownFonts="1">' +
615
+ '<font>' +
616
+ '<sz val="11" />' +
617
+ '<name val="Calibri" />' +
618
+ '</font>' +
619
+ '<font>' +
620
+ '<sz val="11" />' +
621
+ '<name val="Calibri" />' +
622
+ '<color rgb="FFFFFFFF" />' +
623
+ '</font>' +
624
+ '<font>' +
625
+ '<sz val="11" />' +
626
+ '<name val="Calibri" />' +
627
+ '<b />' +
628
+ '</font>' +
629
+ '<font>' +
630
+ '<sz val="11" />' +
631
+ '<name val="Calibri" />' +
632
+ '<i />' +
633
+ '</font>' +
634
+ '<font>' +
635
+ '<sz val="11" />' +
636
+ '<name val="Calibri" />' +
637
+ '<u />' +
638
+ '</font>' +
639
+ '</fonts>' +
640
+ '<fills count="6">' +
641
+ '<fill>' +
642
+ '<patternFill patternType="none" />' +
643
+ '</fill>' +
644
+ '<fill>' + // Excel appears to use this as a dotted background regardless of values but
645
+ '<patternFill patternType="none" />' + // to be valid to the schema, use a patternFill
646
+ '</fill>' +
647
+ '<fill>' +
648
+ '<patternFill patternType="solid">' +
649
+ '<fgColor rgb="FFD9D9D9" />' +
650
+ '<bgColor indexed="64" />' +
651
+ '</patternFill>' +
652
+ '</fill>' +
653
+ '<fill>' +
654
+ '<patternFill patternType="solid">' +
655
+ '<fgColor rgb="FFD99795" />' +
656
+ '<bgColor indexed="64" />' +
657
+ '</patternFill>' +
658
+ '</fill>' +
659
+ '<fill>' +
660
+ '<patternFill patternType="solid">' +
661
+ '<fgColor rgb="ffc6efce" />' +
662
+ '<bgColor indexed="64" />' +
663
+ '</patternFill>' +
664
+ '</fill>' +
665
+ '<fill>' +
666
+ '<patternFill patternType="solid">' +
667
+ '<fgColor rgb="ffc6cfef" />' +
668
+ '<bgColor indexed="64" />' +
669
+ '</patternFill>' +
670
+ '</fill>' +
671
+ '</fills>' +
672
+ '<borders count="2">' +
673
+ '<border>' +
674
+ '<left />' +
675
+ '<right />' +
676
+ '<top />' +
677
+ '<bottom />' +
678
+ '<diagonal />' +
679
+ '</border>' +
680
+ '<border diagonalUp="false" diagonalDown="false">' +
681
+ '<left style="thin">' +
682
+ '<color auto="1" />' +
683
+ '</left>' +
684
+ '<right style="thin">' +
685
+ '<color auto="1" />' +
686
+ '</right>' +
687
+ '<top style="thin">' +
688
+ '<color auto="1" />' +
689
+ '</top>' +
690
+ '<bottom style="thin">' +
691
+ '<color auto="1" />' +
692
+ '</bottom>' +
693
+ '<diagonal />' +
694
+ '</border>' +
695
+ '</borders>' +
696
+ '<cellStyleXfs count="1">' +
697
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" />' +
698
+ '</cellStyleXfs>' +
699
+ '<cellXfs count="68">' +
700
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
701
+ '<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
702
+ '<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
703
+ '<xf numFmtId="0" fontId="3" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
704
+ '<xf numFmtId="0" fontId="4" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
705
+ '<xf numFmtId="0" fontId="0" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
706
+ '<xf numFmtId="0" fontId="1" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
707
+ '<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
708
+ '<xf numFmtId="0" fontId="3" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
709
+ '<xf numFmtId="0" fontId="4" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
710
+ '<xf numFmtId="0" fontId="0" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
711
+ '<xf numFmtId="0" fontId="1" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
712
+ '<xf numFmtId="0" fontId="2" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
713
+ '<xf numFmtId="0" fontId="3" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
714
+ '<xf numFmtId="0" fontId="4" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
715
+ '<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
716
+ '<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
717
+ '<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
718
+ '<xf numFmtId="0" fontId="3" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
719
+ '<xf numFmtId="0" fontId="4" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
720
+ '<xf numFmtId="0" fontId="0" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
721
+ '<xf numFmtId="0" fontId="1" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
722
+ '<xf numFmtId="0" fontId="2" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
723
+ '<xf numFmtId="0" fontId="3" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
724
+ '<xf numFmtId="0" fontId="4" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>' +
725
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
726
+ '<xf numFmtId="0" fontId="1" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
727
+ '<xf numFmtId="0" fontId="2" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
728
+ '<xf numFmtId="0" fontId="3" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
729
+ '<xf numFmtId="0" fontId="4" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
730
+ '<xf numFmtId="0" fontId="0" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
731
+ '<xf numFmtId="0" fontId="1" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
732
+ '<xf numFmtId="0" fontId="2" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
733
+ '<xf numFmtId="0" fontId="3" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
734
+ '<xf numFmtId="0" fontId="4" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
735
+ '<xf numFmtId="0" fontId="0" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
736
+ '<xf numFmtId="0" fontId="1" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
737
+ '<xf numFmtId="0" fontId="2" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
738
+ '<xf numFmtId="0" fontId="3" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
739
+ '<xf numFmtId="0" fontId="4" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
740
+ '<xf numFmtId="0" fontId="0" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
741
+ '<xf numFmtId="0" fontId="1" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
742
+ '<xf numFmtId="0" fontId="2" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
743
+ '<xf numFmtId="0" fontId="3" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
744
+ '<xf numFmtId="0" fontId="4" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
745
+ '<xf numFmtId="0" fontId="0" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
746
+ '<xf numFmtId="0" fontId="1" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
747
+ '<xf numFmtId="0" fontId="2" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
748
+ '<xf numFmtId="0" fontId="3" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
749
+ '<xf numFmtId="0" fontId="4" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>' +
750
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">' +
751
+ '<alignment horizontal="left"/>' +
752
+ '</xf>' +
753
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">' +
754
+ '<alignment horizontal="center"/>' +
755
+ '</xf>' +
756
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">' +
757
+ '<alignment horizontal="right"/>' +
758
+ '</xf>' +
759
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">' +
760
+ '<alignment horizontal="fill"/>' +
761
+ '</xf>' +
762
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">' +
763
+ '<alignment textRotation="90"/>' +
764
+ '</xf>' +
765
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1">' +
766
+ '<alignment wrapText="1"/>' +
767
+ '</xf>' +
768
+ '<xf numFmtId="9" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
769
+ '<xf numFmtId="164" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
770
+ '<xf numFmtId="165" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
771
+ '<xf numFmtId="166" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
772
+ '<xf numFmtId="167" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
773
+ '<xf numFmtId="168" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
774
+ '<xf numFmtId="169" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
775
+ '<xf numFmtId="3" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
776
+ '<xf numFmtId="4" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
777
+ '<xf numFmtId="1" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
778
+ '<xf numFmtId="2" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
779
+ '<xf numFmtId="14" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>' +
780
+ '</cellXfs>' +
781
+ '<cellStyles count="1">' +
782
+ '<cellStyle name="Normal" xfId="0" builtinId="0" />' +
783
+ '</cellStyles>' +
784
+ '<dxfs count="0" />' +
785
+ '<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4" />' +
764
786
  '</styleSheet>'
765
787
  };
766
788
  // Note we could use 3 `for` loops for the styles, but when gzipped there is
@@ -771,21 +793,50 @@ var excelStrings = {
771
793
  // Ref: section 3.8.30 - built in formatters in open spreadsheet
772
794
  // https://www.ecma-international.org/news/TC45_current_work/Office%20Open%20XML%20Part%204%20-%20Markup%20Language%20Reference.pdf
773
795
  var _excelSpecials = [
774
- { match: /^\-?\d+\.\d%$/, style: 60, fmt: function (d) { return d/100; } }, // Precent with d.p.
775
- { match: /^\-?\d+\.?\d*%$/, style: 56, fmt: function (d) { return d/100; } }, // Percent
776
- { match: /^\-?\$[\d,]+.?\d*$/, style: 57 }, // Dollars
777
- { match: /^\-?£[\d,]+.?\d*$/, style: 58 }, // Pounds
778
- { match: /^\-?€[\d,]+.?\d*$/, style: 59 }, // Euros
779
- { match: /^\-?\d+$/, style: 65 }, // Numbers without thousand separators
780
- { match: /^\-?\d+\.\d{2}$/, style: 66 }, // Numbers 2 d.p. without thousands separators
781
- { match: /^\([\d,]+\)$/, style: 61, fmt: function (d) { return -1 * d.replace(/[\(\)]/g, ''); } }, // Negative numbers indicated by brackets
782
- { match: /^\([\d,]+\.\d{2}\)$/, style: 62, fmt: function (d) { return -1 * d.replace(/[\(\)]/g, ''); } }, // Negative numbers indicated by brackets - 2d.p.
783
- { match: /^\-?[\d,]+$/, style: 63 }, // Numbers with thousand separators
784
- { match: /^\-?[\d,]+\.\d{2}$/, style: 64 } // Numbers with 2 d.p. and thousands separators
796
+ {
797
+ match: /^\-?\d+\.\d%$/,
798
+ style: 60,
799
+ fmt: function (d) {
800
+ return d / 100;
801
+ }
802
+ }, // Percent with d.p.
803
+ {
804
+ match: /^\-?\d+\.?\d*%$/,
805
+ style: 56,
806
+ fmt: function (d) {
807
+ return d / 100;
808
+ }
809
+ }, // Percent
810
+ { match: /^\-?\$[\d,]+.?\d*$/, style: 57 }, // Dollars
811
+ { match: /^\-?£[\d,]+.?\d*$/, style: 58 }, // Pounds
812
+ { match: /^\-?€[\d,]+.?\d*$/, style: 59 }, // Euros
813
+ { match: /^\-?\d+$/, style: 65 }, // Numbers without thousand separators
814
+ { match: /^\-?\d+\.\d{2}$/, style: 66 }, // Numbers 2 d.p. without thousands separators
815
+ {
816
+ match: /^\([\d,]+\)$/,
817
+ style: 61,
818
+ fmt: function (d) {
819
+ return -1 * d.replace(/[\(\)]/g, '');
820
+ }
821
+ }, // Negative numbers indicated by brackets
822
+ {
823
+ match: /^\([\d,]+\.\d{2}\)$/,
824
+ style: 62,
825
+ fmt: function (d) {
826
+ return -1 * d.replace(/[\(\)]/g, '');
827
+ }
828
+ }, // Negative numbers indicated by brackets - 2d.p.
829
+ { match: /^\-?[\d,]+$/, style: 63 }, // Numbers with thousand separators
830
+ { match: /^\-?[\d,]+\.\d{2}$/, style: 64 },
831
+ {
832
+ match: /^[\d]{4}\-[01][\d]\-[0123][\d]$/,
833
+ style: 67,
834
+ fmt: function (d) {
835
+ return Math.round(25569 + Date.parse(d) / (86400 * 1000));
836
+ }
837
+ } //Date yyyy-mm-dd
785
838
  ];
786
839
 
787
-
788
-
789
840
  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
790
841
  * Buttons
791
842
  */
@@ -796,83 +847,87 @@ var _excelSpecials = [
796
847
  DataTable.ext.buttons.copyHtml5 = {
797
848
  className: 'buttons-copy buttons-html5',
798
849
 
799
- text: function ( dt ) {
800
- return dt.i18n( 'buttons.copy', 'Copy' );
850
+ text: function (dt) {
851
+ return dt.i18n('buttons.copy', 'Copy');
801
852
  },
802
853
 
803
- action: function ( e, dt, button, config ) {
804
- this.processing( true );
854
+ action: function (e, dt, button, config) {
855
+ this.processing(true);
805
856
 
806
857
  var that = this;
807
- var exportData = _exportData( dt, config );
808
- var info = dt.buttons.exportInfo( config );
858
+ var exportData = _exportData(dt, config);
859
+ var info = dt.buttons.exportInfo(config);
809
860
  var newline = _newLine(config);
810
861
  var output = exportData.str;
811
- var hiddenDiv = $('<div/>')
812
- .css( {
813
- height: 1,
814
- width: 1,
815
- overflow: 'hidden',
816
- position: 'fixed',
817
- top: 0,
818
- left: 0
819
- } );
820
-
821
- if ( info.title ) {
862
+ var hiddenDiv = $('<div/>').css({
863
+ height: 1,
864
+ width: 1,
865
+ overflow: 'hidden',
866
+ position: 'fixed',
867
+ top: 0,
868
+ left: 0
869
+ });
870
+
871
+ if (info.title) {
822
872
  output = info.title + newline + newline + output;
823
873
  }
824
874
 
825
- if ( info.messageTop ) {
875
+ if (info.messageTop) {
826
876
  output = info.messageTop + newline + newline + output;
827
877
  }
828
878
 
829
- if ( info.messageBottom ) {
879
+ if (info.messageBottom) {
830
880
  output = output + newline + newline + info.messageBottom;
831
881
  }
832
882
 
833
- if ( config.customize ) {
834
- output = config.customize( output, config, dt );
883
+ if (config.customize) {
884
+ output = config.customize(output, config, dt);
835
885
  }
836
886
 
837
- var textarea = $('<textarea readonly/>')
838
- .val( output )
839
- .appendTo( hiddenDiv );
887
+ var textarea = $('<textarea readonly/>').val(output).appendTo(hiddenDiv);
840
888
 
841
889
  // For browsers that support the copy execCommand, try to use it
842
- if ( document.queryCommandSupported('copy') ) {
843
- hiddenDiv.appendTo( dt.table().container() );
890
+ if (document.queryCommandSupported('copy')) {
891
+ hiddenDiv.appendTo(dt.table().container());
844
892
  textarea[0].focus();
845
893
  textarea[0].select();
846
894
 
847
895
  try {
848
- var successful = document.execCommand( 'copy' );
896
+ var successful = document.execCommand('copy');
849
897
  hiddenDiv.remove();
850
898
 
851
899
  if (successful) {
852
900
  dt.buttons.info(
853
- dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ),
854
- dt.i18n( 'buttons.copySuccess', {
855
- 1: 'Copied one row to clipboard',
856
- _: 'Copied %d rows to clipboard'
857
- }, exportData.rows ),
901
+ dt.i18n('buttons.copyTitle', 'Copy to clipboard'),
902
+ dt.i18n(
903
+ 'buttons.copySuccess',
904
+ {
905
+ 1: 'Copied one row to clipboard',
906
+ _: 'Copied %d rows to clipboard'
907
+ },
908
+ exportData.rows
909
+ ),
858
910
  2000
859
911
  );
860
912
 
861
- this.processing( false );
913
+ this.processing(false);
862
914
  return;
863
915
  }
864
- }
865
- catch (t) {}
916
+ } catch (t) {}
866
917
  }
867
918
 
868
919
  // Otherwise we show the text box and instruct the user to use it
869
- var message = $('<span>'+dt.i18n( 'buttons.copyKeys',
870
- 'Press <i>ctrl</i> or <i>\u2318</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>'+
871
- 'To cancel, click this message or press escape.' )+'</span>'
872
- )
873
- .append( hiddenDiv );
874
-
875
- dt.buttons.info( dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ), message, 0 );
920
+ var message = $(
921
+ '<span>' +
922
+ dt.i18n(
923
+ 'buttons.copyKeys',
924
+ 'Press <i>ctrl</i> or <i>\u2318</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>' +
925
+ 'To cancel, click this message or press escape.'
926
+ ) +
927
+ '</span>'
928
+ ).append(hiddenDiv);
929
+
930
+ dt.buttons.info(dt.i18n('buttons.copyTitle', 'Copy to clipboard'), message, 0);
876
931
 
877
932
  // Select the text so when the user activates their system clipboard
878
933
  // it will copy that text
@@ -882,23 +937,24 @@ DataTable.ext.buttons.copyHtml5 = {
882
937
  // Event to hide the message when the user is done
883
938
  var container = $(message).closest('.dt-button-info');
884
939
  var close = function () {
885
- container.off( 'click.buttons-copy' );
886
- $(document).off( '.buttons-copy' );
887
- dt.buttons.info( false );
940
+ container.off('click.buttons-copy');
941
+ $(document).off('.buttons-copy');
942
+ dt.buttons.info(false);
888
943
  };
889
944
 
890
- container.on( 'click.buttons-copy', close );
945
+ container.on('click.buttons-copy', close);
891
946
  $(document)
892
- .on( 'keydown.buttons-copy', function (e) {
893
- if ( e.keyCode === 27 ) { // esc
947
+ .on('keydown.buttons-copy', function (e) {
948
+ if (e.keyCode === 27) {
949
+ // esc
894
950
  close();
895
- that.processing( false );
951
+ that.processing(false);
896
952
  }
897
- } )
898
- .on( 'copy.buttons-copy cut.buttons-copy', function () {
953
+ })
954
+ .on('copy.buttons-copy cut.buttons-copy', function () {
899
955
  close();
900
- that.processing( false );
901
- } );
956
+ that.processing(false);
957
+ });
902
958
  },
903
959
 
904
960
  exportOptions: {},
@@ -930,46 +986,42 @@ DataTable.ext.buttons.csvHtml5 = {
930
986
  return window.FileReader !== undefined && window.Blob;
931
987
  },
932
988
 
933
- text: function ( dt ) {
934
- return dt.i18n( 'buttons.csv', 'CSV' );
989
+ text: function (dt) {
990
+ return dt.i18n('buttons.csv', 'CSV');
935
991
  },
936
992
 
937
- action: function ( e, dt, button, config ) {
938
- this.processing( true );
993
+ action: function (e, dt, button, config) {
994
+ this.processing(true);
939
995
 
940
996
  // Set the text
941
- var output = _exportData( dt, config ).str;
997
+ var output = _exportData(dt, config).str;
942
998
  var info = dt.buttons.exportInfo(config);
943
999
  var charset = config.charset;
944
1000
 
945
- if ( config.customize ) {
946
- output = config.customize( output, config, dt );
1001
+ if (config.customize) {
1002
+ output = config.customize(output, config, dt);
947
1003
  }
948
1004
 
949
- if ( charset !== false ) {
950
- if ( ! charset ) {
1005
+ if (charset !== false) {
1006
+ if (!charset) {
951
1007
  charset = document.characterSet || document.charset;
952
1008
  }
953
1009
 
954
- if ( charset ) {
955
- charset = ';charset='+charset;
1010
+ if (charset) {
1011
+ charset = ';charset=' + charset;
956
1012
  }
957
1013
  }
958
1014
  else {
959
1015
  charset = '';
960
1016
  }
961
1017
 
962
- if ( config.bom ) {
963
- output = '\ufeff' + output;
1018
+ if (config.bom) {
1019
+ output = String.fromCharCode(0xfeff) + output;
964
1020
  }
965
1021
 
966
- _saveAs(
967
- new Blob( [output], {type: 'text/csv'+charset} ),
968
- info.filename,
969
- true
970
- );
1022
+ _saveAs(new Blob([output], { type: 'text/csv' + charset }), info.filename, true);
971
1023
 
972
- this.processing( false );
1024
+ this.processing(false);
973
1025
  },
974
1026
 
975
1027
  filename: '*',
@@ -998,61 +1050,65 @@ DataTable.ext.buttons.excelHtml5 = {
998
1050
  className: 'buttons-excel buttons-html5',
999
1051
 
1000
1052
  available: function () {
1001
- return window.FileReader !== undefined && _jsZip() !== undefined && ! _isDuffSafari() && _serialiser;
1053
+ return (
1054
+ window.FileReader !== undefined &&
1055
+ _jsZip() !== undefined &&
1056
+ !_isDuffSafari() &&
1057
+ _serialiser
1058
+ );
1002
1059
  },
1003
1060
 
1004
- text: function ( dt ) {
1005
- return dt.i18n( 'buttons.excel', 'Excel' );
1061
+ text: function (dt) {
1062
+ return dt.i18n('buttons.excel', 'Excel');
1006
1063
  },
1007
1064
 
1008
- action: function ( e, dt, button, config ) {
1009
- this.processing( true );
1065
+ action: function (e, dt, button, config) {
1066
+ this.processing(true);
1010
1067
 
1011
1068
  var that = this;
1012
1069
  var rowPos = 0;
1013
1070
  var dataStartRow, dataEndRow;
1014
- var getXml = function ( type ) {
1015
- var str = excelStrings[ type ];
1071
+ var getXml = function (type) {
1072
+ var str = excelStrings[type];
1016
1073
 
1017
1074
  //str = str.replace( /xmlns:/g, 'xmlns_' ).replace( /mc:/g, 'mc_' );
1018
1075
 
1019
- return $.parseXML( str );
1076
+ return $.parseXML(str);
1020
1077
  };
1021
1078
  var rels = getXml('xl/worksheets/sheet1.xml');
1022
- var relsGet = rels.getElementsByTagName( "sheetData" )[0];
1079
+ var relsGet = rels.getElementsByTagName('sheetData')[0];
1023
1080
 
1024
1081
  var xlsx = {
1025
1082
  _rels: {
1026
- ".rels": getXml('_rels/.rels')
1083
+ '.rels': getXml('_rels/.rels')
1027
1084
  },
1028
1085
  xl: {
1029
1086
  _rels: {
1030
- "workbook.xml.rels": getXml('xl/_rels/workbook.xml.rels')
1087
+ 'workbook.xml.rels': getXml('xl/_rels/workbook.xml.rels')
1031
1088
  },
1032
- "workbook.xml": getXml('xl/workbook.xml'),
1033
- "styles.xml": getXml('xl/styles.xml'),
1034
- "worksheets": {
1035
- "sheet1.xml": rels
1089
+ 'workbook.xml': getXml('xl/workbook.xml'),
1090
+ 'styles.xml': getXml('xl/styles.xml'),
1091
+ worksheets: {
1092
+ 'sheet1.xml': rels
1036
1093
  }
1037
-
1038
1094
  },
1039
- "[Content_Types].xml": getXml('[Content_Types].xml')
1095
+ '[Content_Types].xml': getXml('[Content_Types].xml')
1040
1096
  };
1041
1097
 
1042
- var data = dt.buttons.exportData( config.exportOptions );
1098
+ var data = dt.buttons.exportData(config.exportOptions);
1043
1099
  var currentRow, rowNode;
1044
- var addRow = function ( row ) {
1045
- currentRow = rowPos+1;
1046
- rowNode = _createNode( rels, "row", { attr: {r:currentRow} } );
1100
+ var addRow = function (row) {
1101
+ currentRow = rowPos + 1;
1102
+ rowNode = _createNode(rels, 'row', { attr: { r: currentRow } });
1047
1103
 
1048
- for ( var i=0, ien=row.length ; i<ien ; i++ ) {
1104
+ for (var i = 0, ien = row.length; i < ien; i++) {
1049
1105
  // Concat both the Cell Columns as a letter and the Row of the cell.
1050
1106
  var cellId = createCellPos(i) + '' + currentRow;
1051
1107
  var cell = null;
1052
1108
 
1053
1109
  // For null, undefined of blank cell, continue so it doesn't create the _createNode
1054
- if ( row[i] === null || row[i] === undefined || row[i] === '' ) {
1055
- if ( config.createEmptyCells === true ) {
1110
+ if (row[i] === null || row[i] === undefined || row[i] === '') {
1111
+ if (config.createEmptyCells === true) {
1056
1112
  row[i] = '';
1057
1113
  }
1058
1114
  else {
@@ -1061,215 +1117,235 @@ DataTable.ext.buttons.excelHtml5 = {
1061
1117
  }
1062
1118
 
1063
1119
  var originalContent = row[i];
1064
- row[i] = $.trim( row[i] );
1120
+ row[i] = typeof row[i].trim === 'function' ? row[i].trim() : row[i];
1065
1121
 
1066
1122
  // Special number formatting options
1067
- for ( var j=0, jen=_excelSpecials.length ; j<jen ; j++ ) {
1123
+ for (var j = 0, jen = _excelSpecials.length; j < jen; j++) {
1068
1124
  var special = _excelSpecials[j];
1069
1125
 
1070
1126
  // TODO Need to provide the ability for the specials to say
1071
1127
  // if they are returning a string, since at the moment it is
1072
1128
  // assumed to be a number
1073
- if ( row[i].match && ! row[i].match(/^0\d+/) && row[i].match( special.match ) ) {
1129
+ if (row[i].match && !row[i].match(/^0\d+/) && row[i].match(special.match)) {
1074
1130
  var val = row[i].replace(/[^\d\.\-]/g, '');
1075
1131
 
1076
- if ( special.fmt ) {
1077
- val = special.fmt( val );
1132
+ if (special.fmt) {
1133
+ val = special.fmt(val);
1078
1134
  }
1079
1135
 
1080
- cell = _createNode( rels, 'c', {
1136
+ cell = _createNode(rels, 'c', {
1081
1137
  attr: {
1082
1138
  r: cellId,
1083
1139
  s: special.style
1084
1140
  },
1085
- children: [
1086
- _createNode( rels, 'v', { text: val } )
1087
- ]
1088
- } );
1141
+ children: [_createNode(rels, 'v', { text: val })]
1142
+ });
1089
1143
 
1090
1144
  break;
1091
1145
  }
1092
1146
  }
1093
1147
 
1094
- if ( ! cell ) {
1095
- if ( typeof row[i] === 'number' || (
1096
- row[i].match &&
1097
- row[i].match(/^-?\d+(\.\d+)?$/) &&
1098
- ! row[i].match(/^0\d+/) )
1148
+ if (!cell) {
1149
+ if (
1150
+ typeof row[i] === 'number' ||
1151
+ (row[i].match &&
1152
+ row[i].match(/^-?\d+(\.\d+)?([eE]\-?\d+)?$/) && // Includes exponential format
1153
+ !row[i].match(/^0\d+/))
1099
1154
  ) {
1100
1155
  // Detect numbers - don't match numbers with leading zeros
1101
1156
  // or a negative anywhere but the start
1102
- cell = _createNode( rels, 'c', {
1157
+ cell = _createNode(rels, 'c', {
1103
1158
  attr: {
1104
1159
  t: 'n',
1105
1160
  r: cellId
1106
1161
  },
1107
- children: [
1108
- _createNode( rels, 'v', { text: row[i] } )
1109
- ]
1110
- } );
1162
+ children: [_createNode(rels, 'v', { text: row[i] })]
1163
+ });
1111
1164
  }
1112
1165
  else {
1113
1166
  // String output - replace non standard characters for text output
1114
- var text = ! originalContent.replace ?
1115
- originalContent :
1116
- originalContent.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, '');
1167
+ var text = !originalContent.replace
1168
+ ? originalContent
1169
+ : originalContent.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, '');
1117
1170
 
1118
- cell = _createNode( rels, 'c', {
1171
+ cell = _createNode(rels, 'c', {
1119
1172
  attr: {
1120
1173
  t: 'inlineStr',
1121
1174
  r: cellId
1122
1175
  },
1123
- children:{
1124
- row: _createNode( rels, 'is', {
1176
+ children: {
1177
+ row: _createNode(rels, 'is', {
1125
1178
  children: {
1126
- row: _createNode( rels, 't', {
1179
+ row: _createNode(rels, 't', {
1127
1180
  text: text,
1128
1181
  attr: {
1129
1182
  'xml:space': 'preserve'
1130
1183
  }
1131
- } )
1184
+ })
1132
1185
  }
1133
- } )
1186
+ })
1134
1187
  }
1135
- } );
1188
+ });
1136
1189
  }
1137
1190
  }
1138
1191
 
1139
- rowNode.appendChild( cell );
1192
+ rowNode.appendChild(cell);
1140
1193
  }
1141
1194
 
1142
1195
  relsGet.appendChild(rowNode);
1143
1196
  rowPos++;
1144
1197
  };
1145
1198
 
1146
- if ( config.customizeData ) {
1147
- config.customizeData( data );
1199
+ if (config.customizeData) {
1200
+ config.customizeData(data);
1148
1201
  }
1149
1202
 
1150
- var mergeCells = function ( row, colspan ) {
1203
+ var mergeCells = function (row, colspan) {
1151
1204
  var mergeCells = $('mergeCells', rels);
1152
1205
 
1153
- mergeCells[0].appendChild( _createNode( rels, 'mergeCell', {
1154
- attr: {
1155
- ref: 'A'+row+':'+createCellPos(colspan)+row
1156
- }
1157
- } ) );
1158
- mergeCells.attr( 'count', parseFloat(mergeCells.attr( 'count' ))+1 );
1159
- $('row:eq('+(row-1)+') c', rels).attr( 's', '51' ); // centre
1206
+ mergeCells[0].appendChild(
1207
+ _createNode(rels, 'mergeCell', {
1208
+ attr: {
1209
+ ref: 'A' + row + ':' + createCellPos(colspan) + row
1210
+ }
1211
+ })
1212
+ );
1213
+ mergeCells.attr('count', parseFloat(mergeCells.attr('count')) + 1);
1214
+ $('row:eq(' + (row - 1) + ') c', rels).attr('s', '51'); // centre
1160
1215
  };
1161
1216
 
1162
1217
  // Title and top messages
1163
- var exportInfo = dt.buttons.exportInfo( config );
1164
- if ( exportInfo.title ) {
1165
- addRow( [exportInfo.title], rowPos );
1166
- mergeCells( rowPos, data.header.length-1 );
1218
+ var exportInfo = dt.buttons.exportInfo(config);
1219
+ if (exportInfo.title) {
1220
+ addRow([exportInfo.title], rowPos);
1221
+ mergeCells(rowPos, data.header.length - 1);
1167
1222
  }
1168
1223
 
1169
- if ( exportInfo.messageTop ) {
1170
- addRow( [exportInfo.messageTop], rowPos );
1171
- mergeCells( rowPos, data.header.length-1 );
1224
+ if (exportInfo.messageTop) {
1225
+ addRow([exportInfo.messageTop], rowPos);
1226
+ mergeCells(rowPos, data.header.length - 1);
1172
1227
  }
1173
1228
 
1174
-
1175
1229
  // Table itself
1176
- if ( config.header ) {
1177
- addRow( data.header, rowPos );
1178
- $('row:last c', rels).attr( 's', '2' ); // bold
1230
+ if (config.header) {
1231
+ addRow(data.header, rowPos);
1232
+ $('row:last c', rels).attr('s', '2'); // bold
1179
1233
  }
1180
1234
 
1181
1235
  dataStartRow = rowPos;
1182
1236
 
1183
- for ( var n=0, ie=data.body.length ; n<ie ; n++ ) {
1184
- addRow( data.body[n], rowPos );
1237
+ for (var n = 0, ie = data.body.length; n < ie; n++) {
1238
+ addRow(data.body[n], rowPos);
1185
1239
  }
1186
1240
 
1187
1241
  dataEndRow = rowPos;
1188
1242
 
1189
- if ( config.footer && data.footer ) {
1190
- addRow( data.footer, rowPos);
1191
- $('row:last c', rels).attr( 's', '2' ); // bold
1243
+ if (config.footer && data.footer) {
1244
+ addRow(data.footer, rowPos);
1245
+ $('row:last c', rels).attr('s', '2'); // bold
1192
1246
  }
1193
1247
 
1194
1248
  // Below the table
1195
- if ( exportInfo.messageBottom ) {
1196
- addRow( [exportInfo.messageBottom], rowPos );
1197
- mergeCells( rowPos, data.header.length-1 );
1249
+ if (exportInfo.messageBottom) {
1250
+ addRow([exportInfo.messageBottom], rowPos);
1251
+ mergeCells(rowPos, data.header.length - 1);
1198
1252
  }
1199
1253
 
1200
1254
  // Set column widths
1201
- var cols = _createNode( rels, 'cols' );
1202
- $('worksheet', rels).prepend( cols );
1203
-
1204
- for ( var i=0, ien=data.header.length ; i<ien ; i++ ) {
1205
- cols.appendChild( _createNode( rels, 'col', {
1206
- attr: {
1207
- min: i+1,
1208
- max: i+1,
1209
- width: _excelColWidth( data, i ),
1210
- customWidth: 1
1211
- }
1212
- } ) );
1255
+ var cols = _createNode(rels, 'cols');
1256
+ $('worksheet', rels).prepend(cols);
1257
+
1258
+ for (var i = 0, ien = data.header.length; i < ien; i++) {
1259
+ cols.appendChild(
1260
+ _createNode(rels, 'col', {
1261
+ attr: {
1262
+ min: i + 1,
1263
+ max: i + 1,
1264
+ width: _excelColWidth(data, i),
1265
+ customWidth: 1
1266
+ }
1267
+ })
1268
+ );
1213
1269
  }
1214
1270
 
1215
- // Auto filter for columns
1216
- $('mergeCells', rels).before( _createNode( rels, 'autoFilter', {
1217
- attr: {
1218
- ref: 'A'+dataStartRow+':'+createCellPos(data.header.length-1)+dataEndRow
1219
- }
1220
- } ) );
1221
-
1222
1271
  // Workbook modifications
1223
1272
  var workbook = xlsx.xl['workbook.xml'];
1224
1273
 
1225
- $( 'sheets sheet', workbook ).attr( 'name', _sheetname( config ) );
1274
+ $('sheets sheet', workbook).attr('name', _sheetname(config));
1226
1275
 
1227
- if ( config.autoFilter ) {
1228
- $('definedNames', workbook).append( _createNode( workbook, 'definedName', {
1229
- attr: {
1230
- name: '_xlnm._FilterDatabase',
1231
- localSheetId: '0',
1232
- hidden: 1
1233
- },
1234
- text: _sheetname(config)+'!$A$'+dataStartRow+':'+createCellPos(data.header.length-1)+dataEndRow
1235
- } ) );
1276
+ // Auto filter for columns
1277
+ if (config.autoFilter) {
1278
+ $('mergeCells', rels).before(
1279
+ _createNode(rels, 'autoFilter', {
1280
+ attr: {
1281
+ ref:
1282
+ 'A' +
1283
+ dataStartRow +
1284
+ ':' +
1285
+ createCellPos(data.header.length - 1) +
1286
+ dataEndRow
1287
+ }
1288
+ })
1289
+ );
1290
+
1291
+ $('definedNames', workbook).append(
1292
+ _createNode(workbook, 'definedName', {
1293
+ attr: {
1294
+ name: '_xlnm._FilterDatabase',
1295
+ localSheetId: '0',
1296
+ hidden: 1
1297
+ },
1298
+ text:
1299
+ _sheetname(config) +
1300
+ '!$A$' +
1301
+ dataStartRow +
1302
+ ':' +
1303
+ createCellPos(data.header.length - 1) +
1304
+ dataEndRow
1305
+ })
1306
+ );
1236
1307
  }
1237
1308
 
1238
1309
  // Let the developer customise the document if they want to
1239
- if ( config.customize ) {
1240
- config.customize( xlsx, config, dt );
1310
+ if (config.customize) {
1311
+ config.customize(xlsx, config, dt);
1241
1312
  }
1242
1313
 
1243
1314
  // Excel doesn't like an empty mergeCells tag
1244
- if ( $('mergeCells', rels).children().length === 0 ) {
1315
+ if ($('mergeCells', rels).children().length === 0) {
1245
1316
  $('mergeCells', rels).remove();
1246
1317
  }
1247
1318
 
1248
1319
  var jszip = _jsZip();
1249
1320
  var zip = new jszip();
1250
1321
  var zipConfig = {
1322
+ compression: 'DEFLATE',
1251
1323
  type: 'blob',
1252
1324
  mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
1253
1325
  };
1254
1326
 
1255
- _addToZip( zip, xlsx );
1327
+ _addToZip(zip, xlsx);
1328
+
1329
+ // Modern Excel has a 218 character limit on the file name + path of the file (why!?)
1330
+ // https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
1331
+ // So we truncate to allow for this.
1332
+ var filename = exportInfo.filename;
1333
+
1334
+ if (filename > 175) {
1335
+ filename = filename.substr(0, 175);
1336
+ }
1256
1337
 
1257
- if ( zip.generateAsync ) {
1338
+ if (zip.generateAsync) {
1258
1339
  // JSZip 3+
1259
- zip
1260
- .generateAsync( zipConfig )
1261
- .then( function ( blob ) {
1262
- _saveAs( blob, exportInfo.filename );
1263
- that.processing( false );
1264
- } );
1340
+ zip.generateAsync(zipConfig).then(function (blob) {
1341
+ _saveAs(blob, filename);
1342
+ that.processing(false);
1343
+ });
1265
1344
  }
1266
1345
  else {
1267
1346
  // JSZip 2.5
1268
- _saveAs(
1269
- zip.generate( zipConfig ),
1270
- exportInfo.filename
1271
- );
1272
- this.processing( false );
1347
+ _saveAs(zip.generate(zipConfig), filename);
1348
+ this.processing(false);
1273
1349
  }
1274
1350
  },
1275
1351
 
@@ -1306,46 +1382,52 @@ DataTable.ext.buttons.pdfHtml5 = {
1306
1382
  return window.FileReader !== undefined && _pdfMake();
1307
1383
  },
1308
1384
 
1309
- text: function ( dt ) {
1310
- return dt.i18n( 'buttons.pdf', 'PDF' );
1385
+ text: function (dt) {
1386
+ return dt.i18n('buttons.pdf', 'PDF');
1311
1387
  },
1312
1388
 
1313
- action: function ( e, dt, button, config ) {
1314
- this.processing( true );
1389
+ action: function (e, dt, button, config) {
1390
+ this.processing(true);
1315
1391
 
1316
1392
  var that = this;
1317
- var data = dt.buttons.exportData( config.exportOptions );
1318
- var info = dt.buttons.exportInfo( config );
1393
+ var data = dt.buttons.exportData(config.exportOptions);
1394
+ var info = dt.buttons.exportInfo(config);
1319
1395
  var rows = [];
1320
1396
 
1321
- if ( config.header ) {
1322
- rows.push( $.map( data.header, function ( d ) {
1323
- return {
1324
- text: typeof d === 'string' ? d : d+'',
1325
- style: 'tableHeader'
1326
- };
1327
- } ) );
1397
+ if (config.header) {
1398
+ rows.push(
1399
+ $.map(data.header, function (d) {
1400
+ return {
1401
+ text: typeof d === 'string' ? d : d + '',
1402
+ style: 'tableHeader'
1403
+ };
1404
+ })
1405
+ );
1328
1406
  }
1329
1407
 
1330
- for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
1331
- rows.push( $.map( data.body[i], function ( d ) {
1332
- if ( d === null || d === undefined ) {
1333
- d = '';
1334
- }
1335
- return {
1336
- text: typeof d === 'string' ? d : d+'',
1337
- style: i % 2 ? 'tableBodyEven' : 'tableBodyOdd'
1338
- };
1339
- } ) );
1408
+ for (var i = 0, ien = data.body.length; i < ien; i++) {
1409
+ rows.push(
1410
+ $.map(data.body[i], function (d) {
1411
+ if (d === null || d === undefined) {
1412
+ d = '';
1413
+ }
1414
+ return {
1415
+ text: typeof d === 'string' ? d : d + '',
1416
+ style: i % 2 ? 'tableBodyEven' : 'tableBodyOdd'
1417
+ };
1418
+ })
1419
+ );
1340
1420
  }
1341
1421
 
1342
- if ( config.footer && data.footer) {
1343
- rows.push( $.map( data.footer, function ( d ) {
1344
- return {
1345
- text: typeof d === 'string' ? d : d+'',
1346
- style: 'tableFooter'
1347
- };
1348
- } ) );
1422
+ if (config.footer && data.footer) {
1423
+ rows.push(
1424
+ $.map(data.footer, function (d) {
1425
+ return {
1426
+ text: typeof d === 'string' ? d : d + '',
1427
+ style: 'tableFooter'
1428
+ };
1429
+ })
1430
+ );
1349
1431
  }
1350
1432
 
1351
1433
  var doc = {
@@ -1389,44 +1471,44 @@ DataTable.ext.buttons.pdfHtml5 = {
1389
1471
  }
1390
1472
  };
1391
1473
 
1392
- if ( info.messageTop ) {
1393
- doc.content.unshift( {
1474
+ if (info.messageTop) {
1475
+ doc.content.unshift({
1394
1476
  text: info.messageTop,
1395
1477
  style: 'message',
1396
- margin: [ 0, 0, 0, 12 ]
1397
- } );
1478
+ margin: [0, 0, 0, 12]
1479
+ });
1398
1480
  }
1399
1481
 
1400
- if ( info.messageBottom ) {
1401
- doc.content.push( {
1482
+ if (info.messageBottom) {
1483
+ doc.content.push({
1402
1484
  text: info.messageBottom,
1403
1485
  style: 'message',
1404
- margin: [ 0, 0, 0, 12 ]
1405
- } );
1486
+ margin: [0, 0, 0, 12]
1487
+ });
1406
1488
  }
1407
1489
 
1408
- if ( info.title ) {
1409
- doc.content.unshift( {
1490
+ if (info.title) {
1491
+ doc.content.unshift({
1410
1492
  text: info.title,
1411
1493
  style: 'title',
1412
- margin: [ 0, 0, 0, 12 ]
1413
- } );
1494
+ margin: [0, 0, 0, 12]
1495
+ });
1414
1496
  }
1415
1497
 
1416
- if ( config.customize ) {
1417
- config.customize( doc, config, dt );
1498
+ if (config.customize) {
1499
+ config.customize(doc, config, dt);
1418
1500
  }
1419
1501
 
1420
- var pdf = _pdfMake().createPdf( doc );
1502
+ var pdf = _pdfMake().createPdf(doc);
1421
1503
 
1422
- if ( config.download === 'open' && ! _isDuffSafari() ) {
1504
+ if (config.download === 'open' && !_isDuffSafari()) {
1423
1505
  pdf.open();
1424
1506
  }
1425
1507
  else {
1426
- pdf.download( info.filename );
1508
+ pdf.download(info.filename);
1427
1509
  }
1428
1510
 
1429
- this.processing( false );
1511
+ this.processing(false);
1430
1512
  },
1431
1513
 
1432
1514
  title: '*',
@@ -1455,5 +1537,5 @@ DataTable.ext.buttons.pdfHtml5 = {
1455
1537
  };
1456
1538
 
1457
1539
 
1458
- return DataTable.Buttons;
1540
+ return DataTable;
1459
1541
  }));