Skip to content

Commit 57df514

Browse files
committed
优化表格导出加载
兼容jQuery高版本 优化package.json依赖 优化Gruntfile.js
1 parent c26015f commit 57df514

File tree

11 files changed

+107
-84
lines changed

11 files changed

+107
-84
lines changed

Gruntfile.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ module.exports = function(grunt) {
77
// Project configuration.
88
grunt.initConfig({
99
// Metadata.
10-
pkg: grunt.file.readJSON('bootstrap-table.jquery.json'),
10+
pkg: grunt.file.readJSON('package.json'),
1111
banner: '/*\n' +
12-
'* <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
13-
'<%= pkg.homepage ? "* " + pkg.homepage : "" %>\n' +
14-
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
15-
'* Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
12+
'* bootstrap-table - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
13+
'https://github.com/wenzhixin/bootstrap-table\n' +
14+
'* Copyright (c) 2017 zhixin wen\n' +
15+
'* Licensed MIT License\n' +
1616
'*/\n',
1717
// Task configuration.
1818
clean: ['dist', 'docs/dist'],
1919
concat: {
2020
//basic_target: {
21-
// src: ['src/<%= pkg.name %>.js', 'src/extensions/**/*.js'],
22-
// dest: 'dist/<%= pkg.name %>-all.js'
21+
// src: ['src/bootstrap-table.js', 'src/extensions/**/*.js'],
22+
// dest: 'dist/bootstrap-table-all.js'
2323
//},
2424
locale_target: {
2525
src: ['src/locale/**/*.js'],
26-
dest: 'dist/<%= pkg.name %>-locale-all.js'
26+
dest: 'dist/bootstrap-table-locale-all.js'
2727
}
2828
},
2929
uglify: {
@@ -32,9 +32,9 @@ module.exports = function(grunt) {
3232
},
3333
basic_target: {
3434
files: {
35-
'dist/<%= pkg.name %>.min.js': ['src/<%=pkg.name %>.js'],
36-
//'dist/<%= pkg.name %>-all.min.js': ['dist/<%=pkg.name %>-all.js'],
37-
'dist/<%= pkg.name %>-locale-all.min.js': ['dist/<%=pkg.name %>-locale-all.js']
35+
'dist/bootstrap-table.min.js': ['src/bootstrap-table.js'],
36+
//'dist/bootstrap-table-all.min.js': ['dist/bootstrap-table-all.js'],
37+
'dist/bootstrap-table-locale-all.min.js': ['dist/bootstrap-table-locale-all.js']
3838
}
3939
},
4040
locale_target: {
@@ -62,7 +62,7 @@ module.exports = function(grunt) {
6262
banner: '<%= banner %>'
6363
},
6464
files: {
65-
'dist/<%= pkg.name %>.min.css': ['src/<%=pkg.name %>.css']
65+
'dist/bootstrap-table.min.css': ['src/bootstrap-table.css']
6666
}
6767
}
6868
},
@@ -79,12 +79,6 @@ module.exports = function(grunt) {
7979
dest: 'docs/dist', // destination folder
8080
expand: true // required when using cwd
8181
}
82-
},
83-
release: {
84-
options: {
85-
additionalFiles: ['bootstrap-table.jquery.json'],
86-
beforeRelease: ['docs', 'default']
87-
}
8882
}
8983
});
9084

@@ -126,7 +120,6 @@ module.exports = function(grunt) {
126120
grunt.loadNpmTasks('grunt-contrib-uglify');
127121
grunt.loadNpmTasks('grunt-contrib-cssmin');
128122
grunt.loadNpmTasks('grunt-contrib-copy');
129-
grunt.loadNpmTasks('grunt-release');
130123

131124
grunt.registerTask('default', ['clean', 'concat', 'uglify', 'cssmin', 'copy']);
132125
};

dist/bootstrap-table.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @author zhixin wen <[email protected]>
3-
* version: 1.11.8
3+
* version: 1.11.9
44
* https://github.com/wenzhixin/bootstrap-table/
55
*/
66

@@ -453,7 +453,7 @@
453453
return false;
454454
},
455455
onRefresh: function (params) {
456-
return false;
456+
return false;
457457
},
458458
onResetView: function () {
459459
return false;
@@ -881,10 +881,10 @@
881881

882882
this.$selectAll = this.$header.find('[name="btSelectAll"]');
883883
this.$selectAll.off('click').on('click', function () {
884-
var checked = $(this).prop('checked');
885-
that[checked ? 'checkAll' : 'uncheckAll']();
886-
that.updateSelected();
887-
});
884+
var checked = $(this).prop('checked');
885+
that[checked ? 'checkAll' : 'uncheckAll']();
886+
that.updateSelected();
887+
});
888888
};
889889

