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,744 +1,911 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
'use strict';
|
10
|
-
|
11
|
-
var sprintf = $.fn.bootstrapTable.utils.sprintf,
|
12
|
-
objectKeys = $.fn.bootstrapTable.utils.objectKeys;
|
13
|
-
|
14
|
-
var getOptionsFromSelectControl = function (selectControl) {
|
15
|
-
return selectControl.get(selectControl.length - 1).options;
|
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: {}
|
16
9
|
};
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
factory();
|
11
|
+
global.bootstrapTableFilterControl = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function () {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
function _classCallCheck(instance, Constructor) {
|
17
|
+
if (!(instance instanceof Constructor)) {
|
18
|
+
throw new TypeError("Cannot call a class as a function");
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
var _createClass = function () {
|
23
|
+
function defineProperties(target, props) {
|
24
|
+
for (var i = 0; i < props.length; i++) {
|
25
|
+
var descriptor = props[i];
|
26
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
27
|
+
descriptor.configurable = true;
|
28
|
+
if ("value" in descriptor) descriptor.writable = true;
|
29
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
return function (Constructor, protoProps, staticProps) {
|
34
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
35
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
36
|
+
return Constructor;
|
37
|
+
};
|
38
|
+
}();
|
39
|
+
|
40
|
+
function _possibleConstructorReturn(self, call) {
|
41
|
+
if (!self) {
|
42
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
43
|
+
}
|
44
|
+
|
45
|
+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
46
|
+
}
|
47
|
+
|
48
|
+
var _get = function get(object, property, receiver) {
|
49
|
+
if (object === null) object = Function.prototype;
|
50
|
+
var desc = Object.getOwnPropertyDescriptor(object, property);
|
51
|
+
|
52
|
+
if (desc === undefined) {
|
53
|
+
var parent = Object.getPrototypeOf(object);
|
54
|
+
|
55
|
+
if (parent === null) {
|
56
|
+
return undefined;
|
57
|
+
} else {
|
58
|
+
return get(parent, property, receiver);
|
59
|
+
}
|
60
|
+
} else if ("value" in desc) {
|
61
|
+
return desc.value;
|
62
|
+
} else {
|
63
|
+
var getter = desc.get;
|
64
|
+
|
65
|
+
if (getter === undefined) {
|
66
|
+
return undefined;
|
67
|
+
}
|
68
|
+
|
69
|
+
return getter.call(receiver);
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
function _inherits(subClass, superClass) {
|
74
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
75
|
+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
76
|
+
}
|
77
|
+
|
78
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
79
|
+
constructor: {
|
80
|
+
value: subClass,
|
81
|
+
enumerable: false,
|
82
|
+
writable: true,
|
83
|
+
configurable: true
|
84
|
+
}
|
85
|
+
});
|
86
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
87
|
+
}
|
88
|
+
|
89
|
+
/**
|
90
|
+
* @author: Dennis Hernández
|
91
|
+
* @webSite: http://djhvscf.github.io/Blog
|
92
|
+
* @version: v2.2.0
|
93
|
+
*/
|
94
|
+
|
95
|
+
(function ($) {
|
96
|
+
var Utils = $.fn.bootstrapTable.utils;
|
97
|
+
var UtilsFilterControl = {
|
98
|
+
getOptionsFromSelectControl: function getOptionsFromSelectControl(selectControl) {
|
99
|
+
return selectControl.get(selectControl.length - 1).options;
|
100
|
+
},
|
101
|
+
hideUnusedSelectOptions: function hideUnusedSelectOptions(selectControl, uniqueValues) {
|
102
|
+
var options = UtilsFilterControl.getOptionsFromSelectControl(selectControl);
|
20
103
|
|
21
104
|
for (var i = 0; i < options.length; i++) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
105
|
+
if (options[i].value !== '') {
|
106
|
+
if (!uniqueValues.hasOwnProperty(options[i].value)) {
|
107
|
+
selectControl.find(Utils.sprintf('option[value=\'%s\']', options[i].value)).hide();
|
108
|
+
} else {
|
109
|
+
selectControl.find(Utils.sprintf('option[value=\'%s\']', options[i].value)).show();
|
28
110
|
}
|
111
|
+
}
|
29
112
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
selectControl.append($("<option></option>")
|
37
|
-
.attr("value", value)
|
38
|
-
.text($('<div />').html(text).text()));
|
113
|
+
},
|
114
|
+
addOptionToSelectControl: function addOptionToSelectControl(selectControl, _value, text) {
|
115
|
+
var value = $.trim(_value);
|
116
|
+
var $selectControl = $(selectControl.get(selectControl.length - 1));
|
117
|
+
if (!UtilsFilterControl.existOptionInSelectControl(selectControl, value)) {
|
118
|
+
$selectControl.append($('<option></option>').attr('value', value).text($('<div />').html(text).text()));
|
39
119
|
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
});
|
56
|
-
|
57
|
-
selectControl.find('option:gt(0)').remove();
|
58
|
-
selectControl.append($opts);
|
59
|
-
};
|
120
|
+
},
|
121
|
+
sortSelectControl: function sortSelectControl(selectControl) {
|
122
|
+
var $selectControl = $(selectControl.get(selectControl.length - 1));
|
123
|
+
var $opts = $selectControl.find('option:gt(0)');
|
124
|
+
|
125
|
+
$opts.sort(function (a, b) {
|
126
|
+
var aa = $(a).text().toLowerCase();
|
127
|
+
var bb = $(b).text().toLowerCase();
|
128
|
+
if ($.isNumeric(a) && $.isNumeric(b)) {
|
129
|
+
// Convert numerical values from string to float.
|
130
|
+
aa = parseFloat(aa);
|
131
|
+
bb = parseFloat(bb);
|
132
|
+
}
|
133
|
+
return aa > bb ? 1 : aa < bb ? -1 : 0;
|
134
|
+
});
|
60
135
|
|
61
|
-
|
62
|
-
|
136
|
+
$selectControl.find('option:gt(0)').remove();
|
137
|
+
$selectControl.append($opts);
|
138
|
+
},
|
139
|
+
existOptionInSelectControl: function existOptionInSelectControl(selectControl, value) {
|
140
|
+
var options = UtilsFilterControl.getOptionsFromSelectControl(selectControl);
|
63
141
|
for (var i = 0; i < options.length; i++) {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
142
|
+
if (options[i].value === value.toString()) {
|
143
|
+
// The value is not valid to add
|
144
|
+
return true;
|
145
|
+
}
|
68
146
|
}
|
69
147
|
|
70
|
-
//If we get here, the value is valid to add
|
148
|
+
// If we get here, the value is valid to add
|
71
149
|
return false;
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
var header =
|
80
|
-
|
81
|
-
|
150
|
+
},
|
151
|
+
fixHeaderCSS: function fixHeaderCSS(_ref) {
|
152
|
+
var $tableHeader = _ref.$tableHeader;
|
153
|
+
|
154
|
+
$tableHeader.css('height', '77px');
|
155
|
+
},
|
156
|
+
getCurrentHeader: function getCurrentHeader(_ref2) {
|
157
|
+
var $header = _ref2.$header,
|
158
|
+
options = _ref2.options,
|
159
|
+
$tableHeader = _ref2.$tableHeader;
|
160
|
+
|
161
|
+
var header = $header;
|
162
|
+
if (options.height) {
|
163
|
+
header = $tableHeader;
|
82
164
|
}
|
83
165
|
|
84
166
|
return header;
|
85
|
-
|
167
|
+
},
|
168
|
+
getCurrentSearchControls: function getCurrentSearchControls(_ref3) {
|
169
|
+
var options = _ref3.options;
|
86
170
|
|
87
|
-
var getCurrentSearchControls = function (that) {
|
88
171
|
var searchControls = 'select, input';
|
89
|
-
if (
|
90
|
-
|
172
|
+
if (options.height) {
|
173
|
+
searchControls = 'table select, table input';
|
91
174
|
}
|
92
175
|
|
93
176
|
return searchControls;
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
pos = Sel.text.length - SelLength;
|
108
|
-
}
|
109
|
-
return pos;
|
110
|
-
} else {
|
111
|
-
return -1;
|
177
|
+
},
|
178
|
+
getCursorPosition: function getCursorPosition(el) {
|
179
|
+
if (Utils.isIEBrowser()) {
|
180
|
+
if ($(el).is('input[type=text]')) {
|
181
|
+
var pos = 0;
|
182
|
+
if ('selectionStart' in el) {
|
183
|
+
pos = el.selectionStart;
|
184
|
+
} else if ('selection' in document) {
|
185
|
+
el.focus();
|
186
|
+
var Sel = document.selection.createRange();
|
187
|
+
var SelLength = document.selection.createRange().text.length;
|
188
|
+
Sel.moveStart('character', -el.value.length);
|
189
|
+
pos = Sel.text.length - SelLength;
|
112
190
|
}
|
113
|
-
|
114
|
-
|
191
|
+
return pos;
|
192
|
+
}
|
193
|
+
return -1;
|
115
194
|
}
|
116
|
-
|
117
|
-
|
118
|
-
|
195
|
+
return -1;
|
196
|
+
},
|
197
|
+
setCursorPosition: function setCursorPosition(el) {
|
119
198
|
$(el).val(el.value);
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
var
|
124
|
-
searchControls = getCurrentSearchControls(that);
|
199
|
+
},
|
200
|
+
copyValues: function copyValues(that) {
|
201
|
+
var header = UtilsFilterControl.getCurrentHeader(that);
|
202
|
+
var searchControls = UtilsFilterControl.getCurrentSearchControls(that);
|
125
203
|
|
126
204
|
that.options.valuesFilterControl = [];
|
127
205
|
|
128
206
|
header.find(searchControls).each(function () {
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
207
|
+
that.options.valuesFilterControl.push({
|
208
|
+
field: $(this).closest('[data-field]').data('field'),
|
209
|
+
value: $(this).val(),
|
210
|
+
position: UtilsFilterControl.getCursorPosition($(this).get(0)),
|
211
|
+
hasFocus: $(this).is(':focus')
|
212
|
+
});
|
135
213
|
});
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
var
|
140
|
-
|
141
|
-
|
142
|
-
searchControls = getCurrentSearchControls(that);
|
214
|
+
},
|
215
|
+
setValues: function setValues(that) {
|
216
|
+
var field = null;
|
217
|
+
var result = [];
|
218
|
+
var header = UtilsFilterControl.getCurrentHeader(that);
|
219
|
+
var searchControls = UtilsFilterControl.getCurrentSearchControls(that);
|
143
220
|
|
144
221
|
if (that.options.valuesFilterControl.length > 0) {
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
if (result.length > 0) {
|
152
|
-
$(this).val(result[0].value);
|
153
|
-
setCursorPosition($(this).get(0), result[0].position);
|
154
|
-
}
|
222
|
+
// Callback to apply after settings fields values
|
223
|
+
var fieldToFocusCallback = null;
|
224
|
+
header.find(searchControls).each(function (index, ele) {
|
225
|
+
field = $(this).closest('[data-field]').data('field');
|
226
|
+
result = that.options.valuesFilterControl.filter(function (valueObj) {
|
227
|
+
return valueObj.field === field;
|
155
228
|
});
|
156
|
-
}
|
157
|
-
};
|
158
|
-
|
159
|
-
var collectBootstrapCookies = function cookiesRegex() {
|
160
|
-
var cookies = [],
|
161
|
-
foundCookies = document.cookie.match(/(?:bs.table.)(\w*)/g);
|
162
229
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
230
|
+
if (result.length > 0) {
|
231
|
+
$(this).val(result[0].value);
|
232
|
+
if (result[0].hasFocus) {
|
233
|
+
// set callback if the field had the focus.
|
234
|
+
fieldToFocusCallback = function (fieldToFocus, carretPosition) {
|
235
|
+
// Closure here to capture the field and cursor position
|
236
|
+
var closedCallback = function closedCallback() {
|
237
|
+
fieldToFocus.focus();
|
238
|
+
UtilsFilterControl.setCursorPosition(fieldToFocus, carretPosition);
|
239
|
+
};
|
240
|
+
return closedCallback;
|
241
|
+
}($(this).get(0), result[0].position);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
});
|
168
245
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
return cookies;
|
246
|
+
// Callback call.
|
247
|
+
if (fieldToFocusCallback !== null) {
|
248
|
+
fieldToFocusCallback();
|
249
|
+
}
|
174
250
|
}
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
var
|
179
|
-
itemsPerPage = that.pageTo < that.options.data.length ? that.options.data.length : that.pageTo,
|
251
|
+
},
|
252
|
+
collectBootstrapCookies: function collectBootstrapCookies() {
|
253
|
+
var cookies = [];
|
254
|
+
var foundCookies = document.cookie.match(/(?:bs.table.)(\w*)/g);
|
180
255
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
},
|
188
|
-
|
189
|
-
hasSelectControlElement = function (selectControl) {
|
190
|
-
return selectControl && selectControl.length > 0;
|
191
|
-
};
|
256
|
+
if (foundCookies) {
|
257
|
+
$.each(foundCookies, function (i, _cookie) {
|
258
|
+
var cookie = _cookie;
|
259
|
+
if (/./.test(cookie)) {
|
260
|
+
cookie = cookie.split('.').pop();
|
261
|
+
}
|
192
262
|
|
193
|
-
|
194
|
-
|
195
|
-
|
263
|
+
if ($.inArray(cookie, cookies) === -1) {
|
264
|
+
cookies.push(cookie);
|
265
|
+
}
|
266
|
+
});
|
267
|
+
return cookies;
|
268
|
+
}
|
269
|
+
},
|
270
|
+
escapeID: function escapeID(id) {
|
271
|
+
return String(id).replace(/(:|\.|\[|\]|,)/g, '\\$1');
|
272
|
+
},
|
273
|
+
isColumnSearchableViaSelect: function isColumnSearchableViaSelect(_ref4) {
|
274
|
+
var filterControl = _ref4.filterControl,
|
275
|
+
searchable = _ref4.searchable;
|
276
|
+
|
277
|
+
return filterControl && filterControl.toLowerCase() === 'select' && searchable;
|
278
|
+
},
|
279
|
+
isFilterDataNotGiven: function isFilterDataNotGiven(_ref5) {
|
280
|
+
var filterData = _ref5.filterData;
|
281
|
+
|
282
|
+
return filterData === undefined || filterData.toLowerCase() === 'column';
|
283
|
+
},
|
284
|
+
hasSelectControlElement: function hasSelectControlElement(selectControl) {
|
285
|
+
return selectControl && selectControl.length > 0;
|
286
|
+
},
|
287
|
+
initFilterSelectControls: function initFilterSelectControls(that) {
|
288
|
+
var data = that.data;
|
289
|
+
var itemsPerPage = that.pageTo < that.options.data.length ? that.options.data.length : that.pageTo;
|
290
|
+
var z = that.options.pagination ? that.options.sidePagination === 'server' ? that.pageTo : that.options.totalRows : that.pageTo;
|
196
291
|
|
197
292
|
$.each(that.header.fields, function (j, field) {
|
198
|
-
|
199
|
-
|
293
|
+
var column = that.columns[that.fieldsColumnsIndex[field]];
|
294
|
+
var selectControl = $('.bootstrap-table-filter-control-' + UtilsFilterControl.escapeID(column.field));
|
200
295
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
296
|
+
if (UtilsFilterControl.isColumnSearchableViaSelect(column) && UtilsFilterControl.isFilterDataNotGiven(column) && UtilsFilterControl.hasSelectControlElement(selectControl)) {
|
297
|
+
if (selectControl.get(selectControl.length - 1).options.length === 0) {
|
298
|
+
// Added the default option
|
299
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, '', column.filterControlPlaceholder);
|
300
|
+
}
|
206
301
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
302
|
+
var uniqueValues = {};
|
303
|
+
for (var i = 0; i < z; i++) {
|
304
|
+
// Added a new value
|
305
|
+
var fieldValue = data[i][field];
|
306
|
+
var formattedValue = Utils.calculateObjectValue(that.header, that.header.formatters[j], [fieldValue, data[i], i], fieldValue);
|
212
307
|
|
213
|
-
|
214
|
-
|
308
|
+
uniqueValues[formattedValue] = fieldValue;
|
309
|
+
}
|
215
310
|
|
216
|
-
|
217
|
-
|
218
|
-
|
311
|
+
// eslint-disable-next-line guard-for-in
|
312
|
+
for (var key in uniqueValues) {
|
313
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, uniqueValues[key], key);
|
314
|
+
}
|
219
315
|
|
220
|
-
|
316
|
+
UtilsFilterControl.sortSelectControl(selectControl);
|
221
317
|
|
222
|
-
|
223
|
-
|
224
|
-
}
|
318
|
+
if (that.options.hideUnusedSelectOptions) {
|
319
|
+
UtilsFilterControl.hideUnusedSelectOptions(selectControl, uniqueValues);
|
225
320
|
}
|
321
|
+
}
|
226
322
|
});
|
227
|
-
};
|
228
|
-
|
229
|
-
var escapeID = function(id) {
|
230
|
-
return String(id).replace( /(:|\.|\[|\]|,)/g, "\\$1" );
|
231
|
-
};
|
232
323
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
324
|
+
that.trigger('created-controls');
|
325
|
+
},
|
326
|
+
getFilterDataMethod: function getFilterDataMethod(objFilterDataMethod, searchTerm) {
|
327
|
+
var keys = Object.keys(objFilterDataMethod);
|
328
|
+
for (var i = 0; i < keys.length; i++) {
|
329
|
+
if (keys[i] === searchTerm) {
|
330
|
+
return objFilterDataMethod[searchTerm];
|
331
|
+
}
|
332
|
+
}
|
333
|
+
return null;
|
334
|
+
},
|
335
|
+
createControls: function createControls(that, header) {
|
336
|
+
var addedFilterControl = false;
|
337
|
+
var isVisible = void 0;
|
338
|
+
var html = void 0;
|
237
339
|
|
238
340
|
$.each(that.columns, function (i, column) {
|
239
|
-
|
240
|
-
|
341
|
+
isVisible = 'hidden';
|
342
|
+
html = [];
|
241
343
|
|
242
|
-
|
243
|
-
|
344
|
+
if (!column.visible) {
|
345
|
+
return;
|
346
|
+
}
|
347
|
+
|
348
|
+
if (!column.filterControl) {
|
349
|
+
html.push('<div class="no-filter-control"></div>');
|
350
|
+
} else {
|
351
|
+
html.push('<div class="filter-control">');
|
352
|
+
|
353
|
+
var nameControl = column.filterControl.toLowerCase();
|
354
|
+
if (column.searchable && that.options.filterTemplate[nameControl]) {
|
355
|
+
addedFilterControl = true;
|
356
|
+
isVisible = 'visible';
|
357
|
+
html.push(that.options.filterTemplate[nameControl](that, column.field, isVisible, column.filterControlPlaceholder ? column.filterControlPlaceholder : '', 'filter-control-' + i));
|
244
358
|
}
|
359
|
+
}
|
245
360
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
var nameControl = column.filterControl.toLowerCase();
|
252
|
-
if (column.searchable && that.options.filterTemplate[nameControl]) {
|
253
|
-
addedFilterControl = true;
|
254
|
-
isVisible = 'visible';
|
255
|
-
html.push(that.options.filterTemplate[nameControl](that, column.field, isVisible, column.filterControlPlaceholder ? column.filterControlPlaceholder : "", "filter-control-" + i));
|
256
|
-
}
|
361
|
+
$.each(header.children().children(), function (i, tr) {
|
362
|
+
var $tr = $(tr);
|
363
|
+
if ($tr.data('field') === column.field) {
|
364
|
+
$tr.find('.fht-cell').append(html.join(''));
|
365
|
+
return false;
|
257
366
|
}
|
367
|
+
});
|
258
368
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
});
|
369
|
+
if (column.filterData !== undefined && column.filterData.toLowerCase() !== 'column') {
|
370
|
+
var filterDataType = UtilsFilterControl.getFilterDataMethod(
|
371
|
+
/* eslint-disable no-use-before-define */
|
372
|
+
filterDataMethods, column.filterData.substring(0, column.filterData.indexOf(':')));
|
373
|
+
var filterDataSource = void 0;
|
374
|
+
var selectControl = void 0;
|
266
375
|
|
267
|
-
if (
|
268
|
-
|
269
|
-
|
376
|
+
if (filterDataType !== null) {
|
377
|
+
filterDataSource = column.filterData.substring(column.filterData.indexOf(':') + 1, column.filterData.length);
|
378
|
+
selectControl = $('.bootstrap-table-filter-control-' + UtilsFilterControl.escapeID(column.field));
|
270
379
|
|
271
|
-
|
272
|
-
|
273
|
-
|
380
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, '', column.filterControlPlaceholder);
|
381
|
+
filterDataType(filterDataSource, selectControl);
|
382
|
+
} else {
|
383
|
+
throw new SyntaxError('Error. You should use any of these allowed filter data methods: var, json, url.' + ' Use like this: var: {key: "value"}');
|
384
|
+
}
|
274
385
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
386
|
+
var variableValues = void 0;
|
387
|
+
var key = void 0;
|
388
|
+
// eslint-disable-next-line default-case
|
389
|
+
switch (filterDataType) {
|
390
|
+
case 'url':
|
391
|
+
$.ajax({
|
392
|
+
url: filterDataSource,
|
393
|
+
dataType: 'json',
|
394
|
+
success: function success(data) {
|
395
|
+
// eslint-disable-next-line guard-for-in
|
396
|
+
for (var _key in data) {
|
397
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, _key, data[_key]);
|
398
|
+
}
|
399
|
+
UtilsFilterControl.sortSelectControl(selectControl);
|
400
|
+
}
|
401
|
+
});
|
402
|
+
break;
|
403
|
+
case 'var':
|
404
|
+
variableValues = window[filterDataSource];
|
405
|
+
// eslint-disable-next-line guard-for-in
|
406
|
+
for (key in variableValues) {
|
407
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key]);
|
279
408
|
}
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
success: function (data) {
|
288
|
-
for (var key in data) {
|
289
|
-
addOptionToSelectControl(selectControl, key, data[key]);
|
290
|
-
}
|
291
|
-
sortSelectControl(selectControl);
|
292
|
-
}
|
293
|
-
});
|
294
|
-
break;
|
295
|
-
case 'var':
|
296
|
-
variableValues = window[filterDataSource];
|
297
|
-
for (key in variableValues) {
|
298
|
-
addOptionToSelectControl(selectControl, key, variableValues[key]);
|
299
|
-
}
|
300
|
-
sortSelectControl(selectControl);
|
301
|
-
break;
|
302
|
-
case 'jso':
|
303
|
-
variableValues = JSON.parse(filterDataSource);
|
304
|
-
for (key in variableValues) {
|
305
|
-
addOptionToSelectControl(selectControl, key, variableValues[key]);
|
306
|
-
}
|
307
|
-
sortSelectControl(selectControl);
|
308
|
-
break;
|
409
|
+
UtilsFilterControl.sortSelectControl(selectControl);
|
410
|
+
break;
|
411
|
+
case 'jso':
|
412
|
+
variableValues = JSON.parse(filterDataSource);
|
413
|
+
// eslint-disable-next-line guard-for-in
|
414
|
+
for (key in variableValues) {
|
415
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key]);
|
309
416
|
}
|
417
|
+
UtilsFilterControl.sortSelectControl(selectControl);
|
418
|
+
break;
|
310
419
|
}
|
420
|
+
}
|
311
421
|
});
|
312
422
|
|
313
423
|
if (addedFilterControl) {
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
}
|
424
|
+
header.off('keyup', 'input').on('keyup', 'input', function (event, obj) {
|
425
|
+
// Simulate enter key action from clear button
|
426
|
+
event.keyCode = obj ? obj.keyCode : event.keyCode;
|
318
427
|
|
319
|
-
|
320
|
-
|
321
|
-
|
428
|
+
if (that.options.searchOnEnterKey && event.keyCode !== 13) {
|
429
|
+
return;
|
430
|
+
}
|
322
431
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
}, that.options.searchTimeOut);
|
327
|
-
});
|
432
|
+
if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
|
433
|
+
return;
|
434
|
+
}
|
328
435
|
|
329
|
-
|
330
|
-
if (that.options.searchOnEnterKey && event.keyCode !== 13) {
|
331
|
-
return;
|
332
|
-
}
|
436
|
+
var $currentTarget = $(event.currentTarget);
|
333
437
|
|
334
|
-
|
335
|
-
|
336
|
-
|
438
|
+
if ($currentTarget.is(':checkbox') || $currentTarget.is(':radio')) {
|
439
|
+
return;
|
440
|
+
}
|
337
441
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
442
|
+
clearTimeout(event.currentTarget.timeoutId || 0);
|
443
|
+
event.currentTarget.timeoutId = setTimeout(function () {
|
444
|
+
that.onColumnSearch(event);
|
445
|
+
}, that.options.searchTimeOut);
|
446
|
+
});
|
343
447
|
|
344
|
-
|
345
|
-
|
346
|
-
|
448
|
+
header.off('change', 'select').on('change', 'select', function (event) {
|
449
|
+
if (that.options.searchOnEnterKey && event.keyCode !== 13) {
|
450
|
+
return;
|
451
|
+
}
|
347
452
|
|
348
|
-
|
349
|
-
|
350
|
-
|
453
|
+
if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
|
454
|
+
return;
|
455
|
+
}
|
351
456
|
|
352
|
-
|
353
|
-
|
457
|
+
clearTimeout(event.currentTarget.timeoutId || 0);
|
458
|
+
event.currentTarget.timeoutId = setTimeout(function () {
|
459
|
+
that.onColumnSearch(event);
|
460
|
+
}, that.options.searchTimeOut);
|
461
|
+
});
|
354
462
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
that.onColumnSearch(event);
|
359
|
-
}, that.options.searchTimeOut);
|
360
|
-
}
|
361
|
-
}, 1);
|
362
|
-
});
|
463
|
+
header.off('mouseup', 'input').on('mouseup', 'input', function (event) {
|
464
|
+
var $input = $(this);
|
465
|
+
var oldValue = $input.val();
|
363
466
|
|
364
|
-
if (
|
365
|
-
|
366
|
-
if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'datepicker') {
|
367
|
-
header.find('.date-filter-control.bootstrap-table-filter-control-' + column.field).datepicker(column.filterDatepickerOptions)
|
368
|
-
.on('changeDate', function (e) {
|
369
|
-
$(sprintf("#%s", e.currentTarget.id)).val(e.currentTarget.value);
|
370
|
-
//Fired the keyup event
|
371
|
-
$(e.currentTarget).keyup();
|
372
|
-
});
|
373
|
-
}
|
374
|
-
});
|
467
|
+
if (oldValue === '') {
|
468
|
+
return;
|
375
469
|
}
|
470
|
+
|
471
|
+
setTimeout(function () {
|
472
|
+
var newValue = $input.val();
|
473
|
+
|
474
|
+
if (newValue === '') {
|
475
|
+
clearTimeout(event.currentTarget.timeoutId || 0);
|
476
|
+
event.currentTarget.timeoutId = setTimeout(function () {
|
477
|
+
that.onColumnSearch(event);
|
478
|
+
}, that.options.searchTimeOut);
|
479
|
+
}
|
480
|
+
}, 1);
|
481
|
+
});
|
482
|
+
|
483
|
+
if (header.find('.date-filter-control').length > 0) {
|
484
|
+
$.each(that.columns, function (i, _ref6) {
|
485
|
+
var filterControl = _ref6.filterControl,
|
486
|
+
field = _ref6.field,
|
487
|
+
filterDatepickerOptions = _ref6.filterDatepickerOptions;
|
488
|
+
|
489
|
+
if (filterControl !== undefined && filterControl.toLowerCase() === 'datepicker') {
|
490
|
+
header.find('.date-filter-control.bootstrap-table-filter-control-' + field).datepicker(filterDatepickerOptions).on('changeDate', function (_ref7) {
|
491
|
+
var currentTarget = _ref7.currentTarget;
|
492
|
+
|
493
|
+
$(currentTarget).val(currentTarget.value);
|
494
|
+
// Fired the keyup event
|
495
|
+
$(currentTarget).keyup();
|
496
|
+
});
|
497
|
+
}
|
498
|
+
});
|
499
|
+
}
|
376
500
|
} else {
|
377
|
-
|
501
|
+
header.find('.filterControl').hide();
|
378
502
|
}
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
alignment = alignment === undefined ? 'left' : alignment.toLowerCase();
|
503
|
+
},
|
504
|
+
getDirectionOfSelectOptions: function getDirectionOfSelectOptions(_alignment) {
|
505
|
+
var alignment = _alignment === undefined ? 'left' : _alignment.toLowerCase();
|
383
506
|
|
384
507
|
switch (alignment) {
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
508
|
+
case 'left':
|
509
|
+
return 'ltr';
|
510
|
+
case 'right':
|
511
|
+
return 'rtl';
|
512
|
+
case 'auto':
|
513
|
+
return 'auto';
|
514
|
+
default:
|
515
|
+
return 'ltr';
|
393
516
|
}
|
517
|
+
}
|
394
518
|
};
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
}
|
413
|
-
sortSelectControl(selectControl);
|
414
|
-
}
|
415
|
-
});
|
416
|
-
},
|
417
|
-
'json':function (filterDataSource, selectControl) {
|
418
|
-
var variableValues = JSON.parse(filterDataSource);
|
419
|
-
for (var key in variableValues) {
|
420
|
-
addOptionToSelectControl(selectControl, key, variableValues[key]);
|
421
|
-
}
|
422
|
-
sortSelectControl(selectControl);
|
423
|
-
}
|
424
|
-
};
|
425
|
-
|
426
|
-
var getFilterDataMethod = function (objFilterDataMethod, searchTerm) {
|
427
|
-
var keys = Object.keys(objFilterDataMethod);
|
428
|
-
for (var i = 0; i < keys.length; i++) {
|
429
|
-
if (keys[i] === searchTerm) {
|
430
|
-
return objFilterDataMethod[searchTerm];
|
519
|
+
var filterDataMethods = {
|
520
|
+
var: function _var(filterDataSource, selectControl) {
|
521
|
+
var variableValues = window[filterDataSource];
|
522
|
+
// eslint-disable-next-line guard-for-in
|
523
|
+
for (var key in variableValues) {
|
524
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key]);
|
525
|
+
}
|
526
|
+
UtilsFilterControl.sortSelectControl(selectControl);
|
527
|
+
},
|
528
|
+
url: function url(filterDataSource, selectControl) {
|
529
|
+
$.ajax({
|
530
|
+
url: filterDataSource,
|
531
|
+
dataType: 'json',
|
532
|
+
success: function success(data) {
|
533
|
+
// eslint-disable-next-line guard-for-in
|
534
|
+
for (var key in data) {
|
535
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, key, data[key]);
|
431
536
|
}
|
537
|
+
UtilsFilterControl.sortSelectControl(selectControl);
|
538
|
+
}
|
539
|
+
});
|
540
|
+
},
|
541
|
+
json: function json(filterDataSource, selectControl) {
|
542
|
+
var variableValues = JSON.parse(filterDataSource);
|
543
|
+
// eslint-disable-next-line guard-for-in
|
544
|
+
for (var key in variableValues) {
|
545
|
+
UtilsFilterControl.addOptionToSelectControl(selectControl, key, variableValues[key]);
|
432
546
|
}
|
433
|
-
|
547
|
+
UtilsFilterControl.sortSelectControl(selectControl);
|
548
|
+
}
|
434
549
|
};
|
435
550
|
|
551
|
+
var bootstrap = {
|
552
|
+
3: {
|
553
|
+
icons: {
|
554
|
+
clear: 'glyphicon-trash icon-clear'
|
555
|
+
}
|
556
|
+
},
|
557
|
+
4: {
|
558
|
+
icons: {
|
559
|
+
clear: 'fa-trash icon-clear'
|
560
|
+
}
|
561
|
+
}
|
562
|
+
}[Utils.bootstrapVersion];
|
563
|
+
|
436
564
|
$.extend($.fn.bootstrapTable.defaults, {
|
437
|
-
|
438
|
-
|
439
|
-
|
565
|
+
filterControl: false,
|
566
|
+
onColumnSearch: function onColumnSearch(field, text) {
|
567
|
+
return false;
|
568
|
+
},
|
569
|
+
onCreatedControls: function onCreatedControls() {
|
570
|
+
return true;
|
571
|
+
},
|
572
|
+
|
573
|
+
filterShowClear: false,
|
574
|
+
alignmentSelectControlOptions: undefined,
|
575
|
+
filterTemplate: {
|
576
|
+
input: function input(that, field, isVisible, placeholder) {
|
577
|
+
return Utils.sprintf('<input type="text" class="form-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" placeholder="%s">', field, isVisible, placeholder);
|
440
578
|
},
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
return sprintf('<input type="text" class="form-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" placeholder="%s">', field, isVisible, placeholder);
|
446
|
-
},
|
447
|
-
select: function (that, field, isVisible) {
|
448
|
-
return sprintf('<select class="form-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" dir="%s"></select>',
|
449
|
-
field, isVisible, getDirectionOfSelectOptions(that.options.alignmentSelectControlOptions));
|
450
|
-
},
|
451
|
-
datepicker: function (that, field, isVisible) {
|
452
|
-
return sprintf('<input type="text" class="form-control date-filter-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s">', field, isVisible);
|
453
|
-
}
|
579
|
+
select: function select(_ref8, field, isVisible) {
|
580
|
+
var options = _ref8.options;
|
581
|
+
|
582
|
+
return Utils.sprintf('<select class="form-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s" dir="%s"></select>', field, isVisible, UtilsFilterControl.getDirectionOfSelectOptions(options.alignmentSelectControlOptions));
|
454
583
|
},
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
584
|
+
datepicker: function datepicker(that, field, isVisible) {
|
585
|
+
return Utils.sprintf('<input type="text" class="form-control date-filter-control bootstrap-table-filter-control-%s" style="width: 100%; visibility: %s">', field, isVisible);
|
586
|
+
}
|
587
|
+
},
|
588
|
+
disableControlWhenSearch: false,
|
589
|
+
searchOnEnterKey: false,
|
590
|
+
// internal variables
|
591
|
+
valuesFilterControl: []
|
459
592
|
});
|
460
593
|
|
461
594
|
$.extend($.fn.bootstrapTable.columnDefaults, {
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
595
|
+
filterControl: undefined,
|
596
|
+
filterData: undefined,
|
597
|
+
filterDatepickerOptions: undefined,
|
598
|
+
filterStrictSearch: false,
|
599
|
+
filterStartsWithSearch: false,
|
600
|
+
filterControlPlaceholder: ''
|
468
601
|
});
|
469
602
|
|
470
603
|
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
471
|
-
|
604
|
+
'column-search.bs.table': 'onColumnSearch',
|
605
|
+
'created-controls.bs.table': 'onCreatedControls'
|
472
606
|
});
|
473
607
|
|
474
608
|
$.extend($.fn.bootstrapTable.defaults.icons, {
|
475
|
-
|
609
|
+
clear: bootstrap.icons.clear
|
476
610
|
});
|
477
611
|
|
478
612
|
$.extend($.fn.bootstrapTable.locales, {
|
479
|
-
|
480
|
-
|
481
|
-
|
613
|
+
formatClearFilters: function formatClearFilters() {
|
614
|
+
return 'Clear Filters';
|
615
|
+
}
|
482
616
|
});
|
483
617
|
|
484
618
|
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
|
485
619
|
|
486
620
|
$.fn.bootstrapTable.methods.push('triggerSearch');
|
621
|
+
$.fn.bootstrapTable.methods.push('clearFilterControl');
|
487
622
|
|
488
|
-
|
489
|
-
|
490
|
-
_initToolbar = BootstrapTable.prototype.initToolbar,
|
491
|
-
_initHeader = BootstrapTable.prototype.initHeader,
|
492
|
-
_initBody = BootstrapTable.prototype.initBody,
|
493
|
-
_initSearch = BootstrapTable.prototype.initSearch;
|
623
|
+
$.BootstrapTable = function (_$$BootstrapTable) {
|
624
|
+
_inherits(_class, _$$BootstrapTable);
|
494
625
|
|
495
|
-
|
496
|
-
|
497
|
-
if (this.options.filterControl) {
|
498
|
-
var that = this;
|
626
|
+
function _class() {
|
627
|
+
_classCallCheck(this, _class);
|
499
628
|
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
629
|
+
return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments));
|
630
|
+
}
|
631
|
+
|
632
|
+
_createClass(_class, [{
|
633
|
+
key: 'init',
|
634
|
+
value: function init() {
|
635
|
+
// Make sure that the filterControl option is set
|
636
|
+
if (this.options.filterControl) {
|
637
|
+
var that = this;
|
504
638
|
|
505
|
-
//Make sure that the internal variables are set correctly
|
639
|
+
// Make sure that the internal variables are set correctly
|
506
640
|
this.options.valuesFilterControl = [];
|
507
641
|
|
508
642
|
this.$el.on('reset-view.bs.table', function () {
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
643
|
+
// Create controls on $tableHeader if the height is set
|
644
|
+
if (!that.options.height) {
|
645
|
+
return;
|
646
|
+
}
|
513
647
|
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
648
|
+
// Avoid recreate the controls
|
649
|
+
if (that.$tableHeader.find('select').length > 0 || that.$tableHeader.find('input').length > 0) {
|
650
|
+
return;
|
651
|
+
}
|
518
652
|
|
519
|
-
|
653
|
+
UtilsFilterControl.createControls(that, that.$tableHeader);
|
520
654
|
}).on('post-header.bs.table', function () {
|
521
|
-
|
655
|
+
UtilsFilterControl.setValues(that);
|
522
656
|
}).on('post-body.bs.table', function () {
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
}).on('column-switch.bs.table', function() {
|
527
|
-
|
528
|
-
}).on('load-success.bs.table', function() {
|
529
|
-
|
530
|
-
}).on('load-error.bs.table', function() {
|
531
|
-
|
657
|
+
if (that.options.height) {
|
658
|
+
UtilsFilterControl.fixHeaderCSS(that);
|
659
|
+
}
|
660
|
+
}).on('column-switch.bs.table', function () {
|
661
|
+
UtilsFilterControl.setValues(that);
|
662
|
+
}).on('load-success.bs.table', function () {
|
663
|
+
that.EnableControls(true);
|
664
|
+
}).on('load-error.bs.table', function () {
|
665
|
+
that.EnableControls(true);
|
532
666
|
});
|
533
|
-
|
534
|
-
_init.apply(this, Array.prototype.slice.apply(arguments));
|
535
|
-
};
|
667
|
+
}
|
536
668
|
|
537
|
-
|
538
|
-
|
669
|
+
_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'init', this).call(this);
|
670
|
+
}
|
671
|
+
}, {
|
672
|
+
key: 'initToolbar',
|
673
|
+
value: function initToolbar() {
|
674
|
+
this.showToolbar = this.showToolbar || this.options.filterControl && this.options.filterShowClear;
|
539
675
|
|
540
|
-
|
676
|
+
_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initToolbar', this).call(this);
|
541
677
|
|
542
|
-
|
543
|
-
var $btnGroup = this.$toolbar.find('>.btn-group')
|
544
|
-
|
678
|
+
if (this.options.filterControl && this.options.filterShowClear) {
|
679
|
+
var $btnGroup = this.$toolbar.find('>.btn-group');
|
680
|
+
var $btnClear = $btnGroup.find('.filter-show-clear');
|
545
681
|
|
546
682
|
if (!$btnClear.length) {
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
sprintf('<i class="%s %s"></i> ', this.options.iconsPrefix, this.options.icons.clear),
|
551
|
-
'</button>'
|
552
|
-
].join('')).appendTo($btnGroup);
|
553
|
-
|
554
|
-
$btnClear.off('click').on('click', $.proxy(this.clearFilterControl, this));
|
683
|
+
$btnClear = $([Utils.sprintf('<button class="btn btn-%s filter-show-clear" ', this.options.buttonsClass), Utils.sprintf('type="button" title="%s">', this.options.formatClearFilters()), Utils.sprintf('<i class="%s %s"></i> ', this.options.iconsPrefix, this.options.icons.clear), '</button>'].join('')).appendTo($btnGroup);
|
684
|
+
|
685
|
+
$btnClear.off('click').on('click', $.proxy(this.clearFilterControl, this));
|
555
686
|
}
|
687
|
+
}
|
556
688
|
}
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
689
|
+
}, {
|
690
|
+
key: 'initHeader',
|
691
|
+
value: function initHeader() {
|
692
|
+
_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initHeader', this).call(this);
|
561
693
|
|
562
|
-
|
694
|
+
if (!this.options.filterControl) {
|
563
695
|
return;
|
696
|
+
}
|
697
|
+
UtilsFilterControl.createControls(this, this.$header);
|
564
698
|
}
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
_initBody.apply(this, Array.prototype.slice.apply(arguments));
|
570
|
-
|
571
|
-
initFilterSelectControls(this);
|
572
|
-
};
|
573
|
-
|
574
|
-
BootstrapTable.prototype.initSearch = function () {
|
575
|
-
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
699
|
+
}, {
|
700
|
+
key: 'initBody',
|
701
|
+
value: function initBody() {
|
702
|
+
_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initBody', this).call(this);
|
576
703
|
|
577
|
-
|
578
|
-
return;
|
704
|
+
UtilsFilterControl.initFilterSelectControls(this);
|
579
705
|
}
|
706
|
+
}, {
|
707
|
+
key: 'initSearch',
|
708
|
+
value: function initSearch() {
|
709
|
+
var that = this;
|
710
|
+
var fp = $.isEmptyObject(that.filterColumnsPartial) ? null : that.filterColumnsPartial;
|
580
711
|
|
581
|
-
|
582
|
-
|
712
|
+
if (fp === null || Object.keys(fp).length <= 1) {
|
713
|
+
_get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'initSearch', this).call(this);
|
714
|
+
}
|
583
715
|
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
var thisColumn = that.columns[that.fieldsColumnsIndex[key]];
|
588
|
-
var fval = fp[key].toLowerCase();
|
589
|
-
var value = item[key];
|
716
|
+
if (this.options.sidePagination === 'server') {
|
717
|
+
return;
|
718
|
+
}
|
590
719
|
|
720
|
+
if (fp === null) {
|
721
|
+
return;
|
722
|
+
}
|
723
|
+
|
724
|
+
// Check partial column filter
|
725
|
+
that.data = fp ? that.options.data.filter(function (item, i) {
|
726
|
+
var itemIsExpected = [];
|
727
|
+
Object.keys(item).forEach(function (key, index) {
|
728
|
+
var thisColumn = that.columns[that.fieldsColumnsIndex[key]];
|
729
|
+
var fval = (fp[key] || '').toLowerCase();
|
730
|
+
var value = item[key];
|
731
|
+
|
732
|
+
if (fval === '') {
|
733
|
+
itemIsExpected.push(true);
|
734
|
+
} else {
|
591
735
|
// Fix #142: search use formated data
|
592
736
|
if (thisColumn && thisColumn.searchFormatter) {
|
593
|
-
|
594
|
-
that.header.formatters[$.inArray(key, that.header.fields)],
|
595
|
-
[value, item, i], value);
|
737
|
+
value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header, that.header.formatters[$.inArray(key, that.header.fields)], [value, item, i], value);
|
596
738
|
}
|
597
739
|
|
598
|
-
if($.inArray(key, that.header.fields) !== -1
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
740
|
+
if ($.inArray(key, that.header.fields) !== -1) {
|
741
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
742
|
+
if (thisColumn.filterStrictSearch) {
|
743
|
+
if (value.toString().toLowerCase() === fval.toString().toLowerCase()) {
|
744
|
+
itemIsExpected.push(true);
|
745
|
+
} else {
|
746
|
+
itemIsExpected.push(false);
|
747
|
+
}
|
748
|
+
} else if (thisColumn.filterStartsWithSearch) {
|
749
|
+
if (('' + value).toLowerCase().indexOf(fval) === 0) {
|
750
|
+
itemIsExpected.push(true);
|
751
|
+
} else {
|
752
|
+
itemIsExpected.push(false);
|
753
|
+
}
|
754
|
+
} else {
|
755
|
+
if (('' + value).toLowerCase().includes(fval)) {
|
756
|
+
itemIsExpected.push(true);
|
757
|
+
} else {
|
758
|
+
itemIsExpected.push(false);
|
759
|
+
}
|
613
760
|
}
|
761
|
+
}
|
614
762
|
}
|
615
|
-
|
616
|
-
|
617
|
-
return false;
|
618
|
-
}) : that.data;
|
619
|
-
};
|
763
|
+
}
|
764
|
+
});
|
620
765
|
|
621
|
-
|
622
|
-
|
766
|
+
return !itemIsExpected.includes(false);
|
767
|
+
}) : that.data;
|
768
|
+
}
|
769
|
+
}, {
|
770
|
+
key: 'initColumnSearch',
|
771
|
+
value: function initColumnSearch(filterColumnsDefaults) {
|
772
|
+
UtilsFilterControl.copyValues(this);
|
623
773
|
|
624
|
-
|
774
|
+
if (filterColumnsDefaults) {
|
625
775
|
this.filterColumnsPartial = filterColumnsDefaults;
|
626
776
|
this.updatePagination();
|
627
777
|
|
778
|
+
// eslint-disable-next-line guard-for-in
|
628
779
|
for (var filter in filterColumnsDefaults) {
|
629
780
|
this.trigger('column-search', filter, filterColumnsDefaults[filter]);
|
630
781
|
}
|
782
|
+
}
|
631
783
|
}
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
784
|
+
}, {
|
785
|
+
key: 'onColumnSearch',
|
786
|
+
value: function onColumnSearch(event) {
|
787
|
+
if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
|
636
788
|
return;
|
637
|
-
|
789
|
+
}
|
638
790
|
|
639
|
-
|
640
|
-
|
641
|
-
|
791
|
+
UtilsFilterControl.copyValues(this);
|
792
|
+
var text = $.trim($(event.currentTarget).val());
|
793
|
+
var $field = $(event.currentTarget).closest('[data-field]').data('field');
|
642
794
|
|
643
|
-
|
795
|
+
if ($.isEmptyObject(this.filterColumnsPartial)) {
|
644
796
|
this.filterColumnsPartial = {};
|
645
|
-
|
646
|
-
|
797
|
+
}
|
798
|
+
if (text) {
|
647
799
|
this.filterColumnsPartial[$field] = text;
|
648
|
-
|
800
|
+
} else {
|
649
801
|
delete this.filterColumnsPartial[$field];
|
802
|
+
}
|
803
|
+
|
804
|
+
// if the searchText is the same as the previously selected column value,
|
805
|
+
// bootstrapTable will not try searching again (even though the selected column
|
806
|
+
// may be different from the previous search). As a work around
|
807
|
+
// we're manually appending some text to bootrap's searchText field
|
808
|
+
// to guarantee that it will perform a search again when we call this.onSearch(event)
|
809
|
+
this.searchText += 'randomText';
|
810
|
+
|
811
|
+
this.options.pageNumber = 1;
|
812
|
+
this.EnableControls(false);
|
813
|
+
this.onSearch(event);
|
814
|
+
this.trigger('column-search', $field, text);
|
650
815
|
}
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
};
|
664
|
-
|
665
|
-
BootstrapTable.prototype.clearFilterControl = function () {
|
666
|
-
if (this.options.filterControl && this.options.filterShowClear) {
|
667
|
-
var that = this,
|
668
|
-
cookies = collectBootstrapCookies(),
|
669
|
-
header = getCurrentHeader(that),
|
670
|
-
table = header.closest('table'),
|
671
|
-
controls = header.find(getCurrentSearchControls(that)),
|
672
|
-
search = that.$toolbar.find('.search input'),
|
673
|
-
timeoutId = 0;
|
816
|
+
}, {
|
817
|
+
key: 'clearFilterControl',
|
818
|
+
value: function clearFilterControl() {
|
819
|
+
if (this.options.filterControl && this.options.filterShowClear) {
|
820
|
+
var that = this;
|
821
|
+
var cookies = UtilsFilterControl.collectBootstrapCookies();
|
822
|
+
var header = UtilsFilterControl.getCurrentHeader(that);
|
823
|
+
var table = header.closest('table');
|
824
|
+
var controls = header.find(UtilsFilterControl.getCurrentSearchControls(that));
|
825
|
+
var search = that.$toolbar.find('.search input');
|
826
|
+
var hasValues = false;
|
827
|
+
var timeoutId = 0;
|
674
828
|
|
675
829
|
$.each(that.options.valuesFilterControl, function (i, item) {
|
676
|
-
|
830
|
+
hasValues = hasValues ? true : item.value !== '';
|
831
|
+
item.value = '';
|
677
832
|
});
|
678
833
|
|
679
|
-
setValues(that);
|
834
|
+
UtilsFilterControl.setValues(that);
|
835
|
+
|
836
|
+
// clear cookies once the filters are clean
|
837
|
+
clearTimeout(timeoutId);
|
838
|
+
timeoutId = setTimeout(function () {
|
839
|
+
if (cookies && cookies.length > 0) {
|
840
|
+
$.each(cookies, function (i, item) {
|
841
|
+
if (that.deleteCookie !== undefined) {
|
842
|
+
that.deleteCookie(item);
|
843
|
+
}
|
844
|
+
});
|
845
|
+
}
|
846
|
+
}, that.options.searchTimeOut);
|
847
|
+
|
848
|
+
// If there is not any value in the controls exit this method
|
849
|
+
if (!hasValues) {
|
850
|
+
return;
|
851
|
+
}
|
680
852
|
|
681
853
|
// Clear each type of filter if it exists.
|
682
854
|
// Requires the body to reload each time a type of filter is found because we never know
|
683
855
|
// which ones are going to be present.
|
684
856
|
if (controls.length > 0) {
|
685
|
-
|
686
|
-
|
857
|
+
this.filterColumnsPartial = {};
|
858
|
+
$(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change', { keyCode: 13 });
|
687
859
|
} else {
|
688
|
-
|
860
|
+
return;
|
689
861
|
}
|
690
862
|
|
691
863
|
if (search.length > 0) {
|
692
|
-
|
864
|
+
that.resetSearch();
|
693
865
|
}
|
694
866
|
|
695
867
|
// use the default sort order if it exists. do nothing if it does not
|
696
868
|
if (that.options.sortName !== table.data('sortName') || that.options.sortOrder !== table.data('sortOrder')) {
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
869
|
+
var sorter = header.find(Utils.sprintf('[data-field="%s"]', $(controls[0]).closest('table').data('sortName')));
|
870
|
+
if (sorter.length > 0) {
|
871
|
+
that.onSort({ type: 'keypress', currentTarget: sorter });
|
872
|
+
$(sorter).find('.sortable').trigger('click');
|
873
|
+
}
|
702
874
|
}
|
703
|
-
|
704
|
-
// clear cookies once the filters are clean
|
705
|
-
clearTimeout(timeoutId);
|
706
|
-
timeoutId = setTimeout(function () {
|
707
|
-
if (cookies && cookies.length > 0) {
|
708
|
-
$.each(cookies, function (i, item) {
|
709
|
-
if (that.deleteCookie !== undefined) {
|
710
|
-
that.deleteCookie(item);
|
711
|
-
}
|
712
|
-
});
|
713
|
-
}
|
714
|
-
}, that.options.searchTimeOut);
|
875
|
+
}
|
715
876
|
}
|
716
|
-
|
877
|
+
}, {
|
878
|
+
key: 'triggerSearch',
|
879
|
+
value: function triggerSearch() {
|
880
|
+
var header = UtilsFilterControl.getCurrentHeader(this);
|
881
|
+
var searchControls = UtilsFilterControl.getCurrentSearchControls(this);
|
717
882
|
|
718
|
-
|
719
|
-
var header = getCurrentHeader(this),
|
720
|
-
searchControls = getCurrentSearchControls(this);
|
721
|
-
|
722
|
-
header.find(searchControls).each(function () {
|
883
|
+
header.find(searchControls).each(function () {
|
723
884
|
var el = $(this);
|
724
|
-
if(el.is('select')) {
|
725
|
-
|
885
|
+
if (el.is('select')) {
|
886
|
+
el.change();
|
726
887
|
} else {
|
727
|
-
|
888
|
+
el.keyup();
|
728
889
|
}
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
890
|
+
});
|
891
|
+
}
|
892
|
+
}, {
|
893
|
+
key: 'EnableControls',
|
894
|
+
value: function EnableControls(enable) {
|
895
|
+
if (this.options.disableControlWhenSearch && this.options.sidePagination === 'server') {
|
896
|
+
var header = UtilsFilterControl.getCurrentHeader(this);
|
897
|
+
var searchControls = UtilsFilterControl.getCurrentSearchControls(this);
|
898
|
+
|
899
|
+
if (!enable) {
|
900
|
+
header.find(searchControls).prop('disabled', 'disabled');
|
739
901
|
} else {
|
740
|
-
|
902
|
+
header.find(searchControls).removeProp('disabled');
|
741
903
|
}
|
904
|
+
}
|
742
905
|
}
|
743
|
-
|
744
|
-
|
906
|
+
}]);
|
907
|
+
|
908
|
+
return _class;
|
909
|
+
}($.BootstrapTable);
|
910
|
+
})(jQuery);
|
911
|
+
});
|