You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 lines
2.8 KiB

2 years ago
/*
* bootstrap-table - v1.11.1 - 2017-02-22
* https://github.com/wenzhixin/bootstrap-table
* Copyright (c) 2017 zhixin wen
* Licensed MIT License
*/
!function(a){"use strict";function b(a){return'<html><head><style type="text/css" media="print"> @page { size: auto; margin: 25px 0 25px 0; }</style><style type="text/css" media="all">table{border-collapse: collapse; font-size: 12px; }\ntable, th, td {border: 1px solid grey}\nth, td {text-align: center; vertical-align: middle;}\np {font-weight: bold; margin-left:20px }\ntable { width:94%; margin-left:3%; margin-right:3%}\ndiv.bs-table-print { text-align:center;}\n</style></head><title>Print Table</title><body><p>Printed on: '+new Date+' </p><div class="bs-table-print">'+a+"</div></body></html>"}var c=a.fn.bootstrapTable.utils.sprintf;a.extend(a.fn.bootstrapTable.defaults,{showPrint:!1,printAsFilteredAndSortedOnUI:!0,printSortColumn:void 0,printSortOrder:"asc",printPageBuilder:function(a){return b(a)}}),a.extend(a.fn.bootstrapTable.COLUMN_DEFAULTS,{printFilter:void 0,printIgnore:!1,printFormatter:void 0}),a.extend(a.fn.bootstrapTable.defaults.icons,{print:"glyphicon-print icon-share"});var d=a.fn.bootstrapTable.Constructor,e=d.prototype.initToolbar;d.prototype.initToolbar=function(){if(this.showToolbar=this.options.showPrint,e.apply(this,Array.prototype.slice.apply(arguments)),this.options.showPrint){var b=this,d=this.$toolbar.find(">.btn-group"),f=d.find("button.bs-print");f.length||(f=a(['<button class="bs-print btn btn-default'+c(' btn-%s"',this.options.iconSize)+' name="print" title="print" type="button">',c('<i class="%s %s"></i> ',this.options.iconsPrefix,this.options.icons.print),"</button>"].join("")).appendTo(d),f.click(function(){function a(a,b,c){var d=a[c.field];return"function"==typeof c.printFormatter?c.printFormatter.apply(c,[d,a,b]):d||"-"}function c(b,c){for(var d="<table><thead><tr>",e=0;e<c.length;e++)c[e].printIgnore||(d+="<th>"+c[e].title+"</th>");d+="</tr></thead><tbody>";for(var f=0;f<b.length;f++){d+="<tr>";for(var g=0;g<c.length;g++)c[g].printIgnore||(d+="<td>"+a(b[f],f,c[g])+"</td>");d+="</tr>"}return d+="</tbody></table>"}function d(a,b,c){if(!b)return a;var d="asc"!=c;return d=-(+d||-1),a.sort(function(a,c){return d*a[b].localeCompare(c[b])})}function e(a,b){for(var c=0;c<b.length;++c)if(a[b[c].colName]!=b[c].value)return!1;return!0}function f(a,b){return a.filter(function(a){return e(a,b)})}function g(a){return a&&a[0]?a[0].filter(function(a){return a.printFilter}).map(function(a){return{colName:a.field,value:a.printFilter}}):[]}var h=function(a){a=f(a,g(b.options.columns)),a=d(a,b.options.printSortColumn,b.options.printSortOrder);var e=c(a,b.options.columns[0]),h=window.open("");h.document.write(b.options.printPageBuilder.call(this,e)),h.print(),h.close()};h(b.options.printAsFilteredAndSortedOnUI?b.getData():b.options.data.slice(0))}))}}}(jQuery);