diff --git a/bower.json b/bower.json index aa211b6..1470426 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tableexport.js", - "version": "5.0.0-rc.4", + "version": "5.0.0-rc.6", "authors": [ "clarketm " ], diff --git a/dist/css/tableexport.css b/dist/css/tableexport.css index fc151e8..3fdbaa8 100644 --- a/dist/css/tableexport.css +++ b/dist/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/dist/css/tableexport.min.css b/dist/css/tableexport.min.css index 70b7d2f..b5e570a 100644 --- a/dist/css/tableexport.min.css +++ b/dist/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/dist/js/tableexport.js b/dist/js/tableexport.js index c7fab5d..0b2dea2 100644 --- a/dist/js/tableexport.js +++ b/dist/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -116,6 +116,8 @@ context.rcMap = new RowColMap().build(context, settings); + // console.debug(context.rcMap); + var formatMap = _FORMAT_LIST .reduce(function (acc, cur) { acc[cur] = 0; @@ -147,7 +149,7 @@ * Version. * @memberof TableExport.prototype */ - version: '5.0.0-rc.4', + version: '5.0.0-rc.6', /** * Default library options. * @memberof TableExport.prototype @@ -683,9 +685,16 @@ var _empty = RowColMap.prototype.TYPE.EMPTY; return this.getRowColMapProp(ir, ic, _empty); }; + this.isRowSpan = function (ir) { + var _rowspan = RowColMap.prototype.TYPE.ROWSPAN; + return this.getRowColMapProp(ir, undefined, _rowspan); + }; + this.isColSpan = function (ir) { + var _colspan = RowColMap.prototype.TYPE.COLSPAN; + return this.getRowColMapProp(ir, undefined, _colspan); + }; this.isSpan = function (ir) { - var _span = RowColMap.prototype.TYPE.SPAN; - return this.getRowColMapProp(ir, undefined, _span); + return this.isRowSpan(ir) || this.isColSpan(ir); }; this.getRowColMapProp = function (ir, ic, key) { if (this.rcMap[ir]) { @@ -710,30 +719,21 @@ this.rcMap[ir][ic][key] = value; } }; + this.generateTotal = function (ir, ic) { + var _total = 0; + + if (this.isRowSpan(ir) && this.isColSpan(ir)) { + _total = this.getRowColMapProp(ir, ic) || 0; + } else if (this.getRowColMapProp(ir, ic)) { + _total = this.getRowColMapProp(ir, ic); + } + return _total; + }; this.convertSpanToArray = function (ir, ic, key, _return, colDel) { + if (this.rcMap[ir] && this.isSpan(ir)) { - var threshold = ic + RowColMap.prototype.OFFSET, - total = 0, - count = 0, - skip = null, - max = Math.max.apply(Math, - Object.keys(this.rcMap[ir]).filter(_numeric) - ); - - for (var _col = 0; _col <= max; _col++) { - skip = this.rcMap[ir][_col]; - - if (!skip) { - count++ - } else { - total = (count >= ic) - ? total + skip - : total - } - if (count === threshold) { - break; - } - } + var total = this.generateTotal(ir, ic); + return (_isEnhanced(key)) ? new Array(total).concat(_return) : new Array(total).concat(_return).join(colDel); @@ -757,7 +757,8 @@ TYPE: { IGNORE: 'ignore', EMPTY: 'empty', - SPAN: 'span', + ROWSPAN: 'rowspan', + COLSPAN: 'colspan', DEFAULT: 'default' }, build: function (context, settings) { @@ -780,28 +781,40 @@ self.setRowColMapProp(ir, ic, self.TYPE.EMPTY, true); }; var handleRowSpan = function (val, ir, ic) { - var rowSpan = val.getAttribute('rowspan'); + var rowSpan = +val.getAttribute('rowspan'); var hasColSpan = val.hasAttribute('colspan'); + var handledByColSpan; for (var _row = 0; _row < rowSpan; _row++) { if (_row + ir >= rowLength) { return; } - hasColSpan && handleColSpan(val, _row + ir, ic); + hasColSpan && (handledByColSpan = handleColSpan(val, _row + ir, ic, _row > 0)); if (_row >= 1) { - self.setRowColMapProp(_row + ir, undefined, self.TYPE.SPAN, true); - self.setRowColMapProp(_row + ir, ic, undefined, 1); + var currentRowSpan = self.getRowColMapProp(_row + ir, undefined, self.TYPE.ROWSPAN) || 0; + self.setRowColMapProp(_row + ir, undefined, self.TYPE.ROWSPAN, currentRowSpan + 1); + + if (!handledByColSpan) { + var current = self.getRowColMapProp(_row + ir, ic - currentRowSpan) || 0; + self.setRowColMapProp(_row + ir, ic - currentRowSpan, undefined, current + 1); + } } } }; - var handleColSpan = function (val, ir, ic) { - var colSpan = val.getAttribute('colspan'); + var handleColSpan = function (val, ir, ic, isRowSpan) { + var colSpan = +val.getAttribute('colspan'); + var currentColSpan = self.getRowColMapProp(ir, undefined, self.TYPE.COLSPAN) || 0; + self.setRowColMapProp(ir, undefined, self.TYPE.COLSPAN, currentColSpan + 1); if (colSpan <= 1) { - return; + return false; + } + if (isRowSpan) { + self.setRowColMapProp(ir, ic - currentColSpan, undefined, colSpan); + return true; + } else { + self.setRowColMapProp(ir, ic + OFFSET, undefined, colSpan - OFFSET); } - self.setRowColMapProp(ir, undefined, self.TYPE.SPAN, true); - self.setRowColMapProp(ir, ic + OFFSET, undefined, colSpan - OFFSET); }; _nodesArray(context.rows).map(function (val, ir) { diff --git a/dist/js/tableexport.min.js b/dist/js/tableexport.min.js index 21029b6..ef5cbe9 100644 --- a/dist/js/tableexport.min.js +++ b/dist/js/tableexport.min.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -16,4 +16,4 @@ * limitations under the License. * */ -!function(t,e){if("function"==typeof define&&define.amd)define(function(t){var r;try{r=t("jquery")}catch(n){}return e(r,t("blobjs"),t("file-saverjs"),t("xlsx"))});else if("object"==typeof exports&&"string"!=typeof exports.nodeName){var r;try{r=require("jquery")}catch(n){}module.exports=e(r,require("blobjs"),require("file-saverjs"),require("xlsx"))}else t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,n){"use strict";function o(){for(var t=arguments,e=1;e tr")),e.rows=n.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=n.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=n.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===n.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:n.filename?n.filename:r.defaultFilename,e.uuid=C(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=n.bootstrapSettings.bootstrapSpacing+n.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=h.getInstance().getItem(t),n=t.substring(t.indexOf("-")+1);a[e.uuid]=a[e.uuid]||{},a[e.uuid][n]=JSON.parse(r)}}(),e.rcMap=(new g).build(e,n);var o=x.reduce(function(t,e){return t[e]=0,t},{});n.formats.forEach(function(t){return c(t)?p(t)?void(o[t]||(e.setExportData(r.exporters.build.call(r,e,t)),o[t]++)):f('"'+t+'" requires "js-xlsx".'):f('"'+t+'" is not a valid format. \nFormats: '+x.join(", "))})});var s=document.querySelectorAll("button[tableexport-id]");return E(s,"click",r.downloadHandler,r),r};m.prototype={version:"5.0.0-rc.4",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,e){var r=this,n=r.settings,o=m.prototype.formatConfig[e],a=o.separator,s=t.rcMap,l=function(t){if(y(e))return{v:n.formatValue(t.textContent),t:r.getType(t.className)};switch(e){case v.CSV:return'"'+n.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return n.formatValue(t.textContent)}},u=i(t.rows).map(function(t,r){if(s.isIgnore(r))return s.handleRowColMapProp(s.TYPE.IGNORE);var n=t.querySelectorAll("th, td");return i(n).map(function(t,n){var o=l(t);return s.isIgnore(r,n)?s.handleRowColMapProp(s.TYPE.IGNORE):s.isEmpty(r,n)?s.handleRowColMapProp(s.TYPE.EMPTY):s.handleRowColMapProp(s.TYPE.DEFAULT,r,n,e,o,a)}).processCols(e,a)}).processRows(e,r.rowDel),c=JSON.stringify({data:u,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),p=S({uuid:t.uuid,type:e});return n.exportButtons&&t.checkCaption(m.prototype.createObjButton(p,c,o.buttonContent,o.defaultClass,n.bootstrapSettings)),h.getInstance().setItem(p,c,!0)}},createObjButton:function(t,e,r,n,o){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=o.bootstrapClass+o.bootstrapTheme+n,i.textContent=r,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return m.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=m.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?w.STRING:~t.indexOf(e.number.defaultClass)?w.NUMBER:~t.indexOf(e["boolean"].defaultClass)?w.BOOLEAN:~t.indexOf(e.date.defaultClass)?w.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),n=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(n)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=m.prototype.typeConfig,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){r.s.r>i&&(r.s.r=i),r.s.c>a&&(r.s.c=a),r.e.r=e?a+u:a:l++,l!==i);p++);return y(r)?new Array(a).concat(n):new Array(a).concat(n).join(o)}return n},this.handleRowColMapProp=function(t,e,r,n,o,i){switch(t){case g.prototype.TYPE.IGNORE:return;case g.prototype.TYPE.EMPTY:return" ";case g.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,n,o,i)}}};g.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t,e){var r=this,n=r.OFFSET,o=r.rowLength=t.rows.length,s=function(t){r.setRowColMapProp(t,void 0,r.TYPE.IGNORE,!0)},l=function(t,e){r.setRowColMapProp(t,e,r.TYPE.IGNORE,!0)},u=function(t,e){r.setRowColMapProp(t,e,r.TYPE.EMPTY,!0)},c=function(t,e,n){for(var i=t.getAttribute("rowspan"),a=t.hasAttribute("colspan"),s=0;s=o)return;a&&p(t,s+e,n),s>=1&&(r.setRowColMapProp(s+e,void 0,r.TYPE.SPAN,!0),r.setRowColMapProp(s+e,n,void 0,1))}},p=function(t,e,o){var i=t.getAttribute("colspan");i<=1||(r.setRowColMapProp(e,void 0,r.TYPE.SPAN,!0),r.setRowColMapProp(e,o+n,void 0,i-n))};return i(t.rows).map(function(r,n){(~e.ignoreRows.indexOf(n-t.thAdj)||a(r,e.ignoreCSS))&&s(n);var o=r.querySelectorAll("th, td");return i(o).map(function(t,r){(~e.ignoreCols.indexOf(r)||a(t,e.ignoreCSS))&&l(n,r),a(t,e.emptyCSS)&&u(n,r),t.hasAttribute("rowspan")?c(t,n,r):t.hasAttribute("colspan")&&p(t,n,r)})}),r}};var b=function(t){return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substring(0,4))}(navigator.userAgent||navigator.vendor||window.opera),y=function(){return function(t){return n&&!b&&!m.prototype.formatConfig[t].enforceStrictRFC4180}}(),v=function(){return m.prototype.CONSTANTS.FORMAT}(),x=function(){return Object.keys(v).map(function(t){return v[t]})}(),w=function(){return m.prototype.CONSTANTS.TYPE}();Array.prototype.processRows=function(t,e){return y(t)?this.map(u).filter(l):this.filter(l).join(e)},Array.prototype.processCols=function(t,e){return y(t)?this.filter(l):this.filter(l).join(e)};var C=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),S=function(){var t,e,r=0;return function(n){var o=n.type;if(n=JSON.stringify(n),0===n.length)return r;for(t=0;t tr")),e.rows=o.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=o.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=o.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===o.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:o.filename?o.filename:r.defaultFilename,e.uuid=w(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=o.bootstrapSettings.bootstrapSpacing+o.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=h.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);a[e.uuid]=a[e.uuid]||{},a[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new m).build(e,o);var n=y.reduce(function(t,e){return t[e]=0,t},{});o.formats.forEach(function(t){return p(t)?u(t)?void(n[t]||(e.setExportData(r.exporters.build.call(r,e,t)),n[t]++)):c('"'+t+'" requires "js-xlsx".'):c('"'+t+'" is not a valid format. \nFormats: '+y.join(", "))})});var s=document.querySelectorAll("button[tableexport-id]");return S(s,"click",r.downloadHandler,r),r};d.prototype={version:"5.0.0-rc.6",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,e){var r=this,o=r.settings,n=d.prototype.formatConfig[e],a=n.separator,s=t.rcMap,l=function(t){if(b(e))return{v:o.formatValue(t.textContent),t:r.getType(t.className)};switch(e){case v.CSV:return'"'+o.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return o.formatValue(t.textContent)}},p=i(t.rows).map(function(t,r){if(s.isIgnore(r))return s.handleRowColMapProp(s.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return i(o).map(function(t,o){var n=l(t);return s.isIgnore(r,o)?s.handleRowColMapProp(s.TYPE.IGNORE):s.isEmpty(r,o)?s.handleRowColMapProp(s.TYPE.EMPTY):s.handleRowColMapProp(s.TYPE.DEFAULT,r,o,e,n,a)}).processCols(e,a)}).processRows(e,r.rowDel),u=JSON.stringify({data:p,filename:t.filename,mimeType:n.mimeType,fileExtension:n.fileExtension}),c=C({uuid:t.uuid,type:e});return o.exportButtons&&t.checkCaption(d.prototype.createObjButton(c,u,n.buttonContent,n.defaultClass,o.bootstrapSettings)),h.getInstance().setItem(c,u,!0)}},createObjButton:function(t,e,r,o,n){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=n.bootstrapClass+n.bootstrapTheme+o,i.textContent=r,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return d.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=d.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?x.STRING:~t.indexOf(e.number.defaultClass)?x.NUMBER:~t.indexOf(e["boolean"].defaultClass)?x.BOOLEAN:~t.indexOf(e.date.defaultClass)?x.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),o=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(o)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=d.prototype.typeConfig,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){r.s.r>i&&(r.s.r=i),r.s.c>a&&(r.s.c=a),r.e.r=n)return;if(s&&(i=c(t,l+e,o,l>0)),l>=1){var p=r.getRowColMapProp(l+e,void 0,r.TYPE.ROWSPAN)||0;if(r.setRowColMapProp(l+e,void 0,r.TYPE.ROWSPAN,p+1),!i){var u=r.getRowColMapProp(l+e,o-p)||0;r.setRowColMapProp(l+e,o-p,void 0,u+1)}}}},c=function(t,e,n,i){var a=+t.getAttribute("colspan"),s=r.getRowColMapProp(e,void 0,r.TYPE.COLSPAN)||0;return r.setRowColMapProp(e,void 0,r.TYPE.COLSPAN,s+1),!(a<=1)&&(i?(r.setRowColMapProp(e,n-s,void 0,a),!0):void r.setRowColMapProp(e,n+o,void 0,a-o))};return i(t.rows).map(function(r,o){(~e.ignoreRows.indexOf(o-t.thAdj)||a(r,e.ignoreCSS))&&s(o);var n=r.querySelectorAll("th, td");return i(n).map(function(t,r){(~e.ignoreCols.indexOf(r)||a(t,e.ignoreCSS))&&l(o,r),a(t,e.emptyCSS)&&p(o,r),t.hasAttribute("rowspan")?u(t,o,r):t.hasAttribute("colspan")&&c(t,o,r)})}),r}};var g=function(t){return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substring(0,4))}(navigator.userAgent||navigator.vendor||window.opera),b=function(){return function(t){return o&&!g&&!d.prototype.formatConfig[t].enforceStrictRFC4180}}(),v=function(){return d.prototype.CONSTANTS.FORMAT}(),y=function(){return Object.keys(v).map(function(t){return v[t]})}(),x=function(){return d.prototype.CONSTANTS.TYPE}();Array.prototype.processRows=function(t,e){return b(t)?this.map(l).filter(s):this.filter(s).join(e)},Array.prototype.processCols=function(t,e){return b(t)?this.filter(s):this.filter(s).join(e)};var w=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),C=function(){var t,e,r=0;return function(o){var n=o.type;if(o=JSON.stringify(o),0===o.length)return r;for(t=0;t /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/package.json b/package.json index 7f3e154..916e54f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tableexport", - "version": "5.0.0-rc.4", + "version": "5.0.0-rc.6", "authors": [ "clarketm " ], diff --git a/src/stable/css/tableexport.css b/src/stable/css/tableexport.css index fc151e8..3fdbaa8 100644 --- a/src/stable/css/tableexport.css +++ b/src/stable/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/src/stable/css/tableexport.min.css b/src/stable/css/tableexport.min.css index 70b7d2f..b5e570a 100644 --- a/src/stable/css/tableexport.min.css +++ b/src/stable/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * diff --git a/src/stable/js/tableexport.js b/src/stable/js/tableexport.js index f8306be..0b2dea2 100644 --- a/src/stable/js/tableexport.js +++ b/src/stable/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -116,7 +116,7 @@ context.rcMap = new RowColMap().build(context, settings); - console.debug(context.rcMap); + // console.debug(context.rcMap); var formatMap = _FORMAT_LIST .reduce(function (acc, cur) { @@ -149,7 +149,7 @@ * Version. * @memberof TableExport.prototype */ - version: '5.0.0-rc.4', + version: '5.0.0-rc.6', /** * Default library options. * @memberof TableExport.prototype @@ -790,7 +790,6 @@ return; } hasColSpan && (handledByColSpan = handleColSpan(val, _row + ir, ic, _row > 0)); - if (_row >= 1) { var currentRowSpan = self.getRowColMapProp(_row + ir, undefined, self.TYPE.ROWSPAN) || 0; self.setRowColMapProp(_row + ir, undefined, self.TYPE.ROWSPAN, currentRowSpan + 1); @@ -815,9 +814,7 @@ return true; } else { self.setRowColMapProp(ir, ic + OFFSET, undefined, colSpan - OFFSET); - return false; } - }; _nodesArray(context.rows).map(function (val, ir) { diff --git a/src/stable/js/tableexport.min.js b/src/stable/js/tableexport.min.js index 21029b6..ef5cbe9 100644 --- a/src/stable/js/tableexport.min.js +++ b/src/stable/js/tableexport.min.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.0-rc.4 (https://www.travismclarke.com) + * TableExport.js v5.0.0-rc.6 (https://www.travismclarke.com) * * Copyright (c) 2017 - Travis Clarke - https://www.travismclarke.com * @@ -16,4 +16,4 @@ * limitations under the License. * */ -!function(t,e){if("function"==typeof define&&define.amd)define(function(t){var r;try{r=t("jquery")}catch(n){}return e(r,t("blobjs"),t("file-saverjs"),t("xlsx"))});else if("object"==typeof exports&&"string"!=typeof exports.nodeName){var r;try{r=require("jquery")}catch(n){}module.exports=e(r,require("blobjs"),require("file-saverjs"),require("xlsx"))}else t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,n){"use strict";function o(){for(var t=arguments,e=1;e tr")),e.rows=n.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=n.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=n.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===n.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:n.filename?n.filename:r.defaultFilename,e.uuid=C(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=n.bootstrapSettings.bootstrapSpacing+n.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=h.getInstance().getItem(t),n=t.substring(t.indexOf("-")+1);a[e.uuid]=a[e.uuid]||{},a[e.uuid][n]=JSON.parse(r)}}(),e.rcMap=(new g).build(e,n);var o=x.reduce(function(t,e){return t[e]=0,t},{});n.formats.forEach(function(t){return c(t)?p(t)?void(o[t]||(e.setExportData(r.exporters.build.call(r,e,t)),o[t]++)):f('"'+t+'" requires "js-xlsx".'):f('"'+t+'" is not a valid format. \nFormats: '+x.join(", "))})});var s=document.querySelectorAll("button[tableexport-id]");return E(s,"click",r.downloadHandler,r),r};m.prototype={version:"5.0.0-rc.4",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,e){var r=this,n=r.settings,o=m.prototype.formatConfig[e],a=o.separator,s=t.rcMap,l=function(t){if(y(e))return{v:n.formatValue(t.textContent),t:r.getType(t.className)};switch(e){case v.CSV:return'"'+n.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return n.formatValue(t.textContent)}},u=i(t.rows).map(function(t,r){if(s.isIgnore(r))return s.handleRowColMapProp(s.TYPE.IGNORE);var n=t.querySelectorAll("th, td");return i(n).map(function(t,n){var o=l(t);return s.isIgnore(r,n)?s.handleRowColMapProp(s.TYPE.IGNORE):s.isEmpty(r,n)?s.handleRowColMapProp(s.TYPE.EMPTY):s.handleRowColMapProp(s.TYPE.DEFAULT,r,n,e,o,a)}).processCols(e,a)}).processRows(e,r.rowDel),c=JSON.stringify({data:u,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),p=S({uuid:t.uuid,type:e});return n.exportButtons&&t.checkCaption(m.prototype.createObjButton(p,c,o.buttonContent,o.defaultClass,n.bootstrapSettings)),h.getInstance().setItem(p,c,!0)}},createObjButton:function(t,e,r,n,o){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=o.bootstrapClass+o.bootstrapTheme+n,i.textContent=r,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return m.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=m.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?w.STRING:~t.indexOf(e.number.defaultClass)?w.NUMBER:~t.indexOf(e["boolean"].defaultClass)?w.BOOLEAN:~t.indexOf(e.date.defaultClass)?w.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),n=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(n)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=m.prototype.typeConfig,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){r.s.r>i&&(r.s.r=i),r.s.c>a&&(r.s.c=a),r.e.r=e?a+u:a:l++,l!==i);p++);return y(r)?new Array(a).concat(n):new Array(a).concat(n).join(o)}return n},this.handleRowColMapProp=function(t,e,r,n,o,i){switch(t){case g.prototype.TYPE.IGNORE:return;case g.prototype.TYPE.EMPTY:return" ";case g.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,n,o,i)}}};g.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t,e){var r=this,n=r.OFFSET,o=r.rowLength=t.rows.length,s=function(t){r.setRowColMapProp(t,void 0,r.TYPE.IGNORE,!0)},l=function(t,e){r.setRowColMapProp(t,e,r.TYPE.IGNORE,!0)},u=function(t,e){r.setRowColMapProp(t,e,r.TYPE.EMPTY,!0)},c=function(t,e,n){for(var i=t.getAttribute("rowspan"),a=t.hasAttribute("colspan"),s=0;s=o)return;a&&p(t,s+e,n),s>=1&&(r.setRowColMapProp(s+e,void 0,r.TYPE.SPAN,!0),r.setRowColMapProp(s+e,n,void 0,1))}},p=function(t,e,o){var i=t.getAttribute("colspan");i<=1||(r.setRowColMapProp(e,void 0,r.TYPE.SPAN,!0),r.setRowColMapProp(e,o+n,void 0,i-n))};return i(t.rows).map(function(r,n){(~e.ignoreRows.indexOf(n-t.thAdj)||a(r,e.ignoreCSS))&&s(n);var o=r.querySelectorAll("th, td");return i(o).map(function(t,r){(~e.ignoreCols.indexOf(r)||a(t,e.ignoreCSS))&&l(n,r),a(t,e.emptyCSS)&&u(n,r),t.hasAttribute("rowspan")?c(t,n,r):t.hasAttribute("colspan")&&p(t,n,r)})}),r}};var b=function(t){return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substring(0,4))}(navigator.userAgent||navigator.vendor||window.opera),y=function(){return function(t){return n&&!b&&!m.prototype.formatConfig[t].enforceStrictRFC4180}}(),v=function(){return m.prototype.CONSTANTS.FORMAT}(),x=function(){return Object.keys(v).map(function(t){return v[t]})}(),w=function(){return m.prototype.CONSTANTS.TYPE}();Array.prototype.processRows=function(t,e){return y(t)?this.map(u).filter(l):this.filter(l).join(e)},Array.prototype.processCols=function(t,e){return y(t)?this.filter(l):this.filter(l).join(e)};var C=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),S=function(){var t,e,r=0;return function(n){var o=n.type;if(n=JSON.stringify(n),0===n.length)return r;for(t=0;t tr")),e.rows=o.headers?i(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=o.footers?e.rows.concat(i(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=o.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===o.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:o.filename?o.filename:r.defaultFilename,e.uuid=w(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=o.bootstrapSettings.bootstrapSpacing+o.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=h.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);a[e.uuid]=a[e.uuid]||{},a[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new m).build(e,o);var n=y.reduce(function(t,e){return t[e]=0,t},{});o.formats.forEach(function(t){return p(t)?u(t)?void(n[t]||(e.setExportData(r.exporters.build.call(r,e,t)),n[t]++)):c('"'+t+'" requires "js-xlsx".'):c('"'+t+'" is not a valid format. \nFormats: '+y.join(", "))})});var s=document.querySelectorAll("button[tableexport-id]");return S(s,"click",r.downloadHandler,r),r};d.prototype={version:"5.0.0-rc.6",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,e){var r=this,o=r.settings,n=d.prototype.formatConfig[e],a=n.separator,s=t.rcMap,l=function(t){if(b(e))return{v:o.formatValue(t.textContent),t:r.getType(t.className)};switch(e){case v.CSV:return'"'+o.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return o.formatValue(t.textContent)}},p=i(t.rows).map(function(t,r){if(s.isIgnore(r))return s.handleRowColMapProp(s.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return i(o).map(function(t,o){var n=l(t);return s.isIgnore(r,o)?s.handleRowColMapProp(s.TYPE.IGNORE):s.isEmpty(r,o)?s.handleRowColMapProp(s.TYPE.EMPTY):s.handleRowColMapProp(s.TYPE.DEFAULT,r,o,e,n,a)}).processCols(e,a)}).processRows(e,r.rowDel),u=JSON.stringify({data:p,filename:t.filename,mimeType:n.mimeType,fileExtension:n.fileExtension}),c=C({uuid:t.uuid,type:e});return o.exportButtons&&t.checkCaption(d.prototype.createObjButton(c,u,n.buttonContent,n.defaultClass,o.bootstrapSettings)),h.getInstance().setItem(c,u,!0)}},createObjButton:function(t,e,r,o,n){var i=document.createElement("button");return i.setAttribute("tableexport-id",t),i.className=n.bootstrapClass+n.bootstrapTheme+o,i.textContent=r,i},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return d.prototype.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=d.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?x.STRING:~t.indexOf(e.number.defaultClass)?x.NUMBER:~t.indexOf(e["boolean"].defaultClass)?x.BOOLEAN:~t.indexOf(e.date.defaultClass)?x.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t),o=(r-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(o)},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=d.prototype.typeConfig,i=0;i!==t.length;++i)for(var a=0;a!==t[i].length;++a){r.s.r>i&&(r.s.r=i),r.s.c>a&&(r.s.c=a),r.e.r=n)return;if(s&&(i=c(t,l+e,o,l>0)),l>=1){var p=r.getRowColMapProp(l+e,void 0,r.TYPE.ROWSPAN)||0;if(r.setRowColMapProp(l+e,void 0,r.TYPE.ROWSPAN,p+1),!i){var u=r.getRowColMapProp(l+e,o-p)||0;r.setRowColMapProp(l+e,o-p,void 0,u+1)}}}},c=function(t,e,n,i){var a=+t.getAttribute("colspan"),s=r.getRowColMapProp(e,void 0,r.TYPE.COLSPAN)||0;return r.setRowColMapProp(e,void 0,r.TYPE.COLSPAN,s+1),!(a<=1)&&(i?(r.setRowColMapProp(e,n-s,void 0,a),!0):void r.setRowColMapProp(e,n+o,void 0,a-o))};return i(t.rows).map(function(r,o){(~e.ignoreRows.indexOf(o-t.thAdj)||a(r,e.ignoreCSS))&&s(o);var n=r.querySelectorAll("th, td");return i(n).map(function(t,r){(~e.ignoreCols.indexOf(r)||a(t,e.ignoreCSS))&&l(o,r),a(t,e.emptyCSS)&&p(o,r),t.hasAttribute("rowspan")?u(t,o,r):t.hasAttribute("colspan")&&c(t,o,r)})}),r}};var g=function(t){return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substring(0,4))}(navigator.userAgent||navigator.vendor||window.opera),b=function(){return function(t){return o&&!g&&!d.prototype.formatConfig[t].enforceStrictRFC4180}}(),v=function(){return d.prototype.CONSTANTS.FORMAT}(),y=function(){return Object.keys(v).map(function(t){return v[t]})}(),x=function(){return d.prototype.CONSTANTS.TYPE}();Array.prototype.processRows=function(t,e){return b(t)?this.map(l).filter(s):this.filter(s).join(e)},Array.prototype.processCols=function(t,e){return b(t)?this.filter(s):this.filter(s).join(e)};var w=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),C=function(){var t,e,r=0;return function(o){var n=o.type;if(o=JSON.stringify(o),0===o.length)return r;for(t=0;t