890890
BootstrapTable.prototype.initFooter = function () {
@@ -1064,37 +1064,37 @@
10641064

10651065
if (this.options.showPaginationSwitch) {
10661066
html.push(sprintf('<button class="btn' +
1067-
sprintf(' btn-%s', this.options.buttonsClass) +
1068-
sprintf(' btn-%s', this.options.iconSize) +
1069-
'" type="button" name="paginationSwitch" aria-label="pagination Switch" title="%s">',
1070-
this.options.formatPaginationSwitch()),
1067+
sprintf(' btn-%s', this.options.buttonsClass) +
1068+
sprintf(' btn-%s', this.options.iconSize) +
1069+
'" type="button" name="paginationSwitch" aria-label="pagination Switch" title="%s">',
1070+
this.options.formatPaginationSwitch()),
10711071
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.paginationSwitchDown),
10721072
'</button>');
10731073
}
10741074

10751075
if (this.options.showRefresh) {
10761076
html.push(sprintf('<button class="btn' +
1077-
sprintf(' btn-%s', this.options.buttonsClass) +
1078-
sprintf(' btn-%s', this.options.iconSize) +
1079-
'" type="button" name="refresh" aria-label="refresh" title="%s">',
1080-
this.options.formatRefresh()),
1077+
sprintf(' btn-%s', this.options.buttonsClass) +
1078+
sprintf(' btn-%s', this.options.iconSize) +
1079+
'" type="button" name="refresh" aria-label="refresh" title="%s">',
1080+
this.options.formatRefresh()),
10811081
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.refresh),
10821082
'</button>');
10831083
}
10841084

10851085
if (this.options.showToggle) {
10861086
html.push(sprintf('<button class="btn' +
1087-
sprintf(' btn-%s', this.options.buttonsClass) +
1088-
sprintf(' btn-%s', this.options.iconSize) +
1089-
'" type="button" name="toggle" aria-label="toggle" title="%s">',
1090-
this.options.formatToggle()),
1087+
sprintf(' btn-%s', this.options.buttonsClass) +
1088+
sprintf(' btn-%s', this.options.iconSize) +
1089+
'" type="button" name="toggle" aria-label="toggle" title="%s">',
1090+
this.options.formatToggle()),
10911091
sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.toggle),
10921092
'</button>');
10931093
}
10941094

10951095
if (this.options.showColumns) {
10961096
html.push(sprintf('<div class="keep-open btn-group" title="%s">',
1097-
this.options.formatColumns()),
1097+
this.options.formatColumns()),
10981098
'<button type="button" aria-label="columns" class="btn' +
10991099
sprintf(' btn-%s', this.options.buttonsClass) +
11001100
sprintf(' btn-%s', this.options.iconSize) +
@@ -1146,8 +1146,8 @@
11461146
if (this.options.showToggle) {
11471147
this.$toolbar.find('button[name="toggle"]')
11481148
.off('click').on('click', function () {
1149-
that.toggleView();
1150-
});
1149+
that.toggleView();
1150+
});
11511151
}
11521152

11531153
if (this.options.showColumns) {
@@ -1243,7 +1243,7 @@
12431243
this.data = f ? $.grep(this.options.data, function (item, i) {
12441244
for (var key in f) {
12451245
if ($.isArray(f[key]) && $.inArray(item[key], f[key]) === -1 ||
1246-
!$.isArray(f[key]) && item[key] !== f[key]) {
1246+
!$.isArray(f[key]) && item[key] !== f[key]) {
12471247
return false;
12481248
}
12491249
}
@@ -1351,27 +1351,27 @@
13511351
'<div class="pull-' + this.options.paginationDetailHAlign + ' pagination-detail">',
13521352
'<span class="pagination-info">',
13531353
this.options.onlyInfoPagination ? this.options.formatDetailPagination(this.options.totalRows) :
1354-
this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows),
1354+
this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows),
13551355
'</span>');
13561356

13571357
if (!this.options.onlyInfoPagination) {
13581358
html.push('<span class="page-list">');
13591359

13601360
var pageNumber = [
1361-
sprintf('<span class="btn-group %s">',
1362-
this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
1363-
'dropdown' : 'dropup'),
1364-
'<button type="button" class="btn' +
1365-
sprintf(' btn-%s', this.options.buttonsClass) +
1366-
sprintf(' btn-%s', this.options.iconSize) +
1367-
' dropdown-toggle" data-toggle="dropdown">',
1368-
'<span class="page-size">',
1369-
$allSelected ? this.options.formatAllRows() : this.options.pageSize,
1370-
'</span>',
1371-
' <span class="caret"></span>',
1372-
'</button>',
1373-
'<ul class="dropdown-menu" role="menu">'
1374-
];
1361+
sprintf('<span class="btn-group %s">',
1362+
this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
1363+
'dropdown' : 'dropup'),
1364+
'<button type="button" class="btn' +
1365+
sprintf(' btn-%s', this.options.buttonsClass) +
1366+
sprintf(' btn-%s', this.options.iconSize) +
1367+
' dropdown-toggle" data-toggle="dropdown">',
1368+
'<span class="page-size">',
1369+
$allSelected ? this.options.formatAllRows() : this.options.pageSize,
1370+
'</span>',
1371+
' <span class="caret"></span>',
1372+
'</button>',
1373+
'<ul class="dropdown-menu" role="menu">'
1374+
];
13751375

