bootstrap-table-i18n-enhance.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('core-js/modules/es.object.to-string.js'), require('core-js/modules/web.dom-collections.for-each.js'), require('jquery')) :
  3. typeof define === 'function' && define.amd ? define(['core-js/modules/es.object.to-string.js', 'core-js/modules/web.dom-collections.for-each.js', 'jquery'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(null, null, global.jQuery));
  5. })(this, (function (es_object_toString_js, web_domCollections_forEach_js, $) { 'use strict';
  6. function _assertThisInitialized(e) {
  7. if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  8. return e;
  9. }
  10. function _callSuper(t, o, e) {
  11. return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
  12. }
  13. function _classCallCheck(a, n) {
  14. if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
  15. }
  16. function _defineProperties(e, r) {
  17. for (var t = 0; t < r.length; t++) {
  18. var o = r[t];
  19. o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
  20. }
  21. }
  22. function _createClass(e, r, t) {
  23. return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
  24. writable: !1
  25. }), e;
  26. }
  27. function _getPrototypeOf(t) {
  28. return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
  29. return t.__proto__ || Object.getPrototypeOf(t);
  30. }, _getPrototypeOf(t);
  31. }
  32. function _inherits(t, e) {
  33. if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
  34. t.prototype = Object.create(e && e.prototype, {
  35. constructor: {
  36. value: t,
  37. writable: !0,
  38. configurable: !0
  39. }
  40. }), Object.defineProperty(t, "prototype", {
  41. writable: !1
  42. }), e && _setPrototypeOf(t, e);
  43. }
  44. function _isNativeReflectConstruct() {
  45. try {
  46. var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  47. } catch (t) {}
  48. return (_isNativeReflectConstruct = function () {
  49. return !!t;
  50. })();
  51. }
  52. function _possibleConstructorReturn(t, e) {
  53. if (e && ("object" == typeof e || "function" == typeof e)) return e;
  54. if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
  55. return _assertThisInitialized(t);
  56. }
  57. function _setPrototypeOf(t, e) {
  58. return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
  59. return t.__proto__ = e, t;
  60. }, _setPrototypeOf(t, e);
  61. }
  62. function _toPrimitive(t, r) {
  63. if ("object" != typeof t || !t) return t;
  64. var e = t[Symbol.toPrimitive];
  65. if (void 0 !== e) {
  66. var i = e.call(t, r );
  67. if ("object" != typeof i) return i;
  68. throw new TypeError("@@toPrimitive must return a primitive value.");
  69. }
  70. return (String )(t);
  71. }
  72. function _toPropertyKey(t) {
  73. var i = _toPrimitive(t, "string");
  74. return "symbol" == typeof i ? i : i + "";
  75. }
  76. /**
  77. * @author: Jewway
  78. * @update zhixin wen <wenzhixin2010@gmail.com>
  79. */
  80. $.fn.bootstrapTable.methods.push('changeTitle');
  81. $.fn.bootstrapTable.methods.push('changeLocale');
  82. $.BootstrapTable = /*#__PURE__*/function (_$$BootstrapTable) {
  83. function _class() {
  84. _classCallCheck(this, _class);
  85. return _callSuper(this, _class, arguments);
  86. }
  87. _inherits(_class, _$$BootstrapTable);
  88. return _createClass(_class, [{
  89. key: "changeTitle",
  90. value: function changeTitle(locale) {
  91. this.options.columns.forEach(function (columnList) {
  92. columnList.forEach(function (column) {
  93. if (column.field) {
  94. column.title = locale[column.field];
  95. }
  96. });
  97. });
  98. this.initHeader();
  99. this.initBody();
  100. this.initToolbar();
  101. }
  102. }, {
  103. key: "changeLocale",
  104. value: function changeLocale(localeId) {
  105. this.options.locale = localeId;
  106. this.initLocale();
  107. this.initPagination();
  108. this.initBody();
  109. this.initToolbar();
  110. }
  111. }]);
  112. }($.BootstrapTable);
  113. }));