bootstrap-table-rails 1.12.2 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -12
- data/lib/bootstrap-table-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table-locale-all.js +2534 -1841
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table.css +202 -283
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table.js +3114 -2555
- data/vendor/assets/javascripts/bootstrap-table/extensions/accent-neutralise/bootstrap-table-accent-neutralise.js +247 -152
- data/vendor/assets/javascripts/bootstrap-table/extensions/addrbar/bootstrap-table-addrbar.js +271 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.js +77 -68
- data/vendor/assets/javascripts/bootstrap-table/extensions/cookie/bootstrap-table-cookie.js +452 -315
- data/vendor/assets/javascripts/bootstrap-table/extensions/copy-rows/bootstrap-table-copy-rows.js +105 -86
- data/vendor/assets/javascripts/bootstrap-table/extensions/defer-url/bootstrap-table-defer-url.js +44 -27
- data/vendor/assets/javascripts/bootstrap-table/extensions/editable/bootstrap-table-editable.js +229 -115
- data/vendor/assets/javascripts/bootstrap-table/extensions/export/bootstrap-table-export.js +319 -162
- data/vendor/assets/javascripts/bootstrap-table/extensions/filter-control/bootstrap-table-filter-control.js +733 -566
- data/vendor/assets/javascripts/bootstrap-table/extensions/group-by-v2/bootstrap-table-group-by.js +175 -167
- data/vendor/assets/javascripts/bootstrap-table/extensions/group-by/bootstrap-table-group-by.js +227 -213
- data/vendor/assets/javascripts/bootstrap-table/extensions/i18n-enhance/bootstrap-table-i18n-enhance.js +44 -29
- data/vendor/assets/javascripts/bootstrap-table/extensions/key-events/bootstrap-table-key-events.js +92 -70
- data/vendor/assets/javascripts/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js +134 -118
- data/vendor/assets/javascripts/bootstrap-table/extensions/multi-column-toggle/bootstrap-table-multi-toggle.js +92 -75
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-search/bootstrap-table-multiple-search.js +72 -58
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-selection-row/bootstrap-table-multiple-selection-row.js +129 -113
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-sort/bootstrap-table-multiple-sort.js +362 -349
- data/vendor/assets/javascripts/bootstrap-table/extensions/natural-sorting/bootstrap-table-natural-sorting.js +66 -50
- data/vendor/assets/javascripts/bootstrap-table/extensions/{page-jumpto/bootstrap-table-jumpto.css → page-jump-to/bootstrap-table-page-jump-to.css} +0 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/page-jump-to/bootstrap-table-page-jump-to.js +58 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/pipeline/bootstrap-table-pipeline.js +341 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/print/bootstrap-table-print.js +122 -126
- data/vendor/assets/javascripts/bootstrap-table/extensions/reorder-columns/bootstrap-table-reorder-columns.js +183 -167
- data/vendor/assets/javascripts/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js +124 -110
- data/vendor/assets/javascripts/bootstrap-table/extensions/resizable/bootstrap-table-resizable.js +66 -55
- data/vendor/assets/javascripts/bootstrap-table/extensions/select2-filter/bootstrap-table-select2-filter.js +281 -272
- data/vendor/assets/javascripts/bootstrap-table/extensions/sticky-header/bootstrap-table-sticky-header.css +13 -13
- data/vendor/assets/javascripts/bootstrap-table/extensions/sticky-header/bootstrap-table-sticky-header.js +182 -106
- data/vendor/assets/javascripts/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js +324 -162
- data/vendor/assets/javascripts/bootstrap-table/extensions/tree-column/bootstrap-table-tree-column.js +127 -115
- data/vendor/assets/javascripts/bootstrap-table/extensions/treegrid/bootstrap-table-treegrid.js +106 -96
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-af-ZA.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ar-SA.js +49 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ca-ES.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-cs-CZ.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-da-DK.js +60 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-de-DE.js +61 -48
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-el-GR.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-en-US.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-AR.js +39 -26
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-CL.js +54 -41
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-CR.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-ES.js +103 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-MX.js +59 -46
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-NI.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-SP.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-et-EE.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-eu-EU.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fa-IR.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fi-FI.js +62 -0
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fr-BE.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fr-FR.js +103 -90
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-he-IL.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-hr-HR.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-hu-HU.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-id-ID.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-it-IT.js +59 -47
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ja-JP.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ka-GE.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ko-KR.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ms-MY.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-nb-NO.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-nl-NL.js +60 -47
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pl-PL.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pt-BR.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pt-PT.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ro-RO.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ru-RU.js +82 -68
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-sk-SK.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-sv-SE.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-th-TH.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-tr-TR.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-uk-UA.js +82 -69
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ur-PK.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-uz-Latn-UZ.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-vi-VN.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-zh-CN.js +54 -41
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-zh-TW.js +48 -35
- metadata +6 -8
- data/vendor/assets/javascripts/bootstrap-table/extensions/angular/bootstrap-table-angular.js +0 -107
- data/vendor/assets/javascripts/bootstrap-table/extensions/click-edit-row/bootstrap-table-click-edit-row.css +0 -21
- data/vendor/assets/javascripts/bootstrap-table/extensions/click-edit-row/bootstrap-table-click-edit-row.js +0 -142
- data/vendor/assets/javascripts/bootstrap-table/extensions/filter/bootstrap-table-filter.js +0 -67
- data/vendor/assets/javascripts/bootstrap-table/extensions/flat-json/bootstrap-table-flat-json.js +0 -62
- data/vendor/assets/javascripts/bootstrap-table/extensions/page-jumpto/bootstrap-table-jumpto.js +0 -50
@@ -1,118 +1,132 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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.bootstrapTableReorderRows = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function () {
|
14
|
+
'use strict';
|
6
15
|
|
7
|
-
|
16
|
+
/**
|
17
|
+
* @author: Dennis Hernández
|
18
|
+
* @webSite: http://djhvscf.github.io/Blog
|
19
|
+
* @version: v1.0.1
|
20
|
+
*/
|
8
21
|
|
9
|
-
|
22
|
+
(function ($) {
|
23
|
+
|
24
|
+
'use strict';
|
10
25
|
|
11
|
-
|
26
|
+
var isSearch = false;
|
12
27
|
|
13
|
-
|
14
|
-
|
15
|
-
|
28
|
+
var rowAttr = function rowAttr(row, index) {
|
29
|
+
return {
|
30
|
+
id: 'customId_' + index
|
31
|
+
};
|
16
32
|
};
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
33
|
+
|
34
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
35
|
+
reorderableRows: false,
|
36
|
+
onDragStyle: null,
|
37
|
+
onDropStyle: null,
|
38
|
+
onDragClass: "reorder_rows_onDragClass",
|
39
|
+
dragHandle: null,
|
40
|
+
useRowAttrFunc: false,
|
41
|
+
onReorderRowsDrag: function onReorderRowsDrag(table, row) {
|
42
|
+
return false;
|
43
|
+
},
|
44
|
+
onReorderRowsDrop: function onReorderRowsDrop(table, row) {
|
45
|
+
return false;
|
46
|
+
},
|
47
|
+
onReorderRow: function onReorderRow(newData) {
|
48
|
+
return false;
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
53
|
+
'reorder-row.bs.table': 'onReorderRow'
|
54
|
+
});
|
55
|
+
|
56
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
57
|
+
_init = BootstrapTable.prototype.init,
|
58
|
+
_initSearch = BootstrapTable.prototype.initSearch;
|
59
|
+
|
60
|
+
BootstrapTable.prototype.init = function () {
|
61
|
+
|
62
|
+
if (!this.options.reorderableRows) {
|
63
|
+
_init.apply(this, Array.prototype.slice.apply(arguments));
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
|
67
|
+
var that = this;
|
68
|
+
if (this.options.useRowAttrFunc) {
|
69
|
+
this.options.rowAttributes = rowAttr;
|
70
|
+
}
|
71
|
+
|
72
|
+
var onPostBody = this.options.onPostBody;
|
73
|
+
this.options.onPostBody = function () {
|
74
|
+
setTimeout(function () {
|
75
|
+
that.makeRowsReorderable();
|
76
|
+
onPostBody.apply();
|
77
|
+
}, 1);
|
78
|
+
};
|
79
|
+
|
48
80
|
_init.apply(this, Array.prototype.slice.apply(arguments));
|
49
|
-
return;
|
50
|
-
}
|
51
|
-
|
52
|
-
var that = this;
|
53
|
-
if (this.options.useRowAttrFunc) {
|
54
|
-
this.options.rowAttributes = rowAttr;
|
55
|
-
}
|
56
|
-
|
57
|
-
var onPostBody = this.options.onPostBody;
|
58
|
-
this.options.onPostBody = function () {
|
59
|
-
setTimeout(function () {
|
60
|
-
that.makeRowsReorderable();
|
61
|
-
onPostBody.apply();
|
62
|
-
}, 1);
|
63
81
|
};
|
64
82
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
//Call the event reorder-row
|
116
|
-
tableBsData.trigger('reorder-row', newData);
|
117
|
-
};
|
118
|
-
})(jQuery);
|
83
|
+
BootstrapTable.prototype.initSearch = function () {
|
84
|
+
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
85
|
+
|
86
|
+
if (!this.options.reorderableRows) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
|
90
|
+
//Known issue after search if you reorder the rows the data is not display properly
|
91
|
+
//isSearch = true;
|
92
|
+
};
|
93
|
+
|
94
|
+
BootstrapTable.prototype.makeRowsReorderable = function () {
|
95
|
+
if (this.options.cardView) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
|
99
|
+
var that = this;
|
100
|
+
this.$el.tableDnD({
|
101
|
+
onDragStyle: that.options.onDragStyle,
|
102
|
+
onDropStyle: that.options.onDropStyle,
|
103
|
+
onDragClass: that.options.onDragClass,
|
104
|
+
onDrop: that.onDrop,
|
105
|
+
onDragStart: that.options.onReorderRowsDrag,
|
106
|
+
dragHandle: that.options.dragHandle
|
107
|
+
});
|
108
|
+
};
|
109
|
+
|
110
|
+
BootstrapTable.prototype.onDrop = function (table, droppedRow) {
|
111
|
+
var tableBs = $(table),
|
112
|
+
tableBsData = tableBs.data('bootstrap.table'),
|
113
|
+
tableBsOptions = tableBs.data('bootstrap.table').options,
|
114
|
+
row = null,
|
115
|
+
newData = [];
|
116
|
+
|
117
|
+
for (var i = 0; i < table.tBodies[0].rows.length; i++) {
|
118
|
+
row = $(table.tBodies[0].rows[i]);
|
119
|
+
newData.push(tableBsOptions.data[row.data('index')]);
|
120
|
+
row.data('index', i).attr('data-index', i);
|
121
|
+
}
|
122
|
+
|
123
|
+
tableBsOptions.data = tableBsOptions.data.slice(0, tableBsData.pageFrom - 1).concat(newData).concat(tableBsOptions.data.slice(tableBsData.pageTo));
|
124
|
+
|
125
|
+
//Call the user defined function
|
126
|
+
tableBsOptions.onReorderRowsDrop.apply(table, [table, droppedRow]);
|
127
|
+
|
128
|
+
//Call the event reorder-row
|
129
|
+
tableBsData.trigger('reorder-row', newData);
|
130
|
+
};
|
131
|
+
})(jQuery);
|
132
|
+
});
|
data/vendor/assets/javascripts/bootstrap-table/extensions/resizable/bootstrap-table-resizable.js
CHANGED
@@ -1,75 +1,86 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
+
* @author: Dennis Hernández
|
18
|
+
* @webSite: http://djhvscf.github.io/Blog
|
19
|
+
* @version: v2.0.0
|
20
|
+
*/
|
21
|
+
|
22
|
+
(function ($) {
|
23
|
+
"use strict";
|
6
24
|
|
7
|
-
|
8
|
-
|
25
|
+
var initResizable = function initResizable(that) {
|
26
|
+
if (that.options.resizable && !that.options.cardView && !isInit(that)) {
|
27
|
+
that.$el.resizableColumns();
|
28
|
+
}
|
29
|
+
};
|
9
30
|
|
10
|
-
var
|
11
|
-
|
12
|
-
|
31
|
+
var reInitResizable = function reInitResizable(that) {
|
32
|
+
destroy(that);
|
33
|
+
initResizable(that);
|
34
|
+
};
|
13
35
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
onResize: that.onResize,
|
23
|
-
onDrag: that.options.onResizableDrag,
|
24
|
-
resizeMode: that.options.resizeMode
|
25
|
-
});
|
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;
|
26
44
|
};
|
27
45
|
|
28
46
|
$.extend($.fn.bootstrapTable.defaults, {
|
29
|
-
|
30
|
-
liveDrag: false,
|
31
|
-
fixed: true,
|
32
|
-
headerOnly: false,
|
33
|
-
minWidth: 15,
|
34
|
-
hoverCursor: 'e-resize',
|
35
|
-
dragCursor: 'e-resize',
|
36
|
-
onResizableResize: function (e) {
|
37
|
-
return false;
|
38
|
-
},
|
39
|
-
onResizableDrag: function (e) {
|
40
|
-
return false;
|
41
|
-
}
|
47
|
+
resizable: false
|
42
48
|
});
|
43
49
|
|
44
50
|
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
51
|
+
_initBody = BootstrapTable.prototype.initBody,
|
45
52
|
_toggleView = BootstrapTable.prototype.toggleView,
|
46
53
|
_resetView = BootstrapTable.prototype.resetView;
|
47
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
|
+
|
48
64
|
BootstrapTable.prototype.toggleView = function () {
|
49
|
-
|
65
|
+
_toggleView.apply(this, Array.prototype.slice.apply(arguments));
|
50
66
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
67
|
+
if (this.options.resizable && this.options.cardView) {
|
68
|
+
//Destroy the plugin
|
69
|
+
destroy(this);
|
70
|
+
}
|
55
71
|
};
|
56
72
|
|
57
73
|
BootstrapTable.prototype.resetView = function () {
|
58
|
-
|
74
|
+
var that = this;
|
59
75
|
|
60
|
-
|
76
|
+
_resetView.apply(this, Array.prototype.slice.apply(arguments));
|
61
77
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
78
|
+
if (this.options.resizable) {
|
79
|
+
// because in fitHeader function, we use setTimeout(func, 100);
|
80
|
+
setTimeout(function () {
|
81
|
+
initResizable(that);
|
82
|
+
}, 100);
|
83
|
+
}
|
68
84
|
};
|
69
|
-
|
70
|
-
|
71
|
-
var that = $(e.currentTarget);
|
72
|
-
that.bootstrapTable('resetView');
|
73
|
-
that.data('bootstrap.table').options.onResizableResize.apply(e);
|
74
|
-
}
|
75
|
-
})(jQuery);
|
85
|
+
})(jQuery);
|
86
|
+
});
|
@@ -1,332 +1,341 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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.bootstrapTableSelect2Filter = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function () {
|
7
14
|
'use strict';
|
8
15
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
16
|
+
/**
|
17
|
+
* @author: Jewway
|
18
|
+
* @version: v1.1.1
|
19
|
+
*/
|
14
20
|
|
15
|
-
|
16
|
-
|
21
|
+
!function ($) {
|
22
|
+
'use strict';
|
17
23
|
|
18
|
-
|
19
|
-
|
20
|
-
|
24
|
+
function getCurrentHeader(that) {
|
25
|
+
var header = that.$header;
|
26
|
+
if (that.options.height) {
|
27
|
+
header = that.$tableHeader;
|
28
|
+
}
|
21
29
|
|
22
|
-
|
23
|
-
|
30
|
+
return header;
|
31
|
+
}
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
function initFilterValues(that) {
|
34
|
+
if (!$.isEmptyObject(that.filterColumnsPartial)) {
|
35
|
+
var $header = getCurrentHeader(that);
|
36
|
+
|
37
|
+
$.each(that.columns, function (idx, column) {
|
38
|
+
var value = that.filterColumnsPartial[column.field];
|
39
|
+
|
40
|
+
if (column.filter) {
|
41
|
+
if (column.filter.setFilterValue) {
|
42
|
+
var $filter = $header.find('[data-field=' + column.field + '] .filter');
|
43
|
+
column.filter.setFilterValue($filter, column.field, value);
|
44
|
+
} else {
|
45
|
+
var $ele = $header.find('[data-filter-field=' + column.field + ']');
|
46
|
+
switch (column.filter.type) {
|
47
|
+
case 'input':
|
48
|
+
$ele.val(value);
|
49
|
+
case 'select':
|
50
|
+
$ele.val(value).trigger('change');
|
51
|
+
}
|
36
52
|
}
|
37
53
|
}
|
38
|
-
}
|
39
|
-
}
|
54
|
+
});
|
55
|
+
}
|
40
56
|
}
|
41
|
-
}
|
42
57
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
$.each(that.columns, function (i, column) {
|
50
|
-
isVisible = 'hidden';
|
51
|
-
html = null;
|
52
|
-
|
53
|
-
if (!column.visible) {
|
54
|
-
return;
|
55
|
-
}
|
58
|
+
function createFilter(that, header) {
|
59
|
+
var enableFilter = false,
|
60
|
+
isVisible,
|
61
|
+
html,
|
62
|
+
timeoutId = 0;
|
56
63
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
var filterClass = column.filter.class ? ' ' + column.filter.class : '';
|
61
|
-
html = $('<div style="margin: 0px 2px 2px 2px;" class="filter' + filterClass + '">');
|
64
|
+
$.each(that.columns, function (i, column) {
|
65
|
+
isVisible = 'hidden';
|
66
|
+
html = null;
|
62
67
|
|
63
|
-
if (column.
|
64
|
-
|
65
|
-
isVisible = 'visible'
|
68
|
+
if (!column.visible) {
|
69
|
+
return;
|
66
70
|
}
|
67
71
|
|
68
|
-
if (column.filter
|
69
|
-
html
|
72
|
+
if (!column.filter) {
|
73
|
+
html = $('<div class="no-filter"></div>');
|
70
74
|
} else {
|
71
|
-
var
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
75
|
+
var filterClass = column.filter.class ? ' ' + column.filter.class : '';
|
76
|
+
html = $('<div style="margin: 0px 2px 2px 2px;" class="filter' + filterClass + '">');
|
77
|
+
|
78
|
+
if (column.searchable) {
|
79
|
+
enableFilter = true;
|
80
|
+
isVisible = 'visible';
|
81
|
+
}
|
82
|
+
|
83
|
+
if (column.filter.template) {
|
84
|
+
html.append(column.filter.template(that, column, isVisible));
|
85
|
+
} else {
|
86
|
+
var $filter = $(that.options.filterTemplate[column.filter.type.toLowerCase()](that, column, isVisible));
|
87
|
+
|
88
|
+
switch (column.filter.type) {
|
89
|
+
case 'input':
|
90
|
+
var cpLock = true;
|
91
|
+
$filter.off('compositionstart').on('compositionstart', function (event) {
|
92
|
+
cpLock = false;
|
93
|
+
});
|
94
|
+
|
95
|
+
$filter.off('compositionend').on('compositionend', function (event) {
|
96
|
+
cpLock = true;
|
91
97
|
var $input = $(this);
|
92
98
|
clearTimeout(timeoutId);
|
93
99
|
timeoutId = setTimeout(function () {
|
94
100
|
that.onColumnSearch(event, column.field, $input.val());
|
95
101
|
}, that.options.searchTimeOut);
|
96
|
-
}
|
97
|
-
});
|
98
|
-
|
99
|
-
$filter.off('mouseup').on('mouseup', function (event) {
|
100
|
-
var $input = $(this),
|
101
|
-
oldValue = $input.val();
|
102
|
-
|
103
|
-
if (oldValue === "") {
|
104
|
-
return;
|
105
|
-
}
|
102
|
+
});
|
106
103
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
if (newValue === "") {
|
104
|
+
$filter.off('keyup').on('keyup', function (event) {
|
105
|
+
if (cpLock) {
|
106
|
+
var $input = $(this);
|
111
107
|
clearTimeout(timeoutId);
|
112
108
|
timeoutId = setTimeout(function () {
|
113
|
-
that.onColumnSearch(event, column.field,
|
109
|
+
that.onColumnSearch(event, column.field, $input.val());
|
114
110
|
}, that.options.searchTimeOut);
|
115
111
|
}
|
116
|
-
}
|
117
|
-
});
|
118
|
-
break;
|
119
|
-
case 'select':
|
120
|
-
$filter.on('select2:select', function (event) {
|
121
|
-
that.onColumnSearch(event, column.field, $(this).val());
|
122
|
-
});
|
123
|
-
|
124
|
-
$filter.on("select2:unselecting", function (event) {
|
125
|
-
var $select2 = $(this);
|
126
|
-
event.preventDefault();
|
127
|
-
$select2.val(null).trigger('change');
|
128
|
-
that.searchText = undefined;
|
129
|
-
that.onColumnSearch(event, column.field, $select2.val());
|
130
|
-
});
|
131
|
-
break;
|
132
|
-
}
|
112
|
+
});
|
133
113
|
|
134
|
-
|
135
|
-
|
136
|
-
|
114
|
+
$filter.off('mouseup').on('mouseup', function (event) {
|
115
|
+
var $input = $(this),
|
116
|
+
oldValue = $input.val();
|
137
117
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
118
|
+
if (oldValue === "") {
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
|
122
|
+
setTimeout(function () {
|
123
|
+
var newValue = $input.val();
|
124
|
+
|
125
|
+
if (newValue === "") {
|
126
|
+
clearTimeout(timeoutId);
|
127
|
+
timeoutId = setTimeout(function () {
|
128
|
+
that.onColumnSearch(event, column.field, newValue);
|
129
|
+
}, that.options.searchTimeOut);
|
130
|
+
}
|
131
|
+
}, 1);
|
132
|
+
});
|
133
|
+
break;
|
134
|
+
case 'select':
|
135
|
+
$filter.on('select2:select', function (event) {
|
136
|
+
that.onColumnSearch(event, column.field, $(this).val());
|
137
|
+
});
|
138
|
+
|
139
|
+
$filter.on("select2:unselecting", function (event) {
|
140
|
+
var $select2 = $(this);
|
141
|
+
event.preventDefault();
|
142
|
+
$select2.val(null).trigger('change');
|
143
|
+
that.searchText = undefined;
|
144
|
+
that.onColumnSearch(event, column.field, $select2.val());
|
145
|
+
});
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
|
149
|
+
html.append($filter);
|
150
|
+
}
|
143
151
|
}
|
152
|
+
|
153
|
+
$.each(header.children().children(), function (i, tr) {
|
154
|
+
tr = $(tr);
|
155
|
+
if (tr.data('field') === column.field) {
|
156
|
+
tr.find('.fht-cell').append(html);
|
157
|
+
return false;
|
158
|
+
}
|
159
|
+
});
|
144
160
|
});
|
145
|
-
});
|
146
161
|
|
147
|
-
|
148
|
-
|
162
|
+
if (!enableFilter) {
|
163
|
+
header.find('.filter').hide();
|
164
|
+
}
|
149
165
|
}
|
150
|
-
}
|
151
|
-
|
152
|
-
function initSelect2(that) {
|
153
|
-
var $header = getCurrentHeader(that);
|
154
|
-
|
155
|
-
$.each(that.columns, function (idx, column) {
|
156
|
-
if (column.filter && column.filter.type === 'select') {
|
157
|
-
var $selectEle = $header.find('select[data-filter-field="' + column.field + '"]');
|
158
166
|
|
159
|
-
|
160
|
-
|
161
|
-
placeholder: "",
|
162
|
-
allowClear: true,
|
163
|
-
data: column.filter.data,
|
164
|
-
dropdownParent: that.$el.closest(".bootstrap-table")
|
165
|
-
};
|
167
|
+
function initSelect2(that) {
|
168
|
+
var $header = getCurrentHeader(that);
|
166
169
|
|
167
|
-
|
170
|
+
$.each(that.columns, function (idx, column) {
|
171
|
+
if (column.filter && column.filter.type === 'select') {
|
172
|
+
var $selectEle = $header.find('select[data-filter-field="' + column.field + '"]');
|
173
|
+
|
174
|
+
if ($selectEle.length > 0 && !$selectEle.data().select2) {
|
175
|
+
var select2Opts = {
|
176
|
+
placeholder: "",
|
177
|
+
allowClear: true,
|
178
|
+
data: column.filter.data,
|
179
|
+
dropdownParent: that.$el.closest(".bootstrap-table")
|
180
|
+
};
|
181
|
+
|
182
|
+
$selectEle.select2(select2Opts);
|
183
|
+
}
|
168
184
|
}
|
169
|
-
}
|
170
|
-
}
|
171
|
-
}
|
185
|
+
});
|
186
|
+
}
|
172
187
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
188
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
189
|
+
filter: false,
|
190
|
+
filterValues: {},
|
191
|
+
filterTemplate: {
|
192
|
+
input: function input(instance, column, isVisible) {
|
193
|
+
return '<input type="text" class="form-control" data-filter-field="' + column.field + '" style="width: 100%; visibility:' + isVisible + '">';
|
194
|
+
},
|
195
|
+
select: function select(instance, column, isVisible) {
|
196
|
+
return '<select data-filter-field="' + column.field + '" style="width: 100%; visibility:' + isVisible + '"></select>';
|
197
|
+
}
|
179
198
|
},
|
180
|
-
|
181
|
-
return
|
199
|
+
onColumnSearch: function onColumnSearch(field, text) {
|
200
|
+
return false;
|
182
201
|
}
|
183
|
-
}
|
184
|
-
onColumnSearch: function (field, text) {
|
185
|
-
return false;
|
186
|
-
}
|
187
|
-
});
|
188
|
-
|
189
|
-
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
|
190
|
-
filter: undefined
|
191
|
-
});
|
192
|
-
|
193
|
-
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
194
|
-
'column-search.bs.table': 'onColumnSearch'
|
195
|
-
});
|
202
|
+
});
|
196
203
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
_initSearch = BootstrapTable.prototype.initSearch;
|
204
|
+
$.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
|
205
|
+
filter: undefined
|
206
|
+
});
|
201
207
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
var that = this;
|
208
|
+
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
209
|
+
'column-search.bs.table': 'onColumnSearch'
|
210
|
+
});
|
206
211
|
|
207
|
-
|
208
|
-
|
209
|
-
|
212
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
213
|
+
_init = BootstrapTable.prototype.init,
|
214
|
+
_initHeader = BootstrapTable.prototype.initHeader,
|
215
|
+
_initSearch = BootstrapTable.prototype.initSearch;
|
210
216
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
217
|
+
BootstrapTable.prototype.init = function () {
|
218
|
+
//Make sure that the filtercontrol option is set
|
219
|
+
if (this.options.filter) {
|
220
|
+
var that = this;
|
215
221
|
|
216
|
-
|
217
|
-
|
218
|
-
if (!that.options.height) {
|
219
|
-
return;
|
222
|
+
if (that.options.filterTemplate) {
|
223
|
+
that.options.filterTemplate = $.extend({}, $.fn.bootstrapTable.defaults.filterTemplate, that.options.filterTemplate);
|
220
224
|
}
|
221
225
|
|
222
|
-
|
223
|
-
|
224
|
-
|
226
|
+
if (!$.isEmptyObject(that.options.filterValues)) {
|
227
|
+
that.filterColumnsPartial = that.options.filterValues;
|
228
|
+
that.options.filterValues = {};
|
225
229
|
}
|
226
230
|
|
227
|
-
|
228
|
-
|
229
|
-
|
231
|
+
this.$el.on('reset-view.bs.table', function () {
|
232
|
+
//Create controls on $tableHeader if the height is set
|
233
|
+
if (!that.options.height) {
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
|
237
|
+
//Avoid recreate the controls
|
238
|
+
if (that.$tableHeader.find('select').length > 0 || that.$tableHeader.find('input').length > 0) {
|
239
|
+
return;
|
240
|
+
}
|
241
|
+
|
242
|
+
createFilter(that, that.$tableHeader);
|
243
|
+
}).on('post-header.bs.table', function () {
|
244
|
+
var timeoutId = 0;
|
230
245
|
|
231
|
-
|
232
|
-
|
233
|
-
|
246
|
+
initSelect2(that);
|
247
|
+
clearTimeout(timeoutId);
|
248
|
+
timeoutId = setTimeout(function () {
|
249
|
+
initFilterValues(that);
|
250
|
+
}, that.options.searchTimeOut - 1000);
|
251
|
+
}).on('column-switch.bs.table', function (field, checked) {
|
234
252
|
initFilterValues(that);
|
235
|
-
}
|
236
|
-
}
|
237
|
-
initFilterValues(that);
|
238
|
-
});
|
239
|
-
}
|
253
|
+
});
|
254
|
+
}
|
240
255
|
|
241
|
-
|
242
|
-
|
256
|
+
_init.apply(this, Array.prototype.slice.apply(arguments));
|
257
|
+
};
|
243
258
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
} else {
|
274
|
-
if (!($.inArray(field, that.header.fields) !== -1 &&
|
275
|
-
(typeof rowValue === 'string' || typeof rowValue === 'number') &&
|
276
|
-
(rowValue + '').toLowerCase().indexOf(filterValue) !== -1)) {
|
277
|
-
return false;
|
259
|
+
BootstrapTable.prototype.initHeader = function () {
|
260
|
+
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
|
261
|
+
if (this.options.filter) {
|
262
|
+
createFilter(this, this.$header);
|
263
|
+
}
|
264
|
+
};
|
265
|
+
|
266
|
+
BootstrapTable.prototype.initSearch = function () {
|
267
|
+
var that = this,
|
268
|
+
filterValues = that.filterColumnsPartial;
|
269
|
+
|
270
|
+
// Filter for client
|
271
|
+
if (that.options.sidePagination === 'client') {
|
272
|
+
this.data = $.grep(this.data, function (row, idx) {
|
273
|
+
for (var field in filterValues) {
|
274
|
+
var column = that.columns[that.fieldsColumnsIndex[field]],
|
275
|
+
filterValue = filterValues[field].toLowerCase(),
|
276
|
+
rowValue = row[field];
|
277
|
+
|
278
|
+
rowValue = $.fn.bootstrapTable.utils.calculateObjectValue(that.header, that.header.formatters[$.inArray(field, that.header.fields)], [rowValue, row, idx], rowValue);
|
279
|
+
|
280
|
+
if (column.filterStrictSearch) {
|
281
|
+
if (!($.inArray(field, that.header.fields) !== -1 && (typeof rowValue === 'string' || typeof rowValue === 'number') && rowValue.toString().toLowerCase() === filterValue.toString().toLowerCase())) {
|
282
|
+
return false;
|
283
|
+
}
|
284
|
+
} else {
|
285
|
+
if (!($.inArray(field, that.header.fields) !== -1 && (typeof rowValue === 'string' || typeof rowValue === 'number') && (rowValue + '').toLowerCase().indexOf(filterValue) !== -1)) {
|
286
|
+
return false;
|
287
|
+
}
|
278
288
|
}
|
279
289
|
}
|
280
|
-
}
|
281
|
-
|
282
|
-
return true;
|
283
|
-
});
|
284
|
-
}
|
285
|
-
|
286
|
-
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
287
|
-
};
|
288
290
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
}
|
291
|
+
return true;
|
292
|
+
});
|
293
|
+
}
|
293
294
|
|
294
|
-
|
295
|
-
|
296
|
-
} else {
|
297
|
-
delete this.filterColumnsPartial[field];
|
298
|
-
}
|
295
|
+
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
296
|
+
};
|
299
297
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
BootstrapTable.prototype.setSelect2Data = function (field, data) {
|
306
|
-
var that = this,
|
307
|
-
$header = getCurrentHeader(that),
|
308
|
-
$selectEle = $header.find('select[data-filter-field=\"' + field + '\"]');
|
309
|
-
$selectEle.empty();
|
310
|
-
$selectEle.select2({
|
311
|
-
data: data,
|
312
|
-
placeholder: "",
|
313
|
-
allowClear: true,
|
314
|
-
dropdownParent: that.$el.closest(".bootstrap-table")
|
315
|
-
});
|
298
|
+
BootstrapTable.prototype.onColumnSearch = function (event, field, value) {
|
299
|
+
if ($.isEmptyObject(this.filterColumnsPartial)) {
|
300
|
+
this.filterColumnsPartial = {};
|
301
|
+
}
|
316
302
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
303
|
+
if (value) {
|
304
|
+
this.filterColumnsPartial[field] = value;
|
305
|
+
} else {
|
306
|
+
delete this.filterColumnsPartial[field];
|
321
307
|
}
|
322
|
-
});
|
323
|
-
};
|
324
308
|
|
325
|
-
|
326
|
-
|
327
|
-
|
309
|
+
this.options.pageNumber = 1;
|
310
|
+
this.onSearch(event);
|
311
|
+
this.trigger('column-search', field, value);
|
312
|
+
};
|
313
|
+
|
314
|
+
BootstrapTable.prototype.setSelect2Data = function (field, data) {
|
315
|
+
var that = this,
|
316
|
+
$header = getCurrentHeader(that),
|
317
|
+
$selectEle = $header.find('select[data-filter-field=\"' + field + '\"]');
|
318
|
+
$selectEle.empty();
|
319
|
+
$selectEle.select2({
|
320
|
+
data: data,
|
321
|
+
placeholder: "",
|
322
|
+
allowClear: true,
|
323
|
+
dropdownParent: that.$el.closest(".bootstrap-table")
|
324
|
+
});
|
325
|
+
|
326
|
+
$.each(this.columns, function (idx, column) {
|
327
|
+
if (column.field === field) {
|
328
|
+
column.filter.data = data;
|
329
|
+
return false;
|
330
|
+
}
|
331
|
+
});
|
332
|
+
};
|
328
333
|
|
329
|
-
|
330
|
-
|
334
|
+
BootstrapTable.prototype.setFilterValues = function (values) {
|
335
|
+
this.filterColumnsPartial = values;
|
336
|
+
};
|
331
337
|
|
332
|
-
|
338
|
+
$.fn.bootstrapTable.methods.push('setSelect2Data');
|
339
|
+
$.fn.bootstrapTable.methods.push('setFilterValues');
|
340
|
+
}(jQuery);
|
341
|
+
});
|