13761376
if (typeof this.options.pageList === 'string') {
13771377
var list = this.options.pageList.replace('[', '').replace(']', '')
@@ -1744,16 +1744,16 @@
17441744
type = column.radio ? 'radio' : type;
17451745

17461746
text = [sprintf(that.options.cardView ?
1747-
'<div class="card-view %s">' : '<td class="bs-checkbox %s">', column['class'] || ''),
1747+
'<div class="card-view %s">' : '<td class="bs-checkbox %s">', column['class'] || ''),
17481748
'<input' +
17491749
sprintf(' data-index="%s"', i) +
17501750
sprintf(' name="%s"', that.options.selectItemName) +
17511751
sprintf(' type="%s"', type) +
17521752
sprintf(' value="%s"', item[that.options.idField]) +
17531753
sprintf(' checked="%s"', value === true ||
1754-
(value_ || value && value.checked) ? 'checked' : undefined) +
1754+
(value_ || value && value.checked) ? 'checked' : undefined) +
17551755
sprintf(' disabled="%s"', !column.checkboxEnabled ||
1756-
(value && value.disabled) ? 'disabled' : undefined) +
1756+
(value && value.disabled) ? 'disabled' : undefined) +
17571757
' />',
17581758
that.header.formatters[j] && typeof value === 'string' ? value : '',
17591759
that.options.cardView ? '</div>' : '</td>'
@@ -1770,7 +1770,7 @@
17701770
sprintf('<span class="value">%s</span>', value),
17711771
'</div>'
17721772
].join('') : [sprintf('<td%s %s %s %s %s %s %s>',
1773-
id_, class_, style, data_, rowspan_, colspan_, title_),
1773+
id_, class_, style, data_, rowspan_, colspan_, title_),
17741774
value,
17751775
'</td>'
17761776
].join('');
@@ -1828,8 +1828,8 @@
18281828
if (!hasTr) {
18291829
trFragments.append('<tr class="no-records-found">' +
18301830
sprintf('<td colspan="%s">%s</td>',
1831-
this.$header.find('th').length,
1832-
this.options.formatNoMatches()) +
1831+
this.$header.find('th').length,
1832+
this.options.formatNoMatches()) +
18331833
'</tr>');
18341834
}
18351835

dist/bootstrap-table.min.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/extensions/export/bootstrap-table-export.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,16 @@
9393
$menu.find('li').click(function () {
9494
var type = $(this).data('type'),
9595
doExport = function () {
96-
that.$el.tableExport($.extend({}, that.options.exportOptions, {
97-
type: type,
98-
escape: false
99-
}));
96+
if (typeof require === 'function') {
97+
require(['tableexport'], function () {
98+
that.$el.tableExport($.extend({}, that.options.exportOptions, {
99+
type: type,
100+
escape: false
101+
}));
102+
});
103+
} else {
104+
throw new Error("RequireJS not found");
105+
}
100106
};
101107

102108
if (that.options.exportDataType === 'all' && that.options.pagination) {

dist/extensions/export/bootstrap-table-export.min.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/extensions/fixed-columns/bootstrap-table-fixed-columns.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@
120120
}
121121

122122
if (this.options.fixedNumber) {
123-
this.$tableContainer.find('.fixed-columns').size() == 0 && this.$tableContainer.append('<div class="fixed-columns"></div>');
123+
this.$tableContainer.find('.fixed-columns').length == 0 && this.$tableContainer.append('<div class="fixed-columns"></div>');
124124
this.$fixedColumns = this.$tableContainer.find('.fixed-columns');
125125
}
126126

127127
if (this.options.fixedRightNumber) {
128-
this.$tableContainer.find('.fixed-columns-right').size() == 0 && this.$tableContainer.append('<div class="fixed-columns-right"></div>');
128+
this.$tableContainer.find('.fixed-columns-right').length == 0 && this.$tableContainer.append('<div class="fixed-columns-right"></div>');
129129
this.$fixedColumnsRight = this.$tableContainer.find('.fixed-columns-right');
130130
}
131131
};

0 commit comments

Comments
 (0)