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.

462 lines
20 KiB

4 years ago
  1. (function (g)
  2. {
  3. "function" === typeof define && define.amd ? define(["jquery", "datatables.net", "datatables.net-buttons"], function (d) {
  4. return g(d, window, document);
  5. }) : "object" === typeof exports ? module.exports = function (d, f) {
  6. d || (d = window);
  7. if (!f || !f.fn.dataTable) f = require("datatables.net")(d, f).$;
  8. f.fn.dataTable.Buttons || require("datatables.net-buttons")(d, f);
  9. return g(f, d, d.document);
  10. } : g(jQuery, window, document);
  11. })(function (g, d, f, k)
  12. {
  13. var l = g.fn.dataTable,
  14. j;
  15. if ("undefined" !== typeof navigator && /MSIE [1-9]\./.test(navigator.userAgent)) j =
  16. void 0;
  17. else
  18. {
  19. var v = d.document,
  20. o = v.createElementNS("http://www.w3.org/1999/xhtml", "a"),
  21. D = "download" in o,
  22. p = d.webkitRequestFileSystem,
  23. w = d.requestFileSystem || p || d.mozRequestFileSystem,
  24. E = function (a)
  25. {
  26. (d.setImmediate || d.setTimeout)(function () {
  27. throw a;
  28. }, 0);
  29. },
  30. q = 0,
  31. r = function (a)
  32. {
  33. var b = function ()
  34. {
  35. "string" === typeof a ? (d.URL || d.webkitURL || d).revokeObjectURL(a) : a.remove();
  36. };
  37. d.chrome ? b() : setTimeout(b, 500);
  38. },
  39. s = function (a, b, e)
  40. {
  41. for(b = [].concat(b), c = b.length; c--;)
  42. {
  43. var d = a["on" + b[c]];
  44. if ("function" === typeof d) try
  45. {
  46. d.call(a,
  47. e || a);
  48. }
  49. catch (h)
  50. {
  51. E(h);
  52. }
  53. }
  54. },
  55. y = function (a)
  56. {
  57. return /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type) ? new Blob(["", a],
  58. {
  59. type: a.type
  60. }) : a;
  61. },
  62. A = function (a, b)
  63. {
  64. a = y(a),
  65. e = this,
  66. c = a.type,
  67. x = !1,
  68. h, g, z = function ()
  69. {
  70. s(e, ["writestart", "progress", "write", "writeend"]);
  71. },
  72. f = function ()
  73. {
  74. if (x || !h) h = (d.URL || d.webkitURL || d).createObjectURL(a);
  75. g ? g.location.href = h : d.open(h, "_blank") === k && "undefined" !== typeof safari && (d.location.href = h);
  76. e.readyState = e.DONE;
  77. z();
  78. r(h);
  79. },
  80. n = function (a)
  81. {
  82. return function () {
  83. if (e.readyState !==
  84. e.DONE) return a.apply(this, arguments);
  85. };
  86. },
  87. i = {
  88. create: !0,
  89. exclusive: !1
  90. },
  91. j;
  92. e.readyState = e.INIT;
  93. b || (b = "download");
  94. if (D) h = (d.URL || d.webkitURL || d).createObjectURL(a), o.href = h, o.download = b, c = v.createEvent("MouseEvents"), c.initMouseEvent("click", !0, !1, d, 0, 0, 0, 0, 0, !1, !1, !1, !1, 0, null), o.dispatchEvent(c), e.readyState = e.DONE, z(), r(h);
  95. else
  96. {
  97. d.chrome && (c && "application/octet-stream" !== c) && (j = a.slice || a.webkitSlice, a = j.call(a, 0, a.size, "application/octet-stream"), x = !0);
  98. p && "download" !== b && (b += ".download");
  99. if ("application/octet-stream" ===
  100. c || p) g = d;
  101. w ? (q += a.size, w(d.TEMPORARY, q, n(function (c) {
  102. c.root.getDirectory("saved", i, n(function (c) {
  103. var d = function () {
  104. c.getFile(b, i, n(function (b) {
  105. b.createWriter(n(function (c) {
  106. c.onwriteend = function (a) {
  107. g.location.href = b.toURL();
  108. e.readyState = e.DONE;
  109. s(e, "writeend", a);
  110. r(b);
  111. };
  112. c.onerror = function () {
  113. var a = c.error;
  114. a.code !== a.ABORT_ERR && f();
  115. };
  116. ["writestart", "progress", "write", "abort"].forEach(function (a) {
  117. c["on" + a] = e["on" + a];
  118. });
  119. c.write(a);
  120. e.abort = function () {
  121. c.abort();
  122. e.readyState = e.DONE;
  123. };
  124. e.readyState = e.WRITING;
  125. }), f);
  126. }),
  127. f);
  128. };
  129. c.getFile(b,
  130. {
  131. create: false
  132. }, n(function (a) {
  133. a.remove();
  134. d();
  135. }), n(function (a) {
  136. a.code === a.NOT_FOUND_ERR ? d() : f();
  137. }));
  138. }), f);
  139. }), f)) : f();
  140. }
  141. },
  142. i = A.prototype;
  143. "undefined" !== typeof navigator && navigator.msSaveOrOpenBlob ? j = function (a, b) {
  144. return navigator.msSaveOrOpenBlob(y(a), b);
  145. } : (i.abort = function () {
  146. this.readyState = this.DONE;
  147. s(this, "abort");
  148. }, i.readyState = i.INIT = 0, i.WRITING = 1, i.DONE = 2, i.error = i.onwritestart = i.onprogress = i.onwrite = i.onabort = i.onerror = i.onwriteend = null, j = function (a, b) {
  149. return new A(a, b);
  150. });
  151. }
  152. var t = function (a,
  153. b)
  154. {
  155. var e = "*" === a.filename && "*" !== a.title && a.title !== k ? a.title : a.filename; - 1 !== e.indexOf("*") && (e = e.replace("*", g("title").text()));
  156. e = e.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
  157. return b === k || !0 === b ? e + a.extension : e;
  158. },
  159. F = function (a)
  160. {
  161. a = a.title;
  162. return -1 !== a.indexOf("*") ? a.replace("*", g("title").text()) : a;
  163. },
  164. u = function (a)
  165. {
  166. return a.newline ? a.newline : navigator.userAgent.match(/Windows/) ? "\r\n" : "\n";
  167. },
  168. B = function (a, b)
  169. {
  170. for (var e = u(b), c = a.buttons.exportData(b.exportOptions), d = b.fieldBoundary, h = b.fieldSeparator,
  171. f = RegExp(d, "g"), g = b.escapeChar !== k ? b.escapeChar : "\\", i = function (a)
  172. {
  173. for (var b = "", c = 0, e = a.length; c < e; c++) 0 < c && (b += h), b += d ? d + ("" + a[c]).replace(f, g + d) + d : a[c];
  174. return b;
  175. }, n = b.header ? i(c.header) + e : "", j = b.footer ? e + i(c.footer) : "", l = [], m = 0, o = c.body.length; m < o; m++) l.push(i(c.body[m]));
  176. return {
  177. str: n + l.join(e) + j,
  178. rows: l.length
  179. };
  180. },
  181. C = function ()
  182. {
  183. return -1 !== navigator.userAgent.indexOf("Safari") && -1 === navigator.userAgent.indexOf("Chrome") && -1 === navigator.userAgent.indexOf("Opera");
  184. },
  185. m = {
  186. "_rels/.rels": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\t<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',
  187. "xl/_rels/workbook.xml.rels": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\t<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/></Relationships>',
  188. "[Content_Types].xml": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">\t<Default Extension="xml" ContentType="application/xml"/>\t<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>\t<Default Extension="jpeg" ContentType="image/jpeg"/>\t<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>\t<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/></Types>',
  189. "xl/workbook.xml": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">\t<fileVersion appName="xl" lastEdited="5" lowestEdited="5" rupBuild="24816"/>\t<workbookPr showInkAnnotation="0" autoCompressPictures="0"/>\t<bookViews>\t\t<workbookView xWindow="0" yWindow="0" windowWidth="25600" windowHeight="19020" tabRatio="500"/>\t</bookViews>\t<sheets>\t\t<sheet name="Sheet1" sheetId="1" r:id="rId1"/>\t</sheets></workbook>',
  190. "xl/worksheets/sheet1.xml": '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">\t<sheetData>\t\t__DATA__\t</sheetData></worksheet>'
  191. };
  192. l.ext.buttons.copyHtml5 = {
  193. className: "buttons-copy buttons-html5",
  194. text: function (a)
  195. {
  196. return a.i18n("buttons.copy", " Copy");
  197. },
  198. action: function (a, b, d, c)
  199. {
  200. a = B(b, c);
  201. c = a.str;
  202. d = g("<div/>").css(
  203. {
  204. height: 1,
  205. width: 1,
  206. overflow: "hidden",
  207. position: "fixed",
  208. top: 0,
  209. left: 0
  210. });
  211. c = g("<textarea readonly/>").val(c).appendTo(d);
  212. if (f.queryCommandSupported("copy"))
  213. {
  214. d.appendTo("body");
  215. c[0].focus();
  216. c[0].select();
  217. try
  218. {
  219. f.execCommand("copy");
  220. d.remove();
  221. b.buttons.info(b.i18n("buttons.copyTitle", "Copy to clipboard"), b.i18n("buttons.copySuccess",
  222. {
  223. 1: "Copied one row to clipboard",
  224. _: "Copied %d rows to clipboard"
  225. },
  226. a.rows), 2E3);
  227. return;
  228. }
  229. catch (i)
  230. { return i;}
  231. }
  232. a = g("<span>" + b.i18n("buttons.copyKeys", "Press <i>ctrl</i> or <i>⌘</i> + <i>C</i> to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.") + "</span>").append(d);
  233. b.buttons.info(b.i18n("buttons.copyTitle", "Copy to clipboard"), a, 0);
  234. c[0].focus();
  235. c[0].select();
  236. var h = g(a).closest(".dt-button-info"),
  237. j = function ()
  238. {
  239. h.off("click.buttons-copy");
  240. g(f).off(".buttons-copy");
  241. b.buttons.info(!1);
  242. };
  243. h.on("click.buttons-copy", j);
  244. g(f).on("keydown.buttons-copy",
  245. function (a) {
  246. 27 === a.keyCode && j();
  247. }).on("copy.buttons-copy cut.buttons-copy", function () {
  248. j();
  249. });
  250. },
  251. exportOptions:
  252. {},
  253. fieldSeparator: "\t",
  254. fieldBoundary: "",
  255. header: !0,
  256. footer: !1
  257. };
  258. l.ext.buttons.csvHtml5 = {
  259. className: "buttons-csv buttons-html5",
  260. available: function ()
  261. {
  262. return d.FileReader !== k && d.Blob;
  263. },
  264. text: function (a)
  265. {
  266. return a.i18n("buttons.csv", " CSV");
  267. },
  268. action: function (a, b, d, c)
  269. {
  270. u(c);
  271. a = B(b, c).str;
  272. b = c.charset;
  273. !1 !== b ? (b || (b = f.characterSet || f.charset), b && (b = ";charset=" + b)) : b = "";
  274. j(new Blob([a],
  275. {
  276. type: "text/csv" + b
  277. }), t(c));
  278. },
  279. filename: "*",
  280. extension: ".csv",
  281. exportOptions:
  282. {},
  283. fieldSeparator: ",",
  284. fieldBoundary: '"',
  285. escapeChar: '"',
  286. charset: null,
  287. header: !0,
  288. footer: !1
  289. };
  290. l.ext.buttons.excelHtml5 = {
  291. className: "buttons-excel buttons-html5",
  292. available: function ()
  293. {
  294. return d.FileReader !== k && d.JSZip !== k && !C();
  295. },
  296. text: function (a)
  297. {
  298. return a.i18n("buttons.excel", " Excel");
  299. },
  300. action: function (a, b, e, c)
  301. {
  302. a = "";
  303. b = b.buttons.exportData(c.exportOptions);
  304. e = function (a)
  305. {
  306. for (var b = [], c = 0, d = a.length; c < d; c++)
  307. {
  308. if (null === a[c] || a[c] === k) a[c] = "";
  309. b.push("number" === typeof a[c] ||
  310. a[c].match && a[c].match(/^-?[0-9\.]+$/) && "0" !== a[c].charAt(0) ? '<c t="n"><v>' + a[c] + "</v></c>" : '<c t="inlineStr"><is><t>' + (!a[c].replace ? a[c] : a[c].replace(/&(?!amp;)/g, "&amp;").replace(/[\x00-\x1F\x7F-\x9F]/g, "")) + "</t></is></c>")
  311. }
  312. return "<row>" + b.join("") + "</row>"
  313. };
  314. c.header && (a += e(b.header));
  315. for (var f = 0, h = b.body.length; f < h; f++) a += e(b.body[f]);
  316. c.footer && (a += e(b.footer));
  317. var b = new d.JSZip,
  318. e = b.folder("_rels"),
  319. f = b.folder("xl"),
  320. h = b.folder("xl/_rels"),
  321. g = b.folder("xl/worksheets");
  322. b.file("%5bContent_Types%5d.html",
  323. m["[Content_Types].xml"]);
  324. e.file(".rels", m["_rels/.rels"]);
  325. f.file("workbook.html", m["xl/workbook.xml"]);
  326. h.file("workbook.xml.rels", m["xl/_rels/workbook.xml.rels"]);
  327. g.file("sheet1.html", m["xl/worksheets/sheet1.xml"].replace("__DATA__", a));
  328. j(b.generate(
  329. {
  330. type: "blob"
  331. }), t(c));
  332. },
  333. filename: "*",
  334. extension: ".xlsx",
  335. exportOptions:
  336. {},
  337. header: !0,
  338. footer: !1
  339. };
  340. l.ext.buttons.pdfHtml5 = {
  341. className: "buttons-pdf buttons-html5",
  342. available: function ()
  343. {
  344. return d.FileReader !== k && d.pdfMake;
  345. },
  346. text: function (a)
  347. {
  348. return a.i18n("buttons.html",
  349. " PDF");
  350. },
  351. action: function (a, b, e, c)
  352. {
  353. u(c);
  354. a = b.buttons.exportData(c.exportOptions);
  355. b = [];
  356. c.header && b.push(g.map(a.header, function (a)
  357. {
  358. return {
  359. text: "string" === typeof a ? a : a + "",
  360. style: "tableHeader"
  361. };
  362. }));
  363. for (var f = 0, e = a.body.length; f < e; f++) b.push(g.map(a.body[f], function (a)
  364. {
  365. return {
  366. text: "string" === typeof a ? a : a + "",
  367. style: f % 2 ? "tableBodyEven" : "tableBodyOdd"
  368. };
  369. }));
  370. c.footer && b.push(g.map(a.footer, function (a)
  371. {
  372. return {
  373. text: "string" === typeof a ? a : a + "",
  374. style: "tableFooter"
  375. };
  376. }));
  377. a = {
  378. pageSize: c.pageSize,
  379. pageOrientation: c.orientation,
  380. content: [
  381. {
  382. table:
  383. {
  384. headerRows: 1,
  385. body: b
  386. },
  387. layout: "noBorders"
  388. }],
  389. styles:
  390. {
  391. tableHeader:
  392. {
  393. bold: !0,
  394. fontSize: 11,
  395. color: "white",
  396. fillColor: "#2d4154",
  397. alignment: "center"
  398. },
  399. tableBodyEven:
  400. {},
  401. tableBodyOdd:
  402. {
  403. fillColor: "#f3f3f3"
  404. },
  405. tableFooter:
  406. {
  407. bold: !0,
  408. fontSize: 11,
  409. color: "white",
  410. fillColor: "#2d4154"
  411. },
  412. title:
  413. {
  414. alignment: "center",
  415. fontSize: 15
  416. },
  417. message:
  418. {}
  419. },
  420. defaultStyle:
  421. {
  422. fontSize: 10
  423. }
  424. };
  425. c.message && a.content.unshift(
  426. {
  427. text: c.message,
  428. style: "message",
  429. margin: [0, 0, 0, 12]
  430. });
  431. c.title && a.content.unshift(
  432. {
  433. text: F(c, !1),
  434. style: "title",
  435. margin: [0, 0,
  436. 0, 12
  437. ]
  438. });
  439. c.customize && c.customize(a);
  440. a = d.pdfMake.createPdf(a);
  441. "open" === c.download && !C() ? a.open() : a.getBuffer(function (a) {
  442. a = new Blob([a],
  443. {
  444. type: "application/pdf"
  445. });
  446. j(a, t(c));
  447. });
  448. },
  449. title: "*",
  450. filename: "*",
  451. extension: ".pdf",
  452. exportOptions:
  453. {},
  454. orientation: "portrait",
  455. pageSize: "A4",
  456. header: !0,
  457. footer: !1,
  458. message: null,
  459. customize: null,
  460. download: "download"
  461. };
  462. return l.Buttons;
  463. });