jquery-datatables 1.10.13 → 1.10.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/Rakefile +1 -1
- data/app/assets/javascripts/datatables/dataTables.bootstrap2.js +162 -0
- data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +7 -7
- data/app/assets/javascripts/datatables/dataTables.semanticui.js +2 -2
- data/app/assets/javascripts/datatables/extensions/AutoFill/dataTables.autoFill.js +104 -13
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.colVis.js +17 -9
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.flash.js +41 -15
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.html5.js +48 -18
- data/app/assets/javascripts/datatables/extensions/Buttons/buttons.print.js +29 -13
- data/app/assets/javascripts/datatables/extensions/Buttons/dataTables.buttons.js +46 -5
- data/app/assets/javascripts/datatables/extensions/ColReorder/dataTables.colReorder.js +37 -19
- data/app/assets/javascripts/datatables/extensions/KeyTable/dataTables.keyTable.js +65 -37
- data/app/assets/javascripts/datatables/extensions/RowGroup/dataTables.rowGroup.js +386 -0
- data/app/assets/javascripts/datatables/extensions/Select/dataTables.select.js +24 -14
- data/app/assets/javascripts/datatables/jquery.dataTables.js +48 -10
- data/app/assets/stylesheets/datatables/dataTables.bootstrap.css +7 -7
- data/app/assets/stylesheets/datatables/dataTables.bootstrap2.css +178 -0
- data/app/assets/stylesheets/datatables/dataTables.bootstrap4.css +1 -0
- data/app/assets/stylesheets/datatables/dataTables.foundation.css +8 -6
- data/app/assets/stylesheets/datatables/dataTables.jqueryui.css +6 -5
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap.css +56 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.bootstrap4.css +56 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.dataTables.css +56 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.foundation.css +60 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.jqueryui.css +56 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/buttons.semanticui.css +57 -0
- data/app/assets/stylesheets/datatables/extensions/Buttons/mixins.scss +47 -0
- data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.bootstrap.css +4 -0
- data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.bootstrap4.css +4 -0
- data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.dataTables.css +4 -0
- data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.foundation.css +4 -0
- data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.jqueryui.css +4 -0
- data/app/assets/stylesheets/datatables/extensions/RowGroup/rowGroup.semanticui.css +4 -0
- data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap.css +7 -7
- data/app/assets/stylesheets/datatables/extensions/Select/select.bootstrap4.css +7 -7
- data/app/assets/stylesheets/datatables/extensions/Select/select.dataTables.css +7 -7
- data/app/assets/stylesheets/datatables/extensions/Select/select.foundation.css +7 -7
- data/app/assets/stylesheets/datatables/extensions/Select/select.jqueryui.css +7 -7
- data/app/assets/stylesheets/datatables/extensions/Select/select.semanticui.css +7 -7
- data/app/assets/stylesheets/datatables/jquery.dataTables.css +14 -11
- data/lib/generators/jquery/datatables/templates/bootstrap2.css.tt +15 -0
- data/lib/generators/jquery/datatables/templates/bootstrap2.js.tt +22 -0
- data/lib/jquery-datatables/version.rb +1 -1
- metadata +14 -3
@@ -752,7 +752,10 @@ function _excelColWidth( data, col ) {
|
|
752
752
|
}
|
753
753
|
|
754
754
|
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
|
755
|
-
|
755
|
+
var point = data.body[i][col];
|
756
|
+
str = point !== null && point !== undefined ?
|
757
|
+
point.toString() :
|
758
|
+
'';
|
756
759
|
|
757
760
|
// If there is a newline character, workout the width of the column
|
758
761
|
// based on the longest line in the string
|
@@ -774,7 +777,7 @@ function _excelColWidth( data, col ) {
|
|
774
777
|
|
775
778
|
// Max width rather than having potentially massive column widths
|
776
779
|
if ( max > 40 ) {
|
777
|
-
|
780
|
+
return 52; // 40 * 1.3
|
778
781
|
}
|
779
782
|
}
|
780
783
|
|
@@ -784,11 +787,19 @@ function _excelColWidth( data, col ) {
|
|
784
787
|
return max > 6 ? max : 6;
|
785
788
|
}
|
786
789
|
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
790
|
+
var _serialiser = "";
|
791
|
+
if (typeof window.XMLSerializer === 'undefined') {
|
792
|
+
_serialiser = new function () {
|
793
|
+
this.serializeToString = function (input) {
|
794
|
+
return input.xml
|
795
|
+
}
|
796
|
+
};
|
797
|
+
} else {
|
798
|
+
_serialiser = new XMLSerializer();
|
799
|
+
}
|
800
|
+
|
801
|
+
var _ieExcel;
|
802
|
+
|
792
803
|
|
793
804
|
/**
|
794
805
|
* Convert XML documents in an object to strings
|
@@ -853,7 +864,7 @@ function _xlsxToStrings( obj ) {
|
|
853
864
|
|
854
865
|
// Safari, IE and Edge will put empty name space attributes onto
|
855
866
|
// various elements making them useless. This strips them out
|
856
|
-
str = str.replace( /<(
|
867
|
+
str = str.replace( /<([^<>]*?) xmlns=""([^<>]*?)>/g, '<$1 $2>' );
|
857
868
|
|
858
869
|
obj[ name ] = str;
|
859
870
|
}
|
@@ -1010,11 +1021,11 @@ var excelStrings = {
|
|
1010
1021
|
'<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1011
1022
|
'<xf numFmtId="0" fontId="3" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1012
1023
|
'<xf numFmtId="0" fontId="4" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1013
|
-
'<xf numFmtId="0" fontId="0" fillId="
|
1014
|
-
'<xf numFmtId="0" fontId="1" fillId="
|
1015
|
-
'<xf numFmtId="0" fontId="2" fillId="
|
1016
|
-
'<xf numFmtId="0" fontId="3" fillId="
|
1017
|
-
'<xf numFmtId="0" fontId="4" fillId="
|
1024
|
+
'<xf numFmtId="0" fontId="0" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1025
|
+
'<xf numFmtId="0" fontId="1" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1026
|
+
'<xf numFmtId="0" fontId="2" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1027
|
+
'<xf numFmtId="0" fontId="3" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1028
|
+
'<xf numFmtId="0" fontId="4" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1018
1029
|
'<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1019
1030
|
'<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
1020
1031
|
'<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
@@ -1109,7 +1120,7 @@ var _excelSpecials = [
|
|
1109
1120
|
*/
|
1110
1121
|
|
1111
1122
|
// Set the default SWF path
|
1112
|
-
DataTable.Buttons.swfPath = '//cdn.datatables.net/buttons/1.2.
|
1123
|
+
DataTable.Buttons.swfPath = '//cdn.datatables.net/buttons/1.2.4/swf/flashExport.swf';
|
1113
1124
|
|
1114
1125
|
// Method to allow Flash buttons to be resized when made visible - as they are
|
1115
1126
|
// of zero height and width if initialised hidden
|
@@ -1140,6 +1151,8 @@ DataTable.ext.buttons.copyFlash = $.extend( {}, flashButton, {
|
|
1140
1151
|
return;
|
1141
1152
|
}
|
1142
1153
|
|
1154
|
+
this.processing( true );
|
1155
|
+
|
1143
1156
|
var flash = config._flash;
|
1144
1157
|
var data = _exportData( dt, config );
|
1145
1158
|
var output = config.customize ?
|
@@ -1149,6 +1162,8 @@ DataTable.ext.buttons.copyFlash = $.extend( {}, flashButton, {
|
|
1149
1162
|
flash.setAction( 'copy' );
|
1150
1163
|
_setText( flash, output );
|
1151
1164
|
|
1165
|
+
this.processing( false );
|
1166
|
+
|
1152
1167
|
dt.buttons.info(
|
1153
1168
|
dt.i18n( 'buttons.copyTitle', 'Copy to clipboard' ),
|
1154
1169
|
dt.i18n( 'buttons.copySuccess', {
|
@@ -1197,6 +1212,8 @@ DataTable.ext.buttons.excelFlash = $.extend( {}, flashButton, {
|
|
1197
1212
|
},
|
1198
1213
|
|
1199
1214
|
action: function ( e, dt, button, config ) {
|
1215
|
+
this.processing( true );
|
1216
|
+
|
1200
1217
|
var flash = config._flash;
|
1201
1218
|
var rowPos = 0;
|
1202
1219
|
var rels = $.parseXML( excelStrings['xl/worksheets/sheet1.xml'] ) ; //Parses xml
|
@@ -1242,7 +1259,10 @@ DataTable.ext.buttons.excelFlash = $.extend( {}, flashButton, {
|
|
1242
1259
|
for ( var j=0, jen=_excelSpecials.length ; j<jen ; j++ ) {
|
1243
1260
|
var special = _excelSpecials[j];
|
1244
1261
|
|
1245
|
-
|
1262
|
+
// TODO Need to provide the ability for the specials to say
|
1263
|
+
// if they are returning a string, since at the moment it is
|
1264
|
+
// assumed to be a number
|
1265
|
+
if ( row[i].match && ! row[i].match(/^0\d+/) && row[i].match( special.match ) ) {
|
1246
1266
|
var val = row[i].replace(/[^\d\.\-]/g, '');
|
1247
1267
|
|
1248
1268
|
if ( special.fmt ) {
|
@@ -1358,6 +1378,8 @@ DataTable.ext.buttons.excelFlash = $.extend( {}, flashButton, {
|
|
1358
1378
|
flash.setFileName( _filename( config ) );
|
1359
1379
|
flash.setSheetData( xlsx );
|
1360
1380
|
_setText( flash, '' );
|
1381
|
+
|
1382
|
+
this.processing( false );
|
1361
1383
|
},
|
1362
1384
|
|
1363
1385
|
extension: '.xlsx'
|
@@ -1374,6 +1396,8 @@ DataTable.ext.buttons.pdfFlash = $.extend( {}, flashButton, {
|
|
1374
1396
|
},
|
1375
1397
|
|
1376
1398
|
action: function ( e, dt, button, config ) {
|
1399
|
+
this.processing( true );
|
1400
|
+
|
1377
1401
|
// Set the text
|
1378
1402
|
var flash = config._flash;
|
1379
1403
|
var data = dt.buttons.exportData( config.exportOptions );
|
@@ -1397,6 +1421,8 @@ DataTable.ext.buttons.pdfFlash = $.extend( {}, flashButton, {
|
|
1397
1421
|
footer: config.footer ? data.footer : null,
|
1398
1422
|
body: data.body
|
1399
1423
|
} ) );
|
1424
|
+
|
1425
|
+
this.processing( false );
|
1400
1426
|
},
|
1401
1427
|
|
1402
1428
|
extension: '.pdf',
|
@@ -473,7 +473,7 @@ function _addToZip( zip, obj ) {
|
|
473
473
|
|
474
474
|
// Safari, IE and Edge will put empty name space attributes onto
|
475
475
|
// various elements making them useless. This strips them out
|
476
|
-
str = str.replace( /<(
|
476
|
+
str = str.replace( /<([^<>]*?) xmlns=""([^<>]*?)>/g, '<$1 $2>' );
|
477
477
|
|
478
478
|
zip.file( name, str );
|
479
479
|
}
|
@@ -527,7 +527,10 @@ function _excelColWidth( data, col ) {
|
|
527
527
|
}
|
528
528
|
|
529
529
|
for ( var i=0, ien=data.body.length ; i<ien ; i++ ) {
|
530
|
-
|
530
|
+
var point = data.body[i][col];
|
531
|
+
str = point !== null && point !== undefined ?
|
532
|
+
point.toString() :
|
533
|
+
'';
|
531
534
|
|
532
535
|
// If there is a newline character, workout the width of the column
|
533
536
|
// based on the longest line in the string
|
@@ -549,7 +552,7 @@ function _excelColWidth( data, col ) {
|
|
549
552
|
|
550
553
|
// Max width rather than having potentially massive column widths
|
551
554
|
if ( max > 40 ) {
|
552
|
-
|
555
|
+
return 52; // 40 * 1.3
|
553
556
|
}
|
554
557
|
}
|
555
558
|
|
@@ -698,7 +701,7 @@ var excelStrings = {
|
|
698
701
|
'<cellStyleXfs count="1">'+
|
699
702
|
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" />'+
|
700
703
|
'</cellStyleXfs>'+
|
701
|
-
'<cellXfs count="
|
704
|
+
'<cellXfs count="67">'+
|
702
705
|
'<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
703
706
|
'<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
704
707
|
'<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
@@ -709,11 +712,11 @@ var excelStrings = {
|
|
709
712
|
'<xf numFmtId="0" fontId="2" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
710
713
|
'<xf numFmtId="0" fontId="3" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
711
714
|
'<xf numFmtId="0" fontId="4" fillId="2" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
712
|
-
'<xf numFmtId="0" fontId="0" fillId="
|
713
|
-
'<xf numFmtId="0" fontId="1" fillId="
|
714
|
-
'<xf numFmtId="0" fontId="2" fillId="
|
715
|
-
'<xf numFmtId="0" fontId="3" fillId="
|
716
|
-
'<xf numFmtId="0" fontId="4" fillId="
|
715
|
+
'<xf numFmtId="0" fontId="0" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
716
|
+
'<xf numFmtId="0" fontId="1" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
717
|
+
'<xf numFmtId="0" fontId="2" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
718
|
+
'<xf numFmtId="0" fontId="3" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
719
|
+
'<xf numFmtId="0" fontId="4" fillId="3" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
717
720
|
'<xf numFmtId="0" fontId="0" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
718
721
|
'<xf numFmtId="0" fontId="1" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
719
722
|
'<xf numFmtId="0" fontId="2" fillId="4" borderId="0" applyFont="1" applyFill="1" applyBorder="1"/>'+
|
@@ -776,6 +779,8 @@ var excelStrings = {
|
|
776
779
|
'<xf numFmtId="169" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
|
777
780
|
'<xf numFmtId="3" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
|
778
781
|
'<xf numFmtId="4" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
|
782
|
+
'<xf numFmtId="1" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
|
783
|
+
'<xf numFmtId="2" fontId="0" fillId="0" borderId="0" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyNumberFormat="1"/>'+
|
779
784
|
'</cellXfs>'+
|
780
785
|
'<cellStyles count="1">'+
|
781
786
|
'<cellStyle name="Normal" xfId="0" builtinId="0" />'+
|
@@ -797,10 +802,12 @@ var _excelSpecials = [
|
|
797
802
|
{ match: /^\-?\$[\d,]+.?\d*$/, style: 57 }, // Dollars
|
798
803
|
{ match: /^\-?£[\d,]+.?\d*$/, style: 58 }, // Pounds
|
799
804
|
{ match: /^\-?€[\d,]+.?\d*$/, style: 59 }, // Euros
|
805
|
+
{ match: /^\-?\d+$/, style: 65 }, // Numbers without thousand separators
|
806
|
+
{ match: /^\-?\d+\.\d{2}$/, style: 66 }, // Numbers 2 d.p. without thousands separators
|
800
807
|
{ match: /^\([\d,]+\)$/, style: 61, fmt: function (d) { return -1 * d.replace(/[\(\)]/g, ''); } }, // Negative numbers indicated by brackets
|
801
808
|
{ match: /^\([\d,]+\.\d{2}\)$/, style: 62, fmt: function (d) { return -1 * d.replace(/[\(\)]/g, ''); } }, // Negative numbers indicated by brackets - 2d.p.
|
802
|
-
{ match:
|
803
|
-
{ match:
|
809
|
+
{ match: /^\-?[\d,]+$/, style: 63 }, // Numbers with thousand separators
|
810
|
+
{ match: /^\-?[\d,]+\.\d{2}$/, style: 64 } // Numbers with 2 d.p. and thousands separators
|
804
811
|
];
|
805
812
|
|
806
813
|
|
@@ -820,6 +827,9 @@ DataTable.ext.buttons.copyHtml5 = {
|
|
820
827
|
},
|
821
828
|
|
822
829
|
action: function ( e, dt, button, config ) {
|
830
|
+
this.processing( true );
|
831
|
+
|
832
|
+
var that = this;
|
823
833
|
var exportData = _exportData( dt, config );
|
824
834
|
var output = exportData.str;
|
825
835
|
var hiddenDiv = $('<div/>')
|
@@ -859,6 +869,8 @@ DataTable.ext.buttons.copyHtml5 = {
|
|
859
869
|
}, exportData.rows ),
|
860
870
|
2000
|
861
871
|
);
|
872
|
+
|
873
|
+
this.processing( false );
|
862
874
|
return;
|
863
875
|
}
|
864
876
|
}
|
@@ -892,10 +904,12 @@ DataTable.ext.buttons.copyHtml5 = {
|
|
892
904
|
.on( 'keydown.buttons-copy', function (e) {
|
893
905
|
if ( e.keyCode === 27 ) { // esc
|
894
906
|
close();
|
907
|
+
that.processing( false );
|
895
908
|
}
|
896
909
|
} )
|
897
910
|
.on( 'copy.buttons-copy cut.buttons-copy', function () {
|
898
911
|
close();
|
912
|
+
that.processing( false );
|
899
913
|
} );
|
900
914
|
},
|
901
915
|
|
@@ -927,6 +941,8 @@ DataTable.ext.buttons.csvHtml5 = {
|
|
927
941
|
},
|
928
942
|
|
929
943
|
action: function ( e, dt, button, config ) {
|
944
|
+
this.processing( true );
|
945
|
+
|
930
946
|
// Set the text
|
931
947
|
var output = _exportData( dt, config ).str;
|
932
948
|
var charset = config.charset;
|
@@ -957,6 +973,8 @@ DataTable.ext.buttons.csvHtml5 = {
|
|
957
973
|
_filename( config ),
|
958
974
|
true
|
959
975
|
);
|
976
|
+
|
977
|
+
this.processing( false );
|
960
978
|
},
|
961
979
|
|
962
980
|
filename: '*',
|
@@ -993,6 +1011,9 @@ DataTable.ext.buttons.excelHtml5 = {
|
|
993
1011
|
},
|
994
1012
|
|
995
1013
|
action: function ( e, dt, button, config ) {
|
1014
|
+
this.processing( true );
|
1015
|
+
|
1016
|
+
var that = this;
|
996
1017
|
var rowPos = 0;
|
997
1018
|
var getXml = function ( type ) {
|
998
1019
|
var str = excelStrings[ type ];
|
@@ -1044,7 +1065,10 @@ DataTable.ext.buttons.excelHtml5 = {
|
|
1044
1065
|
for ( var j=0, jen=_excelSpecials.length ; j<jen ; j++ ) {
|
1045
1066
|
var special = _excelSpecials[j];
|
1046
1067
|
|
1047
|
-
|
1068
|
+
// TODO Need to provide the ability for the specials to say
|
1069
|
+
// if they are returning a string, since at the moment it is
|
1070
|
+
// assumed to be a number
|
1071
|
+
if ( row[i].match && ! row[i].match(/^0\d+/) && row[i].match( special.match ) ) {
|
1048
1072
|
var val = row[i].replace(/[^\d\.\-]/g, '');
|
1049
1073
|
|
1050
1074
|
if ( special.fmt ) {
|
@@ -1169,6 +1193,7 @@ DataTable.ext.buttons.excelHtml5 = {
|
|
1169
1193
|
.generateAsync( zipConfig )
|
1170
1194
|
.then( function ( blob ) {
|
1171
1195
|
_saveAs( blob, _filename( config ) );
|
1196
|
+
that.processing( false );
|
1172
1197
|
} );
|
1173
1198
|
}
|
1174
1199
|
else {
|
@@ -1177,6 +1202,7 @@ DataTable.ext.buttons.excelHtml5 = {
|
|
1177
1202
|
zip.generate( zipConfig ),
|
1178
1203
|
_filename( config )
|
1179
1204
|
);
|
1205
|
+
this.processing( false );
|
1180
1206
|
}
|
1181
1207
|
},
|
1182
1208
|
|
@@ -1206,7 +1232,9 @@ DataTable.ext.buttons.pdfHtml5 = {
|
|
1206
1232
|
},
|
1207
1233
|
|
1208
1234
|
action: function ( e, dt, button, config ) {
|
1209
|
-
|
1235
|
+
this.processing( true );
|
1236
|
+
|
1237
|
+
var that = this;
|
1210
1238
|
var data = dt.buttons.exportData( config.exportOptions );
|
1211
1239
|
var rows = [];
|
1212
1240
|
|
@@ -1279,11 +1307,11 @@ DataTable.ext.buttons.pdfHtml5 = {
|
|
1279
1307
|
};
|
1280
1308
|
|
1281
1309
|
if ( config.message ) {
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1310
|
+
doc.content.unshift( {
|
1311
|
+
text: typeof config.message == 'function' ? config.message(dt, button, config) : config.message,
|
1312
|
+
style: 'message',
|
1313
|
+
margin: [ 0, 0, 0, 12 ]
|
1314
|
+
} );
|
1287
1315
|
}
|
1288
1316
|
|
1289
1317
|
if ( config.title ) {
|
@@ -1302,12 +1330,14 @@ DataTable.ext.buttons.pdfHtml5 = {
|
|
1302
1330
|
|
1303
1331
|
if ( config.download === 'open' && ! _isDuffSafari() ) {
|
1304
1332
|
pdf.open();
|
1333
|
+
this.processing( false );
|
1305
1334
|
}
|
1306
1335
|
else {
|
1307
1336
|
pdf.getBuffer( function (buffer) {
|
1308
1337
|
var blob = new Blob( [buffer], {type:'application/pdf'} );
|
1309
1338
|
|
1310
1339
|
_saveAs( blob, _filename( config ) );
|
1340
|
+
that.processing( false );
|
1311
1341
|
} );
|
1312
1342
|
}
|
1313
1343
|
},
|
@@ -40,30 +40,42 @@ var DataTable = $.fn.dataTable;
|
|
40
40
|
var _link = document.createElement( 'a' );
|
41
41
|
|
42
42
|
/**
|
43
|
-
*
|
44
|
-
*
|
43
|
+
* Clone link and style tags, taking into account the need to change the source
|
44
|
+
* path.
|
45
45
|
*
|
46
46
|
* @param {node} el Element to convert
|
47
47
|
*/
|
48
|
-
var
|
48
|
+
var _styleToAbs = function( el ) {
|
49
49
|
var url;
|
50
50
|
var clone = $(el).clone()[0];
|
51
51
|
var linkHost;
|
52
52
|
|
53
53
|
if ( clone.nodeName.toLowerCase() === 'link' ) {
|
54
|
-
|
55
|
-
|
54
|
+
clone.href = _relToAbs( clone.href );
|
55
|
+
}
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
if ( linkHost.indexOf('/') === -1 && _link.pathname.indexOf('/') !== 0) {
|
60
|
-
linkHost += '/';
|
61
|
-
}
|
57
|
+
return clone.outerHTML;
|
58
|
+
};
|
62
59
|
|
63
|
-
|
60
|
+
/**
|
61
|
+
* Convert a URL from a relative to an absolute address so it will work
|
62
|
+
* correctly in the popup window which has no base URL.
|
63
|
+
*
|
64
|
+
* @param {string} href URL
|
65
|
+
*/
|
66
|
+
var _relToAbs = function( href ) {
|
67
|
+
// Assign to a link on the original page so the browser will do all the
|
68
|
+
// hard work of figuring out where the file actually is
|
69
|
+
_link.href = href;
|
70
|
+
var linkHost = _link.host;
|
71
|
+
|
72
|
+
// IE doesn't have a trailing slash on the host
|
73
|
+
// Chrome has it on the pathname
|
74
|
+
if ( linkHost.indexOf('/') === -1 && _link.pathname.indexOf('/') !== 0) {
|
75
|
+
linkHost += '/';
|
64
76
|
}
|
65
77
|
|
66
|
-
return
|
78
|
+
return _link.protocol+"//"+linkHost+_link.pathname+_link.search;
|
67
79
|
};
|
68
80
|
|
69
81
|
|
@@ -123,7 +135,7 @@ DataTable.ext.buttons.print = {
|
|
123
135
|
// in the host document and then appended to the new window.
|
124
136
|
var head = '<title>'+title+'</title>';
|
125
137
|
$('style, link').each( function () {
|
126
|
-
head +=
|
138
|
+
head += _styleToAbs( this );
|
127
139
|
} );
|
128
140
|
|
129
141
|
try {
|
@@ -146,6 +158,10 @@ DataTable.ext.buttons.print = {
|
|
146
158
|
|
147
159
|
$(win.document.body).addClass('dt-print-view');
|
148
160
|
|
161
|
+
$('img', win.document.body).each( function ( i, img ) {
|
162
|
+
img.setAttribute( 'src', _relToAbs( img.getAttribute('src') ) );
|
163
|
+
} );
|
164
|
+
|
149
165
|
if ( config.customize ) {
|
150
166
|
config.customize( win );
|
151
167
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Buttons for DataTables 1.
|
1
|
+
/*! Buttons for DataTables 1.3.1
|
2
2
|
* ©2016 SpryMedia Ltd - datatables.net/license
|
3
3
|
*/
|
4
4
|
|
@@ -48,6 +48,11 @@ var _dtButtons = DataTable.ext.buttons;
|
|
48
48
|
*/
|
49
49
|
var Buttons = function( dt, config )
|
50
50
|
{
|
51
|
+
// If there is no config set it to an empty object
|
52
|
+
if ( typeof( config ) === 'undefined' ) {
|
53
|
+
config = {};
|
54
|
+
}
|
55
|
+
|
51
56
|
// Allow a boolean true for defaults
|
52
57
|
if ( config === true ) {
|
53
58
|
config = {};
|
@@ -253,6 +258,24 @@ $.extend( Buttons.prototype, {
|
|
253
258
|
return $(button.node);
|
254
259
|
},
|
255
260
|
|
261
|
+
/**
|
262
|
+
* Set / get a processing class on the selected button
|
263
|
+
* @param {boolean} flag true to add, false to remove, undefined to get
|
264
|
+
* @return {boolean|Buttons} Getter value or this if a setter.
|
265
|
+
*/
|
266
|
+
processing: function ( node, flag )
|
267
|
+
{
|
268
|
+
var button = this._nodeToButton( node );
|
269
|
+
|
270
|
+
if ( flag === undefined ) {
|
271
|
+
return $(button.node).hasClass( 'processing' );
|
272
|
+
}
|
273
|
+
|
274
|
+
$(button.node).toggleClass( 'processing', flag );
|
275
|
+
|
276
|
+
return this;
|
277
|
+
},
|
278
|
+
|
256
279
|
/**
|
257
280
|
* Remove a button.
|
258
281
|
* @param {node} node Button node
|
@@ -462,7 +485,8 @@ $.extend( Buttons.prototype, {
|
|
462
485
|
if ( built.conf.buttons ) {
|
463
486
|
var collectionDom = this.c.dom.collection;
|
464
487
|
built.collection = $('<'+collectionDom.tag+'/>')
|
465
|
-
.addClass( collectionDom.className )
|
488
|
+
.addClass( collectionDom.className )
|
489
|
+
.attr( 'role', 'menu') ;
|
466
490
|
built.conf._collection = built.collection;
|
467
491
|
|
468
492
|
this._expandButton( built.buttons, built.conf.buttons, true, attachPoint );
|
@@ -569,7 +593,7 @@ $.extend( Buttons.prototype, {
|
|
569
593
|
}
|
570
594
|
|
571
595
|
if ( config.titleAttr ) {
|
572
|
-
button.attr( 'title', config.titleAttr );
|
596
|
+
button.attr( 'title', text( config.titleAttr ) );
|
573
597
|
}
|
574
598
|
|
575
599
|
if ( ! config.namespace ) {
|
@@ -1118,7 +1142,7 @@ Buttons.defaults = {
|
|
1118
1142
|
* @type {string}
|
1119
1143
|
* @static
|
1120
1144
|
*/
|
1121
|
-
Buttons.version = '1.
|
1145
|
+
Buttons.version = '1.3.1';
|
1122
1146
|
|
1123
1147
|
|
1124
1148
|
$.extend( _dtButtons, {
|
@@ -1399,6 +1423,19 @@ DataTable.Api.registerPlural( 'buttons().nodes()', 'button().node()', function (
|
|
1399
1423
|
return jq;
|
1400
1424
|
} );
|
1401
1425
|
|
1426
|
+
// Get / set button processing state
|
1427
|
+
DataTable.Api.registerPlural( 'buttons().processing()', 'button().processing()', function ( flag ) {
|
1428
|
+
if ( flag === undefined ) {
|
1429
|
+
return this.map( function ( set ) {
|
1430
|
+
return set.inst.processing( set.node );
|
1431
|
+
} );
|
1432
|
+
}
|
1433
|
+
|
1434
|
+
return this.each( function ( set ) {
|
1435
|
+
set.inst.processing( set.node, flag );
|
1436
|
+
} );
|
1437
|
+
} );
|
1438
|
+
|
1402
1439
|
// Get / set button text (i.e. the button labels)
|
1403
1440
|
DataTable.Api.registerPlural( 'buttons().text()', 'button().text()', function ( label ) {
|
1404
1441
|
if ( label === undefined ) {
|
@@ -1556,6 +1593,9 @@ var _exportData = function ( dt, inOpts )
|
|
1556
1593
|
return str;
|
1557
1594
|
}
|
1558
1595
|
|
1596
|
+
// Always remove script tags
|
1597
|
+
str = str.replace( /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '' );
|
1598
|
+
|
1559
1599
|
if ( config.stripHtml ) {
|
1560
1600
|
str = str.replace( /<[^>]*>/g, '' );
|
1561
1601
|
}
|
@@ -1589,7 +1629,8 @@ var _exportData = function ( dt, inOpts )
|
|
1589
1629
|
} ).toArray() :
|
1590
1630
|
null;
|
1591
1631
|
|
1592
|
-
var
|
1632
|
+
var rowIndexes = dt.rows( config.rows, config.modifier ).indexes().toArray();
|
1633
|
+
var selectedCells = dt.cells( rowIndexes, config.columns );
|
1593
1634
|
var cells = selectedCells
|
1594
1635
|
.render( config.orthogonal )
|
1595
1636
|
.toArray();
|