bootstrap-table-rails 1.12.2 → 1.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -12
- data/lib/bootstrap-table-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table-locale-all.js +2534 -1841
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table.css +202 -283
- data/vendor/assets/javascripts/bootstrap-table/bootstrap-table.js +3114 -2555
- data/vendor/assets/javascripts/bootstrap-table/extensions/accent-neutralise/bootstrap-table-accent-neutralise.js +247 -152
- data/vendor/assets/javascripts/bootstrap-table/extensions/addrbar/bootstrap-table-addrbar.js +271 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/auto-refresh/bootstrap-table-auto-refresh.js +77 -68
- data/vendor/assets/javascripts/bootstrap-table/extensions/cookie/bootstrap-table-cookie.js +452 -315
- data/vendor/assets/javascripts/bootstrap-table/extensions/copy-rows/bootstrap-table-copy-rows.js +105 -86
- data/vendor/assets/javascripts/bootstrap-table/extensions/defer-url/bootstrap-table-defer-url.js +44 -27
- data/vendor/assets/javascripts/bootstrap-table/extensions/editable/bootstrap-table-editable.js +229 -115
- data/vendor/assets/javascripts/bootstrap-table/extensions/export/bootstrap-table-export.js +319 -162
- data/vendor/assets/javascripts/bootstrap-table/extensions/filter-control/bootstrap-table-filter-control.js +733 -566
- data/vendor/assets/javascripts/bootstrap-table/extensions/group-by-v2/bootstrap-table-group-by.js +175 -167
- data/vendor/assets/javascripts/bootstrap-table/extensions/group-by/bootstrap-table-group-by.js +227 -213
- data/vendor/assets/javascripts/bootstrap-table/extensions/i18n-enhance/bootstrap-table-i18n-enhance.js +44 -29
- data/vendor/assets/javascripts/bootstrap-table/extensions/key-events/bootstrap-table-key-events.js +92 -70
- data/vendor/assets/javascripts/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js +134 -118
- data/vendor/assets/javascripts/bootstrap-table/extensions/multi-column-toggle/bootstrap-table-multi-toggle.js +92 -75
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-search/bootstrap-table-multiple-search.js +72 -58
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-selection-row/bootstrap-table-multiple-selection-row.js +129 -113
- data/vendor/assets/javascripts/bootstrap-table/extensions/multiple-sort/bootstrap-table-multiple-sort.js +362 -349
- data/vendor/assets/javascripts/bootstrap-table/extensions/natural-sorting/bootstrap-table-natural-sorting.js +66 -50
- data/vendor/assets/javascripts/bootstrap-table/extensions/{page-jumpto/bootstrap-table-jumpto.css → page-jump-to/bootstrap-table-page-jump-to.css} +0 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/page-jump-to/bootstrap-table-page-jump-to.js +58 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/pipeline/bootstrap-table-pipeline.js +341 -0
- data/vendor/assets/javascripts/bootstrap-table/extensions/print/bootstrap-table-print.js +122 -126
- data/vendor/assets/javascripts/bootstrap-table/extensions/reorder-columns/bootstrap-table-reorder-columns.js +183 -167
- data/vendor/assets/javascripts/bootstrap-table/extensions/reorder-rows/bootstrap-table-reorder-rows.js +124 -110
- data/vendor/assets/javascripts/bootstrap-table/extensions/resizable/bootstrap-table-resizable.js +66 -55
- data/vendor/assets/javascripts/bootstrap-table/extensions/select2-filter/bootstrap-table-select2-filter.js +281 -272
- data/vendor/assets/javascripts/bootstrap-table/extensions/sticky-header/bootstrap-table-sticky-header.css +13 -13
- data/vendor/assets/javascripts/bootstrap-table/extensions/sticky-header/bootstrap-table-sticky-header.js +182 -106
- data/vendor/assets/javascripts/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.js +324 -162
- data/vendor/assets/javascripts/bootstrap-table/extensions/tree-column/bootstrap-table-tree-column.js +127 -115
- data/vendor/assets/javascripts/bootstrap-table/extensions/treegrid/bootstrap-table-treegrid.js +106 -96
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-af-ZA.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ar-SA.js +49 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ca-ES.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-cs-CZ.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-da-DK.js +60 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-de-DE.js +61 -48
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-el-GR.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-en-US.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-AR.js +39 -26
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-CL.js +54 -41
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-CR.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-ES.js +103 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-MX.js +59 -46
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-NI.js +48 -35
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-es-SP.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-et-EE.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-eu-EU.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fa-IR.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fi-FI.js +62 -0
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fr-BE.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-fr-FR.js +103 -90
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-he-IL.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-hr-HR.js +52 -39
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-hu-HU.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-id-ID.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-it-IT.js +59 -47
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ja-JP.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ka-GE.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ko-KR.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ms-MY.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-nb-NO.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-nl-NL.js +60 -47
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pl-PL.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pt-BR.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-pt-PT.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ro-RO.js +51 -38
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ru-RU.js +82 -68
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-sk-SK.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-sv-SE.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-th-TH.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-tr-TR.js +49 -36
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-uk-UA.js +82 -69
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-ur-PK.js +45 -32
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-uz-Latn-UZ.js +57 -44
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-vi-VN.js +36 -23
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-zh-CN.js +54 -41
- data/vendor/assets/javascripts/bootstrap-table/locale/bootstrap-table-zh-TW.js +48 -35
- metadata +6 -8
- data/vendor/assets/javascripts/bootstrap-table/extensions/angular/bootstrap-table-angular.js +0 -107
- data/vendor/assets/javascripts/bootstrap-table/extensions/click-edit-row/bootstrap-table-click-edit-row.css +0 -21
- data/vendor/assets/javascripts/bootstrap-table/extensions/click-edit-row/bootstrap-table-click-edit-row.js +0 -142
- data/vendor/assets/javascripts/bootstrap-table/extensions/filter/bootstrap-table-filter.js +0 -67
- data/vendor/assets/javascripts/bootstrap-table/extensions/flat-json/bootstrap-table-flat-json.js +0 -62
- data/vendor/assets/javascripts/bootstrap-table/extensions/page-jumpto/bootstrap-table-jumpto.js +0 -50
@@ -1,88 +1,105 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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.bootstrapTableMultiToggle = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function () {
|
14
|
+
'use strict';
|
15
|
+
|
16
|
+
/**
|
17
|
+
* @author Homer Glascock <HopGlascock@gmail.com>
|
18
|
+
* @version: v1.0.0
|
19
|
+
*/
|
20
|
+
|
21
|
+
!function ($) {
|
22
|
+
"use strict";
|
23
|
+
|
24
|
+
var sprintf = $.fn.bootstrapTable.utils.sprintf;
|
25
|
+
|
26
|
+
var reInit = function reInit(self) {
|
27
|
+
self.initHeader();
|
28
|
+
self.initSearch();
|
29
|
+
self.initPagination();
|
30
|
+
self.initBody();
|
31
|
+
};
|
32
|
+
|
33
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
34
|
+
showToggleBtn: false,
|
35
|
+
multiToggleDefaults: [] //column names go here
|
36
|
+
});
|
29
37
|
|
30
|
-
|
38
|
+
$.fn.bootstrapTable.methods.push('hideAllColumns', 'showAllColumns');
|
31
39
|
|
32
|
-
var
|
33
|
-
|
40
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
41
|
+
_initToolbar = BootstrapTable.prototype.initToolbar;
|
34
42
|
|
35
|
-
|
36
|
-
this.options.multiToggleDefaults = JSON.parse(this.options.multiToggleDefaults);
|
37
|
-
}
|
43
|
+
BootstrapTable.prototype.initToolbar = function () {
|
38
44
|
|
39
|
-
|
40
|
-
var showbtn = "<button class='btn btn-default hidden' id='showAllBtn'><span class='glyphicon glyphicon-resize-full icon-zoom-in'></span></button>",
|
41
|
-
hidebtn = "<button class='btn btn-default' id='hideAllBtn'><span class='glyphicon glyphicon-resize-small icon-zoom-out'></span></button>";
|
45
|
+
_initToolbar.apply(this, Array.prototype.slice.apply(arguments));
|
42
46
|
|
43
|
-
|
47
|
+
var that = this,
|
48
|
+
$btnGroup = this.$toolbar.find('>.btn-group');
|
44
49
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
});
|
49
|
-
$btnGroup.find('#hideAllBtn').click(function () { that.hideAllColumns();
|
50
|
-
$btnGroup.find('#hideAllBtn').toggleClass('hidden');
|
51
|
-
$btnGroup.find('#showAllBtn').toggleClass('hidden');
|
52
|
-
});
|
53
|
-
}
|
54
|
-
};
|
55
|
-
|
56
|
-
BootstrapTable.prototype.hideAllColumns = function () {
|
57
|
-
var that = this,
|
58
|
-
defaults = that.options.multiToggleDefaults;
|
50
|
+
if (typeof this.options.multiToggleDefaults === 'string') {
|
51
|
+
this.options.multiToggleDefaults = JSON.parse(this.options.multiToggleDefaults);
|
52
|
+
}
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
54
|
+
if (this.options.showToggleBtn && this.options.showColumns) {
|
55
|
+
var showbtn = "<button class='btn btn-default hidden' id='showAllBtn'><span class='glyphicon glyphicon-resize-full icon-zoom-in'></span></button>",
|
56
|
+
hidebtn = "<button class='btn btn-default' id='hideAllBtn'><span class='glyphicon glyphicon-resize-small icon-zoom-out'></span></button>";
|
57
|
+
|
58
|
+
$btnGroup.append(showbtn + hidebtn);
|
59
|
+
|
60
|
+
$btnGroup.find('#showAllBtn').click(function () {
|
61
|
+
that.showAllColumns();
|
62
|
+
$btnGroup.find('#hideAllBtn').toggleClass('hidden');
|
63
|
+
$btnGroup.find('#showAllBtn').toggleClass('hidden');
|
64
|
+
});
|
65
|
+
$btnGroup.find('#hideAllBtn').click(function () {
|
66
|
+
that.hideAllColumns();
|
67
|
+
$btnGroup.find('#hideAllBtn').toggleClass('hidden');
|
68
|
+
$btnGroup.find('#showAllBtn').toggleClass('hidden');
|
69
|
+
});
|
66
70
|
}
|
67
|
-
}
|
71
|
+
};
|
72
|
+
|
73
|
+
BootstrapTable.prototype.hideAllColumns = function () {
|
74
|
+
var that = this,
|
75
|
+
defaults = that.options.multiToggleDefaults;
|
76
|
+
|
77
|
+
$.each(this.columns, function (index, column) {
|
78
|
+
//if its one of the defaults dont touch it
|
79
|
+
if (defaults.indexOf(column.field) == -1 && column.switchable) {
|
80
|
+
column.visible = false;
|
81
|
+
var $items = that.$toolbar.find('.keep-open input').prop('disabled', false);
|
82
|
+
$items.filter(sprintf('[value="%s"]', index)).prop('checked', false);
|
83
|
+
}
|
84
|
+
});
|
68
85
|
|
69
|
-
|
70
|
-
|
86
|
+
reInit(that);
|
87
|
+
};
|
71
88
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
89
|
+
BootstrapTable.prototype.showAllColumns = function () {
|
90
|
+
var that = this;
|
91
|
+
$.each(this.columns, function (index, column) {
|
92
|
+
if (column.switchable) {
|
93
|
+
column.visible = true;
|
94
|
+
}
|
78
95
|
|
79
|
-
|
80
|
-
|
81
|
-
|
96
|
+
var $items = that.$toolbar.find('.keep-open input').prop('disabled', false);
|
97
|
+
$items.filter(sprintf('[value="%s"]', index)).prop('checked', true);
|
98
|
+
});
|
82
99
|
|
83
|
-
|
100
|
+
reInit(that);
|
84
101
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
}
|
102
|
+
that.toggleColumn(0, that.columns[0].visible, false);
|
103
|
+
};
|
104
|
+
}(jQuery);
|
105
|
+
});
|
@@ -1,71 +1,85 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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.bootstrapTableMultipleSearch = mod.exports;
|
12
|
+
}
|
13
|
+
})(this, function () {
|
14
|
+
'use strict';
|
6
15
|
|
7
|
-
|
16
|
+
/**
|
17
|
+
* @author: Dennis Hernández
|
18
|
+
* @webSite: http://djhvscf.github.io/Blog
|
19
|
+
* @version: v1.0.0
|
20
|
+
*/
|
8
21
|
|
9
|
-
|
22
|
+
!function ($) {
|
10
23
|
|
11
|
-
|
12
|
-
multipleSearch: false,
|
13
|
-
delimeter: " "
|
14
|
-
});
|
24
|
+
'use strict';
|
15
25
|
|
16
|
-
|
17
|
-
|
26
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
27
|
+
multipleSearch: false,
|
28
|
+
delimeter: " "
|
29
|
+
});
|
18
30
|
|
19
|
-
|
20
|
-
|
21
|
-
if (this.searchText === undefined) {
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
var strArray = this.searchText.split(this.options.delimeter),
|
25
|
-
that = this,
|
26
|
-
f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns,
|
27
|
-
dataFiltered = [];
|
31
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
32
|
+
_initSearch = BootstrapTable.prototype.initSearch;
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
column = that.columns[that.fieldsColumnsIndex[key]],
|
39
|
-
j = $.inArray(key, that.header.fields);
|
34
|
+
BootstrapTable.prototype.initSearch = function () {
|
35
|
+
if (this.options.multipleSearch) {
|
36
|
+
if (this.searchText === undefined) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
var strArray = this.searchText.split(this.options.delimeter),
|
40
|
+
that = this,
|
41
|
+
f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns,
|
42
|
+
dataFiltered = [];
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
if (strArray.length === 1) {
|
45
|
+
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
46
|
+
} else {
|
47
|
+
for (var i = 0; i < strArray.length; i++) {
|
48
|
+
var str = strArray[i].trim();
|
49
|
+
dataFiltered = str ? $.grep(dataFiltered.length === 0 ? this.options.data : dataFiltered, function (item, i) {
|
50
|
+
for (var key in item) {
|
51
|
+
key = $.isNumeric(key) ? parseInt(key, 10) : key;
|
52
|
+
var value = item[key],
|
53
|
+
column = that.columns[that.fieldsColumnsIndex[key]],
|
54
|
+
j = $.inArray(key, that.header.fields);
|
46
55
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
if (
|
55
|
-
|
56
|
+
// Fix #142: search use formated data
|
57
|
+
if (column && column.searchFormatter) {
|
58
|
+
value = $.fn.bootstrapTable.utils.calculateObjectValue(column, that.header.formatters[j], [value, item, i], value);
|
59
|
+
}
|
60
|
+
|
61
|
+
var index = $.inArray(key, that.header.fields);
|
62
|
+
if (index !== -1 && that.header.searchables[index] && (typeof value === 'string' || typeof value === 'number')) {
|
63
|
+
if (that.options.strictSearch) {
|
64
|
+
if ((value + '').toLowerCase() === str) {
|
65
|
+
return true;
|
66
|
+
}
|
67
|
+
} else {
|
68
|
+
if ((value + '').toLowerCase().indexOf(str) !== -1) {
|
69
|
+
return true;
|
70
|
+
}
|
56
71
|
}
|
57
72
|
}
|
58
73
|
}
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
}
|
74
|
+
return false;
|
75
|
+
}) : this.data;
|
76
|
+
}
|
63
77
|
|
64
|
-
|
78
|
+
this.data = dataFiltered;
|
79
|
+
}
|
80
|
+
} else {
|
81
|
+
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
65
82
|
}
|
66
|
-
}
|
67
|
-
|
68
|
-
|
69
|
-
};
|
70
|
-
|
71
|
-
}(jQuery);
|
83
|
+
};
|
84
|
+
}(jQuery);
|
85
|
+
});
|
@@ -1,127 +1,143 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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.bootstrapTableMultipleSelectionRow = 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: v1.0.0
|
20
|
+
*/
|
21
|
+
|
22
|
+
!function ($) {
|
23
|
+
|
24
|
+
'use strict';
|
25
|
+
|
26
|
+
document.onselectstart = function () {
|
27
|
+
return false;
|
28
|
+
};
|
29
|
+
|
30
|
+
var getTableObjectFromCurrentTarget = function getTableObjectFromCurrentTarget(currentTarget) {
|
31
|
+
currentTarget = $(currentTarget);
|
32
|
+
return currentTarget.is("table") ? currentTarget : currentTarget.parents().find(".table");
|
33
|
+
};
|
34
|
+
|
35
|
+
var getRow = function getRow(target) {
|
36
|
+
target = $(target);
|
37
|
+
return target.parent().parent();
|
38
|
+
};
|
39
|
+
|
40
|
+
var onRowClick = function onRowClick(e) {
|
41
|
+
var that = getTableObjectFromCurrentTarget(e.currentTarget);
|
42
|
+
|
43
|
+
if (window.event.ctrlKey) {
|
35
44
|
toggleRow(e.currentTarget, that, false, false);
|
36
45
|
}
|
37
46
|
|
38
|
-
if (window.event.
|
39
|
-
|
47
|
+
if (window.event.button === 0) {
|
48
|
+
if (!window.event.ctrlKey && !window.event.shiftKey) {
|
49
|
+
clearAll(that);
|
50
|
+
toggleRow(e.currentTarget, that, false, false);
|
51
|
+
}
|
52
|
+
|
53
|
+
if (window.event.shiftKey) {
|
54
|
+
selectRowsBetweenIndexes([that.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow.rowIndex, e.currentTarget.rowIndex], that);
|
55
|
+
}
|
40
56
|
}
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
that.bootstrapTable("uncheck", row.data("index"));
|
56
|
-
} else {
|
57
|
-
that.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow = row;
|
58
|
-
row = $(row);
|
59
|
-
if (useShift) {
|
60
|
-
row.addClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
61
|
-
that.bootstrapTable("check", row.data("index"));
|
57
|
+
};
|
58
|
+
|
59
|
+
var onCheckboxChange = function onCheckboxChange(e) {
|
60
|
+
var that = getTableObjectFromCurrentTarget(e.currentTarget);
|
61
|
+
clearAll(that);
|
62
|
+
toggleRow(getRow(e.currentTarget), that, false, false);
|
63
|
+
};
|
64
|
+
|
65
|
+
var toggleRow = function toggleRow(row, that, clearAll, useShift) {
|
66
|
+
if (clearAll) {
|
67
|
+
row = $(row);
|
68
|
+
that.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow = undefined;
|
69
|
+
row.removeClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
70
|
+
that.bootstrapTable("uncheck", row.data("index"));
|
62
71
|
} else {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
} else {
|
72
|
+
that.bootstrapTable("getOptions").multipleSelectRowLastSelectedRow = row;
|
73
|
+
row = $(row);
|
74
|
+
if (useShift) {
|
67
75
|
row.addClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
68
|
-
that.bootstrapTable("check", row.data("index"));
|
76
|
+
that.bootstrapTable("check", row.data("index"));
|
77
|
+
} else {
|
78
|
+
if (row.hasClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass)) {
|
79
|
+
row.removeClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
80
|
+
that.bootstrapTable("uncheck", row.data("index"));
|
81
|
+
} else {
|
82
|
+
row.addClass(that.bootstrapTable("getOptions").multipleSelectRowCssClass);
|
83
|
+
that.bootstrapTable("check", row.data("index"));
|
84
|
+
}
|
69
85
|
}
|
70
86
|
}
|
71
|
-
}
|
72
|
-
|
87
|
+
};
|
88
|
+
|
89
|
+
var selectRowsBetweenIndexes = function selectRowsBetweenIndexes(indexes, that) {
|
90
|
+
indexes.sort(function (a, b) {
|
91
|
+
return a - b;
|
92
|
+
});
|
93
|
+
|
94
|
+
for (var i = indexes[0]; i <= indexes[1]; i++) {
|
95
|
+
toggleRow(that.bootstrapTable("getOptions").multipleSelectRowRows[i - 1], that, false, true);
|
96
|
+
}
|
97
|
+
};
|
73
98
|
|
74
|
-
|
75
|
-
|
76
|
-
|
99
|
+
var clearAll = function clearAll(that) {
|
100
|
+
for (var i = 0; i < that.bootstrapTable("getOptions").multipleSelectRowRows.length; i++) {
|
101
|
+
toggleRow(that.bootstrapTable("getOptions").multipleSelectRowRows[i], that, true, false);
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
$.extend($.fn.bootstrapTable.defaults, {
|
106
|
+
multipleSelectRow: false,
|
107
|
+
multipleSelectRowCssClass: 'multiple-select-row-selected',
|
108
|
+
//internal variables used by the extension
|
109
|
+
multipleSelectRowLastSelectedRow: undefined,
|
110
|
+
multipleSelectRowRows: []
|
77
111
|
});
|
78
112
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
_init = BootstrapTable.prototype.init,
|
100
|
-
_initBody = BootstrapTable.prototype.initBody;
|
101
|
-
|
102
|
-
BootstrapTable.prototype.init = function () {
|
103
|
-
if (this.options.multipleSelectRow) {
|
104
|
-
var that = this;
|
105
|
-
|
106
|
-
//Make sure that the internal variables have the correct value
|
107
|
-
this.options.multipleSelectRowLastSelectedRow = undefined;
|
108
|
-
this.options.multipleSelectRowRows = [];
|
109
|
-
|
110
|
-
this.$el.on("post-body.bs.table", function (e) {
|
111
|
-
setTimeout(function () {
|
112
|
-
that.options.multipleSelectRowRows = that.$body.children();
|
113
|
-
that.options.multipleSelectRowRows.click(onRowClick);
|
114
|
-
that.options.multipleSelectRowRows.find("input[type=checkbox]").change(onCheckboxChange);
|
115
|
-
}, 1);
|
116
|
-
});
|
117
|
-
}
|
113
|
+
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
114
|
+
_init = BootstrapTable.prototype.init,
|
115
|
+
_initBody = BootstrapTable.prototype.initBody;
|
116
|
+
|
117
|
+
BootstrapTable.prototype.init = function () {
|
118
|
+
if (this.options.multipleSelectRow) {
|
119
|
+
var that = this;
|
120
|
+
|
121
|
+
//Make sure that the internal variables have the correct value
|
122
|
+
this.options.multipleSelectRowLastSelectedRow = undefined;
|
123
|
+
this.options.multipleSelectRowRows = [];
|
124
|
+
|
125
|
+
this.$el.on("post-body.bs.table", function (e) {
|
126
|
+
setTimeout(function () {
|
127
|
+
that.options.multipleSelectRowRows = that.$body.children();
|
128
|
+
that.options.multipleSelectRowRows.click(onRowClick);
|
129
|
+
that.options.multipleSelectRowRows.find("input[type=checkbox]").change(onCheckboxChange);
|
130
|
+
}, 1);
|
131
|
+
});
|
132
|
+
}
|
118
133
|
|
119
|
-
|
120
|
-
|
134
|
+
_init.apply(this, Array.prototype.slice.apply(arguments));
|
135
|
+
};
|
121
136
|
|
122
|
-
|
123
|
-
|
124
|
-
|
137
|
+
BootstrapTable.prototype.clearAllMultipleSelectionRow = function () {
|
138
|
+
clearAll(this);
|
139
|
+
};
|
125
140
|
|
126
|
-
|
127
|
-
}(jQuery);
|
141
|
+
$.fn.bootstrapTable.methods.push('clearAllMultipleSelectionRow');
|
142
|
+
}(jQuery);
|
143
|
+
});
|