org.wicketstuff.datatables.media.js.TableTools.min.js Maven / Gradle / Ivy
Show all versions of wicketstuff-datatables Show documentation
/*
* File: TableTools.min.js
* Version: 2.0.0.dev
* Author: Allan Jardine (www.sprymedia.co.uk)
*
* Copyright 2009-2010 Allan Jardine, all rights reserved.
*
* This source file is free software, under either the GPL v2 license or a
* BSD (3 point) style license, as supplied with this software.
*
* This source file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
*/
var TableToolsInit={oFeatures:{bCsv:true,bXls:true,bCopy:true,bPrint:true},oBom:{bCsv:true,bXls:true},bIncFooter:true,bIncHiddenColumns:false,sPrintMessage:"",sPrintInfo:"Print view
Please use your browser's print function to print this table. Press escape when finished.",sTitle:"",sSwfPath:"media/swf/ZeroClipboard.swf",iButtonHeight:30,iButtonWidth:30,sCsvBoundary:"'",_iNextId:1};
(function(j){function D(p){function E(a){_nTools=document.createElement("div");_nTools.className="TableTools";l=TableToolsInit._iNextId++;g=j.extend(true,{},TableToolsInit);e=a.oDTSettings;F=v(e.nTable,"dataTables_wrapper");ZeroClipboard.moviePath=g.sSwfPath;g.oFeatures.bCopy&&G();g.oFeatures.bCsv&&H();g.oFeatures.bXls&&I();g.oFeatures.bPrint&&J();return _nTools}function H(){var a=document.createElement("div");a.id="ToolTables_CSV_"+l;a.style.height=g.iButtonHeight+"px";a.style.width=g.iButtonWidth+
"px";a.className="TableTools_button TableTools_csv";_nTools.appendChild(a);var b=new ZeroClipboard.Client;b.setHandCursor(true);b.setAction("save");b.setCharSet("UTF8");b.setBomInc(g.oBom.bCsv);b.setFileName(w()+".csv");b.addEventListener("mouseOver",function(){a.className="TableTools_button TableTools_csv_hover"});b.addEventListener("mouseOut",function(){a.className="TableTools_button TableTools_csv"});b.addEventListener("mouseDown",function(){q(b,r(",",TableToolsInit.sCsvBoundary))});o(b,a,"ToolTables_CSV_"+
l,"Save as CSV")}function I(){var a=document.createElement("div");a.id="ToolTables_XLS_"+l;a.style.height=g.iButtonHeight+"px";a.style.width=g.iButtonWidth+"px";a.className="TableTools_button TableTools_xls";_nTools.appendChild(a);var b=new ZeroClipboard.Client;b.setHandCursor(true);b.setAction("save");b.setCharSet("UTF16LE");b.setBomInc(g.oBom.bXls);b.setFileName(w()+".xls");b.addEventListener("mouseOver",function(){a.className="TableTools_button TableTools_xls_hover"});b.addEventListener("mouseOut",
function(){a.className="TableTools_button TableTools_xls"});b.addEventListener("mouseDown",function(){q(b,r("\t"))});o(b,a,"ToolTables_XLS_"+l,"Save for Excel")}function G(){var a=document.createElement("div");a.id="ToolTables_Copy_"+l;a.style.height=g.iButtonHeight+"px";a.style.width=g.iButtonWidth+"px";a.className="TableTools_button TableTools_clipboard";_nTools.appendChild(a);var b=new ZeroClipboard.Client;b.setHandCursor(true);b.setAction("copy");b.addEventListener("mouseOver",function(){a.className=
"TableTools_button TableTools_clipboard_hover"});b.addEventListener("mouseOut",function(){a.className="TableTools_button TableTools_clipboard"});b.addEventListener("mouseDown",function(){q(b,r("\t"))});b.addEventListener("complete",function(){var c=x.split("\n");alert("Copied "+(c.length-1)+" rows to the clipboard")});o(b,a,"ToolTables_Copy_"+l,"Copy to clipboard")}function J(){var a=document.createElement("div");a.style.height=g.iButtonHeight+"px";a.style.width=g.iButtonWidth+"px";a.className="TableTools_button TableTools_print";
a.title="Print table";_nTools.appendChild(a);j(a).hover(function(){a.className="TableTools_button TableTools_print_hover"},function(){a.className="TableTools_button TableTools_print"});j(a).click(function(){y(e.nTable);_iPrintSaveStart=e._iDisplayStart;_iPrintSaveLength=e._iDisplayLength;e._iDisplayStart=0;e._iDisplayLength=-1;e.oApi._fnCalculateEnd(e);e.oApi._fnDraw(e);var b=e.anFeatures;for(var c in b)if(c!="i"&&c!="t"){m.push({node:b[c],display:"block"});b[c].style.display="none"}var d=document.createElement("div");
d.className="TableTools_PrintInfo";d.innerHTML=g.sPrintInfo;document.body.appendChild(d);if(g.sPrintMessage!==""){n=document.createElement("p");n.className="TableTools_PrintMessage";n.innerHTML=g.sPrintMessage;document.body.insertBefore(n,document.body.childNodes[0])}z=j(window).scrollTop();window.scrollTo(0,0);j(document).bind("keydown",null,A);setTimeout(function(){j(d).fadeOut("normal",function(){document.body.removeChild(d)})},2E3)})}function A(a){if(a.keyCode==27){K();window.scrollTo(0,z);if(n){document.body.removeChild(n);
n=null}e._iDisplayStart=_iPrintSaveStart;e._iDisplayLength=_iPrintSaveLength;e.oApi._fnCalculateEnd(e);e.oApi._fnDraw(e);j(document).unbind("keydown",A)}}function K(){for(var a=0,b=m.length;a=8&&h>a[c].length-8){a[c].substr(h);a[c]=a[c].substr(0,h)}b.innerHTML=a[c];k+=b.childNodes[0].nodeValue}return k}function B(a,b){for(var c=[],d=a.length,h=0;h/g,"");if(f.indexOf("&")!=-1)f=t(f);i+=s(f,b,u)+a}i=i.slice(0,a.length*-1);i+=C;h=0;for(k=e.aiDisplay.length;h]+)).*?>/gi,
"$1$2$3");f=f.replace(/<.*?>/g,"")}else f=f+"";f=f.replace(/^\s+/,"").replace(/\s+$/,"");if(f.indexOf("&")!=-1)f=t(f);i+=s(f,b,u)+a}i=i.slice(0,a.length*-1);i+=C}i.slice(0,-1);if(g.bIncFooter){c=0;for(d=e.aoColumns.length;c/g,"");if(f.indexOf("&")!=-1)f=t(f);i+=s(f,b,u)+a}i=i.slice(0,a.length*-1)}return x=i}var g,F,m=[],z=0,n=null,e,x,l;return E(p)}
typeof j.fn.dataTable=="function"&&typeof j.fn.dataTableExt.sVersion!="undefined"?j.fn.dataTableExt.aoFeatures.push({fnInit:function(p){return new D({oDTSettings:p})},cFeature:"T",sFeature:"TableTools"}):alert("Warning: TableTools requires DataTables 1.5 or greater - www.datatables.net/download")})(jQuery);