diff --git a/dist/js/tableexport.js b/dist/js/tableexport.js index c1805d3..3bbc304 100644 --- a/dist/js/tableexport.js +++ b/dist/js/tableexport.js @@ -19,22 +19,15 @@ ;(function (root, factory) { - var get$ = function (require) { - try { - require.resolve('jquery'); - } catch (e) { - } - return require('jquery'); - }; if (typeof define === 'function' && define.amd) { // AMD define(function (require) { - var $ = get$(require); + var $; try { $ = require('jquery') } catch(e) {} return factory($, require('blobjs'), require('file-saverjs'), require('xlsx')); }); } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { // CommonJS - var $ = get$(require); + var $; try { $ = require('jquery') } catch(e) {} module.exports = factory($, require('blobjs'), require('file-saverjs'), require('xlsx')); } else { // Browser globals diff --git a/dist/js/tableexport.min.js b/dist/js/tableexport.min.js index 5863d29..dc5327a 100644 --- a/dist/js/tableexport.min.js +++ b/dist/js/tableexport.min.js @@ -16,4 +16,4 @@ * limitations under the License. * */ -!function(t,e){var r=function(t){try{t.resolve("jquery")}catch(e){}return t("jquery")};if("function"==typeof define&&define.amd)define(function(t){var o=r(t);return e(o,t("blobjs"),t("file-saverjs"),t("xlsx"))});else if("object"==typeof exports&&"string"!=typeof exports.nodeName){var o=r(require);module.exports=e(o,require("blobjs"),require("file-saverjs"),require("xlsx"))}else t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,o){"use strict";function n(){for(var t=arguments,e=1;e tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"4.1.0-rc.1",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",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"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"}},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:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.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=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.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=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"4.1.0-rc.1",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",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"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"}},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:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.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=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.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=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"4.1.0-rc.1",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",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"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"}},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:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.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=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.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=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i tr")),e.rows=i.headers?a(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=i.footers?e.rows.concat(a(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=i.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===i.filename?t.getAttribute("id")?t.getAttribute("id"):r.defaultFilename:i.filename?i.filename:r.defaultFilename,e.uuid=g(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption.tableexport-caption");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=i.bootstrapSettings.bootstrapSpacing+i.position+" tableexport-caption",r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=f.getInstance().getItem(t),o=t.substring(t.indexOf("-")+1);s[e.uuid]=s[e.uuid]||{},s[e.uuid][o]=JSON.parse(r)}}(),e.rcMap=(new d).build.call(r,e);var n={};for(var p in h)n[h[p]]=0;i.formats.forEach(function(t){!(!o||v||t!==h.XLS)&&(t=h.BIFF2),!(o&&!v||t!==h.XLSX)&&(t=h.XLS),n[t]||(e.setExportData(r.exporters[t].call(r,e)),n[t]++)})});var p=document.querySelectorAll("button[tableexport-id]");return b(p,"click",r.downloadHandler,r),r};c.prototype={version:"4.1.0-rc.1",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",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"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"}},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:{xlsx:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLSX],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLSX});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},biff2:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=t.rcMap,i=a(t.rows).map(function(t,o){if(n.isIgnore(o))return n.handleRowColMapProp(n.TYPE.IGNORE);var i=t.querySelectorAll("th, td");return a(i).map(function(t,a){var i={v:r.formatValue(t.textContent),t:e.getType(t.className)};return n.isIgnore(o,a)?n.handleRowColMapProp(n.TYPE.IGNORE):n.isEmpty(o,a)?n.handleRowColMapProp(n.TYPE.EMPTY):n.handleRowColMapProp(n.TYPE.DEFAULT,o,a,i)}).filter(p)}).map(l).filter(p),s=JSON.stringify({data:i,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,s,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,s,!0)},xls:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.XLS],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.XLS});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},csv:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.CSV],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a='"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"';return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.CSV});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)},txt:function(t){var e=this,r=e.settings,o=c.prototype.formatConfig[h.TXT],n=o.separator,i=t.rcMap,s=a(t.rows).map(function(t,e){if(i.isIgnore(e))return i.handleRowColMapProp(i.TYPE.IGNORE);var o=t.querySelectorAll("th, td");return a(o).map(function(t,o){var a=r.formatValue(t.textContent);return i.isIgnore(e,o)?i.handleRowColMapProp(i.TYPE.IGNORE):i.isEmpty(e,o)?i.handleRowColMapProp(i.TYPE.EMPTY):i.handleRowColMapProp(i.TYPE.DEFAULT,e,o,a,n)}).filter(p).join(n)}).filter(p).join(e.rowDel),l=JSON.stringify({data:s,filename:t.filename,mimeType:o.mimeType,fileExtension:o.fileExtension}),u=y({uuid:t.uuid,type:h.TXT});return r.exportButtons&&t.checkCaption(c.prototype.createObjButton(u,l,o.buttonContent,o.defaultClass,r.bootstrapSettings)),f.getInstance().setItem(u,l,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("tableexport-id",t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return c.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=c.prototype.typeConfig;return~t.indexOf(e.string.defaultClass)?m.STRING:~t.indexOf(e.number.defaultClass)?m.NUMBER:~t.indexOf(e["boolean"].defaultClass)?m.BOOLEAN:~t.indexOf(e.date.defaultClass)?m.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=c.prototype.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){r.s.r>a&&(r.s.r=a),r.s.c>i&&(r.s.c=i),r.e.r=e?a+p:a:i++,i!==n);u++);return"undefined"!=typeof o?new Array(a).concat(r).join(o):new Array(a).concat(r)}return r},this.handleRowColMapProp=function(t,e,r,o,n){switch(t){case d.prototype.TYPE.IGNORE:return;case d.prototype.TYPE.EMPTY:return" ";case d.prototype.TYPE.DEFAULT:default:return this.convertSpanToArray(e,r,o,n)}}};d.prototype={OFFSET:1,TYPE:{IGNORE:"ignore",EMPTY:"empty",SPAN:"span",DEFAULT:"default"},build:function(t){var e=this,r=e.settings,o=1,n=new d,s=function(t){n.setRowColMapProp(t,void 0,n.TYPE.IGNORE,!0)},p=function(t,e){n.setRowColMapProp(t,e,n.TYPE.IGNORE,!0)},l=function(t,e){n.setRowColMapProp(t,e,n.TYPE.EMPTY,!0)},u=function(t,e,r){var o=t.getAttribute("rowspan"),a=t.hasAttribute("colspan");a&&c(t,e,r);for(var i=1;i