bootstrap-table-rails 1.8.2 → 1.8.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +68 -29
  3. data/bootstrap-table-rails-1.8.2.gem +0 -0
  4. data/lib/bootstrap-table-rails/version.rb +1 -1
  5. data/vendor/assets/javascripts/bootstrap-table-all.js +5177 -9
  6. data/vendor/assets/javascripts/bootstrap-table-locale-all.js +1500 -6
  7. data/vendor/assets/javascripts/bootstrap-table.js +2506 -8
  8. data/vendor/assets/javascripts/extensions/bootstrap-table-angular.js +105 -7
  9. data/vendor/assets/javascripts/extensions/bootstrap-table-cookie.js +318 -7
  10. data/vendor/assets/javascripts/extensions/bootstrap-table-editable.js +107 -7
  11. data/vendor/assets/javascripts/extensions/bootstrap-table-export.js +103 -7
  12. data/vendor/assets/javascripts/extensions/bootstrap-table-filter-control.js +458 -7
  13. data/vendor/assets/javascripts/extensions/bootstrap-table-filter.js +67 -7
  14. data/vendor/assets/javascripts/extensions/bootstrap-table-flat-json.js +62 -7
  15. data/vendor/assets/javascripts/extensions/bootstrap-table-group-by.js +228 -0
  16. data/vendor/assets/javascripts/extensions/bootstrap-table-key-events.js +80 -7
  17. data/vendor/assets/javascripts/extensions/bootstrap-table-mobile.js +142 -7
  18. data/vendor/assets/javascripts/extensions/bootstrap-table-multiple-sort.js +378 -7
  19. data/vendor/assets/javascripts/extensions/bootstrap-table-natural-sorting.js +47 -7
  20. data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-columns.js +130 -7
  21. data/vendor/assets/javascripts/extensions/bootstrap-table-reorder-rows.js +115 -7
  22. data/vendor/assets/javascripts/extensions/bootstrap-table-resizable.js +74 -7
  23. data/vendor/assets/javascripts/extensions/bootstrap-table-toolbar.js +245 -7
  24. data/vendor/assets/javascripts/locale/bootstrap-table-ar-SA.js +40 -0
  25. data/vendor/assets/javascripts/locale/bootstrap-table-ca-ES.js +43 -0
  26. data/vendor/assets/javascripts/locale/bootstrap-table-cs-CZ.js +44 -0
  27. data/vendor/assets/javascripts/locale/bootstrap-table-da-DK.js +37 -0
  28. data/vendor/assets/javascripts/locale/bootstrap-table-de-DE.js +37 -0
  29. data/vendor/assets/javascripts/locale/bootstrap-table-el-GR.js +28 -0
  30. data/vendor/assets/javascripts/locale/bootstrap-table-en-US.js +43 -0
  31. data/vendor/assets/javascripts/locale/bootstrap-table-es-AR.js +31 -0
  32. data/vendor/assets/javascripts/locale/bootstrap-table-es-CR.js +40 -0
  33. data/vendor/assets/javascripts/locale/bootstrap-table-es-ES.js +43 -0
  34. data/vendor/assets/javascripts/locale/bootstrap-table-es-MX.js +32 -0
  35. data/vendor/assets/javascripts/locale/bootstrap-table-es-NI.js +40 -0
  36. data/vendor/assets/javascripts/locale/bootstrap-table-es-SP.js +40 -0
  37. data/vendor/assets/javascripts/locale/bootstrap-table-fa-IR.js +43 -0
  38. data/vendor/assets/javascripts/locale/bootstrap-table-fr-BE.js +28 -0
  39. data/vendor/assets/javascripts/locale/bootstrap-table-fr-FR.js +41 -0
  40. data/vendor/assets/javascripts/locale/bootstrap-table-hr-HR.js +44 -0
  41. data/vendor/assets/javascripts/locale/bootstrap-table-hu-HU.js +43 -0
  42. data/vendor/assets/javascripts/locale/bootstrap-table-it-IT.js +37 -0
  43. data/vendor/assets/javascripts/locale/bootstrap-table-ja-JP.js +40 -0
  44. data/vendor/assets/javascripts/locale/bootstrap-table-ka-GE.js +40 -0
  45. data/vendor/assets/javascripts/locale/bootstrap-table-ko-KR.js +37 -0
  46. data/vendor/assets/javascripts/locale/bootstrap-table-ms-MY.js +40 -0
  47. data/vendor/assets/javascripts/locale/bootstrap-table-nb-NO.js +37 -0
  48. data/vendor/assets/javascripts/locale/bootstrap-table-nl-NL.js +28 -0
  49. data/vendor/assets/javascripts/locale/bootstrap-table-pl-PL.js +37 -0
  50. data/vendor/assets/javascripts/locale/bootstrap-table-pt-BR.js +41 -0
  51. data/vendor/assets/javascripts/locale/bootstrap-table-pt-PT.js +28 -0
  52. data/vendor/assets/javascripts/locale/bootstrap-table-ro-RO.js +43 -0
  53. data/vendor/assets/javascripts/locale/bootstrap-table-ru-RU.js +36 -0
  54. data/vendor/assets/javascripts/locale/bootstrap-table-sk-SK.js +37 -0
  55. data/vendor/assets/javascripts/locale/bootstrap-table-sv-SE.js +37 -0
  56. data/vendor/assets/javascripts/locale/bootstrap-table-th-TH.js +37 -0
  57. data/vendor/assets/javascripts/locale/bootstrap-table-tr-TR.js +41 -0
  58. data/vendor/assets/javascripts/locale/bootstrap-table-uk-UA.js +37 -0
  59. data/vendor/assets/javascripts/locale/bootstrap-table-ur-PK.js +37 -0
  60. data/vendor/assets/javascripts/locale/bootstrap-table-vi-VN.js +28 -0
  61. data/vendor/assets/javascripts/locale/bootstrap-table-zh-CN.js +40 -0
  62. data/vendor/assets/javascripts/locale/bootstrap-table-zh-TW.js +40 -0
  63. data/vendor/assets/stylesheets/bootstrap-table.css +297 -1
  64. data/vendor/assets/stylesheets/extensions/bootstrap-table-group-by.css +53 -0
  65. metadata +44 -2
