jquery-datatables 1.10.12
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.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +27 -0
- data/README.md +118 -0
- data/Rakefile +166 -0
- data/app/assets/images/datatables/sort_asc.png +0 -0
- data/app/assets/images/datatables/sort_asc_disabled.png +0 -0
- data/app/assets/images/datatables/sort_both.png +0 -0
- data/app/assets/images/datatables/sort_desc.png +0 -0
- data/app/assets/images/datatables/sort_desc_disabled.png +0 -0
- data/app/assets/javascripts/datatables/dataTables.bootstrap.js +182 -0
- data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +184 -0
- data/app/assets/javascripts/datatables/dataTables.foundation.js +174 -0
- data/app/assets/javascripts/datatables/dataTables.jqueryui.js +164 -0
- data/app/assets/javascripts/datatables/dataTables.material.js +191 -0
- data/app/assets/javascripts/datatables/dataTables.semanticui.js +208 -0
- data/app/assets/javascripts/datatables/dataTables.uikit.js +176 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.bootstrap.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.bootstrap4.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.foundation.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.jqueryui.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/autoFill.semanticui.js +43 -0
- data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +1036 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap.js +68 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.bootstrap4.js +60 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +199 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.flash.js +1325 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.foundation.js +85 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +1322 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.jqueryui.js +62 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +172 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.semanticui.js +57 -0
- data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +1634 -0
- data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +1335 -0
- data/app/assets/javascripts/datatables/extensions/FixedColumns/dataTables.fixedColumns.js +1623 -0
- data/app/assets/javascripts/datatables/extensions/FixedHeader/dataTables.fixedHeader.js +672 -0
- data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +883 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/dataTables.responsive.js +1232 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.bootstrap.js +81 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.bootstrap4.js +81 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.foundation.js +62 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.jqueryui.js +63 -0
- data/app/assets/javascripts/datatables/extensions/Responsive/responsive.semanticui.js +77 -0
- data/app/assets/javascripts/datatables/extensions/RowReorder/dataTables.rowReorder.js +709 -0
- data/app/assets/javascripts/datatables/extensions/Scroller/dataTables.scroller.js +1349 -0
- data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +1109 -0
- data/app/assets/javascripts/datatables/jquery.dataTables.js +15278 -0
- data/app/assets/media/swf/flashExport.swf +0 -0
- data/app/assets/stylesheets/datatables/dataTables.bootstrap.css +185 -0
- data/app/assets/stylesheets/datatables/dataTables.bootstrap4.css +193 -0
- data/app/assets/stylesheets/datatables/dataTables.foundation.css +116 -0
- data/app/assets/stylesheets/datatables/dataTables.jqueryui.css +481 -0
- data/app/assets/stylesheets/datatables/dataTables.material.css +87 -0
- data/app/assets/stylesheets/datatables/dataTables.semanticui.css +103 -0
- data/app/assets/stylesheets/datatables/dataTables.uikit.css +146 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.bootstrap.css +81 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.bootstrap4.css +81 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.dataTables.css +92 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.foundation.css +85 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.jqueryui.css +85 -0
- data/app/assets/stylesheets/datatables/extensions/AutoFill/autoFill.semanticui.css +81 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.css +102 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.css +163 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.css +298 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.css +129 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.css +162 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.css +114 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/common.scss +27 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +89 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.bootstrap.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.bootstrap4.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.dataTables.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.foundation.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.jqueryui.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/ColReorder/colReorder.semanticui.css +11 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap.css +44 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.bootstrap4.css +44 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.dataTables.css +18 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.foundation.css +27 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.jqueryui.css +8 -0
- data/app/assets/stylesheets/datatables/extensions/FixedColumns/fixedColumns.semanticui.css +16 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.bootstrap.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.bootstrap4.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.dataTables.css +19 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.foundation.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.jqueryui.css +15 -0
- data/app/assets/stylesheets/datatables/extensions/FixedHeader/fixedHeader.semanticui.css +14 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.bootstrap.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.bootstrap4.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.dataTables.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.foundation.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.jqueryui.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/KeyTable/keyTable.semanticui.css +5 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.bootstrap.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.bootstrap4.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.dataTables.css +178 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.foundation.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.jqueryui.css +178 -0
- data/app/assets/stylesheets/datatables/extensions/Responsive/responsive.semanticui.css +181 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.bootstrap.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.bootstrap4.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.dataTables.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.foundation.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.jqueryui.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/rowReorder.semanticui.css +22 -0
- data/app/assets/stylesheets/datatables/extensions/RowReorder/semanticui.scss +5 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.bootstrap.css +24 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.bootstrap4.css +24 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.dataTables.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.foundation.css +17 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.jqueryui.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/Scroller/scroller.semanticui.css +20 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap.css +110 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap4.css +110 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.dataTables.css +100 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.foundation.css +112 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.jqueryui.css +100 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.semanticui.css +105 -0
- data/app/assets/stylesheets/datatables/jquery.dataTables.css +452 -0
- data/app/assets/stylesheets/datatables/jquery.dataTables_themeroller.css +416 -0
- data/jquery-datatables.gemspec +27 -0
- data/lib/generators/jquery/datatables/install_generator.rb +63 -0
- data/lib/generators/jquery/datatables/templates/bootstrap.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/bootstrap.js.tt +22 -0
- data/lib/generators/jquery/datatables/templates/bootstrap4.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/bootstrap4.js.tt +22 -0
- data/lib/generators/jquery/datatables/templates/foundation.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/foundation.js.tt +24 -0
- data/lib/generators/jquery/datatables/templates/jqueryui.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/jqueryui.js.tt +18 -0
- data/lib/generators/jquery/datatables/templates/material.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/material.js.tt +19 -0
- data/lib/generators/jquery/datatables/templates/regular.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/regular.js.tt +18 -0
- data/lib/generators/jquery/datatables/templates/semanticui.css.tt +16 -0
- data/lib/generators/jquery/datatables/templates/semanticui.js.tt +22 -0
- data/lib/generators/jquery/datatables/templates/uikit.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/uikit.js.tt +19 -0
- data/lib/jquery-datatables.rb +26 -0
- data/lib/jquery-datatables/engine.rb +11 -0
- data/lib/jquery-datatables/version.rb +6 -0
- metadata +269 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
/*! Foundation integration for DataTables' Buttons
|
2
|
+
* ©2016 SpryMedia Ltd - datatables.net/license
|
3
|
+
*/
|
4
|
+
|
5
|
+
(function( factory ){
|
6
|
+
if ( typeof define === 'function' && define.amd ) {
|
7
|
+
// AMD
|
8
|
+
define( ['jquery', 'datatables.net-zf', 'datatables.net-buttons'], function ( $ ) {
|
9
|
+
return factory( $, window, document );
|
10
|
+
} );
|
11
|
+
}
|
12
|
+
else if ( typeof exports === 'object' ) {
|
13
|
+
// CommonJS
|
14
|
+
module.exports = function (root, $) {
|
15
|
+
if ( ! root ) {
|
16
|
+
root = window;
|
17
|
+
}
|
18
|
+
|
19
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
20
|
+
$ = require('datatables.net-zf')(root, $).$;
|
21
|
+
}
|
22
|
+
|
23
|
+
if ( ! $.fn.dataTable.Buttons ) {
|
24
|
+
require('datatables.net-buttons')(root, $);
|
25
|
+
}
|
26
|
+
|
27
|
+
return factory( $, root, root.document );
|
28
|
+
};
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
// Browser
|
32
|
+
factory( jQuery, window, document );
|
33
|
+
}
|
34
|
+
}(function( $, window, document, undefined ) {
|
35
|
+
'use strict';
|
36
|
+
var DataTable = $.fn.dataTable;
|
37
|
+
|
38
|
+
|
39
|
+
// F6 has different requirements for the dropdown button set. We can use the
|
40
|
+
// Foundation version found by DataTables in order to support both F5 and F6 in
|
41
|
+
// the same file, but not that this requires DataTables 1.10.11+ for F6 support.
|
42
|
+
var collection = DataTable.ext.foundationVersion === 6 ?
|
43
|
+
{
|
44
|
+
tag: 'div',
|
45
|
+
className: 'dt-button-collection dropdown-pane is-open button-group stacked'
|
46
|
+
} :
|
47
|
+
{
|
48
|
+
tag: 'ul',
|
49
|
+
className: 'dt-button-collection f-dropdown open dropdown-pane is-open',
|
50
|
+
button: {
|
51
|
+
tag: 'li',
|
52
|
+
className: 'small'
|
53
|
+
},
|
54
|
+
buttonLiner: {
|
55
|
+
tag: 'a'
|
56
|
+
}
|
57
|
+
};
|
58
|
+
|
59
|
+
$.extend( true, DataTable.Buttons.defaults, {
|
60
|
+
dom: {
|
61
|
+
container: {
|
62
|
+
tag: 'div',
|
63
|
+
className: 'dt-buttons button-group'
|
64
|
+
},
|
65
|
+
buttonContainer: {
|
66
|
+
tag: null,
|
67
|
+
className: ''
|
68
|
+
},
|
69
|
+
button: {
|
70
|
+
tag: 'a',
|
71
|
+
className: 'button small'
|
72
|
+
},
|
73
|
+
buttonLiner: {
|
74
|
+
tag: null
|
75
|
+
},
|
76
|
+
collection: collection
|
77
|
+
}
|
78
|
+
} );
|
79
|
+
|
80
|
+
|
81
|
+
DataTable.ext.buttons.collection.className = 'buttons-collection dropdown';
|
82
|
+
|
83
|
+
|
84
|
+
return DataTable.Buttons;
|
85
|
+
}));
|
@@ -0,0 +1,1322 @@
|
|
1
|
+
/*!
|
2
|
+
* HTML5 export buttons for Buttons and DataTables.
|
3
|
+
* 2016 SpryMedia Ltd - datatables.net/license
|
4
|
+
*
|
5
|
+
* FileSaver.js (1.1.20160328) - MIT license
|
6
|
+
* Copyright © 2016 Eli Grey - http://eligrey.com
|
7
|
+
*/
|
8
|
+
|
9
|
+
(function( factory ){
|
10
|
+
if ( typeof define === 'function' && define.amd ) {
|
11
|
+
// AMD
|
12
|
+
define( ['jquery', 'datatables.net', 'datatables.net-buttons'], function ( $ ) {
|
13
|
+
return factory( $, window, document );
|
14
|
+
} );
|
15
|
+
}
|
16
|
+
else if ( typeof exports === 'object' ) {
|
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, $).$;
|
25
|
+
}
|
26
|
+
|
27
|
+
if ( ! $.fn.dataTable.Buttons ) {
|
28
|
+
require('datatables.net-buttons')(root, $);
|
29
|
+
}
|
30
|
+
|
31
|
+
return factory( $, root, root.document, jszip, pdfmake );
|
32
|
+
};
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
// Browser
|
36
|
+
factory( jQuery, window, document );
|
37
|
+
}
|
38
|
+
}(function( $, window, document, jsZip, pdfMake, undefined ) {
|
39
|
+
'use strict';
|
40
|
+
var DataTable = $.fn.dataTable;
|
41
|
+
|
42
|
+
// Allow the constructor to pass in JSZip and PDFMake from external requires.
|
43
|
+
// Otherwise, use globally defined variables, if they are available.
|
44
|
+
if ( jsZip === undefined ) {
|
45
|
+
jsZip = window.JSZip;
|
46
|
+
}
|
47
|
+
if ( pdfMake === undefined ) {
|
48
|
+
pdfMake = window.pdfMake;
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
53
|
+
* FileSaver.js dependency
|
54
|
+
*/
|
55
|
+
|
56
|
+
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
|
57
|
+
|
58
|
+
var _saveAs = (function(view) {
|
59
|
+
"use strict";
|
60
|
+
// IE <10 is explicitly unsupported
|
61
|
+
if (typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
var
|
65
|
+
doc = view.document
|
66
|
+
// only get URL when necessary in case Blob.js hasn't overridden it yet
|
67
|
+
, get_URL = function() {
|
68
|
+
return view.URL || view.webkitURL || view;
|
69
|
+
}
|
70
|
+
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
71
|
+
, can_use_save_link = "download" in save_link
|
72
|
+
, click = function(node) {
|
73
|
+
var event = new MouseEvent("click");
|
74
|
+
node.dispatchEvent(event);
|
75
|
+
}
|
76
|
+
, is_safari = /Version\/[\d\.]+.*Safari/.test(navigator.userAgent)
|
77
|
+
, webkit_req_fs = view.webkitRequestFileSystem
|
78
|
+
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
|
79
|
+
, throw_outside = function(ex) {
|
80
|
+
(view.setImmediate || view.setTimeout)(function() {
|
81
|
+
throw ex;
|
82
|
+
}, 0);
|
83
|
+
}
|
84
|
+
, force_saveable_type = "application/octet-stream"
|
85
|
+
, fs_min_size = 0
|
86
|
+
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
|
87
|
+
, arbitrary_revoke_timeout = 1000 * 40 // in ms
|
88
|
+
, revoke = function(file) {
|
89
|
+
var revoker = function() {
|
90
|
+
if (typeof file === "string") { // file is an object URL
|
91
|
+
get_URL().revokeObjectURL(file);
|
92
|
+
} else { // file is a File
|
93
|
+
file.remove();
|
94
|
+
}
|
95
|
+
};
|
96
|
+
/* // Take note W3C:
|
97
|
+
var
|
98
|
+
uri = typeof file === "string" ? file : file.toURL()
|
99
|
+
, revoker = function(evt) {
|
100
|
+
// idealy DownloadFinishedEvent.data would be the URL requested
|
101
|
+
if (evt.data === uri) {
|
102
|
+
if (typeof file === "string") { // file is an object URL
|
103
|
+
get_URL().revokeObjectURL(file);
|
104
|
+
} else { // file is a File
|
105
|
+
file.remove();
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
;
|
110
|
+
view.addEventListener("downloadfinished", revoker);
|
111
|
+
*/
|
112
|
+
setTimeout(revoker, arbitrary_revoke_timeout);
|
113
|
+
}
|
114
|
+
, dispatch = function(filesaver, event_types, event) {
|
115
|
+
event_types = [].concat(event_types);
|
116
|
+
var i = event_types.length;
|
117
|
+
while (i--) {
|
118
|
+
var listener = filesaver["on" + event_types[i]];
|
119
|
+
if (typeof listener === "function") {
|
120
|
+
try {
|
121
|
+
listener.call(filesaver, event || filesaver);
|
122
|
+
} catch (ex) {
|
123
|
+
throw_outside(ex);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
, auto_bom = function(blob) {
|
129
|
+
// prepend BOM for UTF-8 XML and text/* types (including HTML)
|
130
|
+
if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
|
131
|
+
return new Blob(["\ufeff", blob], {type: blob.type});
|
132
|
+
}
|
133
|
+
return blob;
|
134
|
+
}
|
135
|
+
, FileSaver = function(blob, name, no_auto_bom) {
|
136
|
+
if (!no_auto_bom) {
|
137
|
+
blob = auto_bom(blob);
|
138
|
+
}
|
139
|
+
// First try a.download, then web filesystem, then object URLs
|
140
|
+
var
|
141
|
+
filesaver = this
|
142
|
+
, type = blob.type
|
143
|
+
, blob_changed = false
|
144
|
+
, object_url
|
145
|
+
, target_view
|
146
|
+
, dispatch_all = function() {
|
147
|
+
dispatch(filesaver, "writestart progress write writeend".split(" "));
|
148
|
+
}
|
149
|
+
// on any filesys errors revert to saving with object URLs
|
150
|
+
, fs_error = function() {
|
151
|
+
if (target_view && is_safari && typeof FileReader !== "undefined") {
|
152
|
+
// Safari doesn't allow downloading of blob urls
|
153
|
+
var reader = new FileReader();
|
154
|
+
reader.onloadend = function() {
|
155
|
+
var base64Data = reader.result;
|
156
|
+
target_view.location.href = "data:attachment/file" + base64Data.slice(base64Data.search(/[,;]/));
|
157
|
+
filesaver.readyState = filesaver.DONE;
|
158
|
+
dispatch_all();
|
159
|
+
};
|
160
|
+
reader.readAsDataURL(blob);
|
161
|
+
filesaver.readyState = filesaver.INIT;
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
// don't create more object URLs than needed
|
165
|
+
if (blob_changed || !object_url) {
|
166
|
+
object_url = get_URL().createObjectURL(blob);
|
167
|
+
}
|
168
|
+
if (target_view) {
|
169
|
+
target_view.location.href = object_url;
|
170
|
+
} else {
|
171
|
+
var new_tab = view.open(object_url, "_blank");
|
172
|
+
if (new_tab === undefined && is_safari) {
|
173
|
+
//Apple do not allow window.open, see http://bit.ly/1kZffRI
|
174
|
+
view.location.href = object_url
|
175
|
+
}
|
176
|
+
}
|
177
|
+
filesaver.readyState = filesaver.DONE;
|
178
|
+
dispatch_all();
|
179
|
+
revoke(object_url);
|
180
|
+
}
|
181
|
+
, abortable = function(func) {
|
182
|
+
return function() {
|
183
|
+
if (filesaver.readyState !== filesaver.DONE) {
|
184
|
+
return func.apply(this, arguments);
|
185
|
+
}
|
186
|
+
};
|
187
|
+
}
|
188
|
+
, create_if_not_found = {create: true, exclusive: false}
|
189
|
+
, slice
|
190
|
+
;
|
191
|
+
filesaver.readyState = filesaver.INIT;
|
192
|
+
if (!name) {
|
193
|
+
name = "download";
|
194
|
+
}
|
195
|
+
if (can_use_save_link) {
|
196
|
+
object_url = get_URL().createObjectURL(blob);
|
197
|
+
setTimeout(function() {
|
198
|
+
save_link.href = object_url;
|
199
|
+
save_link.download = name;
|
200
|
+
click(save_link);
|
201
|
+
dispatch_all();
|
202
|
+
revoke(object_url);
|
203
|
+
filesaver.readyState = filesaver.DONE;
|
204
|
+
});
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
// Object and web filesystem URLs have a problem saving in Google Chrome when
|
208
|
+
// viewed in a tab, so I force save with application/octet-stream
|
209
|
+
// http://code.google.com/p/chromium/issues/detail?id=91158
|
210
|
+
// Update: Google errantly closed 91158, I submitted it again:
|
211
|
+
// https://code.google.com/p/chromium/issues/detail?id=389642
|
212
|
+
if (view.chrome && type && type !== force_saveable_type) {
|
213
|
+
slice = blob.slice || blob.webkitSlice;
|
214
|
+
blob = slice.call(blob, 0, blob.size, force_saveable_type);
|
215
|
+
blob_changed = true;
|
216
|
+
}
|
217
|
+
// Since I can't be sure that the guessed media type will trigger a download
|
218
|
+
// in WebKit, I append .download to the filename.
|
219
|
+
// https://bugs.webkit.org/show_bug.cgi?id=65440
|
220
|
+
if (webkit_req_fs && name !== "download") {
|
221
|
+
name += ".download";
|
222
|
+
}
|
223
|
+
if (type === force_saveable_type || webkit_req_fs) {
|
224
|
+
target_view = view;
|
225
|
+
}
|
226
|
+
if (!req_fs) {
|
227
|
+
fs_error();
|
228
|
+
return;
|
229
|
+
}
|
230
|
+
fs_min_size += blob.size;
|
231
|
+
req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
|
232
|
+
fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
|
233
|
+
var save = function() {
|
234
|
+
dir.getFile(name, create_if_not_found, abortable(function(file) {
|
235
|
+
file.createWriter(abortable(function(writer) {
|
236
|
+
writer.onwriteend = function(event) {
|
237
|
+
target_view.location.href = file.toURL();
|
238
|
+
filesaver.readyState = filesaver.DONE;
|
239
|
+
dispatch(filesaver, "writeend", event);
|
240
|
+
revoke(file);
|
241
|
+
};
|
242
|
+
writer.onerror = function() {
|
243
|
+
var error = writer.error;
|
244
|
+
if (error.code !== error.ABORT_ERR) {
|
245
|
+
fs_error();
|
246
|
+
}
|
247
|
+
};
|
248
|
+
"writestart progress write abort".split(" ").forEach(function(event) {
|
249
|
+
writer["on" + event] = filesaver["on" + event];
|
250
|
+
});
|
251
|
+
writer.write(blob);
|
252
|
+
filesaver.abort = function() {
|
253
|
+
writer.abort();
|
254
|
+
filesaver.readyState = filesaver.DONE;
|
255
|
+
};
|
256
|
+
filesaver.readyState = filesaver.WRITING;
|
257
|
+
}), fs_error);
|
258
|
+
}), fs_error);
|
259
|
+
};
|
260
|
+
dir.getFile(name, {create: false}, abortable(function(file) {
|
261
|
+
// delete file if it already exists
|
262
|
+
file.remove();
|
263
|
+
save();
|
264
|
+
}), abortable(function(ex) {
|
265
|
+
if (ex.code === ex.NOT_FOUND_ERR) {
|
266
|
+
save();
|
267
|
+
} else {
|
268
|
+
fs_error();
|
269
|
+
}
|
270
|
+
}));
|
271
|
+
}), fs_error);
|
272
|
+
}), fs_error);
|
273
|
+
}
|
274
|
+
, FS_proto = FileSaver.prototype
|
275
|
+
, saveAs = function(blob, name, no_auto_bom) {
|
276
|
+
return new FileSaver(blob, name, no_auto_bom);
|
277
|
+
}
|
278
|
+
;
|
279
|
+
// IE 10+ (native saveAs)
|
280
|
+
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
|
281
|
+
return function(blob, name, no_auto_bom) {
|
282
|
+
if (!no_auto_bom) {
|
283
|
+
blob = auto_bom(blob);
|
284
|
+
}
|
285
|
+
return navigator.msSaveOrOpenBlob(blob, name || "download");
|
286
|
+
};
|
287
|
+
}
|
288
|
+
|
289
|
+
FS_proto.abort = function() {
|
290
|
+
var filesaver = this;
|
291
|
+
filesaver.readyState = filesaver.DONE;
|
292
|
+
dispatch(filesaver, "abort");
|
293
|
+
};
|
294
|
+
FS_proto.readyState = FS_proto.INIT = 0;
|
295
|
+
FS_proto.WRITING = 1;
|
296
|
+
FS_proto.DONE = 2;
|
297
|
+
|
298
|
+
FS_proto.error =
|
299
|
+
FS_proto.onwritestart =
|
300
|
+
FS_proto.onprogress =
|
301
|
+
FS_proto.onwrite =
|
302
|
+
FS_proto.onabort =
|
303
|
+
FS_proto.onerror =
|
304
|
+
FS_proto.onwriteend =
|
305
|
+
null;
|
306
|
+
|
307
|
+
return saveAs;
|
308
|
+
}(
|
309
|
+
typeof self !== "undefined" && self
|
310
|
+
|| typeof window !== "undefined" && window
|
311
|
+
|| this.content
|
312
|
+
));
|
313
|
+
|
314
|
+
|
315
|
+
// Expose file saver on the DataTables API. Can't attach to `DataTables.Buttons`
|
316
|
+
// since this file can be loaded before Button's core!
|
317
|
+
DataTable.fileSave = _saveAs;
|
318
|
+
|
319
|
+
|
320
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
321
|
+
* Local (private) functions
|
322
|
+
*/
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Get the file name for an exported file.
|
326
|
+
*
|
327
|
+
* @param {object} config Button configuration
|
328
|
+
* @param {boolean} incExtension Include the file name extension
|
329
|
+
*/
|
330
|
+
var _filename = function ( config, incExtension )
|
331
|
+
{
|
332
|
+
// Backwards compatibility
|
333
|
+
var filename = config.filename === '*' && config.title !== '*' && config.title !== undefined ?
|
334
|
+
config.title :
|
335
|
+
config.filename;
|
336
|
+
|
337
|
+
if ( typeof filename === 'function' ) {
|
338
|
+
filename = filename();
|
339
|
+
}
|
340
|
+
|
341
|
+
if ( filename.indexOf( '*' ) !== -1 ) {
|
342
|
+
filename = $.trim( filename.replace( '*', $('title').text() ) );
|
343
|
+
}
|
344
|
+
|
345
|
+
// Strip characters which the OS will object to
|
346
|
+
filename = filename.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
|
347
|
+
|
348
|
+
return incExtension === undefined || incExtension === true ?
|
349
|
+
filename+config.extension :
|
350
|
+
filename;
|
351
|
+
};
|
352
|
+
|
353
|
+
/**
|
354
|
+
* Get the sheet name for Excel exports.
|
355
|
+
*
|
356
|
+
* @param {object} config Button configuration
|
357
|
+
*/
|
358
|
+
var _sheetname = function ( config )
|
359
|
+
{
|
360
|
+
var sheetName = 'Sheet1';
|
361
|
+
|
362
|
+
if ( config.sheetName ) {
|
363
|
+
sheetName = config.sheetName.replace(/[\[\]\*\/\\\?\:]/g, '');
|
364
|
+
}
|
365
|
+
|
366
|
+
return sheetName;
|
367
|
+
};
|
368
|
+
|
369
|
+
/**
|
370
|
+
* Get the title for an exported file.
|
371
|
+
*
|
372
|
+
* @param {object} config Button configuration
|
373
|
+
*/
|
374
|
+
var _title = function ( config )
|
375
|
+
{
|
376
|
+
var title = config.title;
|
377
|
+
|
378
|
+
if ( typeof title === 'function' ) {
|
379
|
+
title = title();
|
380
|
+
}
|
381
|
+
|
382
|
+
return title.indexOf( '*' ) !== -1 ?
|
383
|
+
title.replace( '*', $('title').text() || 'Exported data' ) :
|
384
|
+
title;
|
385
|
+
};
|
386
|
+
|
387
|
+
/**
|
388
|
+
* Get the newline character(s)
|
389
|
+
*
|
390
|
+
* @param {object} config Button configuration
|
391
|
+
* @return {string} Newline character
|
392
|
+
*/
|
393
|
+
var _newLine = function ( config )
|
394
|
+
{
|
395
|
+
return config.newline ?
|
396
|
+
config.newline :
|
397
|
+
navigator.userAgent.match(/Windows/) ?
|
398
|
+
'\r\n' :
|
399
|
+
'\n';
|
400
|
+
};
|
401
|
+
|
402
|
+
/**
|
403
|
+
* Combine the data from the `buttons.exportData` method into a string that
|
404
|
+
* will be used in the export file.
|
405
|
+
*
|
406
|
+
* @param {DataTable.Api} dt DataTables API instance
|
407
|
+
* @param {object} config Button configuration
|
408
|
+
* @return {object} The data to export
|
409
|
+
*/
|
410
|
+
var _exportData = function ( dt, config )
|
411
|
+
{
|
412
|
+
var newLine = _newLine( config );
|
413
|
+
var data = dt.buttons.exportData( config.exportOptions );
|
414
|
+
var boundary = config.fieldBoundary;
|
415
|
+
var separator = config.fieldSeparator;
|
416
|
+
var reBoundary = new RegExp( boundary, 'g' );
|
417
|
+
var escapeChar = config.escapeChar !== undefined ?
|
418
|
+
config.escapeChar :
|
419
|
+
'\\';
|
420
|
+
var join = function ( a ) {
|
421
|
+
var s = '';
|
422
|
+
|
423
|
+
// If there is a field boundary, then we might need to escape it in
|
424
|
+
// the source data
|
425
|
+
for ( var i=0, ien=a.length ; i<ien ; i++ ) {
|
426
|
+
if ( i > 0 ) {
|
427
|
+
s += separator;
|
428
|
+
}
|
429
|
+
|
430
|
+
s += boundary ?
|
431
|
+
boundary + ('' + a[i]).replace( reBoundary, escapeChar+boundary ) + boundary :
|
432
|
+
a[i];
|
433
|
+
}
|
434
|
+
|
435
|
+
return s;
|
436
|
+
};
|
437
|
+
|
438
|
+
var header = config.header ? join( data.header )+newLine : '';
|
439
|
+
var footer = config.footer && data.footer ? newLine+join( data.footer ) : '';
|
440
|
+
var body = [];
|
441
|
+
|
442
|
+
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
|
443
|
+
body.push( join( data.body[i] ) );
|
444
|
+
}
|
445
|
+
|
446
|
+
return {
|
447
|
+
str: header + body.join( newLine ) + footer,
|
448
|
+
rows: body.length
|
449
|
+
};
|
450
|
+
};
|
451
|
+
|
452
|
+
/**
|
453
|
+
* Safari's data: support for creating and downloading files is really poor, so
|
454
|
+
* various options need to be disabled in it. See
|
455
|
+
* https://bugs.webkit.org/show_bug.cgi?id=102914
|
456
|
+
*
|
457
|
+
* @return {Boolean} `true` if Safari
|
458
|
+
*/
|
459
|
+
var _isSafari = function ()
|
460
|
+
{
|
461
|
+
return navigator.userAgent.indexOf('Safari') !== -1 &&
|
462
|
+
navigator.userAgent.indexOf('Chrome') === -1 &&
|
463
|
+
navigator.userAgent.indexOf('Opera') === -1;
|
464
|
+
};
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Convert from numeric position to letter for column names in Excel
|
468
|
+
* @param {int} n Column number
|
469
|
+
* @return {string} Column letter(s) name
|
470
|
+
*/
|
471
|
+
function createCellPos( n ){
|
472
|
+
var ordA = 'A'.charCodeAt(0);
|
473
|
+
var ordZ = 'Z'.charCodeAt(0);
|
474
|
+
var len = ordZ - ordA + 1;
|
475
|
+
var s = "";
|
476
|
+
|
477
|
+
while( n >= 0 ) {
|
478
|
+
s = String.fromCharCode(n % len + ordA) + s;
|
479
|
+
n = Math.floor(n / len) - 1;
|
480
|
+
}
|
481
|
+
|
482
|
+
return s;
|
483
|
+
}
|
484
|
+
|
485
|
+
try {
|
486
|
+
var _serialiser = new XMLSerializer();
|
487
|
+
var _ieExcel;
|
488
|
+
}
|
489
|
+
catch (t) {}
|
490
|
+
|
491
|
+
/**
|
492
|
+
* Recursively add XML files from an object's structure to a ZIP file. This
|
493
|
+
* allows the XSLX file to be easily defined with an object's structure matching
|
494
|
+
* the files structure.
|
495
|
+
*
|
496
|
+
* @param {JSZip} zip ZIP package
|
497
|
+
* @param {object} obj Object to add (recursive)
|
498
|
+
*/
|
499
|
+
function _addToZip( zip, obj ) {
|
500
|
+
if ( _ieExcel === undefined ) {
|
501
|
+
// Detect if we are dealing with IE's _awful_ serialiser by seeing if it
|
502
|
+
// drop attributes
|
503
|
+
_ieExcel = _serialiser
|
504
|
+
.serializeToString(
|
505
|
+
$.parseXML( excelStrings['xl/worksheets/sheet1.xml'] )
|
506
|
+
)
|
507
|
+
.indexOf( 'xmlns:r' ) === -1;
|
508
|
+
}
|
509
|
+
|
510
|
+
$.each( obj, function ( name, val ) {
|
511
|
+
if ( $.isPlainObject( val ) ) {
|
512
|
+
var newDir = zip.folder( name );
|
513
|
+
_addToZip( newDir, val );
|
514
|
+
}
|
515
|
+
else {
|
516
|
+
if ( _ieExcel ) {
|
517
|
+
// IE's XML serialiser will drop some name space attributes from
|
518
|
+
// from the root node, so we need to save them. Do this by
|
519
|
+
// replacing the namespace nodes with a regular attribute that
|
520
|
+
// we convert back when serialised. Edge does not have this
|
521
|
+
// issue
|
522
|
+
var worksheet = val.childNodes[0];
|
523
|
+
var i, ien;
|
524
|
+
var attrs = [];
|
525
|
+
|
526
|
+
for ( i=worksheet.attributes.length-1 ; i>=0 ; i-- ) {
|
527
|
+
var attrName = worksheet.attributes[i].nodeName;
|
528
|
+
var attrValue = worksheet.attributes[i].nodeValue;
|
529
|
+
|
530
|
+
if ( attrName.indexOf( ':' ) !== -1 ) {
|
531
|
+
attrs.push( { name: attrName, value: attrValue } );
|
532
|
+
|
533
|
+
worksheet.removeAttribute( attrName );
|
534
|
+
}
|
535
|
+
}
|
536
|
+
|
537
|
+
for ( i=0, ien=attrs.length ; i<ien ; i++ ) {
|
538
|
+
var attr = val.createAttribute( attrs[i].name.replace( ':', '_dt_b_namespace_token_' ) );
|
539
|
+
attr.value = attrs[i].value;
|
540
|
+
worksheet.setAttributeNode( attr );
|
541
|
+
}
|
542
|
+
}
|
543
|
+
|
544
|
+
var str = _serialiser.serializeToString(val);
|
545
|
+
|
546
|
+
// Fix IE's XML
|
547
|
+
if ( _ieExcel ) {
|
548
|
+
// IE doesn't include the XML declaration
|
549
|
+
if ( str.indexOf( '<?xml' ) === -1 ) {
|
550
|
+
str = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+str;
|
551
|
+
}
|
552
|
+
|
553
|
+
// Return namespace attributes to being as such
|
554
|
+
str = str.replace( /_dt_b_namespace_token_/g, ':' );
|
555
|
+
}
|
556
|
+
|
557
|
+
// Both IE and Edge will put empty name space attributes onto the
|
558
|
+
// rows and columns making them useless
|
559
|
+
str = str
|
560
|
+
.replace( /<row xmlns="" /g, '<row ' )
|
561
|
+
.replace( /<cols xmlns="">/g, '<cols>' );
|
562
|
+
|
563
|
+
zip.file( name, str );
|
564
|
+
}
|
565
|
+
} );
|
566
|
+
}
|
567
|
+
|
568
|
+
/**
|
569
|
+
* Create an XML node and add any children, attributes, etc without needing to
|
570
|
+
* be verbose in the DOM.
|
571
|
+
*
|
572
|
+
* @param {object} doc XML document
|
573
|
+
* @param {string} nodeName Node name
|
574
|
+
* @param {object} opts Options - can be `attr` (attributes), `children`
|
575
|
+
* (child nodes) and `text` (text content)
|
576
|
+
* @return {node} Created node
|
577
|
+
*/
|
578
|
+
function _createNode( doc, nodeName, opts ) {
|
579
|
+
var tempNode = doc.createElement( nodeName );
|
580
|
+
|
581
|
+
if ( opts ) {
|
582
|
+
if ( opts.attr ) {
|
583
|
+
$(tempNode).attr( opts.attr );
|
584
|
+
}
|
585
|
+
|
586
|
+
if( opts.children ) {
|
587
|
+
$.each( opts.children, function ( key, value ) {
|
588
|
+
tempNode.appendChild( value );
|
589
|
+
});
|
590
|
+
}
|
591
|
+
|
592
|
+
if( opts.text ) {
|
593
|
+
tempNode.appendChild( doc.createTextNode( opts.text ) );
|
594
|
+
}
|
595
|
+
}
|
596
|
+
|
597
|
+
return tempNode;
|
598
|
+
}
|
599
|
+
|
600
|
+
/**
|
601
|
+
* Get the width for an Excel column based on the contents of that column
|
602
|
+
* @param {object} data Data for export
|
603
|
+
* @param {int} col Column index
|
604
|
+
* @return {int} Column width
|
605
|
+
*/
|
606
|
+
function _excelColWidth( data, col ) {
|
607
|
+
var max = data.header[col].length;
|
608
|
+
var len;
|
609
|
+
|
610
|
+
if ( data.footer && data.footer[col].length > max ) {
|
611
|
+
max = data.footer[col].length;
|
612
|
+
}
|
613
|
+
|
614
|
+
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
|
615
|
+
len = data.body[i][col].toString().length;
|
616
|
+
|
617
|
+
if ( len > max ) {
|
618
|
+
max = len;
|
619
|
+
}
|
620
|
+
|
621
|
+
// Max width rather than having potentially massive column widths
|
622
|
+
if ( max > 40 ) {
|
623
|
+
break;
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
// And a min width
|
628
|
+
return max > 5 ? max : 5;
|
629
|
+
}
|
630
|
+
|
631
|
+
// Excel - Pre-defined strings to build a basic XLSX file
|
632
|
+
var excelStrings = {
|
633
|
+
"_rels/.rels":
|
634
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
635
|
+
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
|
636
|
+
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'+
|
637
|
+
'</Relationships>',
|
638
|
+
|
639
|
+
"xl/_rels/workbook.xml.rels":
|
640
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
641
|
+
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
|
642
|
+
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>'+
|
643
|
+
'<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+
|
644
|
+
'</Relationships>',
|
645
|
+
|
646
|
+
"[Content_Types].xml":
|
647
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
648
|
+
'<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'+
|
649
|
+
'<Default Extension="xml" ContentType="application/xml" />'+
|
650
|
+
'<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />'+
|
651
|
+
'<Default Extension="jpeg" ContentType="image/jpeg" />'+
|
652
|
+
'<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />'+
|
653
|
+
'<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />'+
|
654
|
+
'<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />'+
|
655
|
+
'</Types>',
|
656
|
+
|
657
|
+
"xl/workbook.xml":
|
658
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
659
|
+
'<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'+
|
660
|
+
'<fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="24816"/>'+
|
661
|
+
'<workbookPr showInkAnnotation="0" autoCompressPictures="0"/>'+
|
662
|
+
'<bookViews>'+
|
663
|
+
'<workbookView xWindow="0" yWindow="0" windowWidth="25600" windowHeight="19020" tabRatio="500"/>'+
|
664
|
+
'</bookViews>'+
|
665
|
+
'<sheets>'+
|
666
|
+
'<sheet name="" sheetId="1" r:id="rId1"/>'+
|
667
|
+
'</sheets>'+
|
668
|
+
'</workbook>',
|
669
|
+
|
670
|
+
"xl/worksheets/sheet1.xml":
|
671
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
672
|
+
'<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">'+
|
673
|
+
'<sheetData/>'+
|
674
|
+
'</worksheet>',
|
675
|
+
|
676
|
+
"xl/styles.xml":
|
677
|
+
'<?xml version="1.0" encoding="UTF-8"?>'+
|
678
|
+
'<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">'+
|
679
|
+
'<fonts count="5" x14ac:knownFonts="1">'+
|
680
|
+
'<font>'+
|
681
|
+
'<sz val="11" />'+
|
682
|
+
'<name val="Calibri" />'+
|
683
|
+
'</font>'+
|
684
|
+
'<font>'+
|
685
|
+
'<sz val="11" />'+
|
686
|
+
'<name val="Calibri" />'+
|
687
|
+
'<color rgb="FFFFFFFF" />'+
|
688
|
+
'</font>'+
|
689
|
+
'<font>'+
|
690
|
+
'<sz val="11" />'+
|
691
|
+
'<name val="Calibri" />'+
|
692
|
+
'<b />'+
|
693
|
+
'</font>'+
|
694
|
+
'<font>'+
|
695
|
+
'<sz val="11" />'+
|
696
|
+
'<name val="Calibri" />'+
|
697
|
+
'<i />'+
|
698
|
+
'</font>'+
|
699
|
+
'<font>'+
|
700
|
+
'<sz val="11" />'+
|
701
|
+
'<name val="Calibri" />'+
|
702
|
+
'<u />'+
|
703
|
+
'</font>'+
|
704
|
+
'</fonts>'+
|
705
|
+
'<fills count="6">'+
|
706
|
+
'<fill>'+
|
707
|
+
'<patternFill patternType="none" />'+
|
708
|
+
'</fill>'+
|
709
|
+
'<fill/>'+ // Excel appears to use this as a dotted background regardless of values
|
710
|
+
'<fill>'+
|
711
|
+
'<patternFill patternType="solid">'+
|
712
|
+
'<fgColor rgb="FFD9D9D9" />'+
|
713
|
+
'<bgColor indexed="64" />'+
|
714
|
+
'</patternFill>'+
|
715
|
+
'</fill>'+
|
716
|
+
'<fill>'+
|
717
|
+
'<patternFill patternType="solid">'+
|
718
|
+
'<fgColor rgb="FFD99795" />'+
|
719
|
+
'<bgColor indexed="64" />'+
|
720
|
+
'</patternFill>'+
|
721
|
+
'</fill>'+
|
722
|
+
'<fill>'+
|
723
|
+
'<patternFill patternType="solid">'+
|
724
|
+
'<fgColor rgb="ffc6efce" />'+
|
725
|
+
'<bgColor indexed="64" />'+
|
726
|
+
'</patternFill>'+
|
727
|
+
'</fill>'+
|
728
|
+
'<fill>'+
|
729
|
+
'<patternFill patternType="solid">'+
|
730
|
+
'<fgColor rgb="ffc6cfef" />'+
|
731
|
+
'<bgColor indexed="64" />'+
|
732
|
+
'</patternFill>'+
|
733
|
+
'</fill>'+
|
734
|
+
'</fills>'+
|
735
|
+
'<borders count="2">'+
|
736
|
+
'<border>'+
|
737
|
+
'<left />'+
|
738
|
+
'<right />'+
|
739
|
+
'<top />'+
|
740
|
+
'<bottom />'+
|
741
|
+
'<diagonal />'+
|
742
|
+
'</border>'+
|
743
|
+
'<border diagonalUp="false" diagonalDown="false">'+
|
744
|
+
'<left style="thin">'+
|
745
|
+
'<color auto="1" />'+
|
746
|
+
'</left>'+
|
747
|
+
'<right style="thin">'+
|
748
|
+
'<color auto="1" />'+
|
749
|
+
'</right>'+
|
750
|
+
'<top style="thin">'+
|
751
|
+
'<color auto="1" />'+
|
752
|
+
'</top>'+
|
753
|
+
'<bottom style="thin">'+
|
754
|
+
'<color auto="1" />'+
|
755
|
+
'</bottom>'+
|
756
|
+
'<diagonal />'+
|
757
|
+
'</border>'+
|
758
|
+
'</borders>'+
|
759
|
+
'<cellStyleXfs count="1">'+
|
760
|
+
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" />'+
|
761
|
+
'</cellStyleXfs>'+
|
762
|
+
'<cellXfs count="2">'+
|
763
|
+
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
764
|
+
'<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
765
|
+
'<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
766
|
+
'<xf numFmtId="0" fontId="3" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
767
|
+
'<xf numFmtId="0" fontId="4" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
768
|
+
'<xf numFmtId="0" fontId="0" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
769
|
+
'<xf numFmtId="0" fontId="1" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
770
|
+
'<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
771
|
+
'<xf numFmtId="0" fontId="3" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
772
|
+
'<xf numFmtId="0" fontId="4" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
773
|
+
'<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
774
|
+
'<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
775
|
+
'<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
776
|
+
'<xf numFmtId="0" fontId="3" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
777
|
+
'<xf numFmtId="0" fontId="4" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
778
|
+
'<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
779
|
+
'<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
780
|
+
'<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
781
|
+
'<xf numFmtId="0" fontId="3" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
782
|
+
'<xf numFmtId="0" fontId="4" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
783
|
+
'<xf numFmtId="0" fontId="0" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
784
|
+
'<xf numFmtId="0" fontId="1" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
785
|
+
'<xf numFmtId="0" fontId="2" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
786
|
+
'<xf numFmtId="0" fontId="3" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
787
|
+
'<xf numFmtId="0" fontId="4" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
788
|
+
'<xf numFmtId="0" fontId="0" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
789
|
+
'<xf numFmtId="0" fontId="1" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
790
|
+
'<xf numFmtId="0" fontId="2" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
791
|
+
'<xf numFmtId="0" fontId="3" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
792
|
+
'<xf numFmtId="0" fontId="4" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
793
|
+
'<xf numFmtId="0" fontId="0" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
794
|
+
'<xf numFmtId="0" fontId="1" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
795
|
+
'<xf numFmtId="0" fontId="2" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
796
|
+
'<xf numFmtId="0" fontId="3" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
797
|
+
'<xf numFmtId="0" fontId="4" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
798
|
+
'<xf numFmtId="0" fontId="0" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
799
|
+
'<xf numFmtId="0" fontId="1" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
800
|
+
'<xf numFmtId="0" fontId="2" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
801
|
+
'<xf numFmtId="0" fontId="3" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
802
|
+
'<xf numFmtId="0" fontId="4" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
803
|
+
'<xf numFmtId="0" fontId="0" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
804
|
+
'<xf numFmtId="0" fontId="1" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
805
|
+
'<xf numFmtId="0" fontId="2" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
806
|
+
'<xf numFmtId="0" fontId="3" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
807
|
+
'<xf numFmtId="0" fontId="4" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
808
|
+
'<xf numFmtId="0" fontId="0" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
809
|
+
'<xf numFmtId="0" fontId="1" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
810
|
+
'<xf numFmtId="0" fontId="2" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
811
|
+
'<xf numFmtId="0" fontId="3" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
812
|
+
'<xf numFmtId="0" fontId="4" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
813
|
+
'</cellXfs>'+
|
814
|
+
'<cellStyles count="1">'+
|
815
|
+
'<cellStyle name="Normal" xfId="0" builtinId="0" />'+
|
816
|
+
'</cellStyles>'+
|
817
|
+
'<dxfs count="0" />'+
|
818
|
+
'<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4" />'+
|
819
|
+
'</styleSheet>'
|
820
|
+
};
|
821
|
+
// Note we could use 3 `for` loops for the styles, but when gzipped there is
|
822
|
+
// virtually no difference in size, since the above can be easily compressed
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
827
|
+
* Buttons
|
828
|
+
*/
|
829
|
+
|
830
|
+
//
|
831
|
+
// Copy to clipboard
|
832
|
+
//
|
833
|
+
DataTable.ext.buttons.copyHtml5 = {
|
834
|
+
className: 'buttons-copy buttons-html5',
|
835
|
+
|
836
|
+
text: function ( dt ) {
|
837
|
+
return dt.i18n( 'buttons.copy', 'Copy' );
|
838
|
+
},
|
839
|
+
|
840
|
+
action: function ( e, dt, button, config ) {
|
841
|
+
var exportData = _exportData( dt, config );
|
842
|
+
var output = exportData.str;
|
843
|
+
var hiddenDiv = $('<div/>')
|
844
|
+
.css( {
|
845
|
+
height: 1,
|
846
|
+
width: 1,
|
847
|
+
overflow: 'hidden',
|
848
|
+
position: 'fixed',
|
849
|
+
top: 0,
|
850
|
+
left: 0
|
851
|
+
} );
|
852
|
+
|
853
|
+
if ( config.customize ) {
|
854
|
+
output = config.customize( output, config );
|
855
|
+
}
|
856
|
+
|
857
|
+
var textarea = $('<textarea readonly/>')
|
858
|
+
.val( output )
|
859
|
+
.appendTo( hiddenDiv );
|
860
|
+
|
861
|
+
// For browsers that support the copy execCommand, try to use it
|
862
|
+
if ( document.queryCommandSupported('copy') ) {
|
863
|
+
hiddenDiv.appendTo( dt.table().container() );
|
864
|
+
textarea[0].focus();
|
865
|
+
textarea[0].select();
|
866
|
+
|
867
|
+
try {
|
868
|
+
document.execCommand( 'copy' );
|
869
|
+
hiddenDiv.remove();
|
870
|
+
|
871
|
+
dt.buttons.info(
|
872
|
+
dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ),
|
873
|
+
dt.i18n( 'buttons.copySuccess', {
|
874
|
+
1: "Copied one row to clipboard",
|
875
|
+
_: "Copied %d rows to clipboard"
|
876
|
+
}, exportData.rows ),
|
877
|
+
2000
|
878
|
+
);
|
879
|
+
|
880
|
+
return;
|
881
|
+
}
|
882
|
+
catch (t) {}
|
883
|
+
}
|
884
|
+
|
885
|
+
// Otherwise we show the text box and instruct the user to use it
|
886
|
+
var message = $('<span>'+dt.i18n( 'buttons.copyKeys',
|
887
|
+
'Press <i>ctrl</i> or <i>\u2318</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>'+
|
888
|
+
'To cancel, click this message or press escape.' )+'</span>'
|
889
|
+
)
|
890
|
+
.append( hiddenDiv );
|
891
|
+
|
892
|
+
dt.buttons.info( dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ), message, 0 );
|
893
|
+
|
894
|
+
// Select the text so when the user activates their system clipboard
|
895
|
+
// it will copy that text
|
896
|
+
textarea[0].focus();
|
897
|
+
textarea[0].select();
|
898
|
+
|
899
|
+
// Event to hide the message when the user is done
|
900
|
+
var container = $(message).closest('.dt-button-info');
|
901
|
+
var close = function () {
|
902
|
+
container.off( 'click.buttons-copy' );
|
903
|
+
$(document).off( '.buttons-copy' );
|
904
|
+
dt.buttons.info( false );
|
905
|
+
};
|
906
|
+
|
907
|
+
container.on( 'click.buttons-copy', close );
|
908
|
+
$(document)
|
909
|
+
.on( 'keydown.buttons-copy', function (e) {
|
910
|
+
if ( e.keyCode === 27 ) { // esc
|
911
|
+
close();
|
912
|
+
}
|
913
|
+
} )
|
914
|
+
.on( 'copy.buttons-copy cut.buttons-copy', function () {
|
915
|
+
close();
|
916
|
+
} );
|
917
|
+
},
|
918
|
+
|
919
|
+
exportOptions: {},
|
920
|
+
|
921
|
+
fieldSeparator: '\t',
|
922
|
+
|
923
|
+
fieldBoundary: '',
|
924
|
+
|
925
|
+
header: true,
|
926
|
+
|
927
|
+
footer: false
|
928
|
+
};
|
929
|
+
|
930
|
+
//
|
931
|
+
// CSV export
|
932
|
+
//
|
933
|
+
DataTable.ext.buttons.csvHtml5 = {
|
934
|
+
className: 'buttons-csv buttons-html5',
|
935
|
+
|
936
|
+
available: function () {
|
937
|
+
return window.FileReader !== undefined && window.Blob;
|
938
|
+
},
|
939
|
+
|
940
|
+
text: function ( dt ) {
|
941
|
+
return dt.i18n( 'buttons.csv', 'CSV' );
|
942
|
+
},
|
943
|
+
|
944
|
+
action: function ( e, dt, button, config ) {
|
945
|
+
// Set the text
|
946
|
+
var output = _exportData( dt, config ).str;
|
947
|
+
var charset = config.charset;
|
948
|
+
|
949
|
+
if ( config.customize ) {
|
950
|
+
output = config.customize( output, config );
|
951
|
+
}
|
952
|
+
|
953
|
+
if ( charset !== false ) {
|
954
|
+
if ( ! charset ) {
|
955
|
+
charset = document.characterSet || document.charset;
|
956
|
+
}
|
957
|
+
|
958
|
+
if ( charset ) {
|
959
|
+
charset = ';charset='+charset;
|
960
|
+
}
|
961
|
+
}
|
962
|
+
else {
|
963
|
+
charset = '';
|
964
|
+
}
|
965
|
+
|
966
|
+
_saveAs(
|
967
|
+
new Blob( [output], {type: 'text/csv'+charset} ),
|
968
|
+
_filename( config )
|
969
|
+
);
|
970
|
+
},
|
971
|
+
|
972
|
+
filename: '*',
|
973
|
+
|
974
|
+
extension: '.csv',
|
975
|
+
|
976
|
+
exportOptions: {},
|
977
|
+
|
978
|
+
fieldSeparator: ',',
|
979
|
+
|
980
|
+
fieldBoundary: '"',
|
981
|
+
|
982
|
+
escapeChar: '"',
|
983
|
+
|
984
|
+
charset: null,
|
985
|
+
|
986
|
+
header: true,
|
987
|
+
|
988
|
+
footer: false
|
989
|
+
};
|
990
|
+
|
991
|
+
//
|
992
|
+
// Excel (xlsx) export
|
993
|
+
//
|
994
|
+
DataTable.ext.buttons.excelHtml5 = {
|
995
|
+
className: 'buttons-excel buttons-html5',
|
996
|
+
|
997
|
+
available: function () {
|
998
|
+
return window.FileReader !== undefined && jsZip !== undefined && ! _isSafari() && _serialiser;
|
999
|
+
},
|
1000
|
+
|
1001
|
+
text: function ( dt ) {
|
1002
|
+
return dt.i18n( 'buttons.excel', 'Excel' );
|
1003
|
+
},
|
1004
|
+
|
1005
|
+
action: function ( e, dt, button, config ) {
|
1006
|
+
var rowPos = 0;
|
1007
|
+
var getXml = function ( type ) {
|
1008
|
+
var str = excelStrings[ type ];
|
1009
|
+
|
1010
|
+
//str = str.replace( /xmlns:/g, 'xmlns_' ).replace( /mc:/g, 'mc_' );
|
1011
|
+
|
1012
|
+
return $.parseXML( str );
|
1013
|
+
};
|
1014
|
+
var rels = getXml('xl/worksheets/sheet1.xml');
|
1015
|
+
var relsGet = rels.getElementsByTagName( "sheetData" )[0];
|
1016
|
+
|
1017
|
+
var xlsx = {
|
1018
|
+
_rels: {
|
1019
|
+
".rels": getXml('_rels/.rels')
|
1020
|
+
},
|
1021
|
+
xl: {
|
1022
|
+
_rels: {
|
1023
|
+
"workbook.xml.rels": getXml('xl/_rels/workbook.xml.rels')
|
1024
|
+
},
|
1025
|
+
"workbook.xml": getXml('xl/workbook.xml'),
|
1026
|
+
"styles.xml": getXml('xl/styles.xml'),
|
1027
|
+
"worksheets": {
|
1028
|
+
"sheet1.xml": rels
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
},
|
1032
|
+
"[Content_Types].xml": getXml('[Content_Types].xml')
|
1033
|
+
};
|
1034
|
+
|
1035
|
+
var data = dt.buttons.exportData( config.exportOptions );
|
1036
|
+
var currentRow, rowNode;
|
1037
|
+
var addRow = function ( row ) {
|
1038
|
+
currentRow = rowPos+1;
|
1039
|
+
rowNode = _createNode( rels, "row", { attr: {r:currentRow} } );
|
1040
|
+
|
1041
|
+
for ( var i=0, ien=row.length ; i<ien ; i++ ) {
|
1042
|
+
// Concat both the Cell Columns as a letter and the Row of the cell.
|
1043
|
+
var cellId = createCellPos(i) + '' + currentRow;
|
1044
|
+
var cell;
|
1045
|
+
|
1046
|
+
if ( row[i] === null || row[i] === undefined ) {
|
1047
|
+
row[i] = '';
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
// Detect numbers - don't match numbers with leading zeros or a negative
|
1051
|
+
// anywhere but the start
|
1052
|
+
if ( typeof row[i] === 'number' || (
|
1053
|
+
row[i].match &&
|
1054
|
+
$.trim(row[i]).match(/^-?\d+(\.\d+)?$/) &&
|
1055
|
+
! $.trim(row[i]).match(/^0\d+/) )
|
1056
|
+
) {
|
1057
|
+
cell = _createNode( rels, 'c', {
|
1058
|
+
attr: {
|
1059
|
+
t: 'n',
|
1060
|
+
r: cellId
|
1061
|
+
},
|
1062
|
+
children: [
|
1063
|
+
_createNode( rels, 'v', { text: row[i] } )
|
1064
|
+
]
|
1065
|
+
} );
|
1066
|
+
}
|
1067
|
+
else {
|
1068
|
+
// Replace non standard characters for text output
|
1069
|
+
var text = ! row[i].replace ?
|
1070
|
+
row[i] :
|
1071
|
+
row[i]
|
1072
|
+
.replace(/&(?!amp;)/g, '&')
|
1073
|
+
.replace(/</g, '<')
|
1074
|
+
.replace(/>/g, '>')
|
1075
|
+
.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, '');
|
1076
|
+
|
1077
|
+
cell = _createNode( rels, 'c', {
|
1078
|
+
attr: {
|
1079
|
+
t: 'inlineStr',
|
1080
|
+
r: cellId
|
1081
|
+
},
|
1082
|
+
children:{
|
1083
|
+
row: _createNode( rels, 'is', {
|
1084
|
+
children: {
|
1085
|
+
row: _createNode( rels, 't', {
|
1086
|
+
text: text
|
1087
|
+
} )
|
1088
|
+
}
|
1089
|
+
} )
|
1090
|
+
}
|
1091
|
+
} );
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
rowNode.appendChild( cell );
|
1095
|
+
}
|
1096
|
+
relsGet.appendChild(rowNode);
|
1097
|
+
rowPos++;
|
1098
|
+
};
|
1099
|
+
|
1100
|
+
$( 'sheets sheet', xlsx.xl['workbook.xml'] ).attr( 'name', _sheetname( config ) );
|
1101
|
+
|
1102
|
+
if ( config.customizeData ) {
|
1103
|
+
config.customizeData( data );
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
if ( config.header ) {
|
1107
|
+
addRow( data.header, rowPos );
|
1108
|
+
$('row c', rels).attr( 's', '2' ); // bold
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
for ( var n=0, ie=data.body.length ; n<ie ; n++ ) {
|
1112
|
+
addRow( data.body[n], rowPos );
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
if ( config.footer && data.footer ) {
|
1116
|
+
addRow( data.footer, rowPos);
|
1117
|
+
$('row:last c', rels).attr( 's', '2' ); // bold
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
// Set column widths
|
1121
|
+
var cols = _createNode( rels, 'cols' );
|
1122
|
+
$('worksheet', rels).prepend( cols );
|
1123
|
+
|
1124
|
+
for ( var i=0, ien=data.header.length ; i<ien ; i++ ) {
|
1125
|
+
cols.appendChild( _createNode( rels, 'col', {
|
1126
|
+
attr: {
|
1127
|
+
min: i+1,
|
1128
|
+
max: i+1,
|
1129
|
+
width: _excelColWidth( data, i ),
|
1130
|
+
customWidth: 1
|
1131
|
+
}
|
1132
|
+
} ) );
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
// Let the developer customise the document if they want to
|
1136
|
+
if ( config.customize ) {
|
1137
|
+
config.customize( xlsx );
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
var zip = new jsZip();
|
1141
|
+
var zipConfig = {
|
1142
|
+
type: 'blob',
|
1143
|
+
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
1144
|
+
};
|
1145
|
+
|
1146
|
+
_addToZip( zip, xlsx );
|
1147
|
+
|
1148
|
+
if ( zip.generateAsync ) {
|
1149
|
+
// JSZip 3+
|
1150
|
+
zip
|
1151
|
+
.generateAsync( zipConfig )
|
1152
|
+
.then( function ( blob ) {
|
1153
|
+
_saveAs( blob, _filename( config ) );
|
1154
|
+
} );
|
1155
|
+
}
|
1156
|
+
else {
|
1157
|
+
// JSZip 2.5
|
1158
|
+
_saveAs(
|
1159
|
+
zip.generate( zipConfig ),
|
1160
|
+
_filename( config )
|
1161
|
+
);
|
1162
|
+
}
|
1163
|
+
},
|
1164
|
+
|
1165
|
+
filename: '*',
|
1166
|
+
|
1167
|
+
extension: '.xlsx',
|
1168
|
+
|
1169
|
+
exportOptions: {},
|
1170
|
+
|
1171
|
+
header: true,
|
1172
|
+
|
1173
|
+
footer: false
|
1174
|
+
};
|
1175
|
+
|
1176
|
+
//
|
1177
|
+
// PDF export - using pdfMake - http://pdfmake.org
|
1178
|
+
//
|
1179
|
+
DataTable.ext.buttons.pdfHtml5 = {
|
1180
|
+
className: 'buttons-pdf buttons-html5',
|
1181
|
+
|
1182
|
+
available: function () {
|
1183
|
+
return window.FileReader !== undefined && pdfMake;
|
1184
|
+
},
|
1185
|
+
|
1186
|
+
text: function ( dt ) {
|
1187
|
+
return dt.i18n( 'buttons.pdf', 'PDF' );
|
1188
|
+
},
|
1189
|
+
|
1190
|
+
action: function ( e, dt, button, config ) {
|
1191
|
+
var newLine = _newLine( config );
|
1192
|
+
var data = dt.buttons.exportData( config.exportOptions );
|
1193
|
+
var rows = [];
|
1194
|
+
|
1195
|
+
if ( config.header ) {
|
1196
|
+
rows.push( $.map( data.header, function ( d ) {
|
1197
|
+
return {
|
1198
|
+
text: typeof d === 'string' ? d : d+'',
|
1199
|
+
style: 'tableHeader'
|
1200
|
+
};
|
1201
|
+
} ) );
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
|
1205
|
+
rows.push( $.map( data.body[i], function ( d ) {
|
1206
|
+
return {
|
1207
|
+
text: typeof d === 'string' ? d : d+'',
|
1208
|
+
style: i % 2 ? 'tableBodyEven' : 'tableBodyOdd'
|
1209
|
+
};
|
1210
|
+
} ) );
|
1211
|
+
}
|
1212
|
+
|
1213
|
+
if ( config.footer && data.footer) {
|
1214
|
+
rows.push( $.map( data.footer, function ( d ) {
|
1215
|
+
return {
|
1216
|
+
text: typeof d === 'string' ? d : d+'',
|
1217
|
+
style: 'tableFooter'
|
1218
|
+
};
|
1219
|
+
} ) );
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
var doc = {
|
1223
|
+
pageSize: config.pageSize,
|
1224
|
+
pageOrientation: config.orientation,
|
1225
|
+
content: [
|
1226
|
+
{
|
1227
|
+
table: {
|
1228
|
+
headerRows: 1,
|
1229
|
+
body: rows
|
1230
|
+
},
|
1231
|
+
layout: 'noBorders'
|
1232
|
+
}
|
1233
|
+
],
|
1234
|
+
styles: {
|
1235
|
+
tableHeader: {
|
1236
|
+
bold: true,
|
1237
|
+
fontSize: 11,
|
1238
|
+
color: 'white',
|
1239
|
+
fillColor: '#2d4154',
|
1240
|
+
alignment: 'center'
|
1241
|
+
},
|
1242
|
+
tableBodyEven: {},
|
1243
|
+
tableBodyOdd: {
|
1244
|
+
fillColor: '#f3f3f3'
|
1245
|
+
},
|
1246
|
+
tableFooter: {
|
1247
|
+
bold: true,
|
1248
|
+
fontSize: 11,
|
1249
|
+
color: 'white',
|
1250
|
+
fillColor: '#2d4154'
|
1251
|
+
},
|
1252
|
+
title: {
|
1253
|
+
alignment: 'center',
|
1254
|
+
fontSize: 15
|
1255
|
+
},
|
1256
|
+
message: {}
|
1257
|
+
},
|
1258
|
+
defaultStyle: {
|
1259
|
+
fontSize: 10
|
1260
|
+
}
|
1261
|
+
};
|
1262
|
+
|
1263
|
+
if ( config.message ) {
|
1264
|
+
doc.content.unshift( {
|
1265
|
+
text: config.message,
|
1266
|
+
style: 'message',
|
1267
|
+
margin: [ 0, 0, 0, 12 ]
|
1268
|
+
} );
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
if ( config.title ) {
|
1272
|
+
doc.content.unshift( {
|
1273
|
+
text: _title( config, false ),
|
1274
|
+
style: 'title',
|
1275
|
+
margin: [ 0, 0, 0, 12 ]
|
1276
|
+
} );
|
1277
|
+
}
|
1278
|
+
|
1279
|
+
if ( config.customize ) {
|
1280
|
+
config.customize( doc, config );
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
var pdf = pdfMake.createPdf( doc );
|
1284
|
+
|
1285
|
+
if ( config.download === 'open' && ! _isSafari() ) {
|
1286
|
+
pdf.open();
|
1287
|
+
}
|
1288
|
+
else {
|
1289
|
+
pdf.getBuffer( function (buffer) {
|
1290
|
+
var blob = new Blob( [buffer], {type:'application/pdf'} );
|
1291
|
+
|
1292
|
+
_saveAs( blob, _filename( config ) );
|
1293
|
+
} );
|
1294
|
+
}
|
1295
|
+
},
|
1296
|
+
|
1297
|
+
title: '*',
|
1298
|
+
|
1299
|
+
filename: '*',
|
1300
|
+
|
1301
|
+
extension: '.pdf',
|
1302
|
+
|
1303
|
+
exportOptions: {},
|
1304
|
+
|
1305
|
+
orientation: 'portrait',
|
1306
|
+
|
1307
|
+
pageSize: 'A4',
|
1308
|
+
|
1309
|
+
header: true,
|
1310
|
+
|
1311
|
+
footer: false,
|
1312
|
+
|
1313
|
+
message: null,
|
1314
|
+
|
1315
|
+
customize: null,
|
1316
|
+
|
1317
|
+
download: 'download'
|
1318
|
+
};
|
1319
|
+
|
1320
|
+
|
1321
|
+
return DataTable.Buttons;
|
1322
|
+
}));
|