bootstrap-table-export.min.js 2.7 KB
/*
* bootstrap-table - v1.11.9 - 2022-10-27
https://github.com/wenzhixin/bootstrap-table
* Copyright (c) 2017 zhixin wen
* Licensed MIT License
*/
!function(p){"use strict";var o=p.fn.bootstrapTable.utils.sprintf,i={json:"JSON",xml:"XML",png:"PNG",csv:"CSV",txt:"TXT",sql:"SQL",doc:"MS-Word",excel:"MS-Excel",xlsx:"MS-Excel (OpenXML)",powerpoint:"MS-Powerpoint",pdf:"PDF"},t=(p.extend(p.fn.bootstrapTable.defaults,{showExport:!1,exportDataType:"basic",exportTypes:["json","xml","csv","txt","sql","excel"],exportOptions:{}}),p.extend(p.fn.bootstrapTable.defaults.icons,{export:"glyphicon-export icon-share"}),p.extend(p.fn.bootstrapTable.locales,{formatExport:function(){return"Export data"}}),p.extend(p.fn.bootstrapTable.defaults,p.fn.bootstrapTable.locales),p.fn.bootstrapTable.Constructor),a=t.prototype.initToolbar;t.prototype.initToolbar=function(){var s,e,t,n;this.showToolbar=this.options.showExport,a.apply(this,Array.prototype.slice.apply(arguments)),this.options.showExport&&!(t=(s=this).$toolbar.find(">.btn-group")).find("div.export").length&&(e=p(['<div class="export btn-group">','<button class="btn'+o(" btn-%s",this.options.buttonsClass)+o(" btn-%s",this.options.iconSize)+' dropdown-toggle" aria-label="export type" title="'+this.options.formatExport()+'" data-toggle="dropdown" type="button">',o('<i class="%s %s"></i> ',this.options.iconsPrefix,this.options.icons.export),'<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"</ul>","</div>"].join("")).appendTo(t).find(".dropdown-menu"),n=this.options.exportTypes,"string"==typeof this.options.exportTypes&&(t=this.options.exportTypes.slice(1,-1).replace(/ /g,"").split(","),n=[],p.each(t,function(t,o){n.push(o.slice(1,-1))})),p.each(n,function(t,o){i.hasOwnProperty(o)&&e.append(['<li role="menuitem" data-type="'+o+'">','<a href="javascript:void(0)">',i[o],"</a>","</li>"].join(""))}),e.find("li").click(function(){function t(){if("function"!=typeof require)throw new Error("RequireJS not found");require(["tableexport"],function(){s.$el.tableExport(p.extend({},s.options.exportOptions,{type:i,escape:!1}))})}var o,e,n,i=p(this).data("type");"all"===s.options.exportDataType&&s.options.pagination?(s.$el.one("server"===s.options.sidePagination?"post-body.bs.table":"page-change.bs.table",function(){t(),s.togglePagination()}),s.togglePagination()):"selected"===s.options.exportDataType?(o=s.getData(),n=s.getAllSelections(),"server"===s.options.sidePagination&&((o={total:s.options.totalRows})[s.options.dataField]=s.getData(),e="function"==typeof require?require("table"):null,(n={total:s.options.totalRows})[s.options.dataField]=e&&s.options.maintainSelected?e.api.selecteddata(s.$el):s.getAllSelections()),s.load(n),t(),s.load(o)):t()}))}}(jQuery);