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