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,226 +1,234 @@
1
- /**
2
- * @author: Yura Knoxville
3
- * @version: v1.0.0
4
- */
5
-
6
- !function ($) {
7
-
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.bootstrapTableGroupBy = mod.exports;
12
+ }
13
+ })(this, function () {
8
14
  'use strict';
9
15
 
10
- var initBodyCaller,
11
- tableGroups;
16
+ /**
17
+ * @author: Yura Knoxville
18
+ * @version: v1.1.0
19
+ */
12
20
 
13
- // it only does '%s', and return '' when arguments are undefined
14
- var sprintf = function (str) {
15
- var args = arguments,
16
- flag = true,
17
- i = 1;
21
+ (function ($) {
18
22
 
19
- str = str.replace(/%s/g, function () {
20
- var arg = args[i++];
23
+ 'use strict';
21
24
 
22
- if (typeof arg === 'undefined') {
23
- flag = false;
24
- return '';
25
- }
26
- return arg;
27
- });
28
- return flag ? str : '';
29
- };
30
-
31
- var groupBy = function (array , f) {
32
- var groups = {};
33
- array.forEach(function(o) {
34
- var group = f(o);
35
- groups[group] = groups[group] || [];
36
- groups[group].push(o);
37
- });
25
+ var initBodyCaller, tableGroups;
38
26
 
39
- return groups;
40
- };
27
+ // it only does '%s', and return '' when arguments are undefined
28
+ var sprintf = function sprintf(str) {
29
+ var args = arguments,
30
+ flag = true,
31
+ i = 1;
41
32
 
42
- $.extend($.fn.bootstrapTable.defaults, {
43
- groupBy: false,
44
- groupByField: ''
45
- });
33
+ str = str.replace(/%s/g, function () {
34
+ var arg = args[i++];
46
35
 
47
- var BootstrapTable = $.fn.bootstrapTable.Constructor,
48
- _initSort = BootstrapTable.prototype.initSort,
49
- _initBody = BootstrapTable.prototype.initBody,
50
- _updateSelected = BootstrapTable.prototype.updateSelected;
36
+ if (typeof arg === 'undefined') {
37
+ flag = false;
38
+ return '';
39
+ }
40
+ return arg;
41
+ });
42
+ return flag ? str : '';
43
+ };
51
44
 
52
- BootstrapTable.prototype.initSort = function () {
53
- _initSort.apply(this, Array.prototype.slice.apply(arguments));
45
+ var groupBy = function groupBy(array, f) {
46
+ var groups = {};
47
+ array.forEach(function (o) {
48
+ var group = f(o);
49
+ groups[group] = groups[group] || [];
50
+ groups[group].push(o);
51
+ });
54
52
 
55
- var that = this;
56
- tableGroups = [];
53
+ return groups;
54
+ };
57
55
 
58
- if ((this.options.groupBy) && (this.options.groupByField !== '')) {
56
+ $.extend($.fn.bootstrapTable.defaults, {
57
+ groupBy: false,
58
+ groupByField: '',
59
+ groupByFormatter: undefined
60
+ });
59
61
 
60
- if ((this.options.sortName != this.options.groupByField)) {
61
- this.data.sort(function(a, b) {
62
- return a[that.options.groupByField].localeCompare(b[that.options.groupByField]);
63
- });
64
- }
62
+ var BootstrapTable = $.fn.bootstrapTable.Constructor,
63
+ _initSort = BootstrapTable.prototype.initSort,
64
+ _initBody = BootstrapTable.prototype.initBody,
65
+ _updateSelected = BootstrapTable.prototype.updateSelected;
66
+
67
+ BootstrapTable.prototype.initSort = function () {
68
+ _initSort.apply(this, Array.prototype.slice.apply(arguments));
65
69
 
66
70
  var that = this;
67
- var groups = groupBy(that.data, function (item) {
68
- return [item[that.options.groupByField]];
69
- });
71
+ tableGroups = [];
70
72
 
71
- var index = 0;
72
- $.each(groups, function(key, value) {
73
- tableGroups.push({
74
- id: index,
75
- name: key
76
- });
73
+ if (this.options.groupBy && this.options.groupByField !== '') {
77
74
 
78
- value.forEach(function(item) {
79
- if (!item._data) {
80
- item._data = {};
81
- }
75
+ if (this.options.sortName != this.options.groupByField) {
76
+ this.data.sort(function (a, b) {
77
+ return a[that.options.groupByField].localeCompare(b[that.options.groupByField]);
78
+ });
79
+ }
82
80
 
83
- item._data['parent-index'] = index;
81
+ var that = this;
82
+ var groups = groupBy(that.data, function (item) {
83
+ return [item[that.options.groupByField]];
84
84
  });
85
85
 
86
- index++;
87
- });
88
- }
89
- }
86
+ var index = 0;
87
+ $.each(groups, function (key, value) {
88
+ tableGroups.push({
89
+ id: index,
90
+ name: key,
91
+ data: value
92
+ });
90
93
 
91
- BootstrapTable.prototype.initBody = function () {
92
- initBodyCaller = true;
94
+ value.forEach(function (item) {
95
+ if (!item._data) {
96
+ item._data = {};
97
+ }
93
98
 
94
- _initBody.apply(this, Array.prototype.slice.apply(arguments));
99
+ item._data['parent-index'] = index;
100
+ });
95
101
 
96
- if ((this.options.groupBy) && (this.options.groupByField !== '')) {
97
- var that = this,
98
- checkBox = false,
99
- visibleColumns = 0;
102
+ index++;
103
+ });
104
+ }
105
+ };
100
106
 
101
- this.columns.forEach(function(column) {
102
- if (column.checkbox) {
103
- checkBox = true;
104
- } else {
105
- if (column.visible) {
106
- visibleColumns += 1;
107
- }
108
- }
109
- });
107
+ BootstrapTable.prototype.initBody = function () {
108
+ initBodyCaller = true;
110
109
 
111
- if (this.options.detailView && !this.options.cardView) {
112
- visibleColumns += 1;
113
- }
110
+ _initBody.apply(this, Array.prototype.slice.apply(arguments));
114
111
 
115
- tableGroups.forEach(function(item){
116
- var html = [];
112
+ if (this.options.groupBy && this.options.groupByField !== '') {
113
+ var that = this,
114
+ checkBox = false,
115
+ visibleColumns = 0;
117
116
 
118
- html.push(sprintf('<tr class="info groupBy expanded" data-group-index="%s">', item.id));
117
+ this.columns.forEach(function (column) {
118
+ if (column.checkbox) {
119
+ checkBox = true;
120
+ } else {
121
+ if (column.visible) {
122
+ visibleColumns += 1;
123
+ }
124
+ }
125
+ });
119
126
 
120
- if (that.options.detailView && !that.options.cardView) {
121
- html.push('<td class="detail"></td>');
127
+ if (this.options.detailView && !this.options.cardView) {
128
+ visibleColumns += 1;
122
129
  }
123
130
 
124
- if (checkBox) {
125
- html.push('<td class="bs-checkbox">',
126
- '<input name="btSelectGroup" type="checkbox" />',
127
- '</td>'
128
- );
129
- }
131
+ tableGroups.forEach(function (item) {
132
+ var html = [];
130
133
 
131
- html.push('<td',
132
- sprintf(' colspan="%s"', visibleColumns),
133
- '>', item.name, '</td>'
134
- );
134
+ html.push(sprintf('<tr class="info groupBy expanded" data-group-index="%s">', item.id));
135
135
 
136
- html.push('</tr>');
136
+ if (that.options.detailView && !that.options.cardView) {
137
+ html.push('<td class="detail"></td>');
138
+ }
137
139
 
138
- that.$body.find('tr[data-parent-index='+item.id+']:first').before($(html.join('')));
139
- });
140
+ if (checkBox) {
141
+ html.push('<td class="bs-checkbox">', '<input name="btSelectGroup" type="checkbox" />', '</td>');
142
+ }
143
+ var formattedValue = item.name;
144
+ if (typeof that.options.groupByFormatter == "function") {
145
+ formattedValue = that.options.groupByFormatter(item.name, item.id, item.data);
146
+ }
147
+ html.push('<td', sprintf(' colspan="%s"', visibleColumns), '>', formattedValue, '</td>');
140
148
 
141
- this.$selectGroup = [];
142
- this.$body.find('[name="btSelectGroup"]').each(function() {
143
- var self = $(this);
149
+ html.push('</tr>');
144
150
 
145
- that.$selectGroup.push({
146
- group: self,
147
- item: that.$selectItem.filter(function () {
148
- return ($(this).closest('tr').data('parent-index') ===
149
- self.closest('tr').data('group-index'));
150
- })
151
+ that.$body.find('tr[data-parent-index=' + item.id + ']:first').before($(html.join('')));
151
152
  });
152
- });
153
153
 
154
- this.$container.off('click', '.groupBy')
155
- .on('click', '.groupBy', function() {
154
+ this.$selectGroup = [];
155
+ this.$body.find('[name="btSelectGroup"]').each(function () {
156
+ var self = $(this);
157
+
158
+ that.$selectGroup.push({
159
+ group: self,
160
+ item: that.$selectItem.filter(function () {
161
+ return $(this).closest('tr').data('parent-index') === self.closest('tr').data('group-index');
162
+ })
163
+ });
164
+ });
165
+
166
+ this.$container.off('click', '.groupBy').on('click', '.groupBy', function () {
156
167
  $(this).toggleClass('expanded');
157
- that.$body.find('tr[data-parent-index='+$(this).closest('tr').data('group-index')+']').toggleClass('hidden');
168
+ that.$body.find('tr[data-parent-index=' + $(this).closest('tr').data('group-index') + ']').toggleClass('hidden');
158
169
  });
159
170
 
160
- this.$container.off('click', '[name="btSelectGroup"]')
161
- .on('click', '[name="btSelectGroup"]', function (event) {
171
+ this.$container.off('click', '[name="btSelectGroup"]').on('click', '[name="btSelectGroup"]', function (event) {
162
172
  event.stopImmediatePropagation();
163
173
 
164
174
  var self = $(this);
165
175
  var checked = self.prop('checked');
166
176
  that[checked ? 'checkGroup' : 'uncheckGroup']($(this).closest('tr').data('group-index'));
167
177
  });
168
- }
178
+ }
169
179
 
170
- initBodyCaller = false;
171
- this.updateSelected();
172
- };
180
+ initBodyCaller = false;
181
+ this.updateSelected();
182
+ };
173
183
 
174
- BootstrapTable.prototype.updateSelected = function () {
175
- if (!initBodyCaller) {
176
- _updateSelected.apply(this, Array.prototype.slice.apply(arguments));
184
+ BootstrapTable.prototype.updateSelected = function () {
185
+ if (!initBodyCaller) {
186
+ _updateSelected.apply(this, Array.prototype.slice.apply(arguments));
177
187
 
178
- if ((this.options.groupBy) && (this.options.groupByField !== '')) {
179
- this.$selectGroup.forEach(function (item) {
180
- var checkGroup = item.item.filter(':enabled').length ===
181
- item.item.filter(':enabled').filter(':checked').length;
188
+ if (this.options.groupBy && this.options.groupByField !== '') {
189
+ this.$selectGroup.forEach(function (item) {
190
+ var checkGroup = item.item.filter(':enabled').length === item.item.filter(':enabled').filter(':checked').length;
182
191
 
183
- item.group.prop('checked', checkGroup);
184
- });
192
+ item.group.prop('checked', checkGroup);
193
+ });
194
+ }
185
195
  }
186
- }
187
- };
188
-
189
- BootstrapTable.prototype.getGroupSelections = function (index) {
190
- var that = this;
191
-
192
- return $.grep(this.data, function (row) {
193
- return (row[that.header.stateField] && (row._data['parent-index'] === index));
194
- });
195
- };
196
+ };
196
197
 
197
- BootstrapTable.prototype.checkGroup = function (index) {
198
- this.checkGroup_(index, true);
199
- };
198
+ BootstrapTable.prototype.getGroupSelections = function (index) {
199
+ var that = this;
200
200
 
201
- BootstrapTable.prototype.uncheckGroup = function (index) {
202
- this.checkGroup_(index, false);
203
- };
201
+ return $.grep(this.data, function (row) {
202
+ return row[that.header.stateField] && row._data['parent-index'] === index;
203
+ });
204
+ };
204
205
 
205
- BootstrapTable.prototype.checkGroup_ = function (index, checked) {
206
- var rows;
207
- var filter = function() {
208
- return ($(this).closest('tr').data('parent-index') === index);
206
+ BootstrapTable.prototype.checkGroup = function (index) {
207
+ this.checkGroup_(index, true);
209
208
  };
210
209
 
211
- if (!checked) {
212
- rows = this.getGroupSelections(index);
213
- }
210
+ BootstrapTable.prototype.uncheckGroup = function (index) {
211
+ this.checkGroup_(index, false);
212
+ };
214
213
 
215
- this.$selectItem.filter(filter).prop('checked', checked);
214
+ BootstrapTable.prototype.checkGroup_ = function (index, checked) {
215
+ var rows;
216
+ var filter = function filter() {
217
+ return $(this).closest('tr').data('parent-index') === index;
218
+ };
216
219
 
220
+ if (!checked) {
221
+ rows = this.getGroupSelections(index);
222
+ }
217
223
 
218
- this.updateRows();
219
- this.updateSelected();
220
- if (checked) {
221
- rows = this.getGroupSelections(index);
222
- }
223
- this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
224
- };
224
+ this.$selectItem.filter(filter).prop('checked', checked);
225
225
 
226
- }(jQuery);
226
+ this.updateRows();
227
+ this.updateSelected();
228
+ if (checked) {
229
+ rows = this.getGroupSelections(index);
230
+ }
231
+ this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
232
+ };
233
+ })(jQuery);
234
+ });
@@ -1,243 +1,257 @@
1
- /**
2
- * @author: Dennis Hernández
3
- * @webSite: http://djhvscf.github.io/Blog
4
- * @version: v1.1.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.bootstrapTableGroupBy = 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.1.0
20
+ */
8
21
 
9
- 'use strict';
22
+ !function ($) {
10
23
 
11
- var originalRowAttr,
12
- dataTTId = 'data-tt-id',
13
- dataTTParentId = 'data-tt-parent-id',
14
- obj = {},
15
- parentId = undefined;
24
+ 'use strict';
16
25
 
17
- var getParentRowId = function (that, id) {
18
- var parentRows = that.$body.find('tr').not('[' + 'data-tt-parent-id]');
26
+ var originalRowAttr,
27
+ dataTTId = 'data-tt-id',
28
+ dataTTParentId = 'data-tt-parent-id',
29
+ obj = {},
30
+ parentId = undefined;
19
31
 
20
- for (var i = 0; i < parentRows.length; i++) {
21
- if (i === id) {
22
- return $(parentRows[i]).attr('data-tt-id');
23
- }
24
- }
32
+ var getParentRowId = function getParentRowId(that, id) {
33
+ var parentRows = that.$body.find('tr').not('[' + 'data-tt-parent-id]');
25
34
 
26
- return undefined;
27
- };
35
+ for (var i = 0; i < parentRows.length; i++) {
36
+ if (i === id) {
37
+ return $(parentRows[i]).attr('data-tt-id');
38
+ }
39
+ }
28
40
 
29
- var sumData = function (that, data) {
30
- var sumRow = {};
31
- $.each(data, function (i, row) {
32
- if (!row.IsParent) {
33
- for (var prop in row) {
34
- if (!isNaN(parseFloat(row[prop]))) {
35
- if (that.columns[that.fieldsColumnsIndex[prop]].groupBySumGroup) {
36
- if (sumRow[prop] === undefined) {
37
- sumRow[prop] = 0;
41
+ return undefined;
42
+ };
43
+
44
+ var sumData = function sumData(that, data) {
45
+ var sumRow = {};
46
+ $.each(data, function (i, row) {
47
+ if (!row.IsParent) {
48
+ for (var prop in row) {
49
+ if (!isNaN(parseFloat(row[prop]))) {
50
+ if (that.columns[that.fieldsColumnsIndex[prop]].groupBySumGroup) {
51
+ if (sumRow[prop] === undefined) {
52
+ sumRow[prop] = 0;
53
+ }
54
+ sumRow[prop] += +row[prop];
38
55
  }
39
- sumRow[prop] += +row[prop];
40
56
  }
41
57
  }
42
58
  }
59
+ });
60
+ return sumRow;
61
+ };
62
+
63
+ var rowAttr = function rowAttr(row, index) {
64
+ //Call the User Defined Function
65
+ originalRowAttr.apply([row, index]);
66
+
67
+ obj[dataTTId.toString()] = index;
68
+
69
+ if (!row.IsParent) {
70
+ obj[dataTTParentId.toString()] = parentId === undefined ? index : parentId;
71
+ } else {
72
+ parentId = index;
73
+ delete obj[dataTTParentId.toString()];
43
74
  }
44
- });
45
- return sumRow;
46
- };
47
-
48
- var rowAttr = function (row, index) {
49
- //Call the User Defined Function
50
- originalRowAttr.apply([row, index]);
51
-
52
- obj[dataTTId.toString()] = index;
53
-
54
- if (!row.IsParent) {
55
- obj[dataTTParentId.toString()] = parentId === undefined ? index : parentId;
56
- } else {
57
- parentId = index;
58
- delete obj[dataTTParentId.toString()];
59
- }
60
-
61
- return obj;
62
- };
63
-
64
- var setObjectKeys = function () {
65
- // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
66
- Object.keys = function (o) {
67
- if (o !== Object(o)) {
68
- throw new TypeError('Object.keys called on a non-object');
75
+
76
+ return obj;
77
+ };
78
+
79
+ var setObjectKeys = function setObjectKeys() {
80
+ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
81
+ Object.keys = function (o) {
82
+ if (o !== Object(o)) {
83
+ throw new TypeError('Object.keys called on a non-object');
84
+ }
85
+ var k = [],
86
+ p;
87
+ for (p in o) {
88
+ if (Object.prototype.hasOwnProperty.call(o, p)) {
89
+ k.push(p);
90
+ }
91
+ }
92
+ return k;
93
+ };
94
+ };
95
+
96
+ var getDataArrayFromItem = function getDataArrayFromItem(that, item) {
97
+ var itemDataArray = [];
98
+ for (var i = 0; i < that.options.groupByField.length; i++) {
99
+ itemDataArray.push(item[that.options.groupByField[i]]);
69
100
  }
70
- var k = [],
71
- p;
72
- for (p in o) {
73
- if (Object.prototype.hasOwnProperty.call(o, p)) {
74
- k.push(p);
101
+
102
+ return itemDataArray;
103
+ };
104
+
105
+ var getNewRow = function getNewRow(that, result, index) {
106
+ var newRow = {};
107
+ for (var i = 0; i < that.options.groupByField.length; i++) {
108
+ newRow[that.options.groupByField[i].toString()] = result[index][0][that.options.groupByField[i]];
109
+ }
110
+
111
+ newRow.IsParent = true;
112
+
113
+ return newRow;
114
+ };
115
+
116
+ var groupBy = function groupBy(array, f) {
117
+ var groups = {};
118
+ $.each(array, function (i, o) {
119
+ var group = JSON.stringify(f(o));
120
+ groups[group] = groups[group] || [];
121
+ groups[group].push(o);
122
+ });
123
+ return Object.keys(groups).map(function (group) {
124
+ return groups[group];
125
+ });
126
+ };
127
+
128
+ var makeGrouped = function makeGrouped(that, data) {
129
+ var newData = [],
130
+ sumRow = {};
131
+
132
+ var result = groupBy(data, function (item) {
133
+ return getDataArrayFromItem(that, item);
134
+ });
135
+
136
+ for (var i = 0; i < result.length; i++) {
137
+ result[i].unshift(getNewRow(that, result, i));
138
+ if (that.options.groupBySumGroup) {
139
+ sumRow = sumData(that, result[i]);
140
+ if (!$.isEmptyObject(sumRow)) {
141
+ result[i].push(sumRow);
142
+ }
75
143
  }
76
144
  }
77
- return k;
78
- }
79
- };
80
-
81
- var getDataArrayFromItem = function (that, item) {
82
- var itemDataArray = [];
83
- for (var i = 0; i < that.options.groupByField.length; i++) {
84
- itemDataArray.push(item[that.options.groupByField[i]]);
85
- }
86
-
87
- return itemDataArray;
88
- };
89
-
90
- var getNewRow = function (that, result, index) {
91
- var newRow = {};
92
- for (var i = 0; i < that.options.groupByField.length; i++) {
93
- newRow[that.options.groupByField[i].toString()] = result[index][0][that.options.groupByField[i]];
94
- }
95
-
96
- newRow.IsParent = true;
97
-
98
- return newRow;
99
- };
100
-
101
- var groupBy = function (array, f) {
102
- var groups = {};
103
- $.each(array, function (i, o) {
104
- var group = JSON.stringify(f(o));
105
- groups[group] = groups[group] || [];
106
- groups[group].push(o);
107
- });
108
- return Object.keys(groups).map(function (group) {
109
- return groups[group];
145
+
146
+ newData = newData.concat.apply(newData, result);
147
+
148
+ if (!that.options.loaded && newData.length > 0) {
149
+ that.options.loaded = true;
150
+ that.options.originalData = that.options.data;
151
+ that.options.data = newData;
152
+ }
153
+
154
+ return newData;
155
+ };
156
+
157
+ $.extend($.fn.bootstrapTable.defaults, {
158
+ groupBy: false,
159
+ groupByField: [],
160
+ groupBySumGroup: false,
161
+ groupByInitExpanded: undefined, //node, 'all'
162
+ //internal variables
163
+ loaded: false,
164
+ originalData: undefined
110
165
  });
111
- };
112
166
 
113
- var makeGrouped = function (that, data) {
114
- var newData = [],
115
- sumRow = {};
167
+ $.fn.bootstrapTable.methods.push('collapseAll', 'expandAll', 'refreshGroupByField');
116
168
 
117
- var result = groupBy(data, function (item) {
118
- return getDataArrayFromItem(that, item);
169
+ $.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
170
+ groupBySumGroup: false
119
171
  });
120
172
 
121
- for (var i = 0; i < result.length; i++) {
122
- result[i].unshift(getNewRow(that, result, i));
123
- if (that.options.groupBySumGroup) {
124
- sumRow = sumData(that, result[i]);
125
- if (!$.isEmptyObject(sumRow)) {
126
- result[i].push(sumRow);
127
- }
128
- }
129
- }
130
-
131
- newData = newData.concat.apply(newData, result);
132
-
133
- if (!that.options.loaded && newData.length > 0) {
134
- that.options.loaded = true;
135
- that.options.originalData = that.options.data;
136
- that.options.data = newData;
137
- }
138
-
139
- return newData;
140
- };
141
-
142
- $.extend($.fn.bootstrapTable.defaults, {
143
- groupBy: false,
144
- groupByField: [],
145
- groupBySumGroup: false,
146
- groupByInitExpanded: undefined, //node, 'all'
147
- //internal variables
148
- loaded: false,
149
- originalData: undefined
150
- });
151
-
152
- $.fn.bootstrapTable.methods.push('collapseAll', 'expandAll', 'refreshGroupByField');
153
-
154
- $.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
155
- groupBySumGroup: false
156
- });
157
-
158
- var BootstrapTable = $.fn.bootstrapTable.Constructor,
159
- _init = BootstrapTable.prototype.init,
160
- _initData = BootstrapTable.prototype.initData;
161
-
162
- BootstrapTable.prototype.init = function () {
163
- //Temporal validation
164
- if (!this.options.sortName) {
165
- if ((this.options.groupBy) && (this.options.groupByField.length > 0)) {
166
- var that = this;
167
-
168
- // Compatibility: IE < 9 and old browsers
169
- if (!Object.keys) {
170
- $.fn.bootstrapTable.utils.objectKeys();
171
- }
173
+ var BootstrapTable = $.fn.bootstrapTable.Constructor,
174
+ _init = BootstrapTable.prototype.init,
175
+ _initData = BootstrapTable.prototype.initData;
176
+
177
+ BootstrapTable.prototype.init = function () {
178
+ //Temporal validation
179
+ if (!this.options.sortName) {
180
+ if (this.options.groupBy && this.options.groupByField.length > 0) {
181
+ var that = this;
182
+
183
+ // Compatibility: IE < 9 and old browsers
184
+ if (!Object.keys) {
185
+ $.fn.bootstrapTable.utils.objectKeys();
186
+ }
172
187
 
173
- //Make sure that the internal variables are set correctly
174
- this.options.loaded = false;
175
- this.options.originalData = undefined;
176
-
177
- originalRowAttr = this.options.rowAttributes;
178
- this.options.rowAttributes = rowAttr;
179
- this.$el.off('post-body.bs.table').on('post-body.bs.table', function () {
180
- that.$el.treetable({
181
- expandable: true,
182
- onNodeExpand: function () {
183
- if (that.options.height) {
184
- that.resetHeader();
188
+ //Make sure that the internal variables are set correctly
189
+ this.options.loaded = false;
190
+ this.options.originalData = undefined;
191
+
192
+ originalRowAttr = this.options.rowAttributes;
193
+ this.options.rowAttributes = rowAttr;
194
+ this.$el.off('post-body.bs.table').on('post-body.bs.table', function () {
195
+ that.$el.treetable({
196
+ expandable: true,
197
+ onNodeExpand: function onNodeExpand() {
198
+ if (that.options.height) {
199
+ that.resetHeader();
200
+ }
201
+ },
202
+ onNodeCollapse: function onNodeCollapse() {
203
+ if (that.options.height) {
204
+ that.resetHeader();
205
+ }
185
206
  }
186
- },
187
- onNodeCollapse: function () {
188
- if (that.options.height) {
189
- that.resetHeader();
207
+ }, true);
208
+
209
+ if (that.options.groupByInitExpanded !== undefined) {
210
+ if (typeof that.options.groupByInitExpanded === 'number') {
211
+ that.expandNode(that.options.groupByInitExpanded);
212
+ } else if (that.options.groupByInitExpanded.toLowerCase() === 'all') {
213
+ that.expandAll();
190
214
  }
191
215
  }
192
- }, true);
216
+ });
217
+ }
218
+ }
219
+ _init.apply(this, Array.prototype.slice.apply(arguments));
220
+ };
193
221
 
194
- if (that.options.groupByInitExpanded !== undefined) {
195
- if (typeof that.options.groupByInitExpanded === 'number') {
196
- that.expandNode(that.options.groupByInitExpanded);
197
- } else if (that.options.groupByInitExpanded.toLowerCase() === 'all') {
198
- that.expandAll();
199
- }
200
- }
201
- });
222
+ BootstrapTable.prototype.initData = function (data, type) {
223
+ //Temporal validation
224
+ if (!this.options.sortName) {
225
+ if (this.options.groupBy && this.options.groupByField.length > 0) {
226
+
227
+ this.options.groupByField = typeof this.options.groupByField === 'string' ? this.options.groupByField.replace('[', '').replace(']', '').replace(/ /g, '').toLowerCase().split(',') : this.options.groupByField;
228
+
229
+ data = makeGrouped(this, data ? data : this.options.data);
230
+ }
202
231
  }
203
- }
204
- _init.apply(this, Array.prototype.slice.apply(arguments));
205
- };
232
+ _initData.apply(this, [data, type]);
233
+ };
206
234
 
207
- BootstrapTable.prototype.initData = function (data, type) {
208
- //Temporal validation
209
- if (!this.options.sortName) {
210
- if ((this.options.groupBy) && (this.options.groupByField.length > 0)) {
235
+ BootstrapTable.prototype.expandAll = function () {
236
+ this.$el.treetable('expandAll');
237
+ };
211
238
 
212
- this.options.groupByField = typeof this.options.groupByField === 'string' ?
213
- this.options.groupByField.replace('[', '').replace(']', '')
214
- .replace(/ /g, '').toLowerCase().split(',') : this.options.groupByField;
239
+ BootstrapTable.prototype.collapseAll = function () {
240
+ this.$el.treetable('collapseAll');
241
+ };
242
+
243
+ BootstrapTable.prototype.expandNode = function (id) {
244
+ id = getParentRowId(this, id);
245
+ if (id !== undefined) {
246
+ this.$el.treetable('expandNode', id);
247
+ }
248
+ };
215
249
 
216
- data = makeGrouped(this, data ? data : this.options.data);
250
+ BootstrapTable.prototype.refreshGroupByField = function (groupByFields) {
251
+ if (!$.fn.bootstrapTable.utils.compareObjects(this.options.groupByField, groupByFields)) {
252
+ this.options.groupByField = groupByFields;
253
+ this.load(this.options.originalData);
217
254
  }
218
- }
219
- _initData.apply(this, [data, type]);
220
- };
221
-
222
- BootstrapTable.prototype.expandAll = function () {
223
- this.$el.treetable('expandAll');
224
- };
225
-
226
- BootstrapTable.prototype.collapseAll = function () {
227
- this.$el.treetable('collapseAll');
228
- };
229
-
230
- BootstrapTable.prototype.expandNode = function (id) {
231
- id = getParentRowId(this, id);
232
- if (id !== undefined) {
233
- this.$el.treetable('expandNode', id);
234
- }
235
- };
236
-
237
- BootstrapTable.prototype.refreshGroupByField = function (groupByFields) {
238
- if (!$.fn.bootstrapTable.utils.compareObjects(this.options.groupByField, groupByFields)) {
239
- this.options.groupByField = groupByFields;
240
- this.load(this.options.originalData);
241
- }
242
- };
243
- }(jQuery);
255
+ };
256
+ }(jQuery);
257
+ });