diff --git a/dist/js/widgets/widget-print.min.js b/dist/js/widgets/widget-print.min.js index dfc06239..53a6640b 100644 --- a/dist/js/widgets/widget-print.min.js +++ b/dist/js/widgets/widget-print.min.js @@ -1 +1 @@ -!function(a){"use strict";var b=a.tablesorter,c=b.printTable={event:"printTable",basicStyle:"table, tr, td, th { border : solid 1px black; border-collapse : collapse; } td, th { padding: 2px; }",popupStyle:"width=500,height=300",init:function(a){a.$table.unbind(c.event).bind(c.event,function(){c.process(a,a.widgetOptions)})},process:function(d,e){var f,g=a("
").append(d.$table.clone()),h=c.basicStyle+"table { width: 100%; }."+(b.css.filterRow||"tablesorter-filter-row")+", ."+(e.filter_filteredRow||"filtered")+" { display: none; }."+(b.css.header||"tablesorter-header")+" { background-image: none !important; }";g.find("["+e.print_dataAttrib+"]").each(function(){f=a(this),f.text(f.attr(e.print_dataAttrib))}),/a/i.test(e.print_rows)?h+="tbody tr { display: table-row !important; }":/f/i.test(e.print_rows)&&(h+="tbody tr:not(."+(e.filter_filteredRow||"filtered")+") { display: table-row !important; }"),/s/i.test(e.print_columns)&&d.selector&&d.widgets.indexOf("columnSelector")>=0?h+=e.columnSelector_mediaquery&&d.selector.auto?"":d.selector.$style.text():/a/i.test(e.print_columns)&&(h+="td, th { display: table-cell !important; }"),h+=e.print_extraCSS,a.isFunction(e.print_callback)?e.print_callback(d,g,h):c.printOutput(d,g.html(),h)},printOutput:function(a,b,d){var e=a.widgetOptions,f=window.open("",e.print_title,c.popupStyle),g=e.print_title||a.$table.find("caption").text()||a.$table[0].id||document.title||"table";return f.document.write(""+g+""+(e.print_styleSheet?'':"")+""+b+""),f.document.close(),f.print(),f.close(),!0},remove:function(a){a.$table.off(c.event)}};b.addWidget({id:"print",options:{print_title:"",print_dataAttrib:"data-name",print_rows:"filtered",print_columns:"selected",print_extraCSS:"",print_styleSheet:"",print_callback:null},init:function(a,b,d){c.init(d)},remove:function(a,b){c.remove(b)}})}(jQuery); \ No newline at end of file +!function(a){"use strict";var b=a.tablesorter,c=b.printTable={event:"printTable",basicStyle:"table, tr, td, th { border : solid 1px black; border-collapse : collapse; } td, th { padding: 2px; }",popupStyle:"width=500,height=300",init:function(a){a.$table.unbind(c.event).bind(c.event,function(){c.process(a,a.widgetOptions)})},process:function(d,e){var f,g=a("
").append(d.$table.clone()),h=c.basicStyle+"table { width: 100%; }."+(b.css.filterRow||"tablesorter-filter-row")+", ."+(e.filter_filteredRow||"filtered")+" { display: none; }."+(b.css.header||"tablesorter-header")+" { background-image: none !important; }";g.find("["+e.print_dataAttrib+"]").each(function(){f=a(this),f.text(f.attr(e.print_dataAttrib))}),/a/i.test(e.print_rows)?h+="tbody tr { display: table-row !important; }":/f/i.test(e.print_rows)&&(h+="tbody tr:not(."+(e.filter_filteredRow||"filtered")+") { display: table-row !important; }"),/s/i.test(e.print_columns)&&d.selector&&d.widgets.indexOf("columnSelector")>=0?h+=e.columnSelector_mediaquery&&d.selector.auto?"":d.selector.$style.text():/a/i.test(e.print_columns)&&(h+="td, th { display: table-cell !important; }"),h+=e.print_extraCSS,a.isFunction(e.print_callback)?e.print_callback(d,g,h):c.printOutput(d,g.html(),h)},printOutput:function(a,b,d){var e=a.widgetOptions,f=window.open("",e.print_title,c.popupStyle),g=e.print_title||a.$table.find("caption").text()||a.$table[0].id||document.title||"table";return f.document.write(""+g+""+(e.print_styleSheet?'':"")+""+b+""),f.document.close(),setTimeout(function(){f.print(),f.close()},10),!0},remove:function(a){a.$table.off(c.event)}};b.addWidget({id:"print",options:{print_title:"",print_dataAttrib:"data-name",print_rows:"filtered",print_columns:"selected",print_extraCSS:"",print_styleSheet:"",print_callback:null},init:function(a,b,d){c.init(d)},remove:function(a,b){c.remove(b)}})}(jQuery); \ No newline at end of file diff --git a/js/widgets/widget-print.js b/js/widgets/widget-print.js index 8f342d4b..04a63aa9 100644 --- a/js/widgets/widget-print.js +++ b/js/widgets/widget-print.js @@ -86,8 +86,12 @@ '' + data + '' ); generator.document.close(); - generator.print(); - generator.close(); + // use timeout to allow browser to build DOM before printing + // Print preview in Chrome doesn't work without this code + setTimeout( function() { + generator.print(); + generator.close(); + }, 10 ); return true; },