/* * File: TableTools.nightly.min.js * Version: 2.1.6-dev * Author: Allan Jardine (www.sprymedia.co.uk) * Info: www.datatables.net * * Copyright 2008-2012 Allan Jardine, all rights reserved. * * This source file is free software, under either the GPL v2 license or a * BSD style license, available at: * http://datatables.net/license_gpl2 * http://datatables.net/license_bsd * * 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 TableTools; (function(f,o,j){TableTools=function(a,b){!this instanceof TableTools&&alert("Warning: TableTools must be initialised with the keyword 'new'");this.s={that:this,dt:a.fnSettings(),print:{saveStart:-1,saveLength:-1,saveScroll:-1,funcEnd:function(){}},buttonCounter:0,select:{type:"",selected:[],preRowSelect:null,postSelected:null,postDeselected:null,all:false,selectedClass:""},custom:{},swfPath:"",buttonSet:[],master:false,tags:{}};this.dom={container:null,table:null,print:{hidden:[],message:null},collection:{collection:null, background:null}};this.classes=f.extend(true,{},TableTools.classes);this.s.dt.bJUI&&f.extend(true,this.classes,TableTools.classes_themeroller);this.fnSettings=function(){return this.s};if(typeof b=="undefined")b={};this._fnConstruct(b);return this};TableTools.prototype={fnGetSelected:function(a){var b=[],c=this.s.dt.aoData,d=this.s.dt.aiDisplay,e;if(a){a=0;for(e=d.length;a0)b=a[0].innerHTML}return"\u00a1".toString().length<4?b.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g,""):b.replace(/[^a-zA-Z0-9_\.,\-_ !\(\)]/g,"")},fnCalcColRatios:function(a){var b=this.s.dt.aoColumns; a=this._fnColumnTargets(a.mColumns);var c=[],d=0,e=0,g,k;g=0;for(k=a.length;gk?g:k)+"px";m.style.width=(h>l?h:l)+"px";m.className=this.classes.collection.background;f(m).css("opacity", 0);j.body.appendChild(m);j.body.appendChild(e);g=f(e).outerWidth();h=f(e).outerHeight();if(b+g>l)e.style.left=l-g+"px";if(d+h>k)e.style.top=d-h-f(a).outerHeight()+"px";this.dom.collection.collection=e;this.dom.collection.background=m;setTimeout(function(){f(e).animate({opacity:1},500);f(m).animate({opacity:0.25},500)},10);this.fnResizeButtons();f(m).click(function(){c._fnCollectionHide.call(c,null,null)})},_fnCollectionHide:function(a,b){if(!(b!==null&&b.sExtends=="collection"))if(this.dom.collection.collection!== null){f(this.dom.collection.collection).animate({opacity:0},500,function(){this.style.display="none"});f(this.dom.collection.background).animate({opacity:0},500,function(){this.parentNode.removeChild(this)});this.dom.collection.collection=null;this.dom.collection.background=null}},_fnRowSelectConfig:function(){if(this.s.master){var a=this,b=this.s.dt;f(b.nTable).addClass(this.classes.select.table);f(b.nTBody).on("click.DTTT_Select","tr",function(c){if(this.parentNode==b.nTBody)if(b.oInstance.fnGetData(this)!== null)if(a.fnIsSelected(this))a._fnRowDeselect(this,c);else if(a.s.select.type=="single"){a.fnSelectNone();a._fnRowSelect(this,c)}else a.s.select.type=="multi"&&a._fnRowSelect(this,c)});b.oApi._fnCallbackReg(b,"aoRowCreatedCallback",function(c,d,e){b.aoData[e]._DTTT_selected&&f(c).addClass(a.classes.select.row)},"TableTools-SelectAll")}},_fnRowSelect:function(a,b){var c=this;a=this._fnSelectData(a);var d=[],e,g;e=0;for(g=a.length;e/g,"").replace(/^\s+|\s+$/g,"");h=this._fnHtmlDecode(h);g.push(this._fnBoundData(h,a.sFieldBoundary,p))}k.push(g.join(a.sFieldSeperator))}var n=l.aiDisplay;e=this.fnGetSelected();if(this.s.select.type!=="none"&&d&&e.length!==0){n=[];b=0;for(c=e.length;b]+)).*?>/gi,"$1$2$3");h=h.replace(/<.*?>/g,"")}else h=h+"";h=h.replace(/^\s+/,"").replace(/\s+$/,"");h=this._fnHtmlDecode(h);g.push(this._fnBoundData(h,a.sFieldBoundary,p))}k.push(g.join(a.sFieldSeperator)); if(a.bOpenRows){b=f.grep(l.aoOpenRows,function(r){return r.nParent===m});if(b.length===1){h=this._fnBoundData(f("td",b[0].nTr).html(),a.sFieldBoundary,p);k.push(h)}}}if(a.bFooter&&l.nTFoot!==null){g=[];b=0;for(c=l.aoColumns.length;b/g,"");h=this._fnHtmlDecode(h);g.push(this._fnBoundData(h,a.sFieldBoundary,p))}k.push(g.join(a.sFieldSeperator))}return _sLastData=k.join(this._fnNewline(a))},_fnBoundData:function(a, b,c){return b===""?a:b+a.replace(c,b+b)+b},_fnChunkData:function(a,b){for(var c=[],d=a.length,e=0;e0&&a.nTable.removeChild(c[0]);if(a.nTFoot!==null){c=a.nTable.getElementsByTagName("tfoot");c.length>0&&a.nTable.removeChild(c[0])}c=a.nTHead.cloneNode(true);a.nTable.insertBefore(c,a.nTable.childNodes[0]);if(a.nTFoot!==null){c=a.nTFoot.cloneNode(true);a.nTable.insertBefore(c,a.nTable.childNodes[1])}if(a.oScroll.sX!==""){a.nTable.style.width=f(a.nTable).outerWidth()+"px";b.style.width=f(a.nTable).outerWidth()+"px";b.style.overflow= "visible"}if(a.oScroll.sY!==""){b.style.height=f(a.nTable).outerHeight()+"px";b.style.overflow="visible"}},_fnPrintScrollEnd:function(){var a=this.s.dt,b=a.nTable.parentNode;if(a.oScroll.sX!==""){b.style.width=a.oApi._fnStringToCss(a.oScroll.sX);b.style.overflow="auto"}if(a.oScroll.sY!==""){b.style.height=a.oApi._fnStringToCss(a.oScroll.sY);b.style.overflow="auto"}},_fnPrintShowNodes:function(){for(var a=this.dom.print.hidden,b=0,c=a.length;bTable copied

Copied "+a+" row"+(a==1?"":"s")+" to the clipboard.

",1500)}}),pdf:f.extend({},TableTools.buttonBase,{sAction:"flash_pdf",sNewLine:"\n",sFileName:"*.pdf",sButtonClass:"DTTT_button_pdf",sButtonText:"PDF",sPdfOrientation:"portrait",sPdfSize:"A4",sPdfMessage:"",fnClick:function(a,b,c){this.fnSetText(c,"title:"+ this.fnGetTitle(b)+"\nmessage:"+b.sPdfMessage+"\ncolWidth:"+this.fnCalcColRatios(b)+"\norientation:"+b.sPdfOrientation+"\nsize:"+b.sPdfSize+"\n--/TableToolsOpts--\n"+this.fnGetTableData(b))}}),print:f.extend({},TableTools.buttonBase,{sInfo:"
Print view

Please use your browser's print function to print this table. Press escape when finished.",sMessage:null,bShowAll:true,sToolTip:"View print view",sButtonClass:"DTTT_button_print",sButtonText:"Print",fnClick:function(a,b){this.fnPrint(true, b)}}),text:f.extend({},TableTools.buttonBase),select:f.extend({},TableTools.buttonBase,{sButtonText:"Select button",fnSelect:function(a){this.fnGetSelected().length!==0?f(a).removeClass(this.classes.buttons.disabled):f(a).addClass(this.classes.buttons.disabled)},fnInit:function(a){f(a).addClass(this.classes.buttons.disabled)}}),select_single:f.extend({},TableTools.buttonBase,{sButtonText:"Select button",fnSelect:function(a){this.fnGetSelected().length==1?f(a).removeClass(this.classes.buttons.disabled): f(a).addClass(this.classes.buttons.disabled)},fnInit:function(a){f(a).addClass(this.classes.buttons.disabled)}}),select_all:f.extend({},TableTools.buttonBase,{sButtonText:"Select all",fnClick:function(){this.fnSelectAll()},fnSelect:function(a){this.fnGetSelected().length==this.s.dt.fnRecordsDisplay()?f(a).addClass(this.classes.buttons.disabled):f(a).removeClass(this.classes.buttons.disabled)}}),select_none:f.extend({},TableTools.buttonBase,{sButtonText:"Deselect all",fnClick:function(){this.fnSelectNone()}, fnSelect:function(a){this.fnGetSelected().length!==0?f(a).removeClass(this.classes.buttons.disabled):f(a).addClass(this.classes.buttons.disabled)},fnInit:function(a){f(a).addClass(this.classes.buttons.disabled)}}),ajax:f.extend({},TableTools.buttonBase,{sAjaxUrl:"/xhr.php",sButtonText:"Ajax button",fnClick:function(a,b){a=this.fnGetTableData(b);f.ajax({url:b.sAjaxUrl,data:[{name:"tableData",value:a}],success:b.fnAjaxComplete,dataType:"json",type:"POST",cache:false,error:function(){alert("Error detected when sending table data to server")}})}, fnAjaxComplete:function(){alert("Ajax complete")}}),div:f.extend({},TableTools.buttonBase,{sAction:"div",sTag:"div",sButtonClass:"DTTT_nonbutton",sButtonText:"Text button"}),collection:f.extend({},TableTools.buttonBase,{sAction:"collection",sButtonClass:"DTTT_button_collection",sButtonText:"Collection",fnClick:function(a,b){this._fnCollectionShow(a,b)}})};TableTools.classes={container:"DTTT_container",buttons:{normal:"DTTT_button",disabled:"DTTT_disabled"},collection:{container:"DTTT_collection", background:"DTTT_collection_background",buttons:{normal:"DTTT_button",disabled:"DTTT_disabled"}},select:{table:"DTTT_selectable",row:"DTTT_selected"},print:{body:"DTTT_Print",info:"DTTT_print_info",message:"DTTT_PrintMessage"}};TableTools.classes_themeroller={container:"DTTT_container ui-buttonset ui-buttonset-multi",buttons:{normal:"DTTT_button ui-button ui-state-default"},collection:{container:"DTTT_collection ui-buttonset ui-buttonset-multi"}};TableTools.DEFAULTS={sSwfPath:"media/swf/copy_csv_xls_pdf.swf", sRowSelect:"none",sSelectedClass:null,fnPreRowSelect:null,fnRowSelected:null,fnRowDeselected:null,aButtons:["copy","csv","xls","pdf","print"],oTags:{container:"div",button:"a",liner:"span",collection:{container:"div",button:"a",liner:"span"}}};TableTools.prototype.CLASS="TableTools";TableTools.VERSION="2.1.6-dev";TableTools.prototype.VERSION=TableTools.VERSION;typeof f.fn.dataTable=="function"&&typeof f.fn.dataTableExt.fnVersionCheck=="function"&&f.fn.dataTableExt.fnVersionCheck("1.9.0")?f.fn.dataTableExt.aoFeatures.push({fnInit:function(a){a= new TableTools(a.oInstance,typeof a.oInit.oTableTools!="undefined"?a.oInit.oTableTools:{});TableTools._aInstances.push(a);return a.dom.container},cFeature:"T",sFeature:"TableTools"}):alert("Warning: TableTools 2 requires DataTables 1.9.0 or newer - www.datatables.net/download");f.fn.DataTable.TableTools=TableTools})(jQuery,window,document);