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.bootstrapTableResizable = mod.exports;
|
12 | }
|
13 | })(this, function () {
|
14 | "use strict";
|
15 |
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | (function ($) {
|
23 | "use strict";
|
24 |
|
25 | var initResizable = function initResizable(that) {
|
26 | if (that.options.resizable && !that.options.cardView && !isInit(that)) {
|
27 | that.$el.resizableColumns();
|
28 | }
|
29 | };
|
30 |
|
31 | var reInitResizable = function reInitResizable(that) {
|
32 | destroy(that);
|
33 | initResizable(that);
|
34 | };
|
35 |
|
36 | var destroy = function destroy(that) {
|
37 | if (isInit(that)) {
|
38 | that.$el.data("resizableColumns").destroy();
|
39 | }
|
40 | };
|
41 |
|
42 | var isInit = function isInit(that) {
|
43 | return that.$el.data("resizableColumns") !== undefined;
|
44 | };
|
45 |
|
46 | $.extend($.fn.bootstrapTable.defaults, {
|
47 | resizable: false
|
48 | });
|
49 |
|
50 | var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
51 | _initBody = BootstrapTable.prototype.initBody,
|
52 | _toggleView = BootstrapTable.prototype.toggleView,
|
53 | _resetView = BootstrapTable.prototype.resetView;
|
54 |
|
55 | BootstrapTable.prototype.initBody = function () {
|
56 | var that = this;
|
57 | _initBody.apply(this, Array.prototype.slice.apply(arguments));
|
58 |
|
59 | that.$el.off("column-switch.bs.table, page-change.bs.table").on("column-switch.bs.table, page-change.bs.table", function () {
|
60 | reInitResizable(that);
|
61 | });
|
62 | };
|
63 |
|
64 | BootstrapTable.prototype.toggleView = function () {
|
65 | _toggleView.apply(this, Array.prototype.slice.apply(arguments));
|
66 |
|
67 | if (this.options.resizable && this.options.cardView) {
|
68 |
|
69 | destroy(this);
|
70 | }
|
71 | };
|
72 |
|
73 | BootstrapTable.prototype.resetView = function () {
|
74 | var that = this;
|
75 |
|
76 | _resetView.apply(this, Array.prototype.slice.apply(arguments));
|
77 |
|
78 | if (this.options.resizable) {
|
79 |
|
80 | setTimeout(function () {
|
81 | initResizable(that);
|
82 | }, 100);
|
83 | }
|
84 | };
|
85 | })(jQuery);
|
86 | }); |
\ | No newline at end of file |