bootstrap-table-i18n-enhance.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define([], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory();
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory();
  11. global.bootstrapTableI18nEnhance = mod.exports;
  12. }
  13. })(this, function () {
  14. 'use strict';
  15. /**
  16. * @author: Jewway
  17. * @version: v1.0.0
  18. */
  19. !function ($) {
  20. 'use strict';
  21. var BootstrapTable = $.fn.bootstrapTable.Constructor;
  22. BootstrapTable.prototype.changeTitle = function (locale) {
  23. $.each(this.options.columns, function (idx, columnList) {
  24. $.each(columnList, function (idx, column) {
  25. if (column.field) {
  26. column.title = locale[column.field];
  27. }
  28. });
  29. });
  30. this.initHeader();
  31. this.initBody();
  32. this.initToolbar();
  33. };
  34. BootstrapTable.prototype.changeLocale = function (localeId) {
  35. this.options.locale = localeId;
  36. this.initLocale();
  37. this.initPagination();
  38. this.initBody();
  39. this.initToolbar();
  40. };
  41. $.fn.bootstrapTable.methods.push('changeTitle');
  42. $.fn.bootstrapTable.methods.push('changeLocale');
  43. }(jQuery);
  44. });