UNPKG

5.32 kBJavaScriptView Raw
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 = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jQuery));
5})(this, (function ($) { 'use strict';
6
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, _toPropertyKey(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 Object.defineProperty(Constructor, "prototype", {
25 writable: false
26 });
27 return Constructor;
28 }
29 function _inherits(subClass, superClass) {
30 if (typeof superClass !== "function" && superClass !== null) {
31 throw new TypeError("Super expression must either be null or a function");
32 }
33 subClass.prototype = Object.create(superClass && superClass.prototype, {
34 constructor: {
35 value: subClass,
36 writable: true,
37 configurable: true
38 }
39 });
40 Object.defineProperty(subClass, "prototype", {
41 writable: false
42 });
43 if (superClass) _setPrototypeOf(subClass, superClass);
44 }
45 function _getPrototypeOf(o) {
46 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
47 return o.__proto__ || Object.getPrototypeOf(o);
48 };
49 return _getPrototypeOf(o);
50 }
51 function _setPrototypeOf(o, p) {
52 _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
53 o.__proto__ = p;
54 return o;
55 };
56 return _setPrototypeOf(o, p);
57 }
58 function _isNativeReflectConstruct() {
59 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
60 if (Reflect.construct.sham) return false;
61 if (typeof Proxy === "function") return true;
62 try {
63 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
64 return true;
65 } catch (e) {
66 return false;
67 }
68 }
69 function _assertThisInitialized(self) {
70 if (self === void 0) {
71 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
72 }
73 return self;
74 }
75 function _possibleConstructorReturn(self, call) {
76 if (call && (typeof call === "object" || typeof call === "function")) {
77 return call;
78 } else if (call !== void 0) {
79 throw new TypeError("Derived constructors may only return object or undefined");
80 }
81 return _assertThisInitialized(self);
82 }
83 function _createSuper(Derived) {
84 var hasNativeReflectConstruct = _isNativeReflectConstruct();
85 return function _createSuperInternal() {
86 var Super = _getPrototypeOf(Derived),
87 result;
88 if (hasNativeReflectConstruct) {
89 var NewTarget = _getPrototypeOf(this).constructor;
90 result = Reflect.construct(Super, arguments, NewTarget);
91 } else {
92 result = Super.apply(this, arguments);
93 }
94 return _possibleConstructorReturn(this, result);
95 };
96 }
97 function _toPrimitive(input, hint) {
98 if (typeof input !== "object" || input === null) return input;
99 var prim = input[Symbol.toPrimitive];
100 if (prim !== undefined) {
101 var res = prim.call(input, hint || "default");
102 if (typeof res !== "object") return res;
103 throw new TypeError("@@toPrimitive must return a primitive value.");
104 }
105 return (hint === "string" ? String : Number)(input);
106 }
107 function _toPropertyKey(arg) {
108 var key = _toPrimitive(arg, "string");
109 return typeof key === "symbol" ? key : String(key);
110 }
111
112 /**
113 * @author: Jewway
114 * @update zhixin wen <wenzhixin2010@gmail.com>
115 */
116
117 $.fn.bootstrapTable.methods.push('changeTitle');
118 $.fn.bootstrapTable.methods.push('changeLocale');
119 $.BootstrapTable = /*#__PURE__*/function (_$$BootstrapTable) {
120 _inherits(_class, _$$BootstrapTable);
121 var _super = _createSuper(_class);
122 function _class() {
123 _classCallCheck(this, _class);
124 return _super.apply(this, arguments);
125 }
126 _createClass(_class, [{
127 key: "changeTitle",
128 value: function changeTitle(locale) {
129 $.each(this.options.columns, function (idx, columnList) {
130 $.each(columnList, function (idx, column) {
131 if (column.field) {
132 column.title = locale[column.field];
133 }
134 });
135 });
136 this.initHeader();
137 this.initBody();
138 this.initToolbar();
139 }
140 }, {
141 key: "changeLocale",
142 value: function changeLocale(localeId) {
143 this.options.locale = localeId;
144 this.initLocale();
145 this.initPagination();
146 this.initBody();
147 this.initToolbar();
148 }
149 }]);
150 return _class;
151 }($.BootstrapTable);
152
153}));