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,149 +1,145 @@
1
- (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.bootstrapTablePrint = mod.exports;
12
+ }
13
+ })(this, function () {
2
14
  'use strict';
3
15
 
4
- var sprintf = $.fn.bootstrapTable.utils.sprintf;
16
+ (function ($) {
17
+ 'use strict';
5
18
 
6
- function printPageBuilderDefault(table) {
7
- return '<html><head>' +
8
- '<style type="text/css" media="print">' +
9
- ' @page { size: auto; margin: 25px 0 25px 0; }' +
10
- '</style>' +
11
- '<style type="text/css" media="all">' +
12
- 'table{border-collapse: collapse; font-size: 12px; }\n' +
13
- 'table, th, td {border: 1px solid grey}\n' +
14
- 'th, td {text-align: center; vertical-align: middle;}\n' +
15
- 'p {font-weight: bold; margin-left:20px }\n' +
16
- 'table { width:94%; margin-left:3%; margin-right:3%}\n' +
17
- 'div.bs-table-print { text-align:center;}\n' +
18
- '</style></head><title>Print Table</title><body>' +
19
- '<p>Printed on: ' + new Date + ' </p>' +
20
- '<div class="bs-table-print">' + table + "</div></body></html>";
21
- }
22
- $.extend($.fn.bootstrapTable.defaults, {
23
- showPrint: false,
24
- printAsFilteredAndSortedOnUI: true, //boolean, when true - print table as sorted and filtered on UI.
25
- //Please note that if true is set, along with explicit predefined print options for filtering and sorting (printFilter, printSortOrder, printSortColumn)- then they will be applied on data already filtered and sorted by UI controls.
26
- //For printing data as filtered and sorted on UI - do not set these 3 options:printFilter, printSortOrder, printSortColumn
19
+ var sprintf = $.fn.bootstrapTable.utils.sprintf;
27
20
 
28
- printSortColumn: undefined , //String, set column field name to be sorted by
29
- printSortOrder: 'asc', //String: 'asc' , 'desc' - relevant only if printSortColumn is set
30
- printPageBuilder: function(table){return printPageBuilderDefault(table)} // function, receive html <table> element as string, returns html string for printing. by default delegates to function printPageBuilderDefault(table). used for styling and adding header or footer
31
- });
32
- $.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
33
- printFilter: undefined, //set value to filter by in print page
34
- printIgnore: false, //boolean, set true to ignore this column in the print page
35
- printFormatter:undefined //function(value, row, index), formats the cell value for this column in the printed table. Function behaviour is similar to the 'formatter' column option
21
+ function printPageBuilderDefault(table) {
22
+ return '<html><head>' + '<style type="text/css" media="print">' + ' @page { size: auto; margin: 25px 0 25px 0; }' + '</style>' + '<style type="text/css" media="all">' + 'table{border-collapse: collapse; font-size: 12px; }\n' + 'table, th, td {border: 1px solid grey}\n' + 'th, td {text-align: center; vertical-align: middle;}\n' + 'p {font-weight: bold; margin-left:20px }\n' + 'table { width:94%; margin-left:3%; margin-right:3%}\n' + 'div.bs-table-print { text-align:center;}\n' + '</style></head><title>Print Table</title><body>' + '<p>Printed on: ' + new Date() + ' </p>' + '<div class="bs-table-print">' + table + "</div></body></html>";
23
+ }
24
+ $.extend($.fn.bootstrapTable.defaults, {
25
+ showPrint: false,
26
+ printAsFilteredAndSortedOnUI: true, //boolean, when true - print table as sorted and filtered on UI.
27
+ //Please note that if true is set, along with explicit predefined print options for filtering and sorting (printFilter, printSortOrder, printSortColumn)- then they will be applied on data already filtered and sorted by UI controls.
28
+ //For printing data as filtered and sorted on UI - do not set these 3 options:printFilter, printSortOrder, printSortColumn
36
29
 
37
- });
38
- $.extend($.fn.bootstrapTable.defaults.icons, {
39
- print: 'glyphicon-print icon-share'
40
- });
30
+ printSortColumn: undefined, //String, set column field name to be sorted by
31
+ printSortOrder: 'asc', //String: 'asc' , 'desc' - relevant only if printSortColumn is set
32
+ printPageBuilder: function printPageBuilder(table) {
33
+ return printPageBuilderDefault(table);
34
+ } // function, receive html <table> element as string, returns html string for printing. by default delegates to function printPageBuilderDefault(table). used for styling and adding header or footer
35
+ });
36
+ $.extend($.fn.bootstrapTable.COLUMN_DEFAULTS, {
37
+ printFilter: undefined, //set value to filter by in print page
38
+ printIgnore: false, //boolean, set true to ignore this column in the print page
39
+ printFormatter: undefined //function(value, row, index), formats the cell value for this column in the printed table. Function behaviour is similar to the 'formatter' column option
41
40
 
42
- var BootstrapTable = $.fn.bootstrapTable.Constructor,
43
- _initToolbar = BootstrapTable.prototype.initToolbar;
41
+ });
42
+ $.extend($.fn.bootstrapTable.defaults.icons, {
43
+ print: 'glyphicon-print icon-share'
44
+ });
44
45
 
45
- BootstrapTable.prototype.initToolbar = function () {
46
- this.showToolbar = this.showToolbar || this.options.showPrint;
46
+ var BootstrapTable = $.fn.bootstrapTable.Constructor,
47
+ _initToolbar = BootstrapTable.prototype.initToolbar;
47
48
 
48
- _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
49
+ BootstrapTable.prototype.initToolbar = function () {
50
+ this.showToolbar = this.showToolbar || this.options.showPrint;
49
51
 
50
- if (this.options.showPrint) {
51
- var that = this,
52
- $btnGroup = this.$toolbar.find('>.btn-group'),
53
- $print = $btnGroup.find('button.bs-print');
52
+ _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
54
53
 
55
- if (!$print.length) {
56
- $print = $([
57
- '<button class="bs-print btn btn-default' + sprintf(' btn-%s"', this.options.iconSize) + ' name="print" title="print" type="button">',
58
- sprintf('<i class="%s %s"></i> ', this.options.iconsPrefix, this.options.icons.print),
59
- '</button>'].join('')).appendTo($btnGroup);
54
+ if (this.options.showPrint) {
55
+ var that = this,
56
+ $btnGroup = this.$toolbar.find('>.btn-group'),
57
+ $print = $btnGroup.find('button.bs-print');
60
58
 
61
- $print.click(function () {
62
- function formatValue(row, i, column ) {
63
- var value = row[column.field];
64
- if (typeof column.printFormatter === 'function') {
65
- return column.printFormatter.apply(column, [value, row, i]);
66
- }
67
- else {
68
- return typeof value === 'undefined' ? "-" : value;
59
+ if (!$print.length) {
60
+ $print = $(['<button class="bs-print btn btn-default' + sprintf(' btn-%s"', this.options.iconSize) + ' name="print" title="print" type="button">', sprintf('<i class="%s %s"></i> ', this.options.iconsPrefix, this.options.icons.print), '</button>'].join('')).appendTo($btnGroup);
61
+
62
+ $print.click(function () {
63
+ function formatValue(row, i, column) {
64
+ var value = row[column.field];
65
+ if (typeof column.printFormatter === 'function') {
66
+ return column.printFormatter.apply(column, [value, row, i]);
67
+ } else {
68
+ return typeof value === 'undefined' ? "-" : value;
69
+ }
69
70
  }
70
- }
71
71
 
72
- function buildTable(data, columnsArray) {
73
- var html = ['<table><thead>'];
74
- for (var k = 0; k < columnsArray.length; k++) {
75
- var columns = columnsArray[k];
76
- html.push('<tr>');
77
- for (var h = 0; h < columns.length; h++) {
78
- if (!columns[h].printIgnore) {
79
- html.push(
80
- '<th',
81
- sprintf(' rowspan="%s"', columns[h].rowspan),
82
- sprintf(' colspan="%s"', columns[h].colspan),
83
- sprintf('>%s</th>', columns[h].title)
84
- );
72
+ function buildTable(data, columnsArray) {
73
+ var html = ['<table><thead>'];
74
+ for (var k = 0; k < columnsArray.length; k++) {
75
+ var columns = columnsArray[k];
76
+ html.push('<tr>');
77
+ for (var h = 0; h < columns.length; h++) {
78
+ if (!columns[h].printIgnore) {
79
+ html.push('<th', sprintf(' rowspan="%s"', columns[h].rowspan), sprintf(' colspan="%s"', columns[h].colspan), sprintf('>%s</th>', columns[h].title));
80
+ }
85
81
  }
82
+ html.push('</tr>');
86
83
  }
87
- html.push('</tr>');
88
- }
89
- html.push('</thead><tbody>');
90
- for (var i = 0; i < data.length; i++) {
91
- html.push('<tr>');
92
- for(var l = 0; l < columnsArray.length; l++) {
93
- var columns = columnsArray[l];
94
- for(var j = 0; j < columns.length; j++) {
95
- if (!columns[j].printIgnore && columns[j].field) {
96
- html.push('<td>', formatValue(data[i], i, columns[j]), '</td>');
84
+ html.push('</thead><tbody>');
85
+ for (var i = 0; i < data.length; i++) {
86
+ html.push('<tr>');
87
+ for (var l = 0; l < columnsArray.length; l++) {
88
+ var columns = columnsArray[l];
89
+ for (var j = 0; j < columns.length; j++) {
90
+ if (!columns[j].printIgnore && columns[j].field) {
91
+ html.push('<td>', formatValue(data[i], i, columns[j]), '</td>');
92
+ }
97
93
  }
98
94
  }
95
+ html.push('</tr>');
99
96
  }
100
- html.push('</tr>');
97
+ html.push('</tbody></table>');
98
+ return html.join('');
101
99
  }
102
- html.push('</tbody></table>');
103
- return html.join('');
104
- }
105
- function sortRows(data,colName,sortOrder) {
106
- if(!colName){
107
- return data;
100
+ function sortRows(data, colName, sortOrder) {
101
+ if (!colName) {
102
+ return data;
103
+ }
104
+ var reverse = sortOrder != 'asc';
105
+ reverse = -(+reverse || -1);
106
+ return data.sort(function (a, b) {
107
+ return reverse * a[colName].localeCompare(b[colName]);
108
+ });
108
109
  }
109
- var reverse = sortOrder != 'asc';
110
- reverse = -((+reverse) || -1);
111
- return data.sort(function (a, b) {
112
- return reverse * (a[colName].localeCompare(b[colName]));
113
- });
114
- }
115
- function filterRow(row,filters) {
116
- for (var index = 0; index < filters.length; ++index) {
117
- if(row[filters[index].colName]!=filters[index].value) {
118
- return false;
110
+ function filterRow(row, filters) {
111
+ for (var index = 0; index < filters.length; ++index) {
112
+ if (row[filters[index].colName] != filters[index].value) {
113
+ return false;
114
+ }
119
115
  }
116
+ return true;
120
117
  }
121
- return true;
122
- }
123
- function filterRows(data,filters) {
124
- return data.filter(function (row) {
125
- return filterRow(row,filters)
126
- });
127
- }
128
- function getColumnFilters(columns) {
129
- return !columns || !columns[0] ? [] : columns[0].filter(function (col) {
130
- return col.printFilter;
131
- }).map(function (col) {
132
- return {colName:col.field, value:col.printFilter};
133
- });
134
- }
135
- var doPrint = function (data) {
136
- data=filterRows(data,getColumnFilters(that.options.columns));
137
- data=sortRows(data,that.options.printSortColumn,that.options.printSortOrder);
138
- var table=buildTable(data,that.options.columns);
139
- var newWin = window.open("");
140
- newWin.document.write(that.options.printPageBuilder.call(this, table));
141
- newWin.print();
142
- newWin.close();
143
- };
144
- doPrint(that.options.printAsFilteredAndSortedOnUI? that.getData() : that.options.data.slice(0));
145
- });
118
+ function filterRows(data, filters) {
119
+ return data.filter(function (row) {
120
+ return filterRow(row, filters);
121
+ });
122
+ }
123
+ function getColumnFilters(columns) {
124
+ return !columns || !columns[0] ? [] : columns[0].filter(function (col) {
125
+ return col.printFilter;
126
+ }).map(function (col) {
127
+ return { colName: col.field, value: col.printFilter };
128
+ });
129
+ }
130
+ var doPrint = function doPrint(data) {
131
+ data = filterRows(data, getColumnFilters(that.options.columns));
132
+ data = sortRows(data, that.options.printSortColumn, that.options.printSortOrder);
133
+ var table = buildTable(data, that.options.columns);
134
+ var newWin = window.open("");
135
+ newWin.document.write(that.options.printPageBuilder.call(this, table));
136
+ newWin.print();
137
+ newWin.close();
138
+ };
139
+ doPrint(that.options.printAsFilteredAndSortedOnUI ? that.getData() : that.options.data.slice(0));
140
+ });
141
+ }
146
142
  }
147
- }
148
- };
149
- })(jQuery);
143
+ };
144
+ })(jQuery);
145
+ });
@@ -1,181 +1,197 @@
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.bootstrapTableReorderColumns = 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
- //From MDN site, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
12
- var filterFn = function () {
13
- if (!Array.prototype.filter) {
14
- Array.prototype.filter = function(fun/*, thisArg*/) {
15
- 'use strict';
24
+ 'use strict';
16
25
 
17
- if (this === void 0 || this === null) {
18
- throw new TypeError();
19
- }
26
+ //From MDN site, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
20
27
 
21
- var t = Object(this);
22
- var len = t.length >>> 0;
23
- if (typeof fun !== 'function') {
24
- throw new TypeError();
25
- }
28
+ var filterFn = function filterFn() {
29
+ if (!Array.prototype.filter) {
30
+ Array.prototype.filter = function (fun /*, thisArg*/) {
31
+ 'use strict';
26
32
 
27
- var res = [];
28
- var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
29
- for (var i = 0; i < len; i++) {
30
- if (i in t) {
31
- var val = t[i];
32
-
33
- // NOTE: Technically this should Object.defineProperty at
34
- // the next index, as push can be affected by
35
- // properties on Object.prototype and Array.prototype.
36
- // But that method's new, and collisions should be
37
- // rare, so use the more-compatible alternative.
38
- if (fun.call(thisArg, val, i, t)) {
39
- res.push(val);
40
- }
33
+ if (this === void 0 || this === null) {
34
+ throw new TypeError();
41
35
  }
42
- }
43
36
 
44
- return res;
45
- };
46
- }
47
- };
48
-
49
- $.extend($.fn.bootstrapTable.defaults, {
50
- reorderableColumns: false,
51
- maxMovingRows: 10,
52
- onReorderColumn: function (headerFields) {
53
- return false;
54
- },
55
- dragaccept: null
56
- });
57
-
58
- $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
59
- 'reorder-column.bs.table': 'onReorderColumn'
60
- });
61
-
62
- var BootstrapTable = $.fn.bootstrapTable.Constructor,
63
- _initHeader = BootstrapTable.prototype.initHeader,
64
- _toggleColumn = BootstrapTable.prototype.toggleColumn,
65
- _toggleView = BootstrapTable.prototype.toggleView,
66
- _resetView = BootstrapTable.prototype.resetView;
67
-
68
- BootstrapTable.prototype.initHeader = function () {
69
- _initHeader.apply(this, Array.prototype.slice.apply(arguments));
70
-
71
- if (!this.options.reorderableColumns) {
72
- return;
73
- }
74
-
75
- this.makeRowsReorderable();
76
- };
77
-
78
- BootstrapTable.prototype.toggleColumn = function () {
79
- _toggleColumn.apply(this, Array.prototype.slice.apply(arguments));
80
-
81
- if (!this.options.reorderableColumns) {
82
- return;
83
- }
84
-
85
- this.makeRowsReorderable();
86
- };
87
-
88
- BootstrapTable.prototype.toggleView = function () {
89
- _toggleView.apply(this, Array.prototype.slice.apply(arguments));
90
-
91
- if (!this.options.reorderableColumns) {
92
- return;
93
- }
94
-
95
- if (this.options.cardView) {
96
- return;
97
- }
98
-
99
- this.makeRowsReorderable();
100
- };
101
-
102
- BootstrapTable.prototype.resetView = function () {
103
- _resetView.apply(this, Array.prototype.slice.apply(arguments));
104
-
105
- if (!this.options.reorderableColumns) {
106
- return;
107
- }
108
-
109
- this.makeRowsReorderable();
110
- };
111
-
112
- BootstrapTable.prototype.makeRowsReorderable = function () {
113
- var that = this;
114
- try {
115
- $(this.$el).dragtable('destroy');
116
- } catch (e) {}
117
- $(this.$el).dragtable({
118
- maxMovingRows: that.options.maxMovingRows,
119
- dragaccept: that.options.dragaccept,
120
- clickDelay:200,
121
- beforeStop: function() {
122
- var ths = [],
123
- formatters = [],
124
- columns = [],
125
- columnsHidden = [],
126
- columnIndex = -1,
127
- optionsColumns = [];
128
- that.$header.find('th').each(function (i) {
129
- ths.push($(this).data('field'));
130
- formatters.push($(this).data('formatter'));
131
- });
132
-
133
- //Exist columns not shown
134
- if (ths.length < that.columns.length) {
135
- columnsHidden = $.grep(that.columns, function (column) {
136
- return !column.visible;
137
- });
138
- for (var i = 0; i < columnsHidden.length; i++) {
139
- ths.push(columnsHidden[i].field);
140
- formatters.push(columnsHidden[i].formatter);
37
+ var t = Object(this);
38
+ var len = t.length >>> 0;
39
+ if (typeof fun !== 'function') {
40
+ throw new TypeError();
141
41
  }
142
- }
143
42
 
144
- for (var i = 0; i < this.length; i++ ) {
145
- columnIndex = that.fieldsColumnsIndex[ths[i]];
146
- if (columnIndex !== -1) {
147
- that.columns[columnIndex].fieldIndex = i;
148
- columns.push(that.columns[columnIndex]);
149
- that.columns.splice(columnIndex, 1);
43
+ var res = [];
44
+ var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
45
+ for (var i = 0; i < len; i++) {
46
+ if (i in t) {
47
+ var val = t[i];
48
+
49
+ // NOTE: Technically this should Object.defineProperty at
50
+ // the next index, as push can be affected by
51
+ // properties on Object.prototype and Array.prototype.
52
+ // But that method's new, and collisions should be
53
+ // rare, so use the more-compatible alternative.
54
+ if (fun.call(thisArg, val, i, t)) {
55
+ res.push(val);
56
+ }
57
+ }
150
58
  }
151
- }
152
59
 
153
- that.columns = that.columns.concat(columns);
154
-
155
- filterFn(); //Support <IE9
156
- $.each(that.columns, function(i, column) {
157
- var found = false,
158
- field = column.field;
159
- that.options.columns[0].filter(function(item) {
160
- if(!found && item["field"] == field) {
161
- optionsColumns.push(item);
162
- found = true;
163
- return false;
164
- } else
165
- return true;
166
- })
167
- });
168
-
169
- that.options.columns[0] = optionsColumns;
170
-
171
- that.header.fields = ths;
172
- that.header.formatters = formatters;
173
- that.initHeader();
174
- that.initToolbar();
175
- that.initBody();
176
- that.resetView();
177
- that.trigger('reorder-column', ths);
60
+ return res;
61
+ };
178
62
  }
63
+ };
64
+
65
+ $.extend($.fn.bootstrapTable.defaults, {
66
+ reorderableColumns: false,
67
+ maxMovingRows: 10,
68
+ onReorderColumn: function onReorderColumn(headerFields) {
69
+ return false;
70
+ },
71
+ dragaccept: null
72
+ });
73
+
74
+ $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
75
+ 'reorder-column.bs.table': 'onReorderColumn'
179
76
  });
180
- };
181
- }(jQuery);
77
+
78
+ var BootstrapTable = $.fn.bootstrapTable.Constructor,
79
+ _initHeader = BootstrapTable.prototype.initHeader,
80
+ _toggleColumn = BootstrapTable.prototype.toggleColumn,
81
+ _toggleView = BootstrapTable.prototype.toggleView,
82
+ _resetView = BootstrapTable.prototype.resetView;
83
+
84
+ BootstrapTable.prototype.initHeader = function () {
85
+ _initHeader.apply(this, Array.prototype.slice.apply(arguments));
86
+
87
+ if (!this.options.reorderableColumns) {
88
+ return;
89
+ }
90
+
91
+ this.makeRowsReorderable();
92
+ };
93
+
94
+ BootstrapTable.prototype.toggleColumn = function () {
95
+ _toggleColumn.apply(this, Array.prototype.slice.apply(arguments));
96
+
97
+ if (!this.options.reorderableColumns) {
98
+ return;
99
+ }
100
+
101
+ this.makeRowsReorderable();
102
+ };
103
+
104
+ BootstrapTable.prototype.toggleView = function () {
105
+ _toggleView.apply(this, Array.prototype.slice.apply(arguments));
106
+
107
+ if (!this.options.reorderableColumns) {
108
+ return;
109
+ }
110
+
111
+ if (this.options.cardView) {
112
+ return;
113
+ }
114
+
115
+ this.makeRowsReorderable();
116
+ };
117
+
118
+ BootstrapTable.prototype.resetView = function () {
119
+ _resetView.apply(this, Array.prototype.slice.apply(arguments));
120
+
121
+ if (!this.options.reorderableColumns) {
122
+ return;
123
+ }
124
+
125
+ this.makeRowsReorderable();
126
+ };
127
+
128
+ BootstrapTable.prototype.makeRowsReorderable = function () {
129
+ var that = this;
130
+ try {
131
+ $(this.$el).dragtable('destroy');
132
+ } catch (e) {}
133
+ $(this.$el).dragtable({
134
+ maxMovingRows: that.options.maxMovingRows,
135
+ dragaccept: that.options.dragaccept,
136
+ clickDelay: 200,
137
+ beforeStop: function beforeStop() {
138
+ var ths = [],
139
+ formatters = [],
140
+ columns = [],
141
+ columnsHidden = [],
142
+ columnIndex = -1,
143
+ optionsColumns = [];
144
+ that.$header.find('th').each(function (i) {
145
+ ths.push($(this).data('field'));
146
+ formatters.push($(this).data('formatter'));
147
+ });
148
+
149
+ //Exist columns not shown
150
+ if (ths.length < that.columns.length) {
151
+ columnsHidden = $.grep(that.columns, function (column) {
152
+ return !column.visible;
153
+ });
154
+ for (var i = 0; i < columnsHidden.length; i++) {
155
+ ths.push(columnsHidden[i].field);
156
+ formatters.push(columnsHidden[i].formatter);
157
+ }
158
+ }
159
+
160
+ for (var i = 0; i < this.length; i++) {
161
+ columnIndex = that.fieldsColumnsIndex[ths[i]];
162
+ if (columnIndex !== -1) {
163
+ that.columns[columnIndex].fieldIndex = i;
164
+ columns.push(that.columns[columnIndex]);
165
+ that.columns.splice(columnIndex, 1);
166
+ }
167
+ }
168
+
169
+ that.columns = that.columns.concat(columns);
170
+
171
+ filterFn(); //Support <IE9
172
+ $.each(that.columns, function (i, column) {
173
+ var found = false,
174
+ field = column.field;
175
+ that.options.columns[0].filter(function (item) {
176
+ if (!found && item["field"] == field) {
177
+ optionsColumns.push(item);
178
+ found = true;
179
+ return false;
180
+ } else return true;
181
+ });
182
+ });
183
+
184
+ that.options.columns[0] = optionsColumns;
185
+
186
+ that.header.fields = ths;
187
+ that.header.formatters = formatters;
188
+ that.initHeader();
189
+ that.initToolbar();
190
+ that.initBody();
191
+ that.resetView();
192
+ that.trigger('reorder-column', ths);
193
+ }
194
+ });
195
+ };
196
+ }(jQuery);
197
+ });