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