Print: Process lazyload images before printing. See #1169

Make sure `print_now` is `false`
This commit is contained in:
Rob Garrison 2016-04-05 11:07:10 -05:00
parent 9feb20551e
commit 9fe5d647ce
2 changed files with 9 additions and 2 deletions

View File

@ -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,scrollbars=1,resizable=1",init:function(a){a.$table.unbind(c.event).bind(c.event,function(){return c.process(a,a.widgetOptions),!1})},process:function(d,e){var f,g=a("<div/>").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; }@media print { .print_widget_hidden { display: none; } }";g.find("["+e.print_dataAttrib+"]").each(function(){f=a(this),f.text(f.attr(e.print_dataAttrib))}),/^f/i.test(e.print_rows)?h+="tbody tr:not(."+(e.filter_filteredRow||"filtered")+") { display: table-row !important; }":/^a/i.test(e.print_rows)?h+="tbody tr { display: table-row !important; }":/^[.#:\[]/.test(e.print_rows)&&(h+="tbody tr"+e.print_rows+" { 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,d,e){var f=a.widgetOptions,g=b.language,h=window.open("",f.print_title,c.popupStyle),i=f.print_title||a.$table.find("caption").text()||a.$table[0].id||document.title||"table",j=f.print_now?"":'<div class="print_widget_hidden"><a href="javascript:window.print();"><button type="button">'+g.button_print+'</button></a> <a href="javascript:window.close();"><button type="button">'+g.button_close+"</button></a><hr></div>";return h.document.write("<html><head><title>"+i+"</title>"+(f.print_styleSheet?'<link rel="stylesheet" href="'+f.print_styleSheet+'">':"")+"<style>"+e+"</style></head><body>"+j+d+"</body></html>"),h.document.close(),f.print_now&&setTimeout(function(){h.print(),h.close()},10),!0},remove:function(a){a.$table.off(c.event)}};b.language.button_close="Close",b.language.button_print="Print",b.addWidget({id:"print",options:{print_title:"",print_dataAttrib:"data-name",print_rows:"filtered",print_columns:"selected",print_extraCSS:"",print_styleSheet:"",print_now:!0,print_callback:null},init:function(a,b,d){c.init(d)},remove:function(a,b){c.remove(b)}})}(jQuery);
!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,scrollbars=1,resizable=1",init:function(a){a.$table.unbind(c.event).bind(c.event,function(){return c.process(a,a.widgetOptions),!1})},process:function(d,e){var f,g,h=a("<div/>").append(d.$table.clone()),i=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; }@media print { .print_widget_hidden { display: none; } }";h.find("["+e.print_dataAttrib+"]").each(function(){f=a(this),f.text(f.attr(e.print_dataAttrib))}),g="data-"+(e.lazyload_data_attribute||"original"),h.find("img["+g+"]").each(function(){f=a(this),f.attr("src",f.attr(g))}),/^f/i.test(e.print_rows)?i+="tbody tr:not(."+(e.filter_filteredRow||"filtered")+") { display: table-row !important; }":/^a/i.test(e.print_rows)?i+="tbody tr { display: table-row !important; }":/^[.#:\[]/.test(e.print_rows)&&(i+="tbody tr"+e.print_rows+" { display: table-row !important; }"),/s/i.test(e.print_columns)&&d.selector&&d.widgets.indexOf("columnSelector")>=0?i+=e.columnSelector_mediaquery&&d.selector.auto?"":d.selector.$style.text():/a/i.test(e.print_columns)&&(i+="td, th { display: table-cell !important; }"),i+=e.print_extraCSS,a.isFunction(e.print_callback)?e.print_callback(d,h,i):c.printOutput(d,h.html(),i)},printOutput:function(a,d,e){var f=a.widgetOptions,g=b.language,h=window.open("",f.print_title,c.popupStyle),i=f.print_title||a.$table.find("caption").text()||a.$table[0].id||document.title||"table",j=f.print_now?"":'<div class="print_widget_hidden"><a href="javascript:window.print();"><button type="button">'+g.button_print+'</button></a> <a href="javascript:window.close();"><button type="button">'+g.button_close+"</button></a><hr></div>";return h.document.write("<html><head><title>"+i+"</title>"+(f.print_styleSheet?'<link rel="stylesheet" href="'+f.print_styleSheet+'">':"")+"<style>"+e+"</style></head><body>"+j+d+"</body></html>"),h.document.close(),f.print_now&&setTimeout(function(){h.print(),h.close()},10),!0},remove:function(a){a.$table.off(c.event)}};b.language.button_close="Close",b.language.button_print="Print",b.addWidget({id:"print",options:{print_title:"",print_dataAttrib:"data-name",print_rows:"filtered",print_columns:"selected",print_extraCSS:"",print_styleSheet:"",print_now:!0,print_callback:null},init:function(a,b,d){c.init(d)},remove:function(a,b){c.remove(b)}})}(jQuery);

View File

@ -26,7 +26,7 @@
},
process : function(c, wo) {
var $this,
var $this, data,
$table = $('<div/>').append(c.$table.clone()),
printStyle = printTable.basicStyle + 'table { width: 100%; }' +
// hide filter row
@ -44,6 +44,13 @@
$this.text( $this.attr(wo.print_dataAttrib) );
});
// Make sure all lazy loaded images are visible - see #1169
data = 'data-' + (wo.lazyload_data_attribute || 'original');
$table.find('img[' + data + ']').each(function(){
$this = $(this);
$this.attr('src', $this.attr(data));
});
// === rows ===
// Assume 'visible' means rows hidden by the pager (rows set to 'display:none')
// or hidden by a class name which is added to the wo.print_extraCSS definition