1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | const isInit = that => that.$el.data('resizableColumns') !== undefined
|
8 |
|
9 | const initResizable = that => {
|
10 | if (that.options.resizable && !that.options.cardView && !isInit(that)) {
|
11 | that.$el.resizableColumns()
|
12 | }
|
13 | }
|
14 |
|
15 | const destroy = that => {
|
16 | if (isInit(that)) {
|
17 | that.$el.data('resizableColumns').destroy()
|
18 | }
|
19 | }
|
20 |
|
21 | const reInitResizable = that => {
|
22 | destroy(that)
|
23 | initResizable(that)
|
24 | }
|
25 |
|
26 | $.extend($.fn.bootstrapTable.defaults, {
|
27 | resizable: false
|
28 | })
|
29 |
|
30 | const BootstrapTable = $.fn.bootstrapTable.Constructor
|
31 | const _initBody = BootstrapTable.prototype.initBody
|
32 | const _toggleView = BootstrapTable.prototype.toggleView
|
33 | const _resetView = BootstrapTable.prototype.resetView
|
34 |
|
35 | BootstrapTable.prototype.initBody = function (...args) {
|
36 | const that = this
|
37 | _initBody.apply(this, Array.prototype.slice.apply(args))
|
38 |
|
39 | that.$el
|
40 | .off('column-switch.bs.table, page-change.bs.table')
|
41 | .on('column-switch.bs.table, page-change.bs.table', () => {
|
42 | reInitResizable(that)
|
43 | })
|
44 | }
|
45 |
|
46 | BootstrapTable.prototype.toggleView = function (...args) {
|
47 | _toggleView.apply(this, Array.prototype.slice.apply(args))
|
48 |
|
49 | if (this.options.resizable && this.options.cardView) {
|
50 |
|
51 | destroy(this)
|
52 | }
|
53 | }
|
54 |
|
55 | BootstrapTable.prototype.resetView = function (...args) {
|
56 | const that = this
|
57 |
|
58 | _resetView.apply(this, Array.prototype.slice.apply(args))
|
59 |
|
60 | if (this.options.resizable) {
|
61 |
|
62 | setTimeout(() => {
|
63 | initResizable(that)
|
64 | }, 100)
|
65 | }
|
66 | }
|