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.

685 lines
28 KiB

4 years ago
  1. /*!
  2. Buttons for DataTables 1.1.0
  3. ©2015 SpryMedia Ltd - datatables.net/license
  4. */
  5. (function (e) {
  6. "function" === typeof define && define.amd ? define(["jquery", "datatables.net"], function (n) {
  7. return e(n, window, document)
  8. }) : "object" === typeof exports ? module.exports = function (n, o) {
  9. n || (n = window);
  10. if (!o || !o.fn.dataTable) o = require("datatables.net")(n, o).$;
  11. return e(o, n, n.document)
  12. } : e(jQuery, window, document)
  13. })(function (e, n, o, m) {
  14. var j = e.fn.dataTable,
  15. s = 0,
  16. t = 0,
  17. k = j.ext.buttons,
  18. l = function (a, b) {
  19. !0 === b && (b = {});
  20. e.isArray(b) && (b = {
  21. buttons: b
  22. });
  23. this.c = e.extend(!0, {}, l.defaults, b);
  24. b.buttons && (this.c.buttons = b.buttons);
  25. this.s = {
  26. dt: new j.Api(a),
  27. buttons: [],
  28. subButtons: [],
  29. listenKeys: "",
  30. namespace: "dtb" + s++
  31. };
  32. this.dom = {
  33. container: e("<" + this.c.dom.container.tag + "/>").addClass(this.c.dom.container.className)
  34. };
  35. this._constructor()
  36. };
  37. e.extend(l.prototype, {
  38. action: function (a, b) {
  39. var c = this._indexToButton(a).conf;
  40. if (b === m) return c.action;
  41. c.action = b;
  42. return this
  43. },
  44. active: function (a, b) {
  45. this._indexToButton(a).node.toggleClass(this.c.dom.button.active, b === m ? !0 : b);
  46. return this
  47. },
  48. add: function (a, b) {
  49. if ("string" === typeof a && -1 !== a.indexOf("-")) {
  50. var c =
  51. a.split("-");
  52. this.c.buttons[1 * c[0]].buttons.splice(1 * c[1], 0, b)
  53. } else this.c.buttons.splice(1 * a, 0, b);
  54. this.dom.container.empty();
  55. this._buildButtons(this.c.buttons);
  56. return this
  57. },
  58. container: function () {
  59. return this.dom.container
  60. },
  61. disable: function (a) {
  62. this._indexToButton(a).node.addClass(this.c.dom.button.disabled);
  63. return this
  64. },
  65. destroy: function () {
  66. e("body").off("keyup." + this.s.namespace);
  67. var a = this.s.buttons,
  68. b = this.s.subButtons,
  69. c, d, f;
  70. c = 0;
  71. for (a = a.length; c < a; c++) {
  72. this.removePrep(c);
  73. d = 0;
  74. for (f = b[c].length; d < f; d++) this.removePrep(c +
  75. "-" + d)
  76. }
  77. this.removeCommit();
  78. this.dom.container.remove();
  79. b = this.s.dt.settings()[0];
  80. c = 0;
  81. for (a = b.length; c < a; c++)
  82. if (b.inst === this) {
  83. b.splice(c, 1);
  84. break
  85. }
  86. return this
  87. },
  88. enable: function (a, b) {
  89. if (!1 === b) return this.disable(a);
  90. this._indexToButton(a).node.removeClass(this.c.dom.button.disabled);
  91. return this
  92. },
  93. name: function () {
  94. return this.c.name
  95. },
  96. node: function (a) {
  97. return this._indexToButton(a).node
  98. },
  99. removeCommit: function () {
  100. var a = this.s.buttons,
  101. b = this.s.subButtons,
  102. c, d;
  103. for (c = a.length - 1; 0 <= c; c--) null === a[c] && (a.splice(c,
  104. 1), b.splice(c, 1), this.c.buttons.splice(c, 1));
  105. c = 0;
  106. for (a = b.length; c < a; c++)
  107. for (d = b[c].length - 1; 0 <= d; d--) null === b[c][d] && (b[c].splice(d, 1), this.c.buttons[c].buttons.splice(d, 1));
  108. return this
  109. },
  110. removePrep: function (a) {
  111. var b, c = this.s.dt;
  112. if ("number" === typeof a || -1 === a.indexOf("-")) b = this.s.buttons[1 * a], b.conf.destroy && b.conf.destroy.call(c.button(a), c, b, b.conf), b.node.remove(), this._removeKey(b.conf), this.s.buttons[1 * a] = null;
  113. else {
  114. var d = a.split("-");
  115. b = this.s.subButtons[1 * d[0]][1 * d[1]];
  116. b.conf.destroy && b.conf.destroy.call(c.button(a),
  117. c, b, b.conf);
  118. b.node.remove();
  119. this._removeKey(b.conf);
  120. this.s.subButtons[1 * d[0]][1 * d[1]] = null
  121. }
  122. return this
  123. },
  124. text: function (a, b) {
  125. var c = this._indexToButton(a),
  126. d = this.c.dom.collection.buttonLiner,
  127. d = "string" === typeof a && -1 !== a.indexOf("-") && d && d.tag ? d.tag : this.c.dom.buttonLiner.tag,
  128. e = this.s.dt,
  129. g = function (a) {
  130. return "function" === typeof a ? a(e, c.node, c.conf) : a
  131. };
  132. if (b === m) return g(c.conf.text);
  133. c.conf.text = b;
  134. d ? c.node.children(d).html(g(b)) : c.node.html(g(b));
  135. return this
  136. },
  137. toIndex: function (a) {
  138. var b, c, d, e;
  139. d = this.s.buttons;
  140. var g = this.s.subButtons;
  141. b = 0;
  142. for (c = d.length; b < c; b++)
  143. if (d[b].node[0] === a) return b + "";
  144. b = 0;
  145. for (c = g.length; b < c; b++) {
  146. d = 0;
  147. for (e = g[b].length; d < e; d++)
  148. if (g[b][d].node[0] === a) return b + "-" + d
  149. }
  150. },
  151. _constructor: function () {
  152. var a = this,
  153. b = this.s.dt,
  154. c = b.settings()[0];
  155. c._buttons || (c._buttons = []);
  156. c._buttons.push({
  157. inst: this,
  158. name: this.c.name
  159. });
  160. this._buildButtons(this.c.buttons);
  161. b.on("destroy", function () {
  162. a.destroy()
  163. });
  164. e("body").on("keyup." + this.s.namespace, function (b) {
  165. if (!o.activeElement || o.activeElement === o.body) {
  166. var c = String.fromCharCode(b.keyCode).toLowerCase();
  167. a.s.listenKeys.toLowerCase().indexOf(c) !== -1 && a._keypress(c, b)
  168. }
  169. })
  170. },
  171. _addKey: function (a) {
  172. a.key && (this.s.listenKeys += e.isPlainObject(a.key) ? a.key.key : a.key)
  173. },
  174. _buildButtons: function (a, b, c) {
  175. var d = this.s.dt;
  176. b || (b = this.dom.container, this.s.buttons = [], this.s.subButtons = []);
  177. for (var f = 0, g = a.length; f < g; f++) {
  178. var h = this._resolveExtends(a[f]);
  179. if (h)
  180. if (e.isArray(h)) this._buildButtons(h, b, c);
  181. else {
  182. var i = this._buildButton(h, c !== m ? !0 : !1);
  183. if (i) {
  184. var q = i.node;
  185. b.append(i.inserter);
  186. c === m ? (this.s.buttons.push({
  187. node: q,
  188. conf: h,
  189. inserter: i.inserter
  190. }), this.s.subButtons.push([])) : this.s.subButtons[c].push({
  191. node: q,
  192. conf: h,
  193. inserter: i.inserter
  194. });
  195. h.buttons && (i = this.c.dom.collection, h._collection = e("<" + i.tag + "/>").addClass(i.className), this._buildButtons(h.buttons, h._collection, f));
  196. h.init && h.init.call(d.button(q), d, q, h)
  197. }
  198. }
  199. }
  200. },
  201. _buildButton: function (a, b) {
  202. var c = this.c.dom.button,
  203. d = this.c.dom.buttonLiner,
  204. f = this.c.dom.collection,
  205. g = this.s.dt,
  206. h = function (b) {
  207. return "function" === typeof b ? b(g, i, a) : b
  208. };
  209. b && f.button && (c = f.button);
  210. b && f.buttonLiner &&
  211. (d = f.buttonLiner);
  212. if (a.available && !a.available(g, a)) return !1;
  213. var i = e("<" + c.tag + "/>").addClass(c.className).attr("tabindex", this.s.dt.settings()[0].iTabIndex).attr("aria-controls", this.s.dt.table().node().id).on("click.dtb", function (b) {
  214. b.preventDefault();
  215. !i.hasClass(c.disabled) && a.action && a.action.call(g.button(i), b, g, i, a);
  216. i.blur()
  217. }).on("keyup.dtb", function (b) {
  218. b.keyCode === 13 && !i.hasClass(c.disabled) && a.action && a.action.call(g.button(i), b, g, i, a)
  219. });
  220. d.tag ? i.append(e("<" + d.tag + "/>").html(h(a.text)).addClass(d.className)) :
  221. i.html(h(a.text));
  222. !1 === a.enabled && i.addClass(c.disabled);
  223. a.className && i.addClass(a.className);
  224. a.titleAttr && i.attr("title", a.titleAttr);
  225. a.namespace || (a.namespace = ".dt-button-" + t++);
  226. d = (d = this.c.dom.buttonContainer) ? e("<" + d.tag + "/>").addClass(d.className).append(i) : i;
  227. this._addKey(a);
  228. return {
  229. node: i,
  230. inserter: d
  231. }
  232. },
  233. _indexToButton: function (a) {
  234. if ("number" === typeof a || -1 === a.indexOf("-")) return this.s.buttons[1 * a];
  235. a = a.split("-");
  236. return this.s.subButtons[1 * a[0]][1 * a[1]]
  237. },
  238. _keypress: function (a, b) {
  239. var c, d, f, g;
  240. f =
  241. this.s.buttons;
  242. var h = this.s.subButtons,
  243. i = function (c, d) {
  244. if (c.key)
  245. if (c.key === a) d.click();
  246. else if (e.isPlainObject(c.key) && c.key.key === a && (!c.key.shiftKey || b.shiftKey))
  247. if (!c.key.altKey || b.altKey)
  248. if (!c.key.ctrlKey || b.ctrlKey) (!c.key.metaKey || b.metaKey) && d.click()
  249. };
  250. c = 0;
  251. for (d = f.length; c < d; c++) i(f[c].conf, f[c].node);
  252. c = 0;
  253. for (d = h.length; c < d; c++) {
  254. f = 0;
  255. for (g = h[c].length; f < g; f++) i(h[c][f].conf, h[c][f].node)
  256. }
  257. },
  258. _removeKey: function (a) {
  259. if (a.key) {
  260. var b = e.isPlainObject(a.key) ? a.key.key : a.key,
  261. a = this.s.listenKeys.split(""),
  262. b = e.inArray(b, a);
  263. a.splice(b, 1);
  264. this.s.listenKeys = a.join("")
  265. }
  266. },
  267. _resolveExtends: function (a) {
  268. for (var b = this.s.dt, c, d, f = function (c) {
  269. for (var d = 0; !e.isPlainObject(c) && !e.isArray(c);) {
  270. if (c === m) return;
  271. if ("function" === typeof c) {
  272. if (c = c(b, a), !c) return !1
  273. } else if ("string" === typeof c) {
  274. if (!k[c]) throw "Unknown button type: " + c;
  275. c = k[c]
  276. }
  277. d++;
  278. if (30 < d) throw "Buttons: Too many iterations";
  279. }
  280. return e.isArray(c) ? c : e.extend({}, c)
  281. }, a = f(a); a && a.extend;) {
  282. if (!k[a.extend]) throw "Cannot extend unknown button type: " + a.extend;
  283. var g =
  284. f(k[a.extend]);
  285. if (e.isArray(g)) return g;
  286. if (!g) return !1;
  287. c = g.className;
  288. a = e.extend({}, g, a);
  289. c && a.className !== c && (a.className = c + " " + a.className);
  290. var h = a.postfixButtons;
  291. if (h) {
  292. a.buttons || (a.buttons = []);
  293. c = 0;
  294. for (d = h.length; c < d; c++) a.buttons.push(h[c]);
  295. a.postfixButtons = null
  296. }
  297. if (h = a.prefixButtons) {
  298. a.buttons || (a.buttons = []);
  299. c = 0;
  300. for (d = h.length; c < d; c++) a.buttons.splice(c, 0, h[c]);
  301. a.prefixButtons = null
  302. }
  303. a.extend = g.extend
  304. }
  305. return a
  306. }
  307. });
  308. l.background = function (a, b, c) {
  309. c === m && (c = 400);
  310. a ? e("<div/>").addClass(b).css("display",
  311. "none").appendTo("body").fadeIn(c) : e("body > div." + b).fadeOut(c, function () {
  312. e(this).remove()
  313. })
  314. };
  315. l.instanceSelector = function (a, b) {
  316. if (!a) return e.map(b, function (a) {
  317. return a.inst
  318. });
  319. var c = [],
  320. d = e.map(b, function (a) {
  321. return a.name
  322. }),
  323. f = function (a) {
  324. if (e.isArray(a))
  325. for (var h = 0, i = a.length; h < i; h++) f(a[h]);
  326. else "string" === typeof a ? -1 !== a.indexOf(",") ? f(a.split(",")) : (a = e.inArray(e.trim(a), d), -1 !== a && c.push(b[a].inst)) : "number" === typeof a && c.push(b[a].inst)
  327. };
  328. f(a);
  329. return c
  330. };
  331. l.buttonSelector = function (a, b) {
  332. for (var c = [], d = function (a, b) {
  333. var f, g, j = [];
  334. e.each(b.s.buttons, function (a, b) {
  335. null !== b && j.push({
  336. node: b.node[0],
  337. name: b.name
  338. })
  339. });
  340. e.each(b.s.subButtons, function (a, b) {
  341. e.each(b, function (a, b) {
  342. null !== b && j.push({
  343. node: b.node[0],
  344. name: b.name
  345. })
  346. })
  347. });
  348. f = e.map(j, function (a) {
  349. return a.node
  350. });
  351. if (e.isArray(a) || a instanceof e) {
  352. f = 0;
  353. for (g = a.length; f < g; f++) d(a[f], b)
  354. } else if (null === a || a === m || "*" === a) {
  355. f = 0;
  356. for (g = j.length; f < g; f++) c.push({
  357. inst: b,
  358. idx: b.toIndex(j[f].node)
  359. })
  360. } else if ("number" === typeof a) c.push({
  361. inst: b,
  362. idx: a
  363. });
  364. else if ("string" ===
  365. typeof a)
  366. if (-1 !== a.indexOf(",")) {
  367. var k = a.split(",");
  368. f = 0;
  369. for (g = k.length; f < g; f++) d(e.trim(k[f]), b)
  370. } else if (a.match(/^\d+(\-\d+)?$/)) c.push({
  371. inst: b,
  372. idx: a
  373. });
  374. else if (-1 !== a.indexOf(":name")) {
  375. k = a.replace(":name", "");
  376. f = 0;
  377. for (g = j.length; f < g; f++) j[f].name === k && c.push({
  378. inst: b,
  379. idx: b.toIndex(j[f].node)
  380. })
  381. } else e(f).filter(a).each(function () {
  382. c.push({
  383. inst: b,
  384. idx: b.toIndex(this)
  385. })
  386. });
  387. else "object" === typeof a && a.nodeName && (g = e.inArray(a, f), -1 !== g && c.push({
  388. inst: b,
  389. idx: b.toIndex(f[g])
  390. }))
  391. }, f = 0, g = a.length; f < g; f++) d(b, a[f]);
  392. return c
  393. };
  394. l.defaults = {
  395. buttons: ["copy", "excel", "csv", "pdf", "print"],
  396. name: "main",
  397. tabIndex: 0,
  398. dom: {
  399. container: {
  400. tag: "div",
  401. className: "dt-buttons"
  402. },
  403. collection: {
  404. tag: "div",
  405. className: "dt-button-collection"
  406. },
  407. button: {
  408. tag: "a",
  409. className: "dt-button",
  410. active: "active",
  411. disabled: "disabled"
  412. },
  413. buttonLiner: {
  414. tag: "span",
  415. className: ""
  416. }
  417. }
  418. };
  419. l.version = "1.1.0";
  420. e.extend(k, {
  421. collection: {
  422. text: function (a) {
  423. return a.i18n("buttons.collection", "Collection")
  424. },
  425. className: "buttons-collection",
  426. action: function (a, b, c, d) {
  427. var a = c.offset(),
  428. b = e(b.table().container()),
  429. f = !1;
  430. e("div.dt-button-background").length && (f = e("div.dt-button-collection").offset(), e(o).trigger("click.dtb-collection"));
  431. d._collection.addClass(d.collectionLayout).css("display", "none").appendTo("body").fadeIn(d.fade);
  432. var g = d._collection.css("position");
  433. f && "absolute" === g ? d._collection.css({
  434. top: f.top + 5,
  435. left: f.left + 5
  436. }) : "absolute" === g ? (d._collection.css({
  437. top: a.top + c.outerHeight(),
  438. left: a.left
  439. }), c = a.left + d._collection.outerWidth(), b = b.offset().left + b.width(), c > b && d._collection.css("left", a.left - (c - b))) :
  440. (a = d._collection.height() / 2, a > e(n).height() / 2 && (a = e(n).height() / 2), d._collection.css("marginTop", -1 * a));
  441. d.background && l.background(!0, d.backgroundClassName, d.fade);
  442. setTimeout(function () {
  443. e("div.dt-button-background").on("click.dtb-collection", function () { });
  444. e("body").on("click.dtb-collection", function (a) {
  445. if (!e(a.target).parents().andSelf().filter(d._collection).length) {
  446. d._collection.fadeOut(d.fade, function () {
  447. d._collection.detach()
  448. });
  449. e("div.dt-button-background").off("click.dtb-collection");
  450. l.background(false,
  451. d.backgroundClassName, d.fade);
  452. e("body").off("click.dtb-collection")
  453. }
  454. })
  455. }, 10)
  456. },
  457. background: !0,
  458. collectionLayout: "",
  459. backgroundClassName: "dt-button-background",
  460. fade: 400
  461. },
  462. copy: function (a, b) {
  463. if (k.copyHtml5) return "copyHtml5";
  464. if (k.copyFlash && k.copyFlash.available(a, b)) return "copyFlash"
  465. },
  466. csv: function (a, b) {
  467. if (k.csvHtml5 && k.csvHtml5.available(a, b)) return "csvHtml5";
  468. if (k.csvFlash && k.csvFlash.available(a, b)) return "csvFlash"
  469. },
  470. excel: function (a, b) {
  471. if (k.excelHtml5 && k.excelHtml5.available(a, b)) return "excelHtml5";
  472. if (k.excelFlash &&
  473. k.excelFlash.available(a, b)) return "excelFlash"
  474. },
  475. pdf: function (a, b) {
  476. if (k.pdfHtml5 && k.pdfHtml5.available(a, b)) return "pdfHtml5";
  477. if (k.pdfFlash && k.pdfFlash.available(a, b)) return "pdfFlash"
  478. },
  479. pageLength: function (a) {
  480. var a = a.settings()[0].aLengthMenu,
  481. b = e.isArray(a[0]) ? a[0] : a,
  482. c = e.isArray(a[0]) ? a[1] : a,
  483. d = function (a) {
  484. return a.i18n("buttons.pageLength", {
  485. "-1": "Show all rows",
  486. _: "Show %d rows"
  487. }, a.page.len())
  488. };
  489. return {
  490. extend: "collection",
  491. text: d,
  492. className: "buttons-page-length",
  493. buttons: e.map(b, function (a, b) {
  494. return {
  495. text: c[b],
  496. action: function (b, c) {
  497. c.page.len(a).draw()
  498. },
  499. init: function (b, c, d) {
  500. var e = this,
  501. c = function () {
  502. e.active(b.page.len() === a)
  503. };
  504. b.on("length.dt" + d.namespace, c);
  505. c()
  506. },
  507. destroy: function (a, b, c) {
  508. a.off("length.dt" + c.namespace)
  509. }
  510. }
  511. }),
  512. init: function (a, b, c) {
  513. var e = this;
  514. a.on("length.dt" + c.namespace, function () {
  515. e.text(d(a))
  516. })
  517. },
  518. destroy: function (a, b, c) {
  519. a.off("length.dt" + c.namespace)
  520. }
  521. }
  522. }
  523. });
  524. j.Api.register("buttons()", function (a, b) {
  525. b === m && (b = a, a = m);
  526. return this.iterator(!0, "table", function (c) {
  527. if (c._buttons) return l.buttonSelector(l.instanceSelector(a,
  528. c._buttons), b)
  529. }, !0)
  530. });
  531. j.Api.register("button()", function (a, b) {
  532. var c = this.buttons(a, b);
  533. 1 < c.length && c.splice(1, c.length);
  534. return c
  535. });
  536. j.Api.register(["buttons().active()", "button().active()"], function (a) {
  537. return this.each(function (b) {
  538. b.inst.active(b.idx, a)
  539. })
  540. });
  541. j.Api.registerPlural("buttons().action()", "button().action()", function (a) {
  542. return a === m ? this.map(function (a) {
  543. return a.inst.action(a.idx)
  544. }) : this.each(function (b) {
  545. b.inst.action(b.idx, a)
  546. })
  547. });
  548. j.Api.register(["buttons().enable()", "button().enable()"],
  549. function (a) {
  550. return this.each(function (b) {
  551. b.inst.enable(b.idx, a)
  552. })
  553. });
  554. j.Api.register(["buttons().disable()", "button().disable()"], function () {
  555. return this.each(function (a) {
  556. a.inst.disable(a.idx)
  557. })
  558. });
  559. j.Api.registerPlural("buttons().nodes()", "button().node()", function () {
  560. var a = e();
  561. e(this.each(function (b) {
  562. a = a.add(b.inst.node(b.idx))
  563. }));
  564. return a
  565. });
  566. j.Api.registerPlural("buttons().text()", "button().text()", function (a) {
  567. return a === m ? this.map(function (a) {
  568. return a.inst.text(a.idx)
  569. }) : this.each(function (b) {
  570. b.inst.text(b.idx,
  571. a)
  572. })
  573. });
  574. j.Api.registerPlural("buttons().trigger()", "button().trigger()", function () {
  575. return this.each(function (a) {
  576. a.inst.node(a.idx).trigger("click")
  577. })
  578. });
  579. j.Api.registerPlural("buttons().containers()", "buttons().container()", function () {
  580. var a = e();
  581. e(this.each(function (b) {
  582. a = a.add(b.inst.container())
  583. }));
  584. return a
  585. });
  586. j.Api.register("button().add()", function (a, b) {
  587. 1 === this.length && this[0].inst.add(a, b);
  588. return this.button(a)
  589. });
  590. j.Api.register("buttons().destroy()", function () {
  591. this.pluck("inst").unique().each(function (a) {
  592. a.destroy()
  593. });
  594. return this
  595. });
  596. j.Api.registerPlural("buttons().remove()", "buttons().remove()", function () {
  597. this.each(function (a) {
  598. a.inst.removePrep(a.idx)
  599. });
  600. this.pluck("inst").unique().each(function (a) {
  601. a.removeCommit()
  602. });
  603. return this
  604. });
  605. var p;
  606. j.Api.register("buttons.info()", function (a, b, c) {
  607. var d = this;
  608. if (!1 === a) return e("#datatables_buttons_info").fadeOut(function () {
  609. e(this).remove()
  610. }), clearTimeout(p), p = null, this;
  611. p && clearTimeout(p);
  612. e("#datatables_buttons_info").length && e("#datatables_buttons_info").remove();
  613. e('<div id="datatables_buttons_info" class="dt-button-info"/>').html(a ?
  614. "<h2>" + a + "</h2>" : "").append(e("<div/>")["string" === typeof b ? "html" : "append"](b)).css("display", "none").appendTo("body").fadeIn();
  615. c !== m && 0 !== c && (p = setTimeout(function () {
  616. d.buttons.info(!1)
  617. }, c));
  618. return this
  619. });
  620. j.Api.register("buttons.exportData()", function (a) {
  621. if (this.context.length) {
  622. for (var b = new j.Api(this.context[0]), c = e.extend(!0, {}, {
  623. rows: null,
  624. columns: "",
  625. modifier: {
  626. search: "applied",
  627. order: "applied"
  628. },
  629. orthogonal: "display",
  630. stripHtml: !0,
  631. stripNewlines: !0,
  632. decodeEntities: !0,
  633. trim: !0,
  634. format: {
  635. header: function (a) {
  636. return d(a)
  637. },
  638. footer: function (a) {
  639. return d(a)
  640. },
  641. body: function (a) {
  642. return d(a)
  643. }
  644. }
  645. }, a), d = function (a) {
  646. if ("string" !== typeof a) return a;
  647. c.stripHtml && (a = a.replace(/<.*?>/g, ""));
  648. c.trim && (a = a.replace(/^\s+|\s+$/g, ""));
  649. c.stripNewlines && (a = a.replace(/\n/g, " "));
  650. c.decodeEntities && (r.innerHTML = a, a = r.value);
  651. return a
  652. }, a = b.columns(c.columns).indexes().map(function (a) {
  653. return c.format.header(b.column(a).header().innerHTML, a)
  654. }).toArray(), f = b.table().footer() ? b.columns(c.columns).indexes().map(function (a) {
  655. var d = b.column(a).footer();
  656. return c.format.footer(d ? d.innerHTML : "", a)
  657. }).toArray() : null, g = b.rows(c.rows, c.modifier).indexes().toArray(), g = b.cells(g, c.columns).render(c.orthogonal).toArray(), h = a.length, i = 0 < h ? g.length / h : 0, k = Array(i), l = 0, m = 0; m < i; m++) {
  658. for (var o = Array(h), n = 0; n < h; n++) o[n] = c.format.body(g[l], n, m), l++;
  659. k[m] = o
  660. }
  661. return {
  662. header: a,
  663. footer: f,
  664. body: k
  665. }
  666. }
  667. });
  668. var r = e("<textarea/>")[0];
  669. e.fn.dataTable.Buttons = l;
  670. e.fn.DataTable.Buttons = l;
  671. e(o).on("init.dt plugin-init.dt", function (a, b) {
  672. if ("dt" === a.namespace) {
  673. var c = b.oInit.buttons || j.defaults.buttons;
  674. c && !b._buttons && (new l(b, c)).container()
  675. }
  676. });
  677. j.ext.feature.push({
  678. fnInit: function (a) {
  679. var a = new j.Api(a),
  680. b = a.init().buttons || j.defaults.buttons;
  681. return (new l(a, b)).container()
  682. },
  683. cFeature: "B"
  684. });
  685. return l
  686. });