ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject svn commit: r1710522 - in /ignite/site/trunk: includes/scripts.html js/tableExport.min.js
Date Mon, 26 Oct 2015 08:01:36 GMT
Author: anovikov
Date: Mon Oct 26 08:01:36 2015
New Revision: 1710522

URL: http://svn.apache.org/viewvc?rev=1710522&view=rev
Log:
Export table fix

Added:
    ignite/site/trunk/js/tableExport.min.js
Modified:
    ignite/site/trunk/includes/scripts.html

Modified: ignite/site/trunk/includes/scripts.html
URL: http://svn.apache.org/viewvc/ignite/site/trunk/includes/scripts.html?rev=1710522&r1=1710521&r2=1710522&view=diff
==============================================================================
--- ignite/site/trunk/includes/scripts.html (original)
+++ ignite/site/trunk/includes/scripts.html Mon Oct 26 08:01:36 2015
@@ -57,7 +57,7 @@
 <script type="text/javascript" src="//cdn.rawgit.com/hhurz/tableExport.jquery.plugin/master/libs/FileSaver/FileSaver.min.js"></script>
 <script type="text/javascript" src="//cdn.rawgit.com/hhurz/tableExport.jquery.plugin/master/libs/jsPDF/jspdf.min.js"></script>
 <script type="text/javascript" src="//cdn.rawgit.com/hhurz/tableExport.jquery.plugin/master/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js"></script>
