diff --git a/dist/js/tableexport.js b/dist/js/tableexport.js index 6a9bccd..177da35 100755 --- a/dist/js/tableexport.js +++ b/dist/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v3.0.0 (http://www.clarketravis.com) + * TableExport.js v3.1.0 (http://www.clarketravis.com) * Copyright 2015 Travis Clarke * Licensed under the MIT license */ diff --git a/dist/js/tableexport.min.js b/dist/js/tableexport.min.js index d290282..e0c8a09 100755 --- a/dist/js/tableexport.min.js +++ b/dist/js/tableexport.min.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v3.0.0 (http://www.clarketravis.com) + * TableExport.js v3.1.0 (http://www.clarketravis.com) * Copyright 2015 Travis Clarke * Licensed under the MIT license */ diff --git a/gulpfile.js b/gulpfile.js index 1dbfd72..be36b7b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,10 +4,7 @@ var gulp = require('gulp'), js = require('gulp-uglify'); gulp.task('js', ['clean'], function () { - return gulp.src('./src/v3/tableexport-3.1.js') - .pipe(rename({ - basename: "tableexport" - })) + return gulp.src('./src/stable/js/tableexport.js') .pipe(gulp.dest('./dist/js/')) .pipe(js({output: {comments: /^!|@preserve|@license|@cc_on/i}})) .pipe(rename({ diff --git a/src/stable/js/tableexport.js b/src/stable/js/tableexport.js index 707e68d..177da35 100755 --- a/src/stable/js/tableexport.js +++ b/src/stable/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v3.0.0 (http://www.clarketravis.com) + * TableExport.js v3.1.0 (http://www.clarketravis.com) * Copyright 2015 Travis Clarke * Licensed under the MIT license */ @@ -40,13 +40,14 @@ data: dataURL, name: name }), + myFile = name + ".xlsx", myContent = $.fn.tableExport.xlsx.buttonContent, myClass = $.fn.tableExport.xlsx.defaultClass; - createObjButton(dataObject, myContent, myClass); + createObjButton(dataObject, myFile, myContent, myClass); }, xls: function (rdel, name) { var colD = $.fn.tableExport.xls.separator, - dataURL = 'data:application/vnd.ms-excel;charset=utf-8,' + + dataURL = 'data:application/vnd.ms-excel;charset=utf-16,' + encodeURIComponent($rows.map(function (i, val) { var $cols = $(val).find('th, td'); return $cols.map(function (i, val) { @@ -61,7 +62,7 @@ csv: function (rdel, name) { rdel = '"' + rdel + '"'; var colD = '"' + $.fn.tableExport.csv.separator + '"', - dataURL = 'data:text/csv;charset=utf-8,' + + dataURL = 'data:text/csv;charset=utf-16,' + encodeURIComponent('"' + $rows.map(function (i, val) { var $cols = $(val).find('th, td'); return $cols.map(function (i, val) { @@ -75,7 +76,7 @@ }, txt: function (rdel, name) { var colD = $.fn.tableExport.txt.separator, - dataURL = 'data:text/plain;charset=utf-8,' + + dataURL = 'data:text/plain;charset=utf-16,' + encodeURIComponent($rows.map(function (i, val) { var $cols = $(val).find('th, td'); return $cols.map(function (i, val) { @@ -105,8 +106,8 @@ checkCaption(exportButton); } - function createObjButton(dataObject, myContent, myClass) { - var exportButton = "" + myContent + ""; + function createObjButton(dataObject, myFile, myContent, myClass) { + var exportButton = "" + myContent + ""; checkCaption(exportButton); addListener(myClass) } diff --git a/src/stable/js/tableexport.min.js b/src/stable/js/tableexport.min.js index 2057193..a3cda0f 100755 --- a/src/stable/js/tableexport.min.js +++ b/src/stable/js/tableexport.min.js @@ -1,6 +1,6 @@ /*! - * TableExport.js v3.0.0 (http://www.clarketravis.com) + * TableExport.js v3.1.0 (http://www.clarketravis.com) * Copyright 2015 Travis Clarke * Licensed under the MIT license */ -(function(window,undefined){var $=window.jQuery;$.fn.tableExport=function(options){var settings=$.extend({},$.fn.tableExport.defaults,options),rowD=$.fn.tableExport.rowDel,bootstrapClass,bootstrapTheme,bootstrapSpacing;if(settings.bootstrap){bootstrapClass=$.fn.tableExport.bootstrap[0]+" ";bootstrapTheme=$.fn.tableExport.bootstrap[1]+" ";bootstrapSpacing=$.fn.tableExport.bootstrap[2]+" ";}else{bootstrapClass=$.fn.tableExport.defaultButton+" ";bootstrapTheme=bootstrapSpacing="";}return this.each(function(){var $el=$(this),$rows=settings.headings?$el.find("tr"):$el.find("tr:has(td)"),fileName=settings.fileName==="id"?($el.attr("id")?$el.attr("id"):$.fn.tableExport.defaultFileName):settings.fileName,exporters={xlsx:function(rDel,name){var dataURL=$rows.map(function(i,val){var $cols=$(val).find("th, td");return $cols.map(function(i,val){return $(val).text();});}).get(),dataObject=JSON.stringify({data:dataURL,name:name}),myContent=$.fn.tableExport.xlsx.buttonContent,myClass=$.fn.tableExport.xlsx.defaultClass;createObjButton(dataObject,myContent,myClass);},xls:function(rdel,name){var colD=$.fn.tableExport.xls.separator,dataURL="data:application/vnd.ms-excel;charset=utf-8,"+encodeURIComponent($rows.map(function(i,val){var $cols=$(val).find("th, td");return $cols.map(function(i,val){return $(val).html();}).get().join(colD);}).get().join(rdel)),myFile=name+".xls",myContent=$.fn.tableExport.xls.buttonContent,myClass=$.fn.tableExport.xls.defaultClass;createButton(dataURL,myFile,myContent,myClass);},csv:function(rdel,name){rdel='"'+rdel+'"';var colD='"'+$.fn.tableExport.csv.separator+'"',dataURL="data:text/csv;charset=utf-8,"+encodeURIComponent('"'+$rows.map(function(i,val){var $cols=$(val).find("th, td");return $cols.map(function(i,val){return $(val).text().replace(/"/g,'""');}).get().join(colD);}).get().join(rdel)+'"'),myFile=name+".csv",myContent=$.fn.tableExport.csv.buttonContent,myClass=$.fn.tableExport.csv.defaultClass;createButton(dataURL,myFile,myContent,myClass);},txt:function(rdel,name){var colD=$.fn.tableExport.txt.separator,dataURL="data:text/plain;charset=utf-8,"+encodeURIComponent($rows.map(function(i,val){var $cols=$(val).find("th, td");return $cols.map(function(i,val){return $(val).text();}).get().join(colD);}).get().join(rdel)),myFile=name+".txt",myContent=$.fn.tableExport.txt.buttonContent,myClass=$.fn.tableExport.txt.defaultClass;createButton(dataURL,myFile,myContent,myClass);}};settings.formats.forEach(function(key){exporters[key](rowD,fileName);});function checkCaption(exportButton){var $caption=$el.find("caption:not(.head)");$caption.length?$caption.append(exportButton):$el.prepend('