jquery-datatables 1.10.12
Sign up to get free protection for your applications and to get access to all the features.
- 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,68 @@
|
|
1
|
+
/*! Bootstrap 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-bs', '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-bs')(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
|
+
$.extend( true, DataTable.Buttons.defaults, {
|
40
|
+
dom: {
|
41
|
+
container: {
|
42
|
+
className: 'dt-buttons btn-group'
|
43
|
+
},
|
44
|
+
button: {
|
45
|
+
className: 'btn btn-default'
|
46
|
+
},
|
47
|
+
collection: {
|
48
|
+
tag: 'ul',
|
49
|
+
className: 'dt-button-collection dropdown-menu',
|
50
|
+
button: {
|
51
|
+
tag: 'li',
|
52
|
+
className: 'dt-button'
|
53
|
+
},
|
54
|
+
buttonLiner: {
|
55
|
+
tag: 'a',
|
56
|
+
className: ''
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
} );
|
61
|
+
|
62
|
+
DataTable.ext.buttons.collection.text = function ( dt ) {
|
63
|
+
return dt.i18n('buttons.collection', 'Collection <span class="caret"/>');
|
64
|
+
};
|
65
|
+
|
66
|
+
|
67
|
+
return DataTable.Buttons;
|
68
|
+
}));
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/*! Bootstrap 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-bs4', '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-bs4')(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
|
+
$.extend( true, DataTable.Buttons.defaults, {
|
39
|
+
dom: {
|
40
|
+
container: {
|
41
|
+
className: 'dt-buttons btn-group'
|
42
|
+
},
|
43
|
+
button: {
|
44
|
+
className: 'btn btn-secondary'
|
45
|
+
},
|
46
|
+
collection: {
|
47
|
+
tag: 'div',
|
48
|
+
className: 'dt-button-collection dropdown-menu',
|
49
|
+
button: {
|
50
|
+
tag: 'a',
|
51
|
+
className: 'dt-button dropdown-item'
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
} );
|
56
|
+
|
57
|
+
DataTable.ext.buttons.collection.className += ' dropdown-toggle';
|
58
|
+
|
59
|
+
return DataTable.Buttons;
|
60
|
+
}));
|
@@ -0,0 +1,199 @@
|
|
1
|
+
/*!
|
2
|
+
* Column visibility buttons for Buttons and DataTables.
|
3
|
+
* 2016 SpryMedia Ltd - datatables.net/license
|
4
|
+
*/
|
5
|
+
|
6
|
+
(function( factory ){
|
7
|
+
if ( typeof define === 'function' && define.amd ) {
|
8
|
+
// AMD
|
9
|
+
define( ['jquery', 'datatables.net', 'datatables.net-buttons'], function ( $ ) {
|
10
|
+
return factory( $, window, document );
|
11
|
+
} );
|
12
|
+
}
|
13
|
+
else if ( typeof exports === 'object' ) {
|
14
|
+
// CommonJS
|
15
|
+
module.exports = function (root, $) {
|
16
|
+
if ( ! root ) {
|
17
|
+
root = window;
|
18
|
+
}
|
19
|
+
|
20
|
+
if ( ! $ || ! $.fn.dataTable ) {
|
21
|
+
$ = require('datatables.net')(root, $).$;
|
22
|
+
}
|
23
|
+
|
24
|
+
if ( ! $.fn.dataTable.Buttons ) {
|
25
|
+
require('datatables.net-buttons')(root, $);
|
26
|
+
}
|
27
|
+
|
28
|
+
return factory( $, root, root.document );
|
29
|
+
};
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
// Browser
|
33
|
+
factory( jQuery, window, document );
|
34
|
+
}
|
35
|
+
}(function( $, window, document, undefined ) {
|
36
|
+
'use strict';
|
37
|
+
var DataTable = $.fn.dataTable;
|
38
|
+
|
39
|
+
|
40
|
+
$.extend( DataTable.ext.buttons, {
|
41
|
+
// A collection of column visibility buttons
|
42
|
+
colvis: function ( dt, conf ) {
|
43
|
+
return {
|
44
|
+
extend: 'collection',
|
45
|
+
text: function ( dt ) {
|
46
|
+
return dt.i18n( 'buttons.colvis', 'Column visibility' );
|
47
|
+
},
|
48
|
+
className: 'buttons-colvis',
|
49
|
+
buttons: [ {
|
50
|
+
extend: 'columnsToggle',
|
51
|
+
columns: conf.columns
|
52
|
+
} ]
|
53
|
+
};
|
54
|
+
},
|
55
|
+
|
56
|
+
// Selected columns with individual buttons - toggle column visibility
|
57
|
+
columnsToggle: function ( dt, conf ) {
|
58
|
+
var columns = dt.columns( conf.columns ).indexes().map( function ( idx ) {
|
59
|
+
return {
|
60
|
+
extend: 'columnToggle',
|
61
|
+
columns: idx
|
62
|
+
};
|
63
|
+
} ).toArray();
|
64
|
+
|
65
|
+
return columns;
|
66
|
+
},
|
67
|
+
|
68
|
+
// Single button to toggle column visibility
|
69
|
+
columnToggle: function ( dt, conf ) {
|
70
|
+
return {
|
71
|
+
extend: 'columnVisibility',
|
72
|
+
columns: conf.columns
|
73
|
+
};
|
74
|
+
},
|
75
|
+
|
76
|
+
// Selected columns with individual buttons - set column visibility
|
77
|
+
columnsVisibility: function ( dt, conf ) {
|
78
|
+
var columns = dt.columns( conf.columns ).indexes().map( function ( idx ) {
|
79
|
+
return {
|
80
|
+
extend: 'columnVisibility',
|
81
|
+
columns: idx,
|
82
|
+
visibility: conf.visibility
|
83
|
+
};
|
84
|
+
} ).toArray();
|
85
|
+
|
86
|
+
return columns;
|
87
|
+
},
|
88
|
+
|
89
|
+
// Single button to set column visibility
|
90
|
+
columnVisibility: {
|
91
|
+
columns: undefined, // column selector
|
92
|
+
text: function ( dt, button, conf ) {
|
93
|
+
return conf._columnText( dt, conf.columns );
|
94
|
+
},
|
95
|
+
className: 'buttons-columnVisibility',
|
96
|
+
action: function ( e, dt, button, conf ) {
|
97
|
+
var col = dt.columns( conf.columns );
|
98
|
+
var curr = col.visible();
|
99
|
+
|
100
|
+
col.visible( conf.visibility !== undefined ?
|
101
|
+
conf.visibility :
|
102
|
+
! (curr.length ? curr[0] : false )
|
103
|
+
);
|
104
|
+
},
|
105
|
+
init: function ( dt, button, conf ) {
|
106
|
+
var that = this;
|
107
|
+
var col = dt.column( conf.columns );
|
108
|
+
|
109
|
+
dt
|
110
|
+
.on( 'column-visibility.dt'+conf.namespace, function (e, settings) {
|
111
|
+
if ( ! settings.bDestroying ) {
|
112
|
+
that.active( col.visible() );
|
113
|
+
}
|
114
|
+
} )
|
115
|
+
.on( 'column-reorder.dt'+conf.namespace, function (e, settings, details) {
|
116
|
+
// Don't rename buttons based on column name if the button
|
117
|
+
// controls more than one column!
|
118
|
+
if ( dt.columns( conf.columns ).count() !== 1 ) {
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
|
122
|
+
if ( typeof conf.columns === 'number' ) {
|
123
|
+
conf.columns = details.mapping[ conf.columns ];
|
124
|
+
}
|
125
|
+
|
126
|
+
var col = dt.column( conf.columns );
|
127
|
+
|
128
|
+
that.text( conf._columnText( dt, conf.columns ) );
|
129
|
+
that.active( col.visible() );
|
130
|
+
} );
|
131
|
+
|
132
|
+
this.active( col.visible() );
|
133
|
+
},
|
134
|
+
destroy: function ( dt, button, conf ) {
|
135
|
+
dt
|
136
|
+
.off( 'column-visibility.dt'+conf.namespace )
|
137
|
+
.off( 'column-reorder.dt'+conf.namespace );
|
138
|
+
},
|
139
|
+
|
140
|
+
_columnText: function ( dt, col ) {
|
141
|
+
// Use DataTables' internal data structure until this is presented
|
142
|
+
// is a public API. The other option is to use
|
143
|
+
// `$( column(col).node() ).text()` but the node might not have been
|
144
|
+
// populated when Buttons is constructed.
|
145
|
+
var idx = dt.column( col ).index();
|
146
|
+
return dt.settings()[0].aoColumns[ idx ].sTitle
|
147
|
+
.replace(/\n/g," ") // remove new lines
|
148
|
+
.replace( /<.*?>/g, "" ) // strip HTML
|
149
|
+
.replace(/^\s+|\s+$/g,""); // trim
|
150
|
+
}
|
151
|
+
},
|
152
|
+
|
153
|
+
|
154
|
+
colvisRestore: {
|
155
|
+
className: 'buttons-colvisRestore',
|
156
|
+
|
157
|
+
text: function ( dt ) {
|
158
|
+
return dt.i18n( 'buttons.colvisRestore', 'Restore visibility' );
|
159
|
+
},
|
160
|
+
|
161
|
+
init: function ( dt, button, conf ) {
|
162
|
+
conf._visOriginal = dt.columns().indexes().map( function ( idx ) {
|
163
|
+
return dt.column( idx ).visible();
|
164
|
+
} ).toArray();
|
165
|
+
},
|
166
|
+
|
167
|
+
action: function ( e, dt, button, conf ) {
|
168
|
+
dt.columns().every( function ( i ) {
|
169
|
+
// Take into account that ColReorder might have disrupted our
|
170
|
+
// indexes
|
171
|
+
var idx = dt.colReorder && dt.colReorder.transpose ?
|
172
|
+
dt.colReorder.transpose( i, 'toOriginal' ) :
|
173
|
+
i;
|
174
|
+
|
175
|
+
this.visible( conf._visOriginal[ idx ] );
|
176
|
+
} );
|
177
|
+
}
|
178
|
+
},
|
179
|
+
|
180
|
+
|
181
|
+
colvisGroup: {
|
182
|
+
className: 'buttons-colvisGroup',
|
183
|
+
|
184
|
+
action: function ( e, dt, button, conf ) {
|
185
|
+
dt.columns( conf.show ).visible( true, false );
|
186
|
+
dt.columns( conf.hide ).visible( false, false );
|
187
|
+
|
188
|
+
dt.columns.adjust();
|
189
|
+
},
|
190
|
+
|
191
|
+
show: [],
|
192
|
+
|
193
|
+
hide: []
|
194
|
+
}
|
195
|
+
} );
|
196
|
+
|
197
|
+
|
198
|
+
return DataTable.Buttons;
|
199
|
+
}));
|
@@ -0,0 +1,1325 @@
|
|
1
|
+
/*!
|
2
|
+
* Flash export buttons for Buttons and DataTables.
|
3
|
+
* 2015 SpryMedia Ltd - datatables.net/license
|
4
|
+
*
|
5
|
+
* ZeroClipbaord - MIT license
|
6
|
+
* Copyright (c) 2012 Joseph Huckaby
|
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, $) {
|
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 );
|
32
|
+
};
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
// Browser
|
36
|
+
factory( jQuery, window, document );
|
37
|
+
}
|
38
|
+
}(function( $, window, document, undefined ) {
|
39
|
+
'use strict';
|
40
|
+
var DataTable = $.fn.dataTable;
|
41
|
+
|
42
|
+
|
43
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
44
|
+
* ZeroClipboard dependency
|
45
|
+
*/
|
46
|
+
|
47
|
+
/*
|
48
|
+
* ZeroClipboard 1.0.4 with modifications
|
49
|
+
* Author: Joseph Huckaby
|
50
|
+
* License: MIT
|
51
|
+
*
|
52
|
+
* Copyright (c) 2012 Joseph Huckaby
|
53
|
+
*/
|
54
|
+
var ZeroClipboard_TableTools = {
|
55
|
+
version: "1.0.4-TableTools2",
|
56
|
+
clients: {}, // registered upload clients on page, indexed by id
|
57
|
+
moviePath: '', // URL to movie
|
58
|
+
nextId: 1, // ID of next movie
|
59
|
+
|
60
|
+
$: function(thingy) {
|
61
|
+
// simple DOM lookup utility function
|
62
|
+
if (typeof(thingy) == 'string') {
|
63
|
+
thingy = document.getElementById(thingy);
|
64
|
+
}
|
65
|
+
if (!thingy.addClass) {
|
66
|
+
// extend element with a few useful methods
|
67
|
+
thingy.hide = function() { this.style.display = 'none'; };
|
68
|
+
thingy.show = function() { this.style.display = ''; };
|
69
|
+
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
|
70
|
+
thingy.removeClass = function(name) {
|
71
|
+
this.className = this.className.replace( new RegExp("\\s*" + name + "\\s*"), " ").replace(/^\s+/, '').replace(/\s+$/, '');
|
72
|
+
};
|
73
|
+
thingy.hasClass = function(name) {
|
74
|
+
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
|
75
|
+
};
|
76
|
+
}
|
77
|
+
return thingy;
|
78
|
+
},
|
79
|
+
|
80
|
+
setMoviePath: function(path) {
|
81
|
+
// set path to ZeroClipboard.swf
|
82
|
+
this.moviePath = path;
|
83
|
+
},
|
84
|
+
|
85
|
+
dispatch: function(id, eventName, args) {
|
86
|
+
// receive event from flash movie, send to client
|
87
|
+
var client = this.clients[id];
|
88
|
+
if (client) {
|
89
|
+
client.receiveEvent(eventName, args);
|
90
|
+
}
|
91
|
+
},
|
92
|
+
|
93
|
+
log: function ( str ) {
|
94
|
+
console.log( 'Flash: '+str );
|
95
|
+
},
|
96
|
+
|
97
|
+
register: function(id, client) {
|
98
|
+
// register new client to receive events
|
99
|
+
this.clients[id] = client;
|
100
|
+
},
|
101
|
+
|
102
|
+
getDOMObjectPosition: function(obj) {
|
103
|
+
// get absolute coordinates for dom element
|
104
|
+
var info = {
|
105
|
+
left: 0,
|
106
|
+
top: 0,
|
107
|
+
width: obj.width ? obj.width : obj.offsetWidth,
|
108
|
+
height: obj.height ? obj.height : obj.offsetHeight
|
109
|
+
};
|
110
|
+
|
111
|
+
if ( obj.style.width !== "" ) {
|
112
|
+
info.width = obj.style.width.replace("px","");
|
113
|
+
}
|
114
|
+
|
115
|
+
if ( obj.style.height !== "" ) {
|
116
|
+
info.height = obj.style.height.replace("px","");
|
117
|
+
}
|
118
|
+
|
119
|
+
while (obj) {
|
120
|
+
info.left += obj.offsetLeft;
|
121
|
+
info.top += obj.offsetTop;
|
122
|
+
obj = obj.offsetParent;
|
123
|
+
}
|
124
|
+
|
125
|
+
return info;
|
126
|
+
},
|
127
|
+
|
128
|
+
Client: function(elem) {
|
129
|
+
// constructor for new simple upload client
|
130
|
+
this.handlers = {};
|
131
|
+
|
132
|
+
// unique ID
|
133
|
+
this.id = ZeroClipboard_TableTools.nextId++;
|
134
|
+
this.movieId = 'ZeroClipboard_TableToolsMovie_' + this.id;
|
135
|
+
|
136
|
+
// register client with singleton to receive flash events
|
137
|
+
ZeroClipboard_TableTools.register(this.id, this);
|
138
|
+
|
139
|
+
// create movie
|
140
|
+
if (elem) {
|
141
|
+
this.glue(elem);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|
146
|
+
ZeroClipboard_TableTools.Client.prototype = {
|
147
|
+
|
148
|
+
id: 0, // unique ID for us
|
149
|
+
ready: false, // whether movie is ready to receive events or not
|
150
|
+
movie: null, // reference to movie object
|
151
|
+
clipText: '', // text to copy to clipboard
|
152
|
+
fileName: '', // default file save name
|
153
|
+
action: 'copy', // action to perform
|
154
|
+
handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
|
155
|
+
cssEffects: true, // enable CSS mouse effects on dom container
|
156
|
+
handlers: null, // user event handlers
|
157
|
+
sized: false,
|
158
|
+
sheetName: '', // default sheet name for excel export
|
159
|
+
|
160
|
+
glue: function(elem, title) {
|
161
|
+
// glue to DOM element
|
162
|
+
// elem can be ID or actual DOM element object
|
163
|
+
this.domElement = ZeroClipboard_TableTools.$(elem);
|
164
|
+
|
165
|
+
// float just above object, or zIndex 99 if dom element isn't set
|
166
|
+
var zIndex = 99;
|
167
|
+
if (this.domElement.style.zIndex) {
|
168
|
+
zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
|
169
|
+
}
|
170
|
+
|
171
|
+
// find X/Y position of domElement
|
172
|
+
var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
|
173
|
+
|
174
|
+
// create floating DIV above element
|
175
|
+
this.div = document.createElement('div');
|
176
|
+
var style = this.div.style;
|
177
|
+
style.position = 'absolute';
|
178
|
+
style.left = '0px';
|
179
|
+
style.top = '0px';
|
180
|
+
style.width = (box.width) + 'px';
|
181
|
+
style.height = box.height + 'px';
|
182
|
+
style.zIndex = zIndex;
|
183
|
+
|
184
|
+
if ( typeof title != "undefined" && title !== "" ) {
|
185
|
+
this.div.title = title;
|
186
|
+
}
|
187
|
+
if ( box.width !== 0 && box.height !== 0 ) {
|
188
|
+
this.sized = true;
|
189
|
+
}
|
190
|
+
|
191
|
+
// style.backgroundColor = '#f00'; // debug
|
192
|
+
if ( this.domElement ) {
|
193
|
+
this.domElement.appendChild(this.div);
|
194
|
+
this.div.innerHTML = this.getHTML( box.width, box.height ).replace(/&/g, '&');
|
195
|
+
}
|
196
|
+
},
|
197
|
+
|
198
|
+
positionElement: function() {
|
199
|
+
var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
|
200
|
+
var style = this.div.style;
|
201
|
+
|
202
|
+
style.position = 'absolute';
|
203
|
+
//style.left = (this.domElement.offsetLeft)+'px';
|
204
|
+
//style.top = this.domElement.offsetTop+'px';
|
205
|
+
style.width = box.width + 'px';
|
206
|
+
style.height = box.height + 'px';
|
207
|
+
|
208
|
+
if ( box.width !== 0 && box.height !== 0 ) {
|
209
|
+
this.sized = true;
|
210
|
+
} else {
|
211
|
+
return;
|
212
|
+
}
|
213
|
+
|
214
|
+
var flash = this.div.childNodes[0];
|
215
|
+
flash.width = box.width;
|
216
|
+
flash.height = box.height;
|
217
|
+
},
|
218
|
+
|
219
|
+
getHTML: function(width, height) {
|
220
|
+
// return HTML for movie
|
221
|
+
var html = '';
|
222
|
+
var flashvars = 'id=' + this.id +
|
223
|
+
'&width=' + width +
|
224
|
+
'&height=' + height;
|
225
|
+
|
226
|
+
if (navigator.userAgent.match(/MSIE/)) {
|
227
|
+
// IE gets an OBJECT tag
|
228
|
+
var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
|
229
|
+
html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard_TableTools.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
|
230
|
+
}
|
231
|
+
else {
|
232
|
+
// all other browsers get an EMBED tag
|
233
|
+
html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard_TableTools.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
|
234
|
+
}
|
235
|
+
return html;
|
236
|
+
},
|
237
|
+
|
238
|
+
hide: function() {
|
239
|
+
// temporarily hide floater offscreen
|
240
|
+
if (this.div) {
|
241
|
+
this.div.style.left = '-2000px';
|
242
|
+
}
|
243
|
+
},
|
244
|
+
|
245
|
+
show: function() {
|
246
|
+
// show ourselves after a call to hide()
|
247
|
+
this.reposition();
|
248
|
+
},
|
249
|
+
|
250
|
+
destroy: function() {
|
251
|
+
// destroy control and floater
|
252
|
+
var that = this;
|
253
|
+
|
254
|
+
if (this.domElement && this.div) {
|
255
|
+
$(this.div).remove();
|
256
|
+
|
257
|
+
this.domElement = null;
|
258
|
+
this.div = null;
|
259
|
+
|
260
|
+
$.each( ZeroClipboard_TableTools.clients, function ( id, client ) {
|
261
|
+
if ( client === that ) {
|
262
|
+
delete ZeroClipboard_TableTools.clients[ id ];
|
263
|
+
}
|
264
|
+
} );
|
265
|
+
}
|
266
|
+
},
|
267
|
+
|
268
|
+
reposition: function(elem) {
|
269
|
+
// reposition our floating div, optionally to new container
|
270
|
+
// warning: container CANNOT change size, only position
|
271
|
+
if (elem) {
|
272
|
+
this.domElement = ZeroClipboard_TableTools.$(elem);
|
273
|
+
if (!this.domElement) {
|
274
|
+
this.hide();
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
if (this.domElement && this.div) {
|
279
|
+
var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
|
280
|
+
var style = this.div.style;
|
281
|
+
style.left = '' + box.left + 'px';
|
282
|
+
style.top = '' + box.top + 'px';
|
283
|
+
}
|
284
|
+
},
|
285
|
+
|
286
|
+
clearText: function() {
|
287
|
+
// clear the text to be copy / saved
|
288
|
+
this.clipText = '';
|
289
|
+
if (this.ready) {
|
290
|
+
this.movie.clearText();
|
291
|
+
}
|
292
|
+
},
|
293
|
+
|
294
|
+
appendText: function(newText) {
|
295
|
+
// append text to that which is to be copied / saved
|
296
|
+
this.clipText += newText;
|
297
|
+
if (this.ready) { this.movie.appendText(newText) ;}
|
298
|
+
},
|
299
|
+
|
300
|
+
setText: function(newText) {
|
301
|
+
// set text to be copied to be copied / saved
|
302
|
+
this.clipText = newText;
|
303
|
+
if (this.ready) { this.movie.setText(newText) ;}
|
304
|
+
},
|
305
|
+
|
306
|
+
setFileName: function(newText) {
|
307
|
+
// set the file name
|
308
|
+
this.fileName = newText;
|
309
|
+
if (this.ready) {
|
310
|
+
this.movie.setFileName(newText);
|
311
|
+
}
|
312
|
+
},
|
313
|
+
|
314
|
+
setSheetData: function(data) {
|
315
|
+
// set the xlsx sheet data
|
316
|
+
if (this.ready) {
|
317
|
+
this.movie.setSheetData( JSON.stringify( data ) );
|
318
|
+
}
|
319
|
+
},
|
320
|
+
|
321
|
+
setAction: function(newText) {
|
322
|
+
// set action (save or copy)
|
323
|
+
this.action = newText;
|
324
|
+
if (this.ready) {
|
325
|
+
this.movie.setAction(newText);
|
326
|
+
}
|
327
|
+
},
|
328
|
+
|
329
|
+
addEventListener: function(eventName, func) {
|
330
|
+
// add user event listener for event
|
331
|
+
// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
|
332
|
+
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
|
333
|
+
if (!this.handlers[eventName]) {
|
334
|
+
this.handlers[eventName] = [];
|
335
|
+
}
|
336
|
+
this.handlers[eventName].push(func);
|
337
|
+
},
|
338
|
+
|
339
|
+
setHandCursor: function(enabled) {
|
340
|
+
// enable hand cursor (true), or default arrow cursor (false)
|
341
|
+
this.handCursorEnabled = enabled;
|
342
|
+
if (this.ready) {
|
343
|
+
this.movie.setHandCursor(enabled);
|
344
|
+
}
|
345
|
+
},
|
346
|
+
|
347
|
+
setCSSEffects: function(enabled) {
|
348
|
+
// enable or disable CSS effects on DOM container
|
349
|
+
this.cssEffects = !!enabled;
|
350
|
+
},
|
351
|
+
|
352
|
+
receiveEvent: function(eventName, args) {
|
353
|
+
var self;
|
354
|
+
|
355
|
+
// receive event from flash
|
356
|
+
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
|
357
|
+
|
358
|
+
// special behavior for certain events
|
359
|
+
switch (eventName) {
|
360
|
+
case 'load':
|
361
|
+
// movie claims it is ready, but in IE this isn't always the case...
|
362
|
+
// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
|
363
|
+
this.movie = document.getElementById(this.movieId);
|
364
|
+
if (!this.movie) {
|
365
|
+
self = this;
|
366
|
+
setTimeout( function() { self.receiveEvent('load', null); }, 1 );
|
367
|
+
return;
|
368
|
+
}
|
369
|
+
|
370
|
+
// firefox on pc needs a "kick" in order to set these in certain cases
|
371
|
+
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
|
372
|
+
self = this;
|
373
|
+
setTimeout( function() { self.receiveEvent('load', null); }, 100 );
|
374
|
+
this.ready = true;
|
375
|
+
return;
|
376
|
+
}
|
377
|
+
|
378
|
+
this.ready = true;
|
379
|
+
this.movie.clearText();
|
380
|
+
this.movie.appendText( this.clipText );
|
381
|
+
this.movie.setFileName( this.fileName );
|
382
|
+
this.movie.setAction( this.action );
|
383
|
+
this.movie.setHandCursor( this.handCursorEnabled );
|
384
|
+
break;
|
385
|
+
|
386
|
+
case 'mouseover':
|
387
|
+
if (this.domElement && this.cssEffects) {
|
388
|
+
//this.domElement.addClass('hover');
|
389
|
+
if (this.recoverActive) {
|
390
|
+
this.domElement.addClass('active');
|
391
|
+
}
|
392
|
+
}
|
393
|
+
break;
|
394
|
+
|
395
|
+
case 'mouseout':
|
396
|
+
if (this.domElement && this.cssEffects) {
|
397
|
+
this.recoverActive = false;
|
398
|
+
if (this.domElement.hasClass('active')) {
|
399
|
+
this.domElement.removeClass('active');
|
400
|
+
this.recoverActive = true;
|
401
|
+
}
|
402
|
+
//this.domElement.removeClass('hover');
|
403
|
+
}
|
404
|
+
break;
|
405
|
+
|
406
|
+
case 'mousedown':
|
407
|
+
if (this.domElement && this.cssEffects) {
|
408
|
+
this.domElement.addClass('active');
|
409
|
+
}
|
410
|
+
break;
|
411
|
+
|
412
|
+
case 'mouseup':
|
413
|
+
if (this.domElement && this.cssEffects) {
|
414
|
+
this.domElement.removeClass('active');
|
415
|
+
this.recoverActive = false;
|
416
|
+
}
|
417
|
+
break;
|
418
|
+
} // switch eventName
|
419
|
+
|
420
|
+
if (this.handlers[eventName]) {
|
421
|
+
for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
|
422
|
+
var func = this.handlers[eventName][idx];
|
423
|
+
|
424
|
+
if (typeof(func) == 'function') {
|
425
|
+
// actual function reference
|
426
|
+
func(this, args);
|
427
|
+
}
|
428
|
+
else if ((typeof(func) == 'object') && (func.length == 2)) {
|
429
|
+
// PHP style object + method, i.e. [myObject, 'myMethod']
|
430
|
+
func[0][ func[1] ](this, args);
|
431
|
+
}
|
432
|
+
else if (typeof(func) == 'string') {
|
433
|
+
// name of function
|
434
|
+
window[func](this, args);
|
435
|
+
}
|
436
|
+
} // foreach event handler defined
|
437
|
+
} // user defined handler for event
|
438
|
+
}
|
439
|
+
};
|
440
|
+
|
441
|
+
ZeroClipboard_TableTools.hasFlash = function ()
|
442
|
+
{
|
443
|
+
try {
|
444
|
+
var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
|
445
|
+
if (fo) {
|
446
|
+
return true;
|
447
|
+
}
|
448
|
+
}
|
449
|
+
catch (e) {
|
450
|
+
if (
|
451
|
+
navigator.mimeTypes &&
|
452
|
+
navigator.mimeTypes['application/x-shockwave-flash'] !== undefined &&
|
453
|
+
navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin
|
454
|
+
) {
|
455
|
+
return true;
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
return false;
|
460
|
+
};
|
461
|
+
|
462
|
+
// For the Flash binding to work, ZeroClipboard_TableTools must be on the global
|
463
|
+
// object list
|
464
|
+
window.ZeroClipboard_TableTools = ZeroClipboard_TableTools;
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
469
|
+
* Local (private) functions
|
470
|
+
*/
|
471
|
+
|
472
|
+
/**
|
473
|
+
* If a Buttons instance is initlaised before it is placed into the DOM, Flash
|
474
|
+
* won't be able to bind to it, so we need to wait until it is available, this
|
475
|
+
* method abstracts that out.
|
476
|
+
*
|
477
|
+
* @param {ZeroClipboard} flash ZeroClipboard instance
|
478
|
+
* @param {jQuery} node Button
|
479
|
+
*/
|
480
|
+
var _glue = function ( flash, node )
|
481
|
+
{
|
482
|
+
var id = node.attr('id');
|
483
|
+
|
484
|
+
if ( node.parents('html').length ) {
|
485
|
+
flash.glue( node[0], '' );
|
486
|
+
}
|
487
|
+
else {
|
488
|
+
setTimeout( function () {
|
489
|
+
_glue( flash, node );
|
490
|
+
}, 500 );
|
491
|
+
}
|
492
|
+
};
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Get the file name for an exported file.
|
496
|
+
*
|
497
|
+
* @param {object} config Button configuration
|
498
|
+
* @param {boolean} incExtension Include the file name extension
|
499
|
+
*/
|
500
|
+
var _filename = function ( config, incExtension )
|
501
|
+
{
|
502
|
+
// Backwards compatibility
|
503
|
+
var filename = config.filename === '*' && config.title !== '*' && config.title !== undefined ?
|
504
|
+
config.title :
|
505
|
+
config.filename;
|
506
|
+
|
507
|
+
if ( typeof filename === 'function' ) {
|
508
|
+
filename = filename();
|
509
|
+
}
|
510
|
+
|
511
|
+
if ( filename.indexOf( '*' ) !== -1 ) {
|
512
|
+
filename = $.trim( filename.replace( '*', $('title').text() ) );
|
513
|
+
}
|
514
|
+
|
515
|
+
// Strip characters which the OS will object to
|
516
|
+
filename = filename.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
|
517
|
+
|
518
|
+
return incExtension === undefined || incExtension === true ?
|
519
|
+
filename+config.extension :
|
520
|
+
filename;
|
521
|
+
};
|
522
|
+
|
523
|
+
/**
|
524
|
+
* Get the sheet name for Excel exports.
|
525
|
+
*
|
526
|
+
* @param {object} config Button configuration
|
527
|
+
*/
|
528
|
+
var _sheetname = function ( config )
|
529
|
+
{
|
530
|
+
var sheetName = 'Sheet1';
|
531
|
+
|
532
|
+
if ( config.sheetName ) {
|
533
|
+
sheetName = config.sheetName.replace(/[\[\]\*\/\\\?\:]/g, '');
|
534
|
+
}
|
535
|
+
|
536
|
+
return sheetName;
|
537
|
+
};
|
538
|
+
|
539
|
+
/**
|
540
|
+
* Get the title for an exported file.
|
541
|
+
*
|
542
|
+
* @param {object} config Button configuration
|
543
|
+
*/
|
544
|
+
var _title = function ( config )
|
545
|
+
{
|
546
|
+
var title = config.title;
|
547
|
+
|
548
|
+
if ( typeof title === 'function' ) {
|
549
|
+
title = title();
|
550
|
+
}
|
551
|
+
|
552
|
+
return title.indexOf( '*' ) !== -1 ?
|
553
|
+
title.replace( '*', $('title').text() || 'Exported data' ) :
|
554
|
+
title;
|
555
|
+
};
|
556
|
+
|
557
|
+
/**
|
558
|
+
* Set the flash text. This has to be broken up into chunks as the Javascript /
|
559
|
+
* Flash bridge has a size limit. There is no indication in the Flash
|
560
|
+
* documentation what this is, and it probably depends upon the browser.
|
561
|
+
* Experimentation shows that the point is around 50k when data starts to get
|
562
|
+
* lost, so an 8K limit used here is safe.
|
563
|
+
*
|
564
|
+
* @param {ZeroClipboard} flash ZeroClipboard instance
|
565
|
+
* @param {string} data Data to send to Flash
|
566
|
+
*/
|
567
|
+
var _setText = function ( flash, data )
|
568
|
+
{
|
569
|
+
var parts = data.match(/[\s\S]{1,8192}/g) || [];
|
570
|
+
|
571
|
+
flash.clearText();
|
572
|
+
for ( var i=0, len=parts.length ; i<len ; i++ )
|
573
|
+
{
|
574
|
+
flash.appendText( parts[i] );
|
575
|
+
}
|
576
|
+
};
|
577
|
+
|
578
|
+
/**
|
579
|
+
* Get the newline character(s)
|
580
|
+
*
|
581
|
+
* @param {object} config Button configuration
|
582
|
+
* @return {string} Newline character
|
583
|
+
*/
|
584
|
+
var _newLine = function ( config )
|
585
|
+
{
|
586
|
+
return config.newline ?
|
587
|
+
config.newline :
|
588
|
+
navigator.userAgent.match(/Windows/) ?
|
589
|
+
'\r\n' :
|
590
|
+
'\n';
|
591
|
+
};
|
592
|
+
|
593
|
+
/**
|
594
|
+
* Combine the data from the `buttons.exportData` method into a string that
|
595
|
+
* will be used in the export file.
|
596
|
+
*
|
597
|
+
* @param {DataTable.Api} dt DataTables API instance
|
598
|
+
* @param {object} config Button configuration
|
599
|
+
* @return {object} The data to export
|
600
|
+
*/
|
601
|
+
var _exportData = function ( dt, config )
|
602
|
+
{
|
603
|
+
var newLine = _newLine( config );
|
604
|
+
var data = dt.buttons.exportData( config.exportOptions );
|
605
|
+
var boundary = config.fieldBoundary;
|
606
|
+
var separator = config.fieldSeparator;
|
607
|
+
var reBoundary = new RegExp( boundary, 'g' );
|
608
|
+
var escapeChar = config.escapeChar !== undefined ?
|
609
|
+
config.escapeChar :
|
610
|
+
'\\';
|
611
|
+
var join = function ( a ) {
|
612
|
+
var s = '';
|
613
|
+
|
614
|
+
// If there is a field boundary, then we might need to escape it in
|
615
|
+
// the source data
|
616
|
+
for ( var i=0, ien=a.length ; i<ien ; i++ ) {
|
617
|
+
if ( i > 0 ) {
|
618
|
+
s += separator;
|
619
|
+
}
|
620
|
+
|
621
|
+
s += boundary ?
|
622
|
+
boundary + ('' + a[i]).replace( reBoundary, escapeChar+boundary ) + boundary :
|
623
|
+
a[i];
|
624
|
+
}
|
625
|
+
|
626
|
+
return s;
|
627
|
+
};
|
628
|
+
|
629
|
+
var header = config.header ? join( data.header )+newLine : '';
|
630
|
+
var footer = config.footer && data.footer ? newLine+join( data.footer ) : '';
|
631
|
+
var body = [];
|
632
|
+
|
633
|
+
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
|
634
|
+
body.push( join( data.body[i] ) );
|
635
|
+
}
|
636
|
+
|
637
|
+
return {
|
638
|
+
str: header + body.join( newLine ) + footer,
|
639
|
+
rows: body.length
|
640
|
+
};
|
641
|
+
};
|
642
|
+
|
643
|
+
|
644
|
+
// Basic initialisation for the buttons is common between them
|
645
|
+
var flashButton = {
|
646
|
+
available: function () {
|
647
|
+
return ZeroClipboard_TableTools.hasFlash();
|
648
|
+
},
|
649
|
+
|
650
|
+
init: function ( dt, button, config ) {
|
651
|
+
// Insert the Flash movie
|
652
|
+
ZeroClipboard_TableTools.moviePath = DataTable.Buttons.swfPath;
|
653
|
+
var flash = new ZeroClipboard_TableTools.Client();
|
654
|
+
|
655
|
+
flash.setHandCursor( true );
|
656
|
+
flash.addEventListener('mouseDown', function(client) {
|
657
|
+
config._fromFlash = true;
|
658
|
+
dt.button( button[0] ).trigger();
|
659
|
+
config._fromFlash = false;
|
660
|
+
} );
|
661
|
+
|
662
|
+
_glue( flash, button );
|
663
|
+
|
664
|
+
config._flash = flash;
|
665
|
+
},
|
666
|
+
|
667
|
+
destroy: function ( dt, button, config ) {
|
668
|
+
config._flash.destroy();
|
669
|
+
},
|
670
|
+
|
671
|
+
fieldSeparator: ',',
|
672
|
+
|
673
|
+
fieldBoundary: '"',
|
674
|
+
|
675
|
+
exportOptions: {},
|
676
|
+
|
677
|
+
title: '*',
|
678
|
+
|
679
|
+
filename: '*',
|
680
|
+
|
681
|
+
extension: '.csv',
|
682
|
+
|
683
|
+
header: true,
|
684
|
+
|
685
|
+
footer: false
|
686
|
+
};
|
687
|
+
|
688
|
+
|
689
|
+
/**
|
690
|
+
* Convert from numeric position to letter for column names in Excel
|
691
|
+
* @param {int} n Column number
|
692
|
+
* @return {string} Column letter(s) name
|
693
|
+
*/
|
694
|
+
function createCellPos( n ){
|
695
|
+
var ordA = 'A'.charCodeAt(0);
|
696
|
+
var ordZ = 'Z'.charCodeAt(0);
|
697
|
+
var len = ordZ - ordA + 1;
|
698
|
+
var s = "";
|
699
|
+
|
700
|
+
while( n >= 0 ) {
|
701
|
+
s = String.fromCharCode(n % len + ordA) + s;
|
702
|
+
n = Math.floor(n / len) - 1;
|
703
|
+
}
|
704
|
+
|
705
|
+
return s;
|
706
|
+
}
|
707
|
+
|
708
|
+
/**
|
709
|
+
* Create an XML node and add any children, attributes, etc without needing to
|
710
|
+
* be verbose in the DOM.
|
711
|
+
*
|
712
|
+
* @param {object} doc XML document
|
713
|
+
* @param {string} nodeName Node name
|
714
|
+
* @param {object} opts Options - can be `attr` (attributes), `children`
|
715
|
+
* (child nodes) and `text` (text content)
|
716
|
+
* @return {node} Created node
|
717
|
+
*/
|
718
|
+
function _createNode( doc, nodeName, opts ){
|
719
|
+
var tempNode = doc.createElement( nodeName );
|
720
|
+
|
721
|
+
if ( opts ) {
|
722
|
+
if ( opts.attr ) {
|
723
|
+
$(tempNode).attr( opts.attr );
|
724
|
+
}
|
725
|
+
|
726
|
+
if( opts.children ) {
|
727
|
+
$.each( opts.children, function ( key, value ) {
|
728
|
+
tempNode.appendChild( value );
|
729
|
+
});
|
730
|
+
}
|
731
|
+
|
732
|
+
if( opts.text ) {
|
733
|
+
tempNode.appendChild( doc.createTextNode( opts.text ) );
|
734
|
+
}
|
735
|
+
}
|
736
|
+
|
737
|
+
return tempNode;
|
738
|
+
}
|
739
|
+
|
740
|
+
/**
|
741
|
+
* Get the width for an Excel column based on the contents of that column
|
742
|
+
* @param {object} data Data for export
|
743
|
+
* @param {int} col Column index
|
744
|
+
* @return {int} Column width
|
745
|
+
*/
|
746
|
+
function _excelColWidth( data, col ) {
|
747
|
+
var max = data.header[col].length;
|
748
|
+
var len;
|
749
|
+
|
750
|
+
if ( data.footer && data.footer[col].length > max ) {
|
751
|
+
max = data.footer[col].length;
|
752
|
+
}
|
753
|
+
|
754
|
+
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
|
755
|
+
len = data.body[i][col].toString().length;
|
756
|
+
|
757
|
+
if ( len > max ) {
|
758
|
+
max = len;
|
759
|
+
}
|
760
|
+
|
761
|
+
// Max width rather than having potentially massive column widths
|
762
|
+
if ( max > 40 ) {
|
763
|
+
break;
|
764
|
+
}
|
765
|
+
}
|
766
|
+
|
767
|
+
// And a min width
|
768
|
+
return max > 5 ? max : 5;
|
769
|
+
}
|
770
|
+
|
771
|
+
try {
|
772
|
+
var _serialiser = new XMLSerializer();
|
773
|
+
var _ieExcel;
|
774
|
+
}
|
775
|
+
catch (t) {}
|
776
|
+
|
777
|
+
/**
|
778
|
+
* Convert XML documents in an object to strings
|
779
|
+
* @param {object} obj XLSX document object
|
780
|
+
*/
|
781
|
+
function _xlsxToStrings( obj ) {
|
782
|
+
if ( _ieExcel === undefined ) {
|
783
|
+
// Detect if we are dealing with IE's _awful_ serialiser by seeing if it
|
784
|
+
// drop attributes
|
785
|
+
_ieExcel = _serialiser
|
786
|
+
.serializeToString(
|
787
|
+
$.parseXML( excelStrings['xl/worksheets/sheet1.xml'] )
|
788
|
+
)
|
789
|
+
.indexOf( 'xmlns:r' ) === -1;
|
790
|
+
}
|
791
|
+
|
792
|
+
$.each( obj, function ( name, val ) {
|
793
|
+
if ( $.isPlainObject( val ) ) {
|
794
|
+
_xlsxToStrings( val );
|
795
|
+
}
|
796
|
+
else {
|
797
|
+
if ( _ieExcel ) {
|
798
|
+
// IE's XML serialiser will drop some name space attributes from
|
799
|
+
// from the root node, so we need to save them. Do this by
|
800
|
+
// replacing the namespace nodes with a regular attribute that
|
801
|
+
// we convert back when serialised. Edge does not have this
|
802
|
+
// issue
|
803
|
+
var worksheet = val.childNodes[0];
|
804
|
+
var i, ien;
|
805
|
+
var attrs = [];
|
806
|
+
|
807
|
+
for ( i=worksheet.attributes.length-1 ; i>=0 ; i-- ) {
|
808
|
+
var attrName = worksheet.attributes[i].nodeName;
|
809
|
+
var attrValue = worksheet.attributes[i].nodeValue;
|
810
|
+
|
811
|
+
if ( attrName.indexOf( ':' ) !== -1 ) {
|
812
|
+
attrs.push( { name: attrName, value: attrValue } );
|
813
|
+
|
814
|
+
worksheet.removeAttribute( attrName );
|
815
|
+
}
|
816
|
+
}
|
817
|
+
|
818
|
+
for ( i=0, ien=attrs.length ; i<ien ; i++ ) {
|
819
|
+
var attr = val.createAttribute( attrs[i].name.replace( ':', '_dt_b_namespace_token_' ) );
|
820
|
+
attr.value = attrs[i].value;
|
821
|
+
worksheet.setAttributeNode( attr );
|
822
|
+
}
|
823
|
+
}
|
824
|
+
|
825
|
+
var str = _serialiser.serializeToString(val);
|
826
|
+
|
827
|
+
// Fix IE's XML
|
828
|
+
if ( _ieExcel ) {
|
829
|
+
// IE doesn't include the XML declaration
|
830
|
+
if ( str.indexOf( '<?xml' ) === -1 ) {
|
831
|
+
str = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+str;
|
832
|
+
}
|
833
|
+
|
834
|
+
// Return namespace attributes to being as such
|
835
|
+
str = str.replace( /_dt_b_namespace_token_/g, ':' );
|
836
|
+
}
|
837
|
+
|
838
|
+
// Both IE and Edge will put empty name space attributes onto the
|
839
|
+
// rows and columns making them useless
|
840
|
+
str = str
|
841
|
+
.replace( /<row xmlns="" /g, '<row ' )
|
842
|
+
.replace( /<cols xmlns="">/g, '<cols>' );
|
843
|
+
|
844
|
+
obj[ name ] = str;
|
845
|
+
}
|
846
|
+
} );
|
847
|
+
}
|
848
|
+
|
849
|
+
// Excel - Pre-defined strings to build a basic XLSX file
|
850
|
+
var excelStrings = {
|
851
|
+
"_rels/.rels":
|
852
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
853
|
+
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
|
854
|
+
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'+
|
855
|
+
'</Relationships>',
|
856
|
+
|
857
|
+
"xl/_rels/workbook.xml.rels":
|
858
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
859
|
+
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'+
|
860
|
+
'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>'+
|
861
|
+
'<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+
|
862
|
+
'</Relationships>',
|
863
|
+
|
864
|
+
"[Content_Types].xml":
|
865
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
866
|
+
'<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'+
|
867
|
+
'<Default Extension="xml" ContentType="application/xml" />'+
|
868
|
+
'<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />'+
|
869
|
+
'<Default Extension="jpeg" ContentType="image/jpeg" />'+
|
870
|
+
'<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" />'+
|
871
|
+
'<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml" />'+
|
872
|
+
'<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml" />'+
|
873
|
+
'</Types>',
|
874
|
+
|
875
|
+
"xl/workbook.xml":
|
876
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
877
|
+
'<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'+
|
878
|
+
'<fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="24816"/>'+
|
879
|
+
'<workbookPr showInkAnnotation="0" autoCompressPictures="0"/>'+
|
880
|
+
'<bookViews>'+
|
881
|
+
'<workbookView xWindow="0" yWindow="0" windowWidth="25600" windowHeight="19020" tabRatio="500"/>'+
|
882
|
+
'</bookViews>'+
|
883
|
+
'<sheets>'+
|
884
|
+
'<sheet name="" sheetId="1" r:id="rId1"/>'+
|
885
|
+
'</sheets>'+
|
886
|
+
'</workbook>',
|
887
|
+
|
888
|
+
"xl/worksheets/sheet1.xml":
|
889
|
+
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
|
890
|
+
'<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">'+
|
891
|
+
'<sheetData/>'+
|
892
|
+
'</worksheet>',
|
893
|
+
|
894
|
+
"xl/styles.xml":
|
895
|
+
'<?xml version="1.0" encoding="UTF-8"?>'+
|
896
|
+
'<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">'+
|
897
|
+
'<fonts count="5" x14ac:knownFonts="1">'+
|
898
|
+
'<font>'+
|
899
|
+
'<sz val="11" />'+
|
900
|
+
'<name val="Calibri" />'+
|
901
|
+
'</font>'+
|
902
|
+
'<font>'+
|
903
|
+
'<sz val="11" />'+
|
904
|
+
'<name val="Calibri" />'+
|
905
|
+
'<color rgb="FFFFFFFF" />'+
|
906
|
+
'</font>'+
|
907
|
+
'<font>'+
|
908
|
+
'<sz val="11" />'+
|
909
|
+
'<name val="Calibri" />'+
|
910
|
+
'<b />'+
|
911
|
+
'</font>'+
|
912
|
+
'<font>'+
|
913
|
+
'<sz val="11" />'+
|
914
|
+
'<name val="Calibri" />'+
|
915
|
+
'<i />'+
|
916
|
+
'</font>'+
|
917
|
+
'<font>'+
|
918
|
+
'<sz val="11" />'+
|
919
|
+
'<name val="Calibri" />'+
|
920
|
+
'<u />'+
|
921
|
+
'</font>'+
|
922
|
+
'</fonts>'+
|
923
|
+
'<fills count="6">'+
|
924
|
+
'<fill>'+
|
925
|
+
'<patternFill patternType="none" />'+
|
926
|
+
'</fill>'+
|
927
|
+
'<fill/>'+ // Excel appears to use this as a dotted background regardless of values
|
928
|
+
'<fill>'+
|
929
|
+
'<patternFill patternType="solid">'+
|
930
|
+
'<fgColor rgb="FFD9D9D9" />'+
|
931
|
+
'<bgColor indexed="64" />'+
|
932
|
+
'</patternFill>'+
|
933
|
+
'</fill>'+
|
934
|
+
'<fill>'+
|
935
|
+
'<patternFill patternType="solid">'+
|
936
|
+
'<fgColor rgb="FFD99795" />'+
|
937
|
+
'<bgColor indexed="64" />'+
|
938
|
+
'</patternFill>'+
|
939
|
+
'</fill>'+
|
940
|
+
'<fill>'+
|
941
|
+
'<patternFill patternType="solid">'+
|
942
|
+
'<fgColor rgb="ffc6efce" />'+
|
943
|
+
'<bgColor indexed="64" />'+
|
944
|
+
'</patternFill>'+
|
945
|
+
'</fill>'+
|
946
|
+
'<fill>'+
|
947
|
+
'<patternFill patternType="solid">'+
|
948
|
+
'<fgColor rgb="ffc6cfef" />'+
|
949
|
+
'<bgColor indexed="64" />'+
|
950
|
+
'</patternFill>'+
|
951
|
+
'</fill>'+
|
952
|
+
'</fills>'+
|
953
|
+
'<borders count="2">'+
|
954
|
+
'<border>'+
|
955
|
+
'<left />'+
|
956
|
+
'<right />'+
|
957
|
+
'<top />'+
|
958
|
+
'<bottom />'+
|
959
|
+
'<diagonal />'+
|
960
|
+
'</border>'+
|
961
|
+
'<border diagonalUp="false" diagonalDown="false">'+
|
962
|
+
'<left style="thin">'+
|
963
|
+
'<color auto="1" />'+
|
964
|
+
'</left>'+
|
965
|
+
'<right style="thin">'+
|
966
|
+
'<color auto="1" />'+
|
967
|
+
'</right>'+
|
968
|
+
'<top style="thin">'+
|
969
|
+
'<color auto="1" />'+
|
970
|
+
'</top>'+
|
971
|
+
'<bottom style="thin">'+
|
972
|
+
'<color auto="1" />'+
|
973
|
+
'</bottom>'+
|
974
|
+
'<diagonal />'+
|
975
|
+
'</border>'+
|
976
|
+
'</borders>'+
|
977
|
+
'<cellStyleXfs count="1">'+
|
978
|
+
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" />'+
|
979
|
+
'</cellStyleXfs>'+
|
980
|
+
'<cellXfs count="2">'+
|
981
|
+
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
982
|
+
'<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
983
|
+
'<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
984
|
+
'<xf numFmtId="0" fontId="3" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
985
|
+
'<xf numFmtId="0" fontId="4" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
986
|
+
'<xf numFmtId="0" fontId="0" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
987
|
+
'<xf numFmtId="0" fontId="1" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
988
|
+
'<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
989
|
+
'<xf numFmtId="0" fontId="3" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
990
|
+
'<xf numFmtId="0" fontId="4" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
991
|
+
'<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
992
|
+
'<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
993
|
+
'<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
994
|
+
'<xf numFmtId="0" fontId="3" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
995
|
+
'<xf numFmtId="0" fontId="4" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
996
|
+
'<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
997
|
+
'<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
998
|
+
'<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
999
|
+
'<xf numFmtId="0" fontId="3" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1000
|
+
'<xf numFmtId="0" fontId="4" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1001
|
+
'<xf numFmtId="0" fontId="0" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1002
|
+
'<xf numFmtId="0" fontId="1" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1003
|
+
'<xf numFmtId="0" fontId="2" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1004
|
+
'<xf numFmtId="0" fontId="3" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1005
|
+
'<xf numFmtId="0" fontId="4" fillId="5" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1006
|
+
'<xf numFmtId="0" fontId="0" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1007
|
+
'<xf numFmtId="0" fontId="1" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1008
|
+
'<xf numFmtId="0" fontId="2" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1009
|
+
'<xf numFmtId="0" fontId="3" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1010
|
+
'<xf numFmtId="0" fontId="4" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1011
|
+
'<xf numFmtId="0" fontId="0" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1012
|
+
'<xf numFmtId="0" fontId="1" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1013
|
+
'<xf numFmtId="0" fontId="2" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1014
|
+
'<xf numFmtId="0" fontId="3" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1015
|
+
'<xf numFmtId="0" fontId="4" fillId="2" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1016
|
+
'<xf numFmtId="0" fontId="0" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1017
|
+
'<xf numFmtId="0" fontId="1" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1018
|
+
'<xf numFmtId="0" fontId="2" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1019
|
+
'<xf numFmtId="0" fontId="3" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1020
|
+
'<xf numFmtId="0" fontId="4" fillId="3" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1021
|
+
'<xf numFmtId="0" fontId="0" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1022
|
+
'<xf numFmtId="0" fontId="1" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1023
|
+
'<xf numFmtId="0" fontId="2" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1024
|
+
'<xf numFmtId="0" fontId="3" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1025
|
+
'<xf numFmtId="0" fontId="4" fillId="4" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1026
|
+
'<xf numFmtId="0" fontId="0" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1027
|
+
'<xf numFmtId="0" fontId="1" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1028
|
+
'<xf numFmtId="0" fontId="2" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1029
|
+
'<xf numFmtId="0" fontId="3" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1030
|
+
'<xf numFmtId="0" fontId="4" fillId="5" borderId="1" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1031
|
+
'</cellXfs>'+
|
1032
|
+
'<cellStyles count="1">'+
|
1033
|
+
'<cellStyle name="Normal" xfId="0" builtinId="0" />'+
|
1034
|
+
'</cellStyles>'+
|
1035
|
+
'<dxfs count="0" />'+
|
1036
|
+
'<tableStyles count="0" defaultTableStyle="TableStyleMedium9" defaultPivotStyle="PivotStyleMedium4" />'+
|
1037
|
+
'</styleSheet>'
|
1038
|
+
};
|
1039
|
+
// Note we could use 3 `for` loops for the styles, but when gzipped there is
|
1040
|
+
// virtually no difference in size, since the above can be easily compressed
|
1041
|
+
|
1042
|
+
|
1043
|
+
|
1044
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
1045
|
+
* DataTables options and methods
|
1046
|
+
*/
|
1047
|
+
|
1048
|
+
// Set the default SWF path
|
1049
|
+
DataTable.Buttons.swfPath = '//cdn.datatables.net/buttons/1.2.0/swf/flashExport.swf';
|
1050
|
+
|
1051
|
+
// Method to allow Flash buttons to be resized when made visible - as they are
|
1052
|
+
// of zero height and width if initialised hidden
|
1053
|
+
DataTable.Api.register( 'buttons.resize()', function () {
|
1054
|
+
$.each( ZeroClipboard_TableTools.clients, function ( i, client ) {
|
1055
|
+
if ( client.domElement !== undefined && client.domElement.parentNode ) {
|
1056
|
+
client.positionElement();
|
1057
|
+
}
|
1058
|
+
} );
|
1059
|
+
} );
|
1060
|
+
|
1061
|
+
|
1062
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
1063
|
+
* Button definitions
|
1064
|
+
*/
|
1065
|
+
|
1066
|
+
// Copy to clipboard
|
1067
|
+
DataTable.ext.buttons.copyFlash = $.extend( {}, flashButton, {
|
1068
|
+
className: 'buttons-copy buttons-flash',
|
1069
|
+
|
1070
|
+
text: function ( dt ) {
|
1071
|
+
return dt.i18n( 'buttons.copy', 'Copy' );
|
1072
|
+
},
|
1073
|
+
|
1074
|
+
action: function ( e, dt, button, config ) {
|
1075
|
+
// Check that the trigger did actually occur due to a Flash activation
|
1076
|
+
if ( ! config._fromFlash ) {
|
1077
|
+
return;
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
var flash = config._flash;
|
1081
|
+
var data = _exportData( dt, config );
|
1082
|
+
var output = config.customize ?
|
1083
|
+
config.customize( data.str, config ) :
|
1084
|
+
data.str;
|
1085
|
+
|
1086
|
+
flash.setAction( 'copy' );
|
1087
|
+
_setText( flash, output );
|
1088
|
+
|
1089
|
+
dt.buttons.info(
|
1090
|
+
dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ),
|
1091
|
+
dt.i18n( 'buttons.copySuccess', {
|
1092
|
+
_: 'Copied %d rows to clipboard',
|
1093
|
+
1: 'Copied 1 row to clipboard'
|
1094
|
+
}, data.rows ),
|
1095
|
+
3000
|
1096
|
+
);
|
1097
|
+
},
|
1098
|
+
|
1099
|
+
fieldSeparator: '\t',
|
1100
|
+
|
1101
|
+
fieldBoundary: ''
|
1102
|
+
} );
|
1103
|
+
|
1104
|
+
// CSV save file
|
1105
|
+
DataTable.ext.buttons.csvFlash = $.extend( {}, flashButton, {
|
1106
|
+
className: 'buttons-csv buttons-flash',
|
1107
|
+
|
1108
|
+
text: function ( dt ) {
|
1109
|
+
return dt.i18n( 'buttons.csv', 'CSV' );
|
1110
|
+
},
|
1111
|
+
|
1112
|
+
action: function ( e, dt, button, config ) {
|
1113
|
+
// Set the text
|
1114
|
+
var flash = config._flash;
|
1115
|
+
var data = _exportData( dt, config );
|
1116
|
+
var output = config.customize ?
|
1117
|
+
config.customize( data.str, config ) :
|
1118
|
+
data.str;
|
1119
|
+
|
1120
|
+
flash.setAction( 'csv' );
|
1121
|
+
flash.setFileName( _filename( config ) );
|
1122
|
+
_setText( flash, output );
|
1123
|
+
},
|
1124
|
+
|
1125
|
+
escapeChar: '"'
|
1126
|
+
} );
|
1127
|
+
|
1128
|
+
// Excel save file - this is really a CSV file using UTF-8 that Excel can read
|
1129
|
+
DataTable.ext.buttons.excelFlash = $.extend( {}, flashButton, {
|
1130
|
+
className: 'buttons-excel buttons-flash',
|
1131
|
+
|
1132
|
+
text: function ( dt ) {
|
1133
|
+
return dt.i18n( 'buttons.excel', 'Excel' );
|
1134
|
+
},
|
1135
|
+
|
1136
|
+
action: function ( e, dt, button, config ) {
|
1137
|
+
var flash = config._flash;
|
1138
|
+
var rowPos = 0;
|
1139
|
+
var rels = $.parseXML( excelStrings['xl/worksheets/sheet1.xml'] ) ; //Parses xml
|
1140
|
+
var relsGet = rels.getElementsByTagName( "sheetData" )[0];
|
1141
|
+
|
1142
|
+
var xlsx = {
|
1143
|
+
_rels: {
|
1144
|
+
".rels": $.parseXML( excelStrings['_rels/.rels'] )
|
1145
|
+
},
|
1146
|
+
xl: {
|
1147
|
+
_rels: {
|
1148
|
+
"workbook.xml.rels": $.parseXML( excelStrings['xl/_rels/workbook.xml.rels'] )
|
1149
|
+
},
|
1150
|
+
"workbook.xml": $.parseXML( excelStrings['xl/workbook.xml'] ),
|
1151
|
+
"styles.xml": $.parseXML( excelStrings['xl/styles.xml'] ),
|
1152
|
+
"worksheets": {
|
1153
|
+
"sheet1.xml": rels
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
},
|
1157
|
+
"[Content_Types].xml": $.parseXML( excelStrings['[Content_Types].xml'])
|
1158
|
+
};
|
1159
|
+
|
1160
|
+
var data = dt.buttons.exportData( config.exportOptions );
|
1161
|
+
var currentRow, rowNode;
|
1162
|
+
var addRow = function ( row ) {
|
1163
|
+
currentRow = rowPos+1;
|
1164
|
+
rowNode = _createNode( rels, "row", { attr: {r:currentRow} } );
|
1165
|
+
|
1166
|
+
for ( var i=0, ien=row.length ; i<ien ; i++ ) {
|
1167
|
+
// Concat both the Cell Columns as a letter and the Row of the cell.
|
1168
|
+
var cellId = createCellPos(i) + '' + currentRow;
|
1169
|
+
var cell;
|
1170
|
+
|
1171
|
+
if ( row[i] === null || row[i] === undefined ) {
|
1172
|
+
row[i] = '';
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
// Detect numbers - don't match numbers with leading zeros or a negative
|
1176
|
+
// anywhere but the start
|
1177
|
+
if ( typeof row[i] === 'number' || (
|
1178
|
+
row[i].match &&
|
1179
|
+
$.trim(row[i]).match(/^-?\d+(\.\d+)?$/) &&
|
1180
|
+
! $.trim(row[i]).match(/^0\d+/) )
|
1181
|
+
) {
|
1182
|
+
cell = _createNode( rels, 'c', {
|
1183
|
+
attr: {
|
1184
|
+
t: 'n',
|
1185
|
+
r: cellId
|
1186
|
+
},
|
1187
|
+
children: [
|
1188
|
+
_createNode( rels, 'v', { text: row[i] } )
|
1189
|
+
]
|
1190
|
+
} );
|
1191
|
+
}
|
1192
|
+
else {
|
1193
|
+
// Replace non standard characters for text output
|
1194
|
+
var text = ! row[i].replace ?
|
1195
|
+
row[i] :
|
1196
|
+
row[i]
|
1197
|
+
.replace(/&(?!amp;)/g, '&')
|
1198
|
+
.replace(/</g, '<')
|
1199
|
+
.replace(/>/g, '>')
|
1200
|
+
.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, '');
|
1201
|
+
|
1202
|
+
cell = _createNode( rels, 'c', {
|
1203
|
+
attr: {
|
1204
|
+
t: 'inlineStr',
|
1205
|
+
r: cellId
|
1206
|
+
},
|
1207
|
+
children:{
|
1208
|
+
row: _createNode( rels, 'is', {
|
1209
|
+
children: {
|
1210
|
+
row: _createNode( rels, 't', {
|
1211
|
+
text: text
|
1212
|
+
} )
|
1213
|
+
}
|
1214
|
+
} )
|
1215
|
+
}
|
1216
|
+
} );
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
rowNode.appendChild( cell );
|
1220
|
+
}
|
1221
|
+
relsGet.appendChild(rowNode);
|
1222
|
+
rowPos++;
|
1223
|
+
};
|
1224
|
+
|
1225
|
+
$( 'sheets sheet', xlsx.xl['workbook.xml'] ).attr( 'name', _sheetname( config ) );
|
1226
|
+
|
1227
|
+
if ( config.customizeData ) {
|
1228
|
+
config.customizeData( data );
|
1229
|
+
}
|
1230
|
+
|
1231
|
+
if ( config.header ) {
|
1232
|
+
addRow( data.header, rowPos );
|
1233
|
+
$('row c', rels).attr( 's', '2' ); // bold
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
for ( var n=0, ie=data.body.length ; n<ie ; n++ ) {
|
1237
|
+
addRow( data.body[n], rowPos );
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
if ( config.footer && data.footer ) {
|
1241
|
+
addRow( data.footer, rowPos);
|
1242
|
+
$('row:last c', rels).attr( 's', '2' ); // bold
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
// Set column widths
|
1246
|
+
var cols = _createNode( rels, 'cols' );
|
1247
|
+
$('worksheet', rels).prepend( cols );
|
1248
|
+
|
1249
|
+
for ( var i=0, ien=data.header.length ; i<ien ; i++ ) {
|
1250
|
+
cols.appendChild( _createNode( rels, 'col', {
|
1251
|
+
attr: {
|
1252
|
+
min: i+1,
|
1253
|
+
max: i+1,
|
1254
|
+
width: _excelColWidth( data, i ),
|
1255
|
+
customWidth: 1
|
1256
|
+
}
|
1257
|
+
} ) );
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
// Let the developer customise the document if they want to
|
1261
|
+
if ( config.customize ) {
|
1262
|
+
config.customize( xlsx );
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
_xlsxToStrings( xlsx );
|
1266
|
+
|
1267
|
+
flash.setAction( 'excel' );
|
1268
|
+
flash.setFileName( _filename( config ) );
|
1269
|
+
flash.setSheetData( xlsx );
|
1270
|
+
_setText( flash, '' );
|
1271
|
+
},
|
1272
|
+
|
1273
|
+
extension: '.xlsx'
|
1274
|
+
} );
|
1275
|
+
|
1276
|
+
|
1277
|
+
|
1278
|
+
// PDF export
|
1279
|
+
DataTable.ext.buttons.pdfFlash = $.extend( {}, flashButton, {
|
1280
|
+
className: 'buttons-pdf buttons-flash',
|
1281
|
+
|
1282
|
+
text: function ( dt ) {
|
1283
|
+
return dt.i18n( 'buttons.pdf', 'PDF' );
|
1284
|
+
},
|
1285
|
+
|
1286
|
+
action: function ( e, dt, button, config ) {
|
1287
|
+
// Set the text
|
1288
|
+
var flash = config._flash;
|
1289
|
+
var data = dt.buttons.exportData( config.exportOptions );
|
1290
|
+
var totalWidth = dt.table().node().offsetWidth;
|
1291
|
+
|
1292
|
+
// Calculate the column width ratios for layout of the table in the PDF
|
1293
|
+
var ratios = dt.columns( config.columns ).indexes().map( function ( idx ) {
|
1294
|
+
return dt.column( idx ).header().offsetWidth / totalWidth;
|
1295
|
+
} );
|
1296
|
+
|
1297
|
+
flash.setAction( 'pdf' );
|
1298
|
+
flash.setFileName( _filename( config ) );
|
1299
|
+
|
1300
|
+
_setText( flash, JSON.stringify( {
|
1301
|
+
title: _filename(config, false),
|
1302
|
+
message: config.message,
|
1303
|
+
colWidth: ratios.toArray(),
|
1304
|
+
orientation: config.orientation,
|
1305
|
+
size: config.pageSize,
|
1306
|
+
header: config.header ? data.header : null,
|
1307
|
+
footer: config.footer ? data.footer : null,
|
1308
|
+
body: data.body
|
1309
|
+
} ) );
|
1310
|
+
},
|
1311
|
+
|
1312
|
+
extension: '.pdf',
|
1313
|
+
|
1314
|
+
orientation: 'portrait',
|
1315
|
+
|
1316
|
+
pageSize: 'A4',
|
1317
|
+
|
1318
|
+
message: '',
|
1319
|
+
|
1320
|
+
newline: '\n'
|
1321
|
+
} );
|
1322
|
+
|
1323
|
+
|
1324
|
+
return DataTable.Buttons;
|
1325
|
+
}));
|