|
|
@@ -185,6 +185,7 @@
|
|
|
|
|
|
BootstrapTable.DEFAULTS = {
|
|
|
classes: 'table table-hover',
|
|
|
+ locale: undefined,
|
|
|
height: undefined,
|
|
|
undefinedText: '-',
|
|
|
sortName: undefined,
|
|
|
@@ -347,7 +348,7 @@
|
|
|
|
|
|
BootstrapTable.LOCALES = [];
|
|
|
|
|
|
- BootstrapTable.LOCALES['en-US'] = {
|
|
|
+ BootstrapTable.LOCALES['en-US'] = BootstrapTable.LOCALES['en'] = {
|
|
|
formatLoadingMessage: function () {
|
|
|
return 'Loading, please wait...';
|
|
|
},
|
|
|
@@ -439,6 +440,7 @@
|
|
|
};
|
|
|
|
|
|
BootstrapTable.prototype.init = function () {
|
|
|
+ this.initLocale();
|
|
|
this.initContainer();
|
|
|
this.initTable();
|
|
|
this.initHeader();
|
|
|
@@ -450,6 +452,24 @@
|
|
|
this.initServer();
|
|
|
};
|
|
|
|
|
|
+ BootstrapTable.prototype.initLocale = function () {
|
|
|
+ if (this.options.locale) {
|
|
|
+ var parts = this.options.locale.split(/-|_/);
|
|
|
+ parts[0].toLowerCase();
|
|
|
+ parts[1] && parts[1].toUpperCase();
|
|
|
+ if ($.fn.bootstrapTable.locales[this.options.locale]) {
|
|
|
+ // locale as requested
|
|
|
+ $.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale]);
|
|
|
+ } else if ($.fn.bootstrapTable.locales[parts.join('-')]) {
|
|
|
+ // locale with sep set to - (in case original was specified with _)
|
|
|
+ $.extend(this.options, $.fn.bootstrapTable.locales[parts.join('-')]);
|
|
|
+ } else if ($.fn.bootstrapTable.locales[parts[0]]) {
|
|
|
+ // short locale language code (i.e. 'en')
|
|
|
+ $.extend(this.options, $.fn.bootstrapTable.locales[parts[0]]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
BootstrapTable.prototype.initContainer = function () {
|
|
|
this.$container = $([
|
|
|
'<div class="bootstrap-table">',
|
|
|
@@ -1035,10 +1055,11 @@
|
|
|
this.options.pageSize = this.options.totalRows;
|
|
|
$allSelected = true;
|
|
|
} else if (this.options.pageSize === this.options.totalRows) {
|
|
|
- // Fix #667 Table with pagination, multiple pages and a search that matches to one page throws exception
|
|
|
+ // Fix #667 Table with pagination,
|
|
|
+ // multiple pages and a search that matches to one page throws exception
|
|
|
var pageLst = typeof this.options.pageList === 'string' ?
|
|
|
- this.options.pageList.replace('[', '').replace(']', '').replace(/ /g, '').toLowerCase().split(',') :
|
|
|
- this.options.pageList;
|
|
|
+ this.options.pageList.replace('[', '').replace(']', '')
|
|
|
+ .replace(/ /g, '').toLowerCase().split(',') : this.options.pageList;
|
|
|
if (pageLst.indexOf(this.options.formatAllRows().toLowerCase()) > -1) {
|
|
|
$allSelected = true;
|
|
|
}
|
|
|
@@ -1067,9 +1088,12 @@
|
|
|
html.push('<span class="page-list">');
|
|
|
|
|
|
var pageNumber = [
|
|
|
- sprintf('<span class="btn-group %s">', this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
|
|
|
+ sprintf('<span class="btn-group %s">',
|
|
|
+ this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
|
|
|
'dropdown' : 'dropup'),
|
|
|
- '<button type="button" class="btn btn-default ' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">',
|
|
|
+ '<button type="button" class="btn btn-default ' +
|
|
|
+ (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) +
|
|
|
+ ' dropdown-toggle" data-toggle="dropdown">',
|
|
|
'<span class="page-size">',
|
|
|
$allSelected ? this.options.formatAllRows() : this.options.pageSize,
|
|
|
'</span>',
|
|
|
@@ -1080,7 +1104,8 @@
|
|
|
pageList = this.options.pageList;
|
|
|
|
|
|
if (typeof this.options.pageList === 'string') {
|
|
|
- var list = this.options.pageList.replace('[', '').replace(']', '').replace(/ /g, '').split(',');
|
|
|
+ var list = this.options.pageList.replace('[', '').replace(']', '')
|
|
|
+ .replace(/ /g, '').split(',');
|
|
|
|
|
|
pageList = [];
|
|
|
$.each(list, function (i, value) {
|
|
|
@@ -1449,8 +1474,10 @@
|
|
|
// if click to select - then trigger the checkbox/radio click
|
|
|
if (e.type === 'click' && that.options.clickToSelect) {
|
|
|
if (that.header.clickToSelects[$tr.children().index($(this))]) {
|
|
|
- $tr.find(sprintf('[name="%s"]',
|
|
|
- that.options.selectItemName))[0].click(); // #144: .trigger('click') bug
|
|
|
+ var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
|
|
|
+ if ($selectItem.length) {
|
|
|
+ $selectItem[0].click(); // #144: .trigger('click') bug
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|