@@ -1,7 +1,103 @@
1
- /*
2
- * bootstrap-table - v1.8.1 - 2015-05-29
3
- * https://github.com/wenzhixin/bootstrap-table
4
- * Copyright (c) 2015 zhixin wen
5
- * Licensed MIT License
6
- */
7
- !function(a){"use strict";var b={json:"JSON",xml:"XML",png:"PNG",csv:"CSV",txt:"TXT",sql:"SQL",doc:"MS-Word",excel:"Ms-Excel",powerpoint:"Ms-Powerpoint",pdf:"PDF"};a.extend(a.fn.bootstrapTable.defaults,{showExport:!1,exportTypes:["json","xml","csv","txt","sql","excel"],exportOptions:{}});var c=a.fn.bootstrapTable.Constructor,d=c.prototype.initToolbar;c.prototype.initToolbar=function(){if(this.showToolbar=this.options.showExport,d.apply(this,Array.prototype.slice.apply(arguments)),this.options.showExport){var c=this,e=this.$toolbar.find(">.btn-group"),f=e.find("div.export");if(!f.length){f=a(['<div class="export btn-group">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button">','<i class="glyphicon glyphicon-export icon-share"></i> ','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"</ul>","</div>"].join("")).appendTo(e);var g=f.find(".dropdown-menu"),h=this.options.exportTypes;if("string"==typeof this.options.exportTypes){var i=this.options.exportTypes.slice(1,-1).replace(/ /g,"").split(",");h=[],a.each(i,function(a,b){h.push(b.slice(1,-1))})}a.each(h,function(a,c){b.hasOwnProperty(c)&&g.append(['<li data-type="'+c+'">','<a href="javascript:void(0)">',b[c],"</a>","</li>"].join(""))}),g.find("li").click(function(){c.$el.tableExport(a.extend({},c.options.exportOptions,{type:a(this).data("type"),escape:!1}))})}}}}(jQuery);
1
+ /**
2
+ * @author zhixin wen <wenzhixin2010@gmail.com>
3
+ * extensions: https://github.com/kayalshri/tableExport.jquery.plugin
4
+ */
5
+
6
+ (function ($) {
7
+ 'use strict';
8
+
9
+ var TYPE_NAME = {
10
+ json: 'JSON',
11
+ xml: 'XML',
12
+ png: 'PNG',
13
+ csv: 'CSV',
14
+ txt: 'TXT',
15
+ sql: 'SQL',
16
+ doc: 'MS-Word',
17
+ excel: 'Ms-Excel',
18
+ powerpoint: 'Ms-Powerpoint',
19
+ pdf: 'PDF'
20
+ };
21
+
22
+ $.extend($.fn.bootstrapTable.defaults, {
23
+ showExport: false,
24
+ exportDataType: 'basic', // basic, all, selected
25
+ // 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf'
26
+ exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
27
+ exportOptions: {}
28
+ });
29
+
30
+ var BootstrapTable = $.fn.bootstrapTable.Constructor,
31
+ _initToolbar = BootstrapTable.prototype.initToolbar;
32
+
33
+ BootstrapTable.prototype.initToolbar = function () {
34
+ this.showToolbar = this.options.showExport;
35
+
36
+ _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
37
+
38
+ if (this.options.showExport) {
39
+ var that = this,
40
+ $btnGroup = this.$toolbar.find('>.btn-group'),
41
+ $export = $btnGroup.find('div.export');
42
+
43
+ if (!$export.length) {
44
+ $export = $([
45
+ '<div class="export btn-group">',
46
+ '<button class="btn btn-default dropdown-toggle" ' +
47
+ 'data-toggle="dropdown" type="button">',
48
+ '<i class="glyphicon glyphicon-export icon-share"></i> ',
49
+ '<span class="caret"></span>',
50
+ '</button>',
51
+ '<ul class="dropdown-menu" role="menu">',
52
+ '</ul>',
53
+ '</div>'].join('')).appendTo($btnGroup);
54
+
55
+ var $menu = $export.find('.dropdown-menu'),
56
+ exportTypes = this.options.exportTypes;
57
+
58
+ if (typeof this.options.exportTypes === 'string') {
59
+ var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(',');
60
+
61
+ exportTypes = [];
62
+ $.each(types, function (i, value) {
63
+ exportTypes.push(value.slice(1, -1));
64
+ });
65
+ }
66
+ $.each(exportTypes, function (i, type) {
67
+ if (TYPE_NAME.hasOwnProperty(type)) {
68
+ $menu.append(['<li data-type="' + type + '">',
69
+ '<a href="javascript:void(0)">',
70
+ TYPE_NAME[type],
71
+ '</a>',
72
+ '</li>'].join(''));
73
+ }
74
+ });
75
+
76
+ $menu.find('li').click(function () {
77
+ var type = $(this).data('type'),
78
+ doExport = function () {
79
+ that.$el.tableExport($.extend({}, that.options.exportOptions, {
80
+ type: type,
81
+ escape: false
82
+ }));
83
+ };
84
+
85
+ if (that.options.exportDataType === 'all' && that.options.pagination) {
86
+ that.togglePagination();
87
+ doExport();
88
+ that.togglePagination();
89
+ } else if (that.options.exportDataType === 'selected') {
90
+ var data = that.getData(),
91
+ selectedData = that.getAllSelections();
92
+
93
+ that.load(selectedData);
94
+ doExport();
95
+ that.load(data);
96
+ } else {
97
+ doExport();
98
+ }
99
+ });
100
+ }
101
+ }
102
+ };
103
+ })(jQuery);
@@ -1,7 +1,458 @@
1
- /*
2
- * bootstrap-table - v1.8.1 - 2015-05-29
3
- * https://github.com/wenzhixin/bootstrap-table
4
- * Copyright (c) 2015 zhixin wen
5
- * Licensed MIT License
6
- */
7
- !function(a){"use strict";var b=function(a){var b=arguments,c=!0,d=1;return a=a.replace(/%s/g,function(){var a=b[d++];return"undefined"==typeof a?(c=!1,""):a}),c?a:""},c=function(b,c){var d=-1;return a.each(b,function(a,b){return b.field===c?(d=a,!1):!0}),d},d=function(b,c,d,e){if("string"==typeof c){var f=c.split(".");f.length>1?(c=window,a.each(f,function(a,b){c=c[b]})):c=window[c]}return"object"==typeof c?c:"function"==typeof c?c.apply(b,d):e};a.extend(a.fn.bootstrapTable.defaults,{filterControl:!1,onColumnSearch:function(){return!1}}),a.extend(a.fn.bootstrapTable.COLUMN_DEFAULTS,{filterControl:void 0,filterData:void 0}),a.extend(a.fn.bootstrapTable.Constructor.EVENTS,{"column-search.bs.table":"onColumnSearch"});var e=a.fn.bootstrapTable.Constructor,f=e.prototype.initHeader,g=e.prototype.initBody,h=e.prototype.initSearch;e.prototype.initHeader=function(){if(f.apply(this,Array.prototype.slice.apply(arguments)),this.options.filterControl){var c,d,e=!1,g=this,h=0;a.each(this.options.columns,function(f,h){if(c="hidden",d=[],h.visible){if(h.filterControl)table(d.push('<div style="margin: 0px 2px 2px 2px;" class="filterControl">'),h.filterControl&&h.searchable&&(e=!0,c="visible"),h.filterControl.toLowerCase()){case"input":d.push(b('<input type="text" class="form-control" style="width: 100%; visibility: %s">',c));break;case"select":d.push(b('<select class="%s form-control" style="width: 100%; visibility: %s"></select>',h.field,c))}else d.push('<div style="height: 34px;"></div>');if(g.$header.find(b('.th-inner:eq("%s")',f)).next().append(d.join("")),void 0!==h.filterData&&"column"!==h.filterData.toLowerCase()){var i=h.filterData.substring(0,3),j=h.filterData.substring(4,h.filterData.length),k=a("."+h.field);table(k.append(a("<option></option>").attr("value","").text("")),i){case"url":a.ajax({url:j,dataType:"json",success:function(b){a.each(b,function(b,c){k.append(a("<option></option>").attr("value",b).text(c))})}});break;case"var":var l=window[j];for(var m in l)k.append(a("<option></option>").attr("value",m).text(l[m]))}}}}),e?(this.$header.off("keyup","input").on("keyup","input",function(a){clearTimeout(h),h=setTimeout(function(){g.onColumnSearch(a)},g.options.searchTimeOut)}),this.$header.off("change","select").on("change","select",function(a){clearTimeout(h),h=setTimeout(function(){g.onColumnSearch(a)},g.options.searchTimeOut)})):this.$header.find(".filterControl").hide()}},e.prototype.initBody=function(){g.apply(this,Array.prototype.slice.apply(arguments));for(var b=this,e=this.getData(),f=this.pageFrom-1;f<this.pageTo;f++){var h=e[f];a.each(this.header.fields,function(e,g){var i=h[g],j=b.options.columns[c(b.options.columns,g)];if(i=d(b.header,b.header.formatters[e],[i,h,f],i),!(j.checkbox&&j.radio||void 0===j.filterControl||"select"!==j.filterControl.toLowerCase()||!j.searchable||void 0!==j.filterData&&"column"!==j.filterData.toLowerCase())){var k,l=a("."+j.field),m=0,n=!1;if(void 0!==l)if(k=l.get(0).options,0===k.length)l.append(a("<option></option>").attr("value","").text("")),l.append(a("<option></option>").attr("value",i).text(i));else{for(;m<k.length;m++)if(k[m].value===i){n=!0;break}n||l.append(a("<option></option>").attr("value",i).text(i))}}})}},e.prototype.initSearch=function(){h.apply(this,Array.prototype.slice.apply(arguments));var b=this,c=a.isEmptyObject(this.filterColumnsPartial)?null:this.filterColumnsPartial;this.data=c?a.grep(this.data,function(e,f){for(var g in c){var h=c[g].toLowerCase(),i=e[g];if(i=d(b.header,b.header.formatters[a.inArray(g,b.header.fields)],[i,e,f],i),-1===a.inArray(g,b.header.fields)||"string"!=typeof i&&"number"!=typeof i||-1===(i+"").toLowerCase().indexOf(h))return!1}return!0}):this.data},e.prototype.onColumnSearch=function(b){var c=a.trim(a(b.currentTarget).val()),d=a(b.currentTarget).parent().parent().parent().data("field");a.isEmptyObject(this.filterColumnsPartial)&&(this.filterColumnsPartial={}),c?this.filterColumnsPartial[d]=c:delete this.filterColumnsPartial[d],this.options.pageNumber=1,this.onSearch(b),this.updatePagination(),this.trigger("column-search",d,c)}}(jQuery);
1
+ /**
2
+ * @author: Dennis Hernández
3
+ * @webSite: http://djhvscf.github.io/Blog
4
+ * @version: v1.0.0
5
+ */
6
+
7
+ !function ($) {
8
+
9
+ 'use strict';
10
+
11
+ var sprintf = function (str) {
12
+ var args = arguments,
13
+ flag = true,
14
+ i = 1;
15
+
16
+ str = str.replace(/%s/g, function () {
17
+ var arg = args[i++];
18
+
19
+ if (typeof arg === 'undefined') {
20
+ flag = false;
21
+ return '';
22
+ }
23
+ return arg;
24
+ });
25
+ return flag ? str : '';
26
+ };
27
+
28
+ var getFieldIndex = function (columns, field) {
29
+ var index = -1;
30
+
31
+ $.each(columns, function (i, column) {
32
+ if (column.field === field) {
33
+ index = i;
34
+ return false;
35
+ }
36
+ return true;
37
+ });
38
+ return index;
39
+ };
40
+
41
+ var calculateObjectValue = function (self, name, args, defaultValue) {
42
+ if (typeof name === 'string') {
43
+ // support obj.func1.func2
44
+ var names = name.split('.');
45
+
46
+ if (names.length > 1) {
47
+ name = window;
48
+ $.each(names, function (i, f) {
49
+ name = name[f];
50
+ });
51
+ } else {
52
+ name = window[name];
53
+ }
54
+ }
55
+ if (typeof name === 'object') {
56
+ return name;
57
+ }
58
+ if (typeof name === 'function') {
59
+ return name.apply(self, args);
60
+ }
61
+ return defaultValue;
62
+ };
63
+
64
+ var addOptionToSelectControl = function (selectControl, value, text) {
65
+ //selectControl = $(selectControl.get(0));
66
+ if (existsOptionInSelectControl(selectControl, value)) {
67
+ selectControl.append($("<option></option>")
68
+ .attr("value", value)
69
+ .text($('<div />').html(text).text()));
70
+
71
+ // Sort it. Not overly efficient to do this here
72
+ var $opts = selectControl.find('option:gt(0)');
73
+ $opts.sort(function (a, b) {
74
+ a = $(a).text().toLowerCase();
75
+ b = $(b).text().toLowerCase();
76
+ if ($.isNumeric(a) && $.isNumeric(b)) {
77
+ // Convert numerical values from string to float.
78
+ a = parseFloat(a);
79
+ b = parseFloat(b);
80
+ }
81
+ return a > b ? 1 : a < b ? -1 : 0;
82
+ });
83
+
84
+ selectControl.find('option:gt(0)').remove();
85
+ selectControl.append($opts);
86
+ }
87
+ };
88
+
89
+ var existsOptionInSelectControl = function (selectControl, value) {
90
+ var options = selectControl.get(0).options,
91
+ iOpt = 0;
92
+
93
+ for (; iOpt < options.length; iOpt++) {
94
+ if (options[iOpt].value === value) {
95
+ //The value is nor valid to add
96
+ return false;
97
+ }
98
+ }
99
+
100
+ //If we get here, the value is valid to add
101
+ return true;
102
+ };
103
+
104
+ var fixHeaderCSS = function (that) {
105
+ that.$tableHeader.css('height', '77px');
106
+ };
107
+
108
+ var getCurrentHeader = function (that) {
109
+ var header = that.$header;
110
+ if (that.options.height) {
111
+ header = that.$tableHeader;
112
+ }
113
+
114
+ return header;
115
+ };
116
+
117
+ var getCurrentSearchControls = function (that) {
118
+ var searchControls = 'select, input';
119
+ if (that.options.height) {
120
+ searchControls = 'table select, table input';
121
+ }
122
+
123
+ return searchControls;
124
+ };
125
+
126
+ var copyValues = function (that) {
127
+ var header = getCurrentHeader(that),
128
+ searchControls = getCurrentSearchControls(that);
129
+
130
+ that.options.values = [];
131
+
132
+ header.find(searchControls).each(function () {
133
+ that.options.values.push(
134
+ {
135
+ field: $(this).parent().parent().parent().data('field'),
136
+ value: $(this).val()
137
+ });
138
+ });
139
+ };
140
+
141
+ var setValues = function(that) {
142
+ var field = null,
143
+ result = [],
144
+ header = getCurrentHeader(that),
145
+ searchControls = getCurrentSearchControls(that);
146
+
147
+ if (that.options.values.length > 0) {
148
+ header.find(searchControls).each(function (index, ele) {
149
+ field = $(this).parent().parent().parent().data('field');
150
+ result = $.grep(that.options.values, function (valueObj) {
151
+ return valueObj.field === field;
152
+ });
153
+
154
+ if (result.length > 0) {
155
+ $(this).val(result[0].value);
156
+ }
157
+ });
158
+ }
159
+ };
160
+
161
+ var createControls = function (that, header) {
162
+ var addedFilterControl = false,
163
+ isVisible,
164
+ html,
165
+ timeoutId = 0;
166
+
167
+ $.each(that.columns, function (i, column) {
168
+ isVisible = 'hidden';
169
+ html = [];
170
+
171
+ if (!column.visible) {
172
+ return;
173
+ }
174
+
175
+ if (!column.filterControl) {
176
+ html.push('<div style="height: 34px;"></div>');
177
+ } else {
178
+ html.push('<div style="margin: 0px 2px 2px 2px;" class="filterControl">');
179
+
180
+ if (column.filterControl && column.searchable) {
181
+ addedFilterControl = true;
182
+ isVisible = 'visible'
183
+ }
184
+ switch (column.filterControl.toLowerCase()) {
185
+ case 'input' :
186
+ html.push(sprintf('<input type="text" class="form-control" style="width: 100%; visibility: %s">', isVisible));
187
+ break;
188
+ case 'select':
189
+ html.push(sprintf('<select class="%s form-control" style="width: 100%; visibility: %s"></select>',
190
+ column.field, isVisible))
191
+ break;
192
+ case 'datepicker':
193
+ html.push(sprintf('<input type="text" class="date-filter-control %s form-control" style="width: 100%; visibility: %s">',
194
+ column.field, isVisible));
195
+ break;
196
+ }
197
+ }
198
+
199
+ $.each(header.children().children(), function (i, tr) {
200
+ tr = $(tr);
201
+ if (tr.data('field') === column.field) {
202
+ tr.find('.fht-cell').append(html.join(''));
203
+ return false;
204
+ }
205
+ });
206
+ if (column.filterData !== undefined && column.filterData.toLowerCase() !== 'column') {
207
+ var filterDataType = column.filterData.substring(0, 3);
208
+ var filterDataSource = column.filterData.substring(4, column.filterData.length);
209
+ var selectControl = $('.' + column.field);
210
+ addOptionToSelectControl(selectControl, '', '');
211
+
212
+ switch (filterDataType) {
213
+ case 'url':
214
+ $.ajax({
215
+ url: filterDataSource,
216
+ dataType: 'json',
217
+ success: function (data) {
218
+ $.each(data, function (key, value) {
219
+ addOptionToSelectControl(selectControl, key, value);
220
+ });
221
+ }
222
+ });
223
+ break;
224
+ case 'var':
225
+ var variableValues = window[filterDataSource];
226
+ for (var key in variableValues) {
227
+ addOptionToSelectControl(selectControl, key, variableValues[key]);
228
+ }
229
+ break;
230
+ }
231
+ }
232
+ });
233
+
234
+ if (addedFilterControl) {
235
+ header.off('keyup', 'input').on('keyup', 'input', function (event) {
236
+ clearTimeout(timeoutId);
237
+ timeoutId = setTimeout(function () {
238
+ that.onColumnSearch(event);
239
+ }, that.options.searchTimeOut);
240
+ });
241
+
242
+ header.off('change', 'select').on('change', 'select', function (event) {
243
+ clearTimeout(timeoutId);
244
+ timeoutId = setTimeout(function () {
245
+ that.onColumnSearch(event);
246
+ }, that.options.searchTimeOut);
247
+ });
248
+
249
+ if (header.find('.date-filter-control').length > 0) {
250
+ $.each(that.columns, function (i, column) {
251
+ if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'datepicker') {
252
+ header.find('.date-filter-control.' + column.field).datepicker(column.filterDatepickerOptions)
253
+ .on('changeDate', function (e) {
254
+ //Fired the keyup event
255
+ $(e.currentTarget).keyup();
256
+ });
257
+ }
258
+ });
259
+ }
260
+ } else {
261
+ header.find('.filterControl').hide();
262
+ }
263
+ };
264
+
265
+ $.extend($.fn.bootstrapTable.defaults, {
266
+ filterControl: false,
267
+ onColumnSearch: function (field, text) {
268
+ return false;
269
+ },
270
+ filterShowClear: false,
271
+ //internal variables
272
+ values: []
273
+ });
274
+
275
+ $.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
276
+ filterControl: undefined,
277
+ filterData: undefined,
278
+ filterDatepickerOptions: undefined
279
+ });
280
+
281
+ $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
282
+ 'column-search.bs.table': 'onColumnSearch'
283
+ });
284
+
285
+ var BootstrapTable = $.fn.bootstrapTable.Constructor,
286
+ _init = BootstrapTable.prototype.init,
287
+ _initToolbar = BootstrapTable.prototype.initToolbar,
288
+ _initHeader = BootstrapTable.prototype.initHeader,
289
+ _initBody = BootstrapTable.prototype.initBody,
290
+ _initSearch = BootstrapTable.prototype.initSearch;
291
+
292
+ BootstrapTable.prototype.init = function () {
293
+ //Make sure that the filtercontrol option is set
294
+ if (this.options.filterControl) {
295
+ var that = this;
296
+ //Make sure that the internal variables are set correctly
297
+ this.options.values = [];
298
+
299
+ this.$el.on('reset-view.bs.table', function () {
300
+ //Create controls on $tableHeader if the height is set
301
+ if (!that.options.height) {
302
+ return;
303
+ }
304
+
305
+ //Avoid recreate the controls
306
+ if (that.$tableHeader.find('select').length > 0 || that.$tableHeader.find('input').length > 0) {
307
+ return;
308
+ }
309
+
310
+ createControls(that, that.$tableHeader);
311
+ }).on('post-header.bs.table', function () {
312
+ setValues(that);
313
+ }).on('post-body.bs.table', function () {
314
+ if (that.options.height) {
315
+ fixHeaderCSS(that);
316
+ }
317
+ }).on('column-switch.bs.table', function(field, checked) {
318
+ setValues(that);
319
+ });
320
+ }
321
+ _init.apply(this, Array.prototype.slice.apply(arguments));
322
+ };
323
+
324
+ BootstrapTable.prototype.initToolbar = function () {
325
+ if ((!this.showToolbar) && (this.options.filterControl)) {
326
+ this.showToolbar = this.options.filterControl;
327
+ }
328
+
329
+ _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
330
+
331
+ if (this.options.filterControl && this.options.filterShowClear) {
332
+ var $btnGroup = this.$toolbar.find('>.btn-group'),
333
+ $btnClear = $btnGroup.find('div.export');
334
+
335
+ if (!$btnClear.length) {
336
+ $btnClear = $([
337
+ '<button class="btn btn-default " ' +
338
+ 'type="button">',
339
+ '<i class="glyphicon glyphicon-trash icon-share"></i> ',
340
+ '</button>',
341
+ '</ul>'].join('')).appendTo($btnGroup);
342
+
343
+ $btnClear.off('click').on('click', $.proxy(this.clearFilterControl, this));
344
+ }
345
+ }
346
+ };
347
+
348
+ BootstrapTable.prototype.initHeader = function () {
349
+ _initHeader.apply(this, Array.prototype.slice.apply(arguments));
350
+
351
+ if (!this.options.filterControl) {
352
+ return;
353
+ }
354
+ createControls(this, this.$header);
355
+ };
356
+
357
+ BootstrapTable.prototype.initBody = function () {
358
+ _initBody.apply(this, Array.prototype.slice.apply(arguments));
359
+
360
+ var that = this,
361
+ data = this.options.data,
362
+ pageTo = this.pageTo < this.options.data.length ? this.options.data.length : this.pageTo;
363
+
364
+ for (var i = this.pageFrom - 1; i < pageTo; i++) {
365
+ var item = data[i];
366
+
367
+ $.each(this.header.fields, function (j, field) {
368
+ var value = item[field],
369
+ column = that.columns[getFieldIndex(that.columns, field)];
370
+
371
+ value = calculateObjectValue(that.header, that.header.formatters[j], [value, item, i], value);
372
+
373
+ if ((!column.checkbox) || (!column.radio)) {
374
+ if (column.filterControl !== undefined && column.filterControl.toLowerCase() === 'select' && column.searchable) {
375
+ if (column.filterData === undefined || column.filterData.toLowerCase() === 'column') {
376
+ var selectControl = $('.' + column.field);
377
+ if (selectControl !== undefined && selectControl.length > 0) {
378
+ if (selectControl.get(0).options.length === 0) {
379
+ //Added the default option
380
+ addOptionToSelectControl(selectControl, '', '');
381
+ }
382
+
383
+ //Added a new value
384
+ addOptionToSelectControl(selectControl, value, value);
385
+ }
386
+ }
387
+ }
388
+ }
389
+ });
390
+ }
391
+ };
392
+
393
+ BootstrapTable.prototype.initSearch = function () {
394
+ _initSearch.apply(this, Array.prototype.slice.apply(arguments));
395
+
396
+ var that = this;
397
+ var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
398
+
399
+ //Check partial column filter
400
+ this.data = fp ? $.grep(this.data, function (item, i) {
401
+ for (var key in fp) {
402
+ var fval = fp[key].toLowerCase();
403
+ var value = item[key];
404
+ value = calculateObjectValue(that.header,
405
+ that.header.formatters[$.inArray(key, that.header.fields)],
406
+ [value, item, i], value);
407
+
408
+ if (!($.inArray(key, that.header.fields) !== -1 &&
409
+ (typeof value === 'string' || typeof value === 'number') &&
410
+ (value + '').toLowerCase().indexOf(fval) !== -1)) {
411
+ return false;
412
+ }
413
+ }
414
+ return true;
415
+ }) : this.data;
416
+ };
417
+
418
+ BootstrapTable.prototype.onColumnSearch = function (event) {
419
+ copyValues(this);
420
+ var text = $.trim($(event.currentTarget).val());
421
+ var $field = $(event.currentTarget).parent().parent().parent().data('field')
422
+
423
+ if ($.isEmptyObject(this.filterColumnsPartial)) {
424
+ this.filterColumnsPartial = {};
425
+ }
426
+ if (text) {
427
+ this.filterColumnsPartial[$field] = text;
428
+ } else {
429
+ delete this.filterColumnsPartial[$field];
430
+ }
431
+
432
+ this.options.pageNumber = 1;
433
+ this.onSearch(event);
434
+ this.updatePagination();
435
+ this.trigger('column-search', $field, text);
436
+ };
437
+
438
+ BootstrapTable.prototype.clearFilterControl = function () {
439
+ if (this.options.filterControl && this.options.filterShowClear) {
440
+ $.each(this.options.values, function (i, item) {
441
+ item.value = '';
442
+ });
443
+
444
+ setValues(this);
445
+
446
+ var controls = getCurrentHeader(this).find(getCurrentSearchControls(this)),
447
+ timeoutId = 0;
448
+
449
+ if (controls.length > 0) {
450
+ this.filterColumnsPartial = {};
451
+ clearTimeout(timeoutId);
452
+ timeoutId = setTimeout(function () {
453
+ $(controls[0]).trigger(controls[0].tagName === 'INPUT' ? 'keyup' : 'change');
454
+ }, this.options.searchTimeOut);
455
+ }
456
+ }
457
+ };
458
+ }(jQuery);