-<script type="text/javascript" src="//raw.githubusercontent.com/hhurz/tableExport.jquery.plugin/master/tableExport.min.js"></script>
+<script type="text/javascript" src="/js/tableExport.min.js"></script>
 
 <script type="text/javascript">
 $(document).ready(function() {
@@ -72,16 +72,17 @@ $(document).ready(function() {
                         styles: {
                             overflow: 'linebreak',
                             fontSize: 14,
-                            rowHeight: 22
+                            rowHeight: 19,
+                            valign: 'top'
                         },
                         headerStyles: {
-                            rowHeight: 28,
+                            rowHeight: 20,
                             fontSize: 16,
                             fillColor: 207,
-                            textColor: 0
+                            textColor: 0,
+                            valign: 'middle'
                         },
                         bodyStyles: {
-                            rowHeight: 20,
                             fillColor: 245
                         },
                         alternateRowStyles: {fillColor: 255}

Added: ignite/site/trunk/js/tableExport.min.js
URL: http://svn.apache.org/viewvc/ignite/site/trunk/js/tableExport.min.js?rev=1710522&view=auto
==============================================================================
--- ignite/site/trunk/js/tableExport.min.js (added)
+++ ignite/site/trunk/js/tableExport.min.js Mon Oct 26 08:01:36 2015
@@ -0,0 +1,29 @@
+(function(b){b.fn.extend({tableExport:function(t){function v(h,x,e,g,H){if(-1==b.inArray(e,a.ignoreRow)&&-1==b.inArray(e-g,a.ignoreRow)){var
d=b(h).filter(function(){return"none"!=b(this).data("tableexport-display")&&(b(this).is(":visible")||"always"==b(this).data("tableexport-display")||"always"==b(this).closest("table").data("tableexport-display"))}).find(x);d.each(function(h){if(("always"==b(this).data("tableexport-display")||"none"!=b(this).css("display")&&"hidden"!=b(this).css("visibility")&&
+"none"!=b(this).data("tableexport-display"))&&-1==b.inArray(h,a.ignoreColumn)&&-1==b.inArray(h-d.length,a.ignoreColumn)&&"function"===typeof
H){var g=0;if("undefined"!=typeof C[e]&&0<C[e].length)for(c=0;c<=h;c++)"undefined"!=typeof
C[e][c]&&(H(null,e,c),delete C[e][c],h++);H(this,e,h);if(b(this).is("[colspan]"))for(g=b(this).attr("colspan"),c=0;c<g-1;c++)H(null,e,h+c);if(b(this).is("[rowspan]")){var
x=parseInt(b(this).attr("rowspan"));for(r=1;r<x;r++)for("undefined"==typeof C[e+r]&&(C[e+r]=[]),C[e+
+r][h]="",c=1;c<g;c++)C[e+r][h+c]=""}}})}}function O(h){!0===a.consoleLog&&console.log(h.output());if("string"==a.outputMode)return
h.output();if("base64"==a.outputMode)return D(h.output());try{var x=h.output("blob");saveAs(x,a.fileName+".pdf")}catch(e){E(a.fileName+".pdf","data:application/pdf;base64,"+D(h.output()))}}function
L(h,a,e){return h.replace(new RegExp(a.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"),"g"),e)}function
P(h,x,e){var g="";if(null!=h)if(h=w(h,x,e),x=null===h||""==h?"":h.toString(),
+h instanceof Date)g=a.csvEnclosure+h.toLocaleString()+a.csvEnclosure;else if(g=L(x,a.csvEnclosure,a.csvEnclosure+a.csvEnclosure),0<=g.indexOf(a.csvSeparator)||/[\r\n
]/g.test(g))g=a.csvEnclosure+g+a.csvEnclosure;return g}function V(h){h=L(h||"0",a.numbers.html.decimalMark,".");h=L(h,a.numbers.html.thousandsSeparator,"");return"number"===typeof
h||!1!==jQuery.isNumeric(h)?h:!1}function w(h,x,e){var g="";if(null!=h){h=b(h);if(!0===a.htmlContent)g=b.trim(h.html());else{var
d=h.html().replace(/\n/g,"\u2028").replace(/<br\s*[\/]?>/gi,
+"\u2060"),f=b("<div/>").html(d).contents(),d="";b.each(f.text().split("\u2028"),function(h,a){0<h&&(d+="
");d+=b.trim(a)});b.each(d.split("\u2060"),function(h,a){0<h&&(g+="\n");g+=b.trim(a).replace(/\u00AD/g,"")});if(a.numbers.html.decimalMark!=a.numbers.output.decimalMark||a.numbers.html.thousandsSeparator!=a.numbers.output.thousandsSeparator)if(f=V(g),!1!==f){var
k=(""+f).split(".");1==k.length&&(k[1]="");var l=3<k[0].length?k[0].length%3:0,g=(0>f?"-":"")+(a.numbers.output.thousandsSeparator?(l?
+k[0].substr(0,l)+a.numbers.output.thousandsSeparator:"")+k[0].substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a.numbers.output.thousandsSeparator):k[0])+(k[1].length?a.numbers.output.decimalMark+k[1]:"")}}!0===a.escape&&(g=escape(g));"function"===typeof
a.onCellData&&(g=a.onCellData(h,x,e,g))}return g}function W(h,a,e){return a+"-"+e.toLowerCase()}function
I(a,b){var e=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(a),g=b;e&&(g=[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]);return
g}function A(a,b){try{return window.getComputedStyle?
+(b=b.replace(/([a-z])([A-Z])/,W),window.getComputedStyle(a,null).getPropertyValue(b)):a.currentStyle?a.currentStyle[b]:a.style[b]}catch(e){}return""}function
M(a,b,e){b=A(a,b).match(/\d+/);if(null!==b){b=b[0];var g=document.createElement("div");g.style.overflow="hidden";g.style.visibility="hidden";a.parentElement.appendChild(g);g.style.width=100+e;e=100/g.offsetWidth;a.parentElement.removeChild(g);return
b*e}return 0}function E(a,b){var e=document.createElement("a");if(e){e.style.display="none";e.download=
+a;e.href=b;document.body.appendChild(e);if(document.createEvent)null==J&&(J=document.createEvent("MouseEvents")),J.initEvent("click",!0,!1),e.dispatchEvent(J);else
if(document.createEventObject)e.fireEvent("onclick");else if("function"==typeof e.onclick)e.onclick();document.body.removeChild(e)}}function
D(a){var b="",e,g,d,f,k,l,m=0;a=a.replace(/\x0d\x0a/g,"\n");g="";for(d=0;d<a.length;d++)f=a.charCodeAt(d),128>f?g+=String.fromCharCode(f):(127<f&&2048>f?g+=String.fromCharCode(f>>6|192):(g+=String.fromCharCode(f>>
+12|224),g+=String.fromCharCode(f>>6&63|128)),g+=String.fromCharCode(f&63|128));for(a=g;m<a.length;)e=a.charCodeAt(m++),g=a.charCodeAt(m++),d=a.charCodeAt(m++),f=e>>2,e=(e&3)<<4|g>>4,k=(g&15)<<2|d>>6,l=d&63,isNaN(g)?k=l=64:isNaN(d)&&(l=64),b=b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(k)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(l);
+return b}var a={consoleLog:!1,csvEnclosure:'"',csvSeparator:",",csvUseBOM:!0,displayTableName:!1,escape:!1,excelstyles:["border-bottom","border-top","border-left","border-right"],fileName:"tableExport",htmlContent:!1,ignoreColumn:[],ignoreRow:[],jspdf:{orientation:"p",unit:"pt",format:"a4",margins:{left:20,right:10,top:10,bottom:10},autotable:{styles:{cellPadding:2,rowHeight:12,fontSize:8,fillColor:255,textColor:50,fontStyle:"normal",overflow:"ellipsize"},headerStyles:{fillColor:[52,73,94],textColor:255,
+fontStyle:"bold"},alternateRowStyles:{fillColor:245},tableExport:{onAfterAutotable:null,onBeforeAutotable:null,onTable:null}}},numbers:{html:{decimalMark:".",thousandsSeparator:","},output:{decimalMark:".",thousandsSeparator:","}},onCellData:null,outputMode:"file",tbodySelector:"tr",theadSelector:"tr",tableName:"myTableName",type:"csv",worksheetName:"xlsWorksheetName"},J=null,m=[],p=[],n=0,C=[],d="";b.extend(!0,a,t);if("csv"==a.type||"txt"==a.type){var
q="",n=0,m=b(this).find("thead").first().find(a.theadSelector);
+m.each(function(){d="";v(this,"th,td",n,m.length,function(h,b,e){d+=P(h,b,e)+a.csvSeparator});d=b.trim(d).substring(0,d.length-1);0<d.length&&(0<q.length&&(q+="\n"),q+=d);n++});p=b(this).find("tbody").first().find(a.tbodySelector);p.each(function(){d="";v(this,"td",n,m.length+p.length,function(h,b,e){d+=P(h,b,e)+a.csvSeparator});d=b.trim(d).substring(0,d.length-1);0<d.length&&(0<q.length&&(q+="\n"),q+=d);n++});q+="\n";!0===a.consoleLog&&console.log(q);if("string"===a.outputMode)return
q;if("base64"===
+a.outputMode)return D(q);try{var y=new Blob([q],{type:"text/"+("csv"==a.type?"csv":"plain")+";charset=utf-8"});saveAs(y,a.fileName+"."+a.type,"csv"!=a.type||!1===a.csvUseBOM)}catch(h){E(a.fileName+"."+a.type,"data:text/"+("csv"==a.type?"csv":"plain")+";charset=utf-8,"+encodeURIComponent(q))}}else
if("sql"==a.type){var n=0,l="INSERT INTO `"+a.tableName+"` (",m=b(this).find("thead").first().find(a.theadSelector);m.each(function(){v(this,"th,td",n,m.length,function(a,b,e){l+="'"+w(a,b,e)+"',"});n++;
+l=b.trim(l);l=b.trim(l).substring(0,l.length-1)});l+=") VALUES ";p=b(this).find("tbody").first().find(a.tbodySelector);p.each(function(){d="";v(this,"td",n,m.length+p.length,function(a,b,e){d+="'"+w(a,b,e)+"',"});3<d.length&&(l+="("+d,l=b.trim(l).substring(0,l.length-1),l+="),");n++});l=b.trim(l).substring(0,l.length-1);l+=";";!0===a.consoleLog&&console.log(l);if("string"==a.outputMode)return
l;if("base64"==a.outputMode)return D(l);try{y=new Blob([l],{type:"text/plain;charset=utf-8"}),saveAs(y,a.fileName+
+".sql")}catch(h){E(a.fileName+".sql","data:application/sql;charset=utf-8,"+encodeURIComponent(l))}}else
if("json"==a.type){var Q=[],m=b(this).find("thead").first().find(a.theadSelector);m.each(function(){var
a=[];v(this,"th,td",n,m.length,function(b,e,g){a.push(w(b,e,g))});Q.push(a)});var R=[],p=b(this).find("tbody").first().find(a.tbodySelector);p.each(function(){var
a=[];v(this,"td",n,m.length+p.length,function(b,e,g){a.push(w(b,e,g))});0<a.length&&(1!=a.length||""!=a[0])&&R.push(a);n++});t=[];
+t.push({header:Q,data:R});var B=JSON.stringify(t);!0===a.consoleLog&&console.log(B);if("string"==a.outputMode)return
B;t=D(B);if("base64"==a.outputMode)return t;try{y=new Blob([B],{type:"application/json;charset=utf-8"}),saveAs(y,a.fileName+".json")}catch(h){E(a.fileName+".json","data:application/json;charset=utf-8;base64,"+t)}}else
if("xml"===a.type){var n=0,u='<?xml version="1.0" encoding="utf-8"?>',u=u+"<tabledata><fields>",m=b(this).find("thead").first().find(a.theadSelector);m.each(function(){v(this,
+"th,td",n,p.length,function(a,b,e){u+="<field>"+w(a,b,e)+"</field>"});n++});var
u=u+"</fields><data>",S=1,p=b(this).find("tbody").first().find(a.tbodySelector);p.each(function(){var
a=1;d="";v(this,"td",n,m.length+p.length,function(b,e,g){d+="<column-"+a+">"+w(b,e,g)+"</column-"+a+">";a++});0<d.length&&"<column-1></column-1>"!=d&&(u+='<row
id="'+S+'">'+d+"</row>",S++);n++});u+="</data></tabledata>";!0===a.consoleLog&&console.log(u);if("string"==a.outputMode)return
u;t=D(u);if("base64"==a.outputMode)return t;
+try{y=new Blob([u],{type:"application/xml;charset=utf-8"}),saveAs(y,a.fileName+".xml")}catch(h){E(a.fileName+".xml","data:application/xml;charset=utf-8;base64,"+t)}}else
if("excel"==a.type||"xls"==a.type||"word"==a.type||"doc"==a.type){var B="excel"==a.type||"xls"==a.type?"excel":"word",N="excel"==B?"xls":"doc";t="xls"==N?'xmlns:x="urn:schemas-microsoft-com:office:excel"':'xmlns:w="urn:schemas-microsoft-com:office:word"';var
n=0,z="<table>",m=b(this).find("thead").first().find(a.theadSelector);m.each(function(){d=
+"";v(this,"th,td",n,m.length,function(h,f,e){if(null!=h){d+='<td style="';for(var g in
a.excelstyles)a.excelstyles.hasOwnProperty(g)&&(d+=a.excelstyles[g]+": "+b(h).css(a.excelstyles[g])+";");d+='">'+w(h,f,e)+"</td>"}});0<d.length&&(z+="<tr>"+d+"</tr>");n++});p=b(this).find("tbody").first().find(a.tbodySelector);p.each(function(){d="";v(this,"td",n,m.length+p.length,function(h,f,e){if(null!=h){d+='<td
style="';for(var g in a.excelstyles)a.excelstyles.hasOwnProperty(g)&&(d+=a.excelstyles[g]+":
"+b(h).css(a.excelstyles[g])+
+";");b(h).is("[colspan]")&&(d+='" colspan="'+b(h).attr("colspan"));b(h).is("[rowspan]")&&(d+='"
rowspan="'+b(h).attr("rowspan"));d+='">'+w(h,f,e)+"</td>"}});0<d.length&&(z+="<tr>"+d+"</tr>");n++});a.displayTableName&&(z+="<tr><td></td></tr><tr><td></td></tr><tr><td>"+w(b("<p>"+a.tableName+"</p>"))+"</td></tr>");z+="</table>";!0===a.consoleLog&&console.log(z);var
f;f='<html xmlns:o="urn:schemas-microsoft-com:office:office" '+t+' xmlns="http://www.w3.org/TR/REC-html40">'+('<meta
http-equiv="content-type" content="application/vnd.ms-'+
+B+'; charset=UTF-8">');f+="<head>";"excel"===B&&(f+="\x3c!--[if gte mso
9]>",f+="<xml>",f+="<x:ExcelWorkbook>",f+="<x:ExcelWorksheets>",f+="<x:ExcelWorksheet>",f+="<x:Name>",f+=a.worksheetName,f+="</x:Name>",f+="<x:WorksheetOptions>",f+="<x:DisplayGridlines/>",f+="</x:WorksheetOptions>",f+="</x:ExcelWorksheet>",f+="</x:ExcelWorksheets>",f+="</x:ExcelWorkbook>",f+="</xml>",f+="<![endif]--\x3e");f+="</head>";f+="<body>";f+=z;f+="</body>";f+="</html>";if("string"==a.outputMode)return
f;t=D(f);if("base64"===
+a.outputMode)return t;try{y=new Blob([f],{type:"application/vnd.ms-"+a.type}),saveAs(y,a.fileName+"."+N)}catch(h){E(a.fileName+"."+N,"data:application/vnd.ms-"+B+";base64,"+t)}}else
if("png"==a.type)html2canvas(b(this)[0],{allowTaint:!0,background:"#fff",onrendered:function(b){b=b.toDataURL();b=b.substring(22);for(var
f=atob(b),e=new ArrayBuffer(f.length),g=new Uint8Array(e),d=0;d<f.length;d++)g[d]=f.charCodeAt(d);try{var
k=new Blob([e],{type:"image/png"});saveAs(k,a.fileName+".png")}catch(l){E(a.fileName+
+".png","data:image/png;base64,"+b)}}});else if("pdf"==a.type)if(!1===a.jspdf.autotable){var
y={dim:{w:M(b(this).first().get(0),"width","mm"),h:M(b(this).first().get(0),"height","mm")},pagesplit:!1},T=new
jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format);T.addHTML(b(this).first(),a.jspdf.margins.left,a.jspdf.margins.top,y,function(){O(T)})}else{var
k=a.jspdf.autotable.tableExport;if("string"===typeof a.jspdf.format&&"bestfit"===a.jspdf.format.toLowerCase()){var
F={a0:[2383.94,3370.39],a1:[1683.78,
+2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89]},K="",G="",U=0;b(this).filter(":visible").each(function(){if("none"!=b(this).css("display")){var
a=M(b(this).get(0),"width","pt");if(a>U){a>F.a0[0]&&(K="a0",G="l");for(var d
in F)F.hasOwnProperty(d)&&F[d][1]>a&&(K=d,G="l",F[d][0]>a&&(G="p"));U=a}}});a.jspdf.format=""==K?"a4":K;a.jspdf.orientation=""==G?"w":G}k.doc=new
jsPDF(a.jspdf.orientation,a.jspdf.unit,a.jspdf.format);b(this).filter(function(){return"none"!=b(this).data("tableexport-display")&&
+(b(this).is(":visible")||"always"==b(this).data("tableexport-display"))}).each(function(){var
d,f=0,e={};k.columns=[];k.rows=[];k.rowoptions={};if("function"===typeof k.onTable&&!1===k.onTable(b(this),a))return!0;Object.keys(a.jspdf.autotable).forEach(function(b){e[b]=a.jspdf.autotable[b]});e.margin={};b.extend(!0,e.margin,a.jspdf.margins);"function"!==typeof
e.createdHeaderCell&&(e.createdHeaderCell=function(a,b){if("undefined"!=typeof k.columns[b.column.dataKey]){var
d=k.columns[b.column.dataKey];
+a.styles.halign=d.style.align;"inherit"===e.styles.fillColor&&(a.styles.fillColor=d.style.bcolor);"inherit"===e.styles.textColor&&(a.styles.textColor=d.style.color)}});"function"!==typeof
e.createdCell&&(e.createdCell=function(a,b){var d=k.rowoptions[b.row.index+":"+b.column.dataKey];"undefined"!=typeof
d&&(a.styles.halign=d.style.align,"inherit"===e.styles.fillColor&&(a.styles.fillColor=d.style.bcolor),"inherit"===e.styles.textColor&&(a.styles.textColor=d.style.color))});"function"!==typeof
e.drawHeaderCell&&
+(e.drawHeaderCell=function(a,b){var d=k.columns[b.column.dataKey];return 1!=d.style.hasOwnProperty("hidden")||!0!==d.style.hidden});m=b(this).find("thead").find(a.theadSelector);m.each(function(){d=0;v(this,"th,td",f,m.length,function(a,b,e){var
f=A(a,"text-align");"start"==f&&(f="rtl"==A(a,"direction")?"right":"left");a={title:w(a,b,e),key:d++,style:{align:f,bcolor:I(A(a,"background-color"),[255,255,255]),color:I(A(a,"color"),[0,0,0])}};k.columns.push(a)});f++});var
g=0;p=b(this).find("tbody").find(a.tbodySelector);
+p.each(function(){var a=[];d=0;v(this,"td",f,m.length+p.length,function(b,e,f){if("undefined"===typeof
k.columns[d]){var l={title:"",key:d,style:{hidden:!0}};k.columns.push(l)}null!==b?(l=A(b,"text-align"),"start"==l&&(l="rtl"==A(b,"direction")?"right":"left"),l={style:{align:l,bcolor:I(A(b,"background-color"),[255,255,255]),color:I(A(b,"color"),[0,0,0])}}):l=k.rowoptions[g+":"+(d-1)];k.rowoptions[g+":"+d++]=l;a.push(w(b,e,f))});a.length&&(k.rows.push(a),g++);f++});if("function"===typeof
k.onBeforeAutotable)k.onBeforeAutotable(b(this),
+k.columns,k.rows,e);k.doc.autoTable(k.columns,k.rows,e);if("function"===typeof k.onAfterAutotable)k.onAfterAutotable(b(this),e);a.jspdf.autotable.startY=k.doc.autoTableEndPosY()+e.margin.top});O(k.doc);k.columns.length=0;k.rows.length=0;delete
k.doc;k.doc=null}return this}})})(jQuery);



Mime
View raw message