tablesorter/dist/js/widgets/widget-print.min.js

1 line
2.6 KiB
JavaScript
Raw Normal View History

2017-05-16 20:33:15 +00:00
!function(t){"use strict";var e=t.tablesorter,i=e.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(t){t.$table.unbind(i.event).bind(i.event,function(){return i.process(t,t.widgetOptions),!1})},process:function(n,r){var o,a,l=t("<div/>").append(n.$table.clone()),p=i.basicStyle+"table { width: 100%; }."+(e.css.filterRow||"tablesorter-filter-row")+", ."+(r.filter_filteredRow||"filtered")+" { display: none; }."+(e.css.header||"tablesorter-header")+" { background-image: none !important; }@media print { .print_widget_hidden { display: none; } }";l.find("["+r.print_dataAttrib+"]").each(function(){(o=t(this)).text(o.attr(r.print_dataAttrib))}),a="data-"+(r.lazyload_data_attribute||"original"),l.find("img["+a+"]").each(function(){(o=t(this)).attr("src",o.attr(a))}),/^f/i.test(r.print_rows)?p+="tbody tr:not(."+(r.filter_filteredRow||"filtered")+") { display: table-row !important; }":/^a/i.test(r.print_rows)?p+="tbody tr { display: table-row !important; }":/^[.#:\[]/.test(r.print_rows)&&(p+="tbody tr"+r.print_rows+" { display: table-row !important; }"),/s/i.test(r.print_columns)&&n.selector&&e.hasWidget(n.table,"columnSelector")?p+=r.columnSelector_mediaquery&&n.selector.auto?"":n.selector.$style.text():/a/i.test(r.print_columns)&&(p+="td, th { display: table-cell !important; }"),p+=r.print_extraCSS,t.isFunction(r.print_callback)?r.print_callback(n,l,p):i.printOutput(n,l.html(),p)},printOutput:function(t,n,r){var o=t.widgetOptions,a=e.language,l=window.open("",o.print_title,i.popupStyle),p=o.print_title||t.$table.find("caption").text()||t.$table[0].id||document.title||"table",s=o.print_now?"":'<div class="print_widget_hidden"><a href="javascript:window.print();"><button type="button">'+a.button_print+'</button></a> <a href="javascript:window.close();"><button type="button">'+a.button_close+"</button></a><hr></div>";return l.document.write("<html><head><title>"+p+"</title>"+(o.print_styleSheet?'<link rel="stylesheet" href="'+o.print_styleSheet+'">':"")+"<style>"+r+"</style></head><body>"+s+n+"</body></html>"),l.document.close(),o.print_now&&setTimeout(function(){l.print(),l.close()},10),!0},remove:function(t){t.$table.off(i.event)}};e.language.button_close="Close",e.language.button_print="Print",e.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(t,e,n){i.init(n)},remove:function(t,e){i.remove(e)}})}(jQuery);