bootstrap-table-i18n-enhance.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) :
  3. typeof define === 'function' && define.amd ? define(['jquery'], factory) :
  4. (global = global || self, factory(global.jQuery));
  5. }(this, function ($) { 'use strict';
  6. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  7. function _classCallCheck(instance, Constructor) {
  8. if (!(instance instanceof Constructor)) {
  9. throw new TypeError("Cannot call a class as a function");
  10. }
  11. }
  12. function _defineProperties(target, props) {
  13. for (var i = 0; i < props.length; i++) {
  14. var descriptor = props[i];
  15. descriptor.enumerable = descriptor.enumerable || false;
  16. descriptor.configurable = true;
  17. if ("value" in descriptor) descriptor.writable = true;
  18. Object.defineProperty(target, descriptor.key, descriptor);
  19. }
  20. }
  21. function _createClass(Constructor, protoProps, staticProps) {
  22. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  23. if (staticProps) _defineProperties(Constructor, staticProps);
  24. return Constructor;
  25. }
  26. function _inherits(subClass, superClass) {
  27. if (typeof superClass !== "function" && superClass !== null) {
  28. throw new TypeError("Super expression must either be null or a function");
  29. }
  30. subClass.prototype = Object.create(superClass && superClass.prototype, {
  31. constructor: {
  32. value: subClass,
  33. writable: true,
  34. configurable: true
  35. }
  36. });
  37. if (superClass) _setPrototypeOf(subClass, superClass);
  38. }
  39. function _getPrototypeOf(o) {
  40. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  41. return o.__proto__ || Object.getPrototypeOf(o);
  42. };
  43. return _getPrototypeOf(o);
  44. }
  45. function _setPrototypeOf(o, p) {
  46. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  47. o.__proto__ = p;
  48. return o;
  49. };
  50. return _setPrototypeOf(o, p);
  51. }
  52. function _assertThisInitialized(self) {
  53. if (self === void 0) {
  54. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  55. }
  56. return self;
  57. }
  58. function _possibleConstructorReturn(self, call) {
  59. if (call && (typeof call === "object" || typeof call === "function")) {
  60. return call;
  61. }
  62. return _assertThisInitialized(self);
  63. }
  64. /**
  65. * @author: Jewway
  66. * @update zhixin wen <wenzhixin2010@gmail.com>
  67. */
  68. $.fn.bootstrapTable.methods.push('changeTitle');
  69. $.fn.bootstrapTable.methods.push('changeLocale');
  70. $.BootstrapTable =
  71. /*#__PURE__*/
  72. function (_$$BootstrapTable) {
  73. _inherits(_class, _$$BootstrapTable);
  74. function _class() {
  75. _classCallCheck(this, _class);
  76. return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
  77. }
  78. _createClass(_class, [{
  79. key: "changeTitle",
  80. value: function changeTitle(locale) {
  81. $.each(this.options.columns, function (idx, columnList) {
  82. $.each(columnList, function (idx, column) {
  83. if (column.field) {
  84. column.title = locale[column.field];
  85. }
  86. });
  87. });
  88. this.initHeader();
  89. this.initBody();
  90. this.initToolbar();
  91. }
  92. }, {
  93. key: "changeLocale",
  94. value: function changeLocale(localeId) {
  95. this.options.locale = localeId;
  96. this.initLocale();
  97. this.initPagination();
  98. this.initBody();
  99. this.initToolbar();
  100. }
  101. }]);
  102. return _class;
  103. }($.BootstrapTable);
  104. }));