vendor/assets/javascripts/bootstrap-table/bootstrap-table.js in bootstrap-table-rails-1.17.1 vs vendor/assets/javascripts/bootstrap-table/bootstrap-table.js in bootstrap-table-rails-1.18.0
- old
+ new
@@ -1992,10 +1992,19 @@
// https://tc39.github.io/ecma262/#sec-parseint-string-radix
_export({ global: true, forced: parseInt != _parseInt }, {
parseInt: _parseInt
});
+ var MATCH = wellKnownSymbol('match');
+
+ // `IsRegExp` abstract operation
+ // https://tc39.github.io/ecma262/#sec-isregexp
+ var isRegexp = function (it) {
+ var isRegExp;
+ return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
+ };
+
// `RegExp.prototype.flags` getter implementation
// https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
var regexpFlags = function () {
var that = anObject(this);
var result = '';
@@ -2031,10 +2040,105 @@
var regexpStickyHelpers = {
UNSUPPORTED_Y: UNSUPPORTED_Y,
BROKEN_CARET: BROKEN_CARET
};
+ var SPECIES$3 = wellKnownSymbol('species');
+
+ var setSpecies = function (CONSTRUCTOR_NAME) {
+ var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
+ var defineProperty = objectDefineProperty.f;
+
+ if (descriptors && Constructor && !Constructor[SPECIES$3]) {
+ defineProperty(Constructor, SPECIES$3, {
+ configurable: true,
+ get: function () { return this; }
+ });
+ }
+ };
+
+ var defineProperty$5 = objectDefineProperty.f;
+ var getOwnPropertyNames$1 = objectGetOwnPropertyNames.f;
+
+
+
+
+
+ var setInternalState$2 = internalState.set;
+
+
+
+ var MATCH$1 = wellKnownSymbol('match');
+ var NativeRegExp = global_1.RegExp;
+ var RegExpPrototype = NativeRegExp.prototype;
+ var re1 = /a/g;
+ var re2 = /a/g;
+
+ // "new" should create a new object, old webkit bug
+ var CORRECT_NEW = new NativeRegExp(re1) !== re1;
+
+ var UNSUPPORTED_Y$1 = regexpStickyHelpers.UNSUPPORTED_Y;
+
+ var FORCED$4 = descriptors && isForced_1('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y$1 || fails(function () {
+ re2[MATCH$1] = false;
+ // RegExp constructor can alter flags and IsRegExp works correct with @@match
+ return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';
+ })));
+
+ // `RegExp` constructor
+ // https://tc39.github.io/ecma262/#sec-regexp-constructor
+ if (FORCED$4) {
+ var RegExpWrapper = function RegExp(pattern, flags) {
+ var thisIsRegExp = this instanceof RegExpWrapper;
+ var patternIsRegExp = isRegexp(pattern);
+ var flagsAreUndefined = flags === undefined;
+ var sticky;
+
+ if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {
+ return pattern;
+ }
+
+ if (CORRECT_NEW) {
+ if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;
+ } else if (pattern instanceof RegExpWrapper) {
+ if (flagsAreUndefined) flags = regexpFlags.call(pattern);
+ pattern = pattern.source;
+ }
+
+ if (UNSUPPORTED_Y$1) {
+ sticky = !!flags && flags.indexOf('y') > -1;
+ if (sticky) flags = flags.replace(/y/g, '');
+ }
+
+ var result = inheritIfRequired(
+ CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),
+ thisIsRegExp ? this : RegExpPrototype,
+ RegExpWrapper
+ );
+
+ if (UNSUPPORTED_Y$1 && sticky) setInternalState$2(result, { sticky: sticky });
+
+ return result;
+ };
+ var proxy = function (key) {
+ key in RegExpWrapper || defineProperty$5(RegExpWrapper, key, {
+ configurable: true,
+ get: function () { return NativeRegExp[key]; },
+ set: function (it) { NativeRegExp[key] = it; }
+ });
+ };
+ var keys$2 = getOwnPropertyNames$1(NativeRegExp);
+ var index = 0;
+ while (keys$2.length > index) proxy(keys$2[index++]);
+ RegExpPrototype.constructor = RegExpWrapper;
+ RegExpWrapper.prototype = RegExpPrototype;
+ redefine(global_1, 'RegExp', RegExpWrapper);
+ }
+
+ // https://tc39.github.io/ecma262/#sec-get-regexp-@@species
+ setSpecies('RegExp');
+
var nativeExec = RegExp.prototype.exec;
// This always refers to the native implementation, because the
// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
// which loads this file before patching the method.
var nativeReplace = String.prototype.replace;
@@ -2047,22 +2151,22 @@
nativeExec.call(re1, 'a');
nativeExec.call(re2, 'a');
return re1.lastIndex !== 0 || re2.lastIndex !== 0;
})();
- var UNSUPPORTED_Y$1 = regexpStickyHelpers.UNSUPPORTED_Y || regexpStickyHelpers.BROKEN_CARET;
+ var UNSUPPORTED_Y$2 = regexpStickyHelpers.UNSUPPORTED_Y || regexpStickyHelpers.BROKEN_CARET;
// nonparticipating capturing group, copied from es5-shim's String#split patch.
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
- var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1;
+ var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$2;
if (PATCH) {
patchedExec = function exec(str) {
var re = this;
var lastIndex, reCopy, match, i;
- var sticky = UNSUPPORTED_Y$1 && re.sticky;
+ var sticky = UNSUPPORTED_Y$2 && re.sticky;
var flags = regexpFlags.call(re);
var source = re.source;
var charsAdded = 0;
var strCopy = str;
@@ -2120,12 +2224,12 @@
_export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
exec: regexpExec
});
var TO_STRING = 'toString';
- var RegExpPrototype = RegExp.prototype;
- var nativeToString = RegExpPrototype[TO_STRING];
+ var RegExpPrototype$1 = RegExp.prototype;
+ var nativeToString = RegExpPrototype$1[TO_STRING];
var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
// FF44- RegExp#toString has a wrong name
var INCORRECT_NAME = nativeToString.name != TO_STRING;
@@ -2134,39 +2238,30 @@
if (NOT_GENERIC || INCORRECT_NAME) {
redefine(RegExp.prototype, TO_STRING, function toString() {
var R = anObject(this);
var p = String(R.source);
var rf = R.flags;
- var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? regexpFlags.call(R) : rf);
+ var f = String(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype$1) ? regexpFlags.call(R) : rf);
return '/' + p + '/' + f;
}, { unsafe: true });
}
- var MATCH = wellKnownSymbol('match');
-
- // `IsRegExp` abstract operation
- // https://tc39.github.io/ecma262/#sec-isregexp
- var isRegexp = function (it) {
- var isRegExp;
- return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
- };
-
var notARegexp = function (it) {
if (isRegexp(it)) {
throw TypeError("The method doesn't accept regular expressions");
} return it;
};
- var MATCH$1 = wellKnownSymbol('match');
+ var MATCH$2 = wellKnownSymbol('match');
var correctIsRegexpLogic = function (METHOD_NAME) {
var regexp = /./;
try {
'/./'[METHOD_NAME](regexp);
} catch (e) {
try {
- regexp[MATCH$1] = false;
+ regexp[MATCH$2] = false;
return '/./'[METHOD_NAME](regexp);
} catch (f) { /* empty */ }
} return false;
};
@@ -2207,17 +2302,17 @@
var charAt = stringMultibyte.charAt;
var STRING_ITERATOR = 'String Iterator';
- var setInternalState$2 = internalState.set;
+ var setInternalState$3 = internalState.set;
var getInternalState$2 = internalState.getterFor(STRING_ITERATOR);
// `String.prototype[@@iterator]` method
// https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
defineIterator(String, 'String', function (iterated) {
- setInternalState$2(this, {
+ setInternalState$3(this, {
type: STRING_ITERATOR,
string: String(iterated),
index: 0
});
// `%StringIteratorPrototype%.next` method
@@ -2231,11 +2326,11 @@
point = charAt(string, index);
state.index += point.length;
return { value: point, done: false };
});
- var SPECIES$3 = wellKnownSymbol('species');
+ var SPECIES$4 = wellKnownSymbol('species');
var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
// #replace needs built-in support for named groups.
// #match works fine because it just return the exec results, even if it has
// a "grops" property.
@@ -2285,11 +2380,11 @@
// https://github.com/zloirock/core-js/issues/306
re = {};
// RegExp[@@split] doesn't call the regex's exec method, but first creates
// a new one. We need to return the patched regex when creating the new one.
re.constructor = {};
- re.constructor[SPECIES$3] = function () { return re; };
+ re.constructor[SPECIES$4] = function () { return re; };
re.flags = '';
re[SYMBOL] = /./[SYMBOL];
}
re.exec = function () { execCalled = true; return null; };
@@ -2513,18 +2608,18 @@
return result === null ? -1 : result.index;
}
];
});
- var SPECIES$4 = wellKnownSymbol('species');
+ var SPECIES$5 = wellKnownSymbol('species');
// `SpeciesConstructor` abstract operation
// https://tc39.github.io/ecma262/#sec-speciesconstructor
var speciesConstructor = function (O, defaultConstructor) {
var C = anObject(O).constructor;
var S;
- return C === undefined || (S = anObject(C)[SPECIES$4]) == undefined ? defaultConstructor : aFunction$1(S);
+ return C === undefined || (S = anObject(C)[SPECIES$5]) == undefined ? defaultConstructor : aFunction$1(S);
};
var arrayPush = [].push;
var min$4 = Math.min;
var MAX_UINT32 = 0xFFFFFFFF;
@@ -2849,11 +2944,11 @@
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
- var VERSION = '1.17.1';
+ var VERSION = '1.18.0';
var bootstrapVersion = 4;
try {
var rawVersion = $.fn.dropdown.Constructor.VERSION; // Only try to parse VERSION if it is defined.
// It is undefined in older versions of Bootstrap (tested with 3.1.1).
@@ -3015,10 +3110,11 @@
}
}[bootstrapVersion];
var DEFAULTS = {
height: undefined,
classes: 'table table-bordered table-hover',
+ buttons: {},
theadClasses: '',
headerStyle: function headerStyle(column) {
return {};
},
rowStyle: function rowStyle(row, index) {
@@ -3059,10 +3155,11 @@
return res;
},
totalField: 'total',
totalNotFilteredField: 'totalNotFiltered',
dataField: 'rows',
+ footerField: 'footer',
pagination: false,
paginationParts: ['pageInfo', 'pageSize', 'pageList'],
showExtendedPagination: false,
paginationLoop: true,
sidePagination: 'client',
@@ -3085,12 +3182,14 @@
paginationPagesBySide: 1,
// Number of pages on each side (right, left) of the current page.
paginationUseIntermediate: false,
// Calculate intermediate pages for quick access
search: false,
+ searchHighlight: false,
searchOnEnterKey: false,
strictSearch: false,
+ searchSelector: false,
visibleSearch: false,
showButtonIcons: true,
showButtonText: false,
showSearchButton: false,
showSearchClearButton: false,
@@ -3344,14 +3443,15 @@
searchable: true,
formatter: undefined,
footerFormatter: undefined,
detailFormatter: undefined,
searchFormatter: true,
+ searchHighlightFormatter: false,
escape: false,
events: undefined
};
- var METHODS = ['getOptions', 'refreshOptions', 'getData', 'getSelections', 'getAllSelections', 'load', 'append', 'prepend', 'remove', 'removeAll', 'insertRow', 'updateRow', 'getRowByUniqueId', 'updateByUniqueId', 'removeByUniqueId', 'updateCell', 'updateCellByUniqueId', 'showRow', 'hideRow', 'getHiddenRows', 'showColumn', 'hideColumn', 'getVisibleColumns', 'getHiddenColumns', 'showAllColumns', 'hideAllColumns', 'mergeCells', 'checkAll', 'uncheckAll', 'checkInvert', 'check', 'uncheck', 'checkBy', 'uncheckBy', 'refresh', 'destroy', 'resetView', 'showLoading', 'hideLoading', 'togglePagination', 'toggleFullscreen', 'toggleView', 'resetSearch', 'filterBy', 'scrollTo', 'getScrollPosition', 'selectPage', 'prevPage', 'nextPage', 'toggleDetailView', 'expandRow', 'collapseRow', 'expandRowByUniqueId', 'collapseRowByUniqueId', 'expandAllRows', 'collapseAllRows', 'updateColumnTitle', 'updateFormatText'];
+ var METHODS = ['getOptions', 'refreshOptions', 'getData', 'getSelections', 'load', 'append', 'prepend', 'remove', 'removeAll', 'insertRow', 'updateRow', 'getRowByUniqueId', 'updateByUniqueId', 'removeByUniqueId', 'updateCell', 'updateCellByUniqueId', 'showRow', 'hideRow', 'getHiddenRows', 'showColumn', 'hideColumn', 'getVisibleColumns', 'getHiddenColumns', 'showAllColumns', 'hideAllColumns', 'mergeCells', 'checkAll', 'uncheckAll', 'checkInvert', 'check', 'uncheck', 'checkBy', 'uncheckBy', 'refresh', 'destroy', 'resetView', 'showLoading', 'hideLoading', 'togglePagination', 'toggleFullscreen', 'toggleView', 'resetSearch', 'filterBy', 'scrollTo', 'getScrollPosition', 'selectPage', 'prevPage', 'nextPage', 'toggleDetailView', 'expandRow', 'collapseRow', 'expandRowByUniqueId', 'collapseRowByUniqueId', 'expandAllRows', 'collapseAllRows', 'updateColumnTitle', 'updateFormatText'];
var EVENTS = {
'all.bs.table': 'onAll',
'click-row.bs.table': 'onClickRow',
'dbl-click-row.bs.table': 'onDblClickRow',
'click-cell.bs.table': 'onClickCell',
@@ -3468,10 +3568,17 @@
: that.slice(index, index + search.length) === search;
}
});
var Utils = {
+ getSearchInput: function getSearchInput(that) {
+ if (typeof that.options.searchSelector === 'string') {
+ return $(that.options.searchSelector);
+ }
+
+ return that.$toolbar.find('.search input');
+ },
// it only does '%s', and return '' when arguments are undefined
sprintf: function sprintf(_str) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
@@ -3490,10 +3597,13 @@
return arg;
});
return flag ? str : '';
},
+ isObject: function isObject(val) {
+ return val instanceof Object && !Array.isArray(val);
+ },
isEmptyObject: function isEmptyObject() {
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return Object.entries(obj).length === 0 && obj.constructor === Object;
},
isNumeric: function isNumeric(n) {
@@ -3587,17 +3697,15 @@
}
} else {
r.colspanGroup = r.colspan;
}
- for (var k = 0; k < rowspan; k++) {
- flag[_i + k][index] = true;
+ for (var _j = 0; _j < rowspan; _j++) {
+ for (var k = 0; k < colspan; k++) {
+ flag[_i + _j][index + k] = true;
+ }
}
-
- for (var _k = 0; _k < colspan; _k++) {
- flag[_i][index + _k] = true;
- }
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
@@ -3611,12 +3719,16 @@
}
}
}
}
},
- normalizeAccent: function normalizeAccent(string) {
- return string.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
+ normalizeAccent: function normalizeAccent(value) {
+ if (typeof value !== 'string') {
+ return value;
+ }
+
+ return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
},
updateFieldGroup: function updateFieldGroup(columns) {
var _ref;
var allColumns = (_ref = []).concat.apply(_ref, _toConsumableArray(columns));
@@ -3705,11 +3817,13 @@
this.cachedWidth = w1 - w2;
}
return this.cachedWidth;
},
- calculateObjectValue: function calculateObjectValue(self, name, args, defaultValue) {
+ calculateObjectValue: function calculateObjectValue(self, name) {
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
+ var defaultValue = arguments.length > 3 ? arguments[3] : undefined;
var func = name;
if (typeof name === 'string') {
// support obj.func1.func2
var names = name.split('.');
@@ -3877,18 +3991,21 @@
var _this = this;
var data = [];
var m = [];
$els.each(function (y, el) {
+ var $el = $(el);
var row = {}; // save tr's id, class and data-* attributes
- row._id = $(el).attr('id');
- row._class = $(el).attr('class');
- row._data = _this.getRealDataAttr($(el).data());
- $(el).find('>td,>th').each(function (_x, el) {
- var cspan = +$(el).attr('colspan') || 1;
- var rspan = +$(el).attr('rowspan') || 1;
+ row._id = $el.attr('id');
+ row._class = $el.attr('class');
+ row._data = _this.getRealDataAttr($el.data());
+ row._style = $el.attr('style');
+ $el.find('>td,>th').each(function (_x, el) {
+ var $el = $(el);
+ var cspan = +$el.attr('colspan') || 1;
+ var rspan = +$el.attr('rowspan') || 1;
var x = _x; // skip already occupied cells in current row
for (; m[y] && m[y][x]; x++) {} // ignore
// mark matrix elements occupied by current cell with true
@@ -3903,18 +4020,19 @@
m[ty][tx] = true;
}
}
var field = columns[x].field;
- row[field] = $(el).html().trim(); // save td's id, class and data-* attributes
+ row[field] = $el.html().trim(); // save td's id, class and data-* attributes
- row["_".concat(field, "_id")] = $(el).attr('id');
- row["_".concat(field, "_class")] = $(el).attr('class');
- row["_".concat(field, "_rowspan")] = $(el).attr('rowspan');
- row["_".concat(field, "_colspan")] = $(el).attr('colspan');
- row["_".concat(field, "_title")] = $(el).attr('title');
- row["_".concat(field, "_data")] = _this.getRealDataAttr($(el).data());
+ row["_".concat(field, "_id")] = $el.attr('id');
+ row["_".concat(field, "_class")] = $el.attr('class');
+ row["_".concat(field, "_rowspan")] = $el.attr('rowspan');
+ row["_".concat(field, "_colspan")] = $el.attr('colspan');
+ row["_".concat(field, "_title")] = $el.attr('title');
+ row["_".concat(field, "_data")] = _this.getRealDataAttr($el.data());
+ row["_".concat(field, "_style")] = $el.attr('style');
});
data.push(row);
});
return data;
},
@@ -3962,18 +4080,21 @@
return order * -1;
}
return order;
},
- getResizeEventName: function getResizeEventName() {
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
+ getEventName: function getEventName(eventPrefix) {
+ var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
id = id || "".concat(+new Date()).concat(~~(Math.random() * 1000000));
- return "resize.bootstrap-table-".concat(id);
+ return "".concat(eventPrefix, "-").concat(id);
},
hasDetailViewIcon: function hasDetailViewIcon(options) {
return options.detailView && options.detailViewIcon && !options.cardView;
},
+ getDetailViewIndexOffset: function getDetailViewIndexOffset(options) {
+ return this.hasDetailViewIcon(options) && options.detailViewAlign !== 'right' ? 1 : 0;
+ },
checkAutoMergeCells: function checkAutoMergeCells(data) {
var _iteratorNormalCompletion9 = true;
var _didIteratorError9 = false;
var _iteratorError9 = undefined;
@@ -4003,10 +4124,17 @@
}
}
}
return false;
+ },
+ deepCopy: function deepCopy(arg) {
+ if (arg === undefined) {
+ return arg;
+ }
+
+ return $.extend(true, Array.isArray(arg) ? [] : {}, arg);
}
};
var BLOCK_ROWS = 50;
var CLUSTER_BLOCKS = 4;
@@ -4169,11 +4297,10 @@
this.options = options;
this.$el = $(el);
this.$el_ = this.$el.clone();
this.timeoutId_ = 0;
this.timeoutFooter_ = 0;
- this.init();
}
_createClass(BootstrapTable, [{
key: "init",
value: function init() {
@@ -4196,10 +4323,11 @@
var opts = this.options;
this.constants = Constants.CONSTANTS;
this.constants.theme = $.fn.bootstrapTable.theme;
var buttonsPrefix = opts.buttonsPrefix ? "".concat(opts.buttonsPrefix, "-") : '';
this.constants.buttonsClass = [opts.buttonsPrefix, buttonsPrefix + opts.buttonsClass, Utils.sprintf("".concat(buttonsPrefix, "%s"), opts.iconSize)].join(' ').trim();
+ this.buttons = Utils.calculateObjectValue(this, opts.buttons, [], []);
}
}, {
key: "initLocale",
value: function initLocale() {
if (this.options.locale) {
@@ -4275,10 +4403,11 @@
} else if (this.options.theadClasses) {
this.$header.addClass(this.options.theadClasses);
}
this._headerTrClasses = [];
+ this._headerTrStyles = [];
this.$header.find('tr').each(function (i, el) {
var $tr = $(el);
var column = [];
$tr.find('th').each(function (i, el) {
var $th = $(el); // #2014: getFieldIndex and elsewhere assume this is string, causes issues if not
@@ -4298,10 +4427,14 @@
columns.push(column);
if ($tr.attr('class')) {
_this._headerTrClasses.push($tr.attr('class'));
}
+
+ if ($tr.attr('style')) {
+ _this._headerTrStyles.push($tr.attr('style'));
+ }
});
if (!Array.isArray(this.options.columns[0])) {
this.options.columns = [this.options.columns];
}
@@ -4330,11 +4463,13 @@
this.options.data = htmlData;
this.fromHtml = true;
}
}
- this.footerData = Utils.trToData(this.columns, this.$el.find('>tfoot>tr'));
+ if (!(this.options.pagination && this.options.sidePagination !== 'server')) {
+ this.footerData = Utils.trToData(this.columns, this.$el.find('>tfoot>tr'));
+ }
if (this.footerData) {
this.$el.find('tfoot').html('<tr></tr>');
}
@@ -4363,11 +4498,11 @@
cellStyles: [],
searchables: []
};
Utils.updateFieldGroup(this.options.columns);
this.options.columns.forEach(function (columns, i) {
- html.push("<tr".concat(Utils.sprintf(' class="%s"', _this2._headerTrClasses[i]), ">"));
+ html.push("<tr".concat(Utils.sprintf(' class="%s"', _this2._headerTrClasses[i]), " ").concat(Utils.sprintf(' style="%s"', _this2._headerTrStyles[i]), ">"));
var detailViewTemplate = '';
if (i === 0 && Utils.hasDetailViewIcon(_this2.options)) {
detailViewTemplate = "<th class=\"detail\" rowspan=\"".concat(_this2.options.columns.length, "\">\n <div class=\"fht-cell\"></div>\n </th>");
}
@@ -4493,11 +4628,11 @@
// Enter keycode
_this2.onSort(e);
}
}
});
- var resizeEvent = Utils.getResizeEventName(this.$el.attr('id'));
+ var resizeEvent = Utils.getEventName('resize.bootstrap-table', this.$el.attr('id'));
$(window).off(resizeEvent);
if (!this.options.showHeader || this.options.cardView) {
this.$header.hide();
this.$tableHeader.hide();
@@ -4529,11 +4664,11 @@
if (type === 'append') {
this.options.data = this.options.data.concat(data);
} else if (type === 'prepend') {
this.options.data = [].concat(data).concat(this.options.data);
} else {
- data = data || this.options.data;
+ data = data || Utils.deepCopy(this.options.data);
this.options.data = Array.isArray(data) ? data : data[this.options.dataField];
}
this.data = _toConsumableArray(this.options.data);
@@ -4677,77 +4812,168 @@
if (typeof opts.icons === 'string') {
opts.icons = Utils.calculateObjectValue(null, opts.icons);
}
- var buttonsHtml = {
- paginationSwitch: "<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"paginationSwitch\"\n aria-label=\"Pagination Switch\" title=\"").concat(opts.formatPaginationSwitch(), "\">\n ").concat(opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.paginationSwitchDown) : '', "\n ").concat(opts.showButtonText ? opts.formatPaginationSwitchUp() : '', "\n </button>"),
- refresh: "<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"refresh\"\n aria-label=\"Refresh\" title=\"").concat(opts.formatRefresh(), "\">\n ").concat(opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.refresh) : '', "\n ").concat(opts.showButtonText ? opts.formatRefresh() : '', "\n </button>"),
- toggle: "<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"toggle\"\n aria-label=\"Toggle\" title=\"").concat(opts.formatToggle(), "\">\n ").concat(opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.toggleOff) : '', "\n ").concat(opts.showButtonText ? opts.formatToggleOn() : '', "\n </button>"),
- fullscreen: "<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"fullscreen\"\n aria-label=\"Fullscreen\" title=\"").concat(opts.formatFullscreen(), "\">\n ").concat(opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.fullscreen) : '', "\n ").concat(opts.showButtonText ? opts.formatFullscreen() : '', "\n </button>"),
- columns: function () {
- var html = [];
- html.push("<div class=\"keep-open ".concat(_this4.constants.classes.buttonsDropdown, "\" title=\"").concat(opts.formatColumns(), "\">\n <button class=\"").concat(_this4.constants.buttonsClass, " dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\"\n aria-label=\"Columns\" title=\"").concat(opts.formatColumns(), "\">\n ").concat(opts.showButtonIcons ? Utils.sprintf(_this4.constants.html.icon, opts.iconsPrefix, opts.icons.columns) : '', "\n ").concat(opts.showButtonText ? opts.formatColumns() : '', "\n ").concat(_this4.constants.html.dropdownCaret, "\n </button>\n ").concat(_this4.constants.html.toolbarDropdown[0]));
+ if (typeof opts.buttonsOrder === 'string') {
+ opts.buttonsOrder = opts.buttonsOrder.replace(/\[|\]| |'/g, '').toLowerCase().split(',');
+ }
- if (opts.showColumnsSearch) {
- html.push(Utils.sprintf(_this4.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="text" class="%s" name="columnsSearch" placeholder="%s" autocomplete="off">', _this4.constants.classes.input, opts.formatSearch())));
- html.push(_this4.constants.html.toolbarDropdownSeparator);
+ this.buttons = Object.assign(this.buttons, {
+ paginationSwitch: {
+ text: opts.pagination ? opts.formatPaginationSwitchUp() : opts.formatPaginationSwitchDown(),
+ icon: opts.pagination ? opts.icons.paginationSwitchDown : opts.icons.paginationSwitchUp,
+ render: false,
+ event: this.togglePagination,
+ attributes: {
+ 'aria-label': opts.formatPaginationSwitch(),
+ title: opts.formatPaginationSwitch()
}
+ },
+ refresh: {
+ text: opts.formatRefresh(),
+ icon: opts.icons.refresh,
+ render: false,
+ event: this.refresh,
+ attributes: {
+ 'aria-label': opts.formatRefresh(),
+ title: opts.formatRefresh()
+ }
+ },
+ toggle: {
+ text: opts.formatToggle(),
+ icon: opts.icons.toggleOff,
+ render: false,
+ event: this.toggleView,
+ attributes: {
+ 'aria-label': opts.formatToggleOn(),
+ title: opts.formatToggleOn()
+ }
+ },
+ fullscreen: {
+ text: opts.formatFullscreen(),
+ icon: opts.icons.fullscreen,
+ render: false,
+ event: this.toggleFullscreen,
+ attributes: {
+ 'aria-label': opts.formatFullscreen(),
+ title: opts.formatFullscreen()
+ }
+ },
+ columns: {
+ render: false,
+ html: function html() {
+ var html = [];
+ html.push("<div class=\"keep-open ".concat(_this4.constants.classes.buttonsDropdown, "\" title=\"").concat(opts.formatColumns(), "\">\n <button class=\"").concat(_this4.constants.buttonsClass, " dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\"\n aria-label=\"Columns\" title=\"").concat(opts.formatColumns(), "\">\n ").concat(opts.showButtonIcons ? Utils.sprintf(_this4.constants.html.icon, opts.iconsPrefix, opts.icons.columns) : '', "\n ").concat(opts.showButtonText ? opts.formatColumns() : '', "\n ").concat(_this4.constants.html.dropdownCaret, "\n </button>\n ").concat(_this4.constants.html.toolbarDropdown[0]));
- if (opts.showColumnsToggleAll) {
- var allFieldsVisible = _this4.getVisibleColumns().length === _this4.columns.filter(function (column) {
- return !_this4.isSelectionColumn(column);
- }).length;
+ if (opts.showColumnsSearch) {
+ html.push(Utils.sprintf(_this4.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="text" class="%s" name="columnsSearch" placeholder="%s" autocomplete="off">', _this4.constants.classes.input, opts.formatSearch())));
+ html.push(_this4.constants.html.toolbarDropdownSeparator);
+ }
- html.push(Utils.sprintf(_this4.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="checkbox" class="toggle-all" %s> <span>%s</span>', allFieldsVisible ? 'checked="checked"' : '', opts.formatColumnsToggleAll())));
- html.push(_this4.constants.html.toolbarDropdownSeparator);
+ if (opts.showColumnsToggleAll) {
+ var allFieldsVisible = _this4.getVisibleColumns().length === _this4.columns.filter(function (column) {
+ return !_this4.isSelectionColumn(column);
+ }).length;
+
+ html.push(Utils.sprintf(_this4.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="checkbox" class="toggle-all" %s> <span>%s</span>', allFieldsVisible ? 'checked="checked"' : '', opts.formatColumnsToggleAll())));
+ html.push(_this4.constants.html.toolbarDropdownSeparator);
+ }
+
+ var visibleColumns = 0;
+
+ _this4.columns.forEach(function (column, i) {
+ if (column.visible) {
+ visibleColumns++;
+ }
+ });
+
+ _this4.columns.forEach(function (column, i) {
+ if (_this4.isSelectionColumn(column)) {
+ return;
+ }
+
+ if (opts.cardView && !column.cardVisible) {
+ return;
+ }
+
+ var checked = column.visible ? ' checked="checked"' : '';
+ var disabled = visibleColumns <= opts.minimumCountColumns && checked ? ' disabled="disabled"' : '';
+
+ if (column.switchable) {
+ html.push(Utils.sprintf(_this4.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="checkbox" data-field="%s" value="%s"%s%s> <span>%s</span>', column.field, i, checked, disabled, column.title)));
+ switchableCount++;
+ }
+ });
+
+ html.push(_this4.constants.html.toolbarDropdown[1], '</div>');
+ return html.join('');
}
+ }
+ });
+ var buttonsHtml = {};
- var visibleColumns = 0;
+ for (var _i2 = 0, _Object$entries2 = Object.entries(this.buttons); _i2 < _Object$entries2.length; _i2++) {
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
+ buttonName = _Object$entries2$_i[0],
+ buttonConfig = _Object$entries2$_i[1];
- _this4.columns.forEach(function (column, i) {
- if (column.visible) {
- visibleColumns++;
- }
- });
+ var buttonHtml = void 0;
- _this4.columns.forEach(function (column, i) {
- if (_this4.isSelectionColumn(column)) {
- return;
- }
+ if (buttonConfig.hasOwnProperty('html')) {
+ buttonHtml = Utils.calculateObjectValue(opts, buttonConfig.html);
+ } else {
+ buttonHtml = "<button class=\"".concat(this.constants.buttonsClass, "\" type=\"button\" name=\"").concat(buttonName, "\"");
- if (opts.cardView && !column.cardVisible) {
- return;
+ if (buttonConfig.hasOwnProperty('attributes')) {
+ for (var _i4 = 0, _Object$entries4 = Object.entries(buttonConfig.attributes); _i4 < _Object$entries4.length; _i4++) {
+ var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
+ attributeName = _Object$entries4$_i[0],
+ value = _Object$entries4$_i[1];
+
+ buttonHtml += " ".concat(attributeName, "=\"").concat(Utils.calculateObjectValue(opts, value), "\"");
}
+ }
- var checked = column.visible ? ' checked="checked"' : '';
- var disabled = visibleColumns <= _this4.options.minimumCountColumns && checked ? ' disabled="disabled"' : '';
+ buttonHtml += '>';
- if (column.switchable) {
- html.push(Utils.sprintf(_this4.constants.html.toolbarDropdownItem, Utils.sprintf('<input type="checkbox" data-field="%s" value="%s"%s%s> <span>%s</span>', column.field, i, checked, disabled, column.title)));
- switchableCount++;
- }
- });
+ if (opts.showButtonIcons && buttonConfig.hasOwnProperty('icon')) {
+ var icon = Utils.calculateObjectValue(opts, buttonConfig.icon);
+ buttonHtml += Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, icon) + ' ';
+ }
- html.push(_this4.constants.html.toolbarDropdown[1], '</div>');
- return html.join('');
- }()
- };
+ if (opts.showButtonText && buttonConfig.hasOwnProperty('text')) {
+ buttonHtml += Utils.calculateObjectValue(opts, buttonConfig.text);
+ }
- if (typeof opts.buttonsOrder === 'string') {
- opts.buttonsOrder = opts.buttonsOrder.replace(/\[|\]| |'/g, '').toLowerCase().split(',');
- }
+ buttonHtml += '</button>';
+ }
+ buttonsHtml[buttonName] = buttonHtml;
+ var optionName = "show".concat(buttonName.charAt(0).toUpperCase()).concat(buttonName.substring(1));
+ var showOption = opts[optionName];
+
+ if ((!buttonConfig.hasOwnProperty('render') || buttonConfig.hasOwnProperty('render') && buttonConfig.render) && (showOption === undefined || showOption === true)) {
+ opts[optionName] = true;
+ }
+
+ if (!opts.buttonsOrder.includes(buttonName)) {
+ opts.buttonsOrder.push(buttonName);
+ }
+ } // Adding the button html to the final toolbar html when the showOption is true
+
+
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = opts.buttonsOrder[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var button = _step.value;
+ var _showOption = opts["show".concat(button.charAt(0).toUpperCase()).concat(button.substring(1))];
- if (opts['show' + button.charAt(0).toUpperCase() + button.substring(1)]) {
+ if (_showOption) {
html.push(buttonsHtml[button]);
}
}
} catch (err) {
_didIteratorError = true;
@@ -4768,32 +4994,46 @@
if (this.showToolbar || html.length > 2) {
this.$toolbar.append(html.join(''));
}
- if (opts.showPaginationSwitch) {
- this.$toolbar.find('button[name="paginationSwitch"]').off('click').on('click', function () {
- return _this4.togglePagination();
- });
- }
+ for (var _i3 = 0, _Object$entries3 = Object.entries(this.buttons); _i3 < _Object$entries3.length; _i3++) {
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
+ _buttonName = _Object$entries3$_i[0],
+ _buttonConfig = _Object$entries3$_i[1];
- if (opts.showFullscreen) {
- this.$toolbar.find('button[name="fullscreen"]').off('click').on('click', function () {
- return _this4.toggleFullscreen();
- });
- }
+ if (_buttonConfig.hasOwnProperty('event')) {
+ if (typeof _buttonConfig.event === 'function' || typeof _buttonConfig.event === 'string') {
+ var _ret = function () {
+ var event = typeof _buttonConfig.event === 'string' ? window[_buttonConfig.event] : _buttonConfig.event;
- if (opts.showRefresh) {
- this.$toolbar.find('button[name="refresh"]').off('click').on('click', function () {
- return _this4.refresh();
- });
- }
+ _this4.$toolbar.find("button[name=\"".concat(_buttonName, "\"]")).off('click').on('click', function () {
+ return event.call(_this4);
+ });
- if (opts.showToggle) {
- this.$toolbar.find('button[name="toggle"]').off('click').on('click', function () {
- _this4.toggleView();
- });
+ return "continue";
+ }();
+
+ if (_ret === "continue") continue;
+ }
+
+ var _loop = function _loop() {
+ var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2),
+ eventType = _Object$entries5$_i[0],
+ eventFunction = _Object$entries5$_i[1];
+
+ var event = typeof eventFunction === 'string' ? window[eventFunction] : eventFunction;
+
+ _this4.$toolbar.find("button[name=\"".concat(_buttonName, "\"]")).off(eventType).on(eventType, function () {
+ return event.call(_this4);
+ });
+ };
+
+ for (var _i5 = 0, _Object$entries5 = Object.entries(_buttonConfig.event); _i5 < _Object$entries5.length; _i5++) {
+ _loop();
+ }
+ }
}
if (opts.showColumns) {
$keepOpen = this.$toolbar.find('.keep-open');
var $checkboxes = $keepOpen.find('input[type="checkbox"]:not(".toggle-all")');
@@ -4841,51 +5081,51 @@
$listItem.hide();
}
});
});
}
- } // Fix #4516: this.showSearchClearButton is for extensions
+ }
+ var handleInputEvent = function handleInputEvent($searchInput) {
+ var eventTriggers = 'keyup drop blur mouseup';
+ $searchInput.off(eventTriggers).on(eventTriggers, function (event) {
+ if (opts.searchOnEnterKey && event.keyCode !== 13) {
+ return;
+ }
- if (opts.search || this.showSearchClearButton) {
+ if ([37, 38, 39, 40].includes(event.keyCode)) {
+ return;
+ }
+
+ clearTimeout(timeoutId); // doesn't matter if it's 0
+
+ timeoutId = setTimeout(function () {
+ _this4.onSearch({
+ currentTarget: event.currentTarget
+ });
+ }, opts.searchTimeOut);
+ });
+ }; // Fix #4516: this.showSearchClearButton is for extensions
+
+
+ if ((opts.search || this.showSearchClearButton) && typeof opts.searchSelector !== 'string') {
html = [];
var showSearchButton = Utils.sprintf(this.constants.html.searchButton, this.constants.buttonsClass, opts.formatSearch(), opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.search) : '', opts.showButtonText ? opts.formatSearch() : '');
var showSearchClearButton = Utils.sprintf(this.constants.html.searchClearButton, this.constants.buttonsClass, opts.formatClearSearch(), opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.clearSearch) : '', opts.showButtonText ? opts.formatClearSearch() : '');
- var searchInputHtml = "<input class=\"".concat(this.constants.classes.input, "\n ").concat(Utils.sprintf(' %s%s', this.constants.classes.inputPrefix, opts.iconSize), "\n search-input\" type=\"text\" placeholder=\"").concat(opts.formatSearch(), "\" autocomplete=\"off\">");
+ var searchInputHtml = "<input class=\"".concat(this.constants.classes.input, "\n ").concat(Utils.sprintf(' %s%s', this.constants.classes.inputPrefix, opts.iconSize), "\n search-input\" type=\"search\" placeholder=\"").concat(opts.formatSearch(), "\" autocomplete=\"off\">");
var searchInputFinalHtml = searchInputHtml;
if (opts.showSearchButton || opts.showSearchClearButton) {
var _buttonsHtml = (opts.showSearchButton ? showSearchButton : '') + (opts.showSearchClearButton ? showSearchClearButton : '');
searchInputFinalHtml = opts.search ? Utils.sprintf(this.constants.html.inputGroup, searchInputHtml, _buttonsHtml) : _buttonsHtml;
}
html.push(Utils.sprintf("\n <div class=\"".concat(this.constants.classes.pull, "-").concat(opts.searchAlign, " search ").concat(this.constants.classes.inputGroup, "\">\n %s\n </div>\n "), searchInputFinalHtml));
this.$toolbar.append(html.join(''));
- var $searchInput = this.$toolbar.find('.search input');
+ var $searchInput = Utils.getSearchInput(this);
- var handleInputEvent = function handleInputEvent() {
- var eventTriggers = "keyup drop blur ".concat(Utils.isIEBrowser() ? 'mouseup' : '');
- $searchInput.off(eventTriggers).on(eventTriggers, function (event) {
- if (opts.searchOnEnterKey && event.keyCode !== 13) {
- return;
- }
-
- if ([37, 38, 39, 40].includes(event.keyCode)) {
- return;
- }
-
- clearTimeout(timeoutId); // doesn't matter if it's 0
-
- timeoutId = setTimeout(function () {
- _this4.onSearch({
- currentTarget: event.currentTarget
- });
- }, opts.searchTimeOut);
- });
- };
-
if (opts.showSearchButton) {
this.$toolbar.find('.search button[name=search]').off('click').on('click', function (event) {
clearTimeout(timeoutId); // doesn't matter if it's 0
timeoutId = setTimeout(function () {
@@ -4894,21 +5134,25 @@
});
}, opts.searchTimeOut);
});
if (opts.searchOnEnterKey) {
- handleInputEvent();
+ handleInputEvent($searchInput);
}
} else {
- handleInputEvent();
+ handleInputEvent($searchInput);
}
if (opts.showSearchClearButton) {
this.$toolbar.find('.search button[name=clearSearch]').click(function () {
_this4.resetSearch();
});
}
+ } else if (typeof opts.searchSelector === 'string') {
+ var _$searchInput = Utils.getSearchInput(this);
+
+ handleInputEvent(_$searchInput);
}
}
}, {
key: "onSearch",
value: function onSearch() {
@@ -4923,15 +5167,15 @@
if (this.options.trimOnSearch && $(currentTarget).val() !== text) {
$(currentTarget).val(text);
}
- if (this.searchText === text && text.length > 0) {
+ if (this.searchText === text) {
return;
}
- if ($(currentTarget).hasClass('search-input')) {
+ if (currentTarget === Utils.getSearchInput(this)[0] || $(currentTarget).hasClass('search-input')) {
this.searchText = text;
this.options.searchText = text;
}
}
@@ -4959,10 +5203,15 @@
this.filterOptions = this.filterOptions || this.options.filterOptions;
if (this.options.sidePagination !== 'server') {
if (this.options.customSearch) {
this.data = Utils.calculateObjectValue(this.options, this.options.customSearch, [this.options.data, this.searchText, this.filterColumns]);
+
+ if (this.options.sortReset) {
+ this.unsortedData = _toConsumableArray(this.data);
+ }
+
return;
}
var s = this.searchText && (this.fromHtml ? Utils.escapeHTML(this.searchText) : this.searchText).toLowerCase();
var f = Utils.isEmptyObject(this.filterColumns) ? null : this.filterColumns; // Check filter
@@ -5010,13 +5259,13 @@
if (typeof key === 'string') {
value = item;
var props = key.split('.');
- for (var _i2 = 0; _i2 < props.length; _i2++) {
- if (value[props[_i2]] !== null) {
- value = value[props[_i2]];
+ for (var _i6 = 0; _i6 < props.length; _i6++) {
+ if (value[props[_i6]] !== null) {
+ value = value[props[_i6]];
}
}
} else {
value = item[key];
}
@@ -5432,47 +5681,47 @@
}
style = Utils.calculateObjectValue(this.options, this.options.rowStyle, [item, i], style);
if (style && style.css) {
- for (var _i3 = 0, _Object$entries2 = Object.entries(style.css); _i3 < _Object$entries2.length; _i3++) {
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
- key = _Object$entries2$_i[0],
- value = _Object$entries2$_i[1];
+ for (var _i7 = 0, _Object$entries6 = Object.entries(style.css); _i7 < _Object$entries6.length; _i7++) {
+ var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i7], 2),
+ key = _Object$entries6$_i[0],
+ value = _Object$entries6$_i[1];
csses.push("".concat(key, ": ").concat(value));
}
}
attributes = Utils.calculateObjectValue(this.options, this.options.rowAttributes, [item, i], attributes);
if (attributes) {
- for (var _i4 = 0, _Object$entries3 = Object.entries(attributes); _i4 < _Object$entries3.length; _i4++) {
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i4], 2),
- _key2 = _Object$entries3$_i[0],
- _value = _Object$entries3$_i[1];
+ for (var _i8 = 0, _Object$entries7 = Object.entries(attributes); _i8 < _Object$entries7.length; _i8++) {
+ var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i8], 2),
+ _key2 = _Object$entries7$_i[0],
+ _value = _Object$entries7$_i[1];
htmlAttributes.push("".concat(_key2, "=\"").concat(Utils.escapeHTML(_value), "\""));
}
}
if (item._data && !Utils.isEmptyObject(item._data)) {
- for (var _i5 = 0, _Object$entries4 = Object.entries(item._data); _i5 < _Object$entries4.length; _i5++) {
- var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i5], 2),
- k = _Object$entries4$_i[0],
- v = _Object$entries4$_i[1];
+ for (var _i9 = 0, _Object$entries8 = Object.entries(item._data); _i9 < _Object$entries8.length; _i9++) {
+ var _Object$entries8$_i = _slicedToArray(_Object$entries8[_i9], 2),
+ k = _Object$entries8$_i[0],
+ v = _Object$entries8$_i[1];
// ignore data-index
if (k === 'index') {
return;
}
data_ += " data-".concat(k, "='").concat(_typeof(v) === 'object' ? JSON.stringify(v) : v, "'");
}
}
- html.push('<tr', Utils.sprintf(' %s', htmlAttributes.length ? htmlAttributes.join(' ') : undefined), Utils.sprintf(' id="%s"', Array.isArray(item) ? undefined : item._id), Utils.sprintf(' class="%s"', style.classes || (Array.isArray(item) ? undefined : item._class)), " data-index=\"".concat(i, "\""), Utils.sprintf(' data-uniqueid="%s"', Utils.getItemField(item, this.options.uniqueId, false)), Utils.sprintf(' data-has-detail-view="%s"', this.options.detailView && Utils.calculateObjectValue(null, this.options.detailFilter, [i, item]) ? 'true' : undefined), Utils.sprintf('%s', data_), '>');
+ html.push('<tr', Utils.sprintf(' %s', htmlAttributes.length ? htmlAttributes.join(' ') : undefined), Utils.sprintf(' id="%s"', Array.isArray(item) ? undefined : item._id), Utils.sprintf(' class="%s"', style.classes || (Array.isArray(item) ? undefined : item._class)), Utils.sprintf(' style="%s"', Array.isArray(item) ? undefined : item._style), " data-index=\"".concat(i, "\""), Utils.sprintf(' data-uniqueid="%s"', Utils.getItemField(item, this.options.uniqueId, false)), Utils.sprintf(' data-has-detail-view="%s"', this.options.detailView && Utils.calculateObjectValue(null, this.options.detailFilter, [i, item]) ? 'true' : undefined), Utils.sprintf('%s', data_), '>');
if (this.options.cardView) {
html.push("<td colspan=\"".concat(this.header.fields.length, "\"><div class=\"card-views\">"));
}
@@ -5499,10 +5748,11 @@
var type = '';
var cellStyle = {};
var id_ = '';
var class_ = _this7.header.classes[j];
var style_ = '';
+ var styleToAdd_ = '';
var data_ = '';
var rowspan_ = '';
var colspan_ = '';
var title_ = '';
var column = _this7.columns[j];
@@ -5521,17 +5771,27 @@
return;
}
if (column.escape) {
value_ = Utils.escapeHTML(value_);
- }
+ } // Style concat
+
if (csses.concat([_this7.header.styles[j]]).length) {
- style_ = " style=\"".concat(csses.concat([_this7.header.styles[j]]).join('; '), "\"");
- } // handle id and class of td
+ styleToAdd_ += "".concat(csses.concat([_this7.header.styles[j]]).join('; '));
+ }
+ if (item["_".concat(field, "_style")]) {
+ styleToAdd_ += "".concat(item["_".concat(field, "_style")]);
+ }
+ if (styleToAdd_) {
+ style_ = " style=\"".concat(styleToAdd_, "\"");
+ } // Style concat
+ // handle id and class of td
+
+
if (item["_".concat(field, "_id")]) {
id_ = Utils.sprintf(' id="%s"', item["_".concat(field, "_id")]);
}
if (item["_".concat(field, "_class")]) {
@@ -5557,28 +5817,32 @@
}
if (cellStyle.css) {
var csses_ = [];
- for (var _i6 = 0, _Object$entries5 = Object.entries(cellStyle.css); _i6 < _Object$entries5.length; _i6++) {
- var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i6], 2),
- _key3 = _Object$entries5$_i[0],
- _value2 = _Object$entries5$_i[1];
+ for (var _i10 = 0, _Object$entries9 = Object.entries(cellStyle.css); _i10 < _Object$entries9.length; _i10++) {
+ var _Object$entries9$_i = _slicedToArray(_Object$entries9[_i10], 2),
+ _key3 = _Object$entries9$_i[0],
+ _value2 = _Object$entries9$_i[1];
csses_.push("".concat(_key3, ": ").concat(_value2));
}
style_ = " style=\"".concat(csses_.concat(_this7.header.styles[j]).join('; '), "\"");
}
value = Utils.calculateObjectValue(column, _this7.header.formatters[j], [value_, item, i, field], value_);
+ if (_this7.searchText !== '' && _this7.options.searchHighlight) {
+ value = Utils.calculateObjectValue(column, column.searchHighlightFormatter, [value, _this7.searchText], value.replace(new RegExp('(' + _this7.searchText + ')', 'gim'), '<mark>$1</mark>'));
+ }
+
if (item["_".concat(field, "_data")] && !Utils.isEmptyObject(item["_".concat(field, "_data")])) {
- for (var _i7 = 0, _Object$entries6 = Object.entries(item["_".concat(field, "_data")]); _i7 < _Object$entries6.length; _i7++) {
- var _Object$entries6$_i = _slicedToArray(_Object$entries6[_i7], 2),
- _k = _Object$entries6$_i[0],
- _v = _Object$entries6$_i[1];
+ for (var _i11 = 0, _Object$entries10 = Object.entries(item["_".concat(field, "_data")]); _i11 < _Object$entries10.length; _i11++) {
+ var _Object$entries10$_i = _slicedToArray(_Object$entries10[_i11], 2),
+ _k = _Object$entries10$_i[0],
+ _v = _Object$entries10$_i[1];
// ignore data-index
if (_k === 'index') {
return;
}
@@ -5589,11 +5853,11 @@
if (column.checkbox || column.radio) {
type = column.checkbox ? 'checkbox' : type;
type = column.radio ? 'radio' : type;
var c = column['class'] || '';
- var isChecked = (value === true || value_ || value && value.checked) && value !== false;
+ var isChecked = Utils.isObject(value) && value.hasOwnProperty('checked') ? value.checked : (value === true || value_) && value !== false;
var isDisabled = !column.checkboxEnabled || value && value.disabled;
text = [_this7.options.cardView ? "<div class=\"card-view ".concat(c, "\">") : "<td class=\"bs-checkbox ".concat(c, "\"").concat(class_).concat(style_, ">"), "<label>\n <input\n data-index=\"".concat(i, "\"\n name=\"").concat(_this7.options.selectItemName, "\"\n type=\"").concat(type, "\"\n ").concat(Utils.sprintf('value="%s"', item[_this7.options.idField]), "\n ").concat(Utils.sprintf('checked="%s"', isChecked ? 'checked' : undefined), "\n ").concat(Utils.sprintf('disabled="%s"', isDisabled ? 'disabled' : undefined), " />\n <span></span>\n </label>"), _this7.header.formatters[j] && typeof value === 'string' ? value : '', _this7.options.cardView ? '</div>' : '</td>'].join('');
item[_this7.header.stateField] = value === true || !!value_ || value && value.checked;
} else {
value = typeof value === 'undefined' || value === null ? _this7.options.undefinedText : value;
@@ -5662,11 +5926,11 @@
}
} // show no records
if (!hasTr) {
- this.$body.html("<tr class=\"no-records-found\">".concat(Utils.sprintf('<td colspan="%s">%s</td>', this.getVisibleFields().length, this.options.formatNoMatches()), "</tr>"));
+ this.$body.html("<tr class=\"no-records-found\">".concat(Utils.sprintf('<td colspan="%s">%s</td>', this.getVisibleFields().length + Utils.getDetailViewIndexOffset(this.options), this.options.formatNoMatches()), "</tr>"));
} else {
if (!this.options.virtualScroll) {
this.$body.html(trFragments);
} else {
if (this.virtualScroll) {
@@ -5718,11 +5982,11 @@
var item = _this9.data[rowIndex];
var index = _this9.options.cardView ? $cardViewArr.index($cardViewTarget) : $td[0].cellIndex;
var fields = _this9.getVisibleFields();
- var field = fields[Utils.hasDetailViewIcon(_this9.options) && _this9.options.detailViewAlign !== 'right' ? index - 1 : index];
+ var field = fields[index - Utils.getDetailViewIndexOffset(_this9.options)];
var column = _this9.columns[_this9.fieldsColumnsIndex[field]];
var value = Utils.getItemField(item, field, _this9.options.escape);
if ($td.find('.detail-icon').length) {
return;
@@ -5781,15 +6045,13 @@
if (fieldIndex === -1) {
return;
}
- if (Utils.hasDetailViewIcon(_this9.options) && _this9.options.detailViewAlign !== 'right') {
- fieldIndex += 1;
- }
+ fieldIndex += Utils.getDetailViewIndexOffset(_this9.options);
- var _loop = function _loop(key) {
+ var _loop2 = function _loop2(key) {
if (!events.hasOwnProperty(key)) {
return "continue";
}
var event = events[key];
@@ -5808,13 +6070,13 @@
});
});
};
for (var key in events) {
- var _ret = _loop(key);
+ var _ret2 = _loop2(key);
- if (_ret === "continue") continue;
+ if (_ret2 === "continue") continue;
}
});
}
}, {
key: "initServer",
@@ -5962,11 +6224,11 @@
value: function initSearchText() {
if (this.options.search) {
this.searchText = '';
if (this.options.searchText !== '') {
- var $search = this.$toolbar.find('.search input');
+ var $search = Utils.getSearchInput(this);
$search.val(this.options.searchText);
this.onSearch({
currentTarget: $search,
firedByInitSearchText: true
});
@@ -6035,23 +6297,29 @@
this.initHiddenRows();
}
}, {
key: "trigger",
value: function trigger(_name) {
- var _this$options;
+ var _this$options, _this$options2;
var name = "".concat(_name, ".bs.table");
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
args[_key4 - 1] = arguments[_key4];
}
- (_this$options = this.options)[BootstrapTable.EVENTS[name]].apply(_this$options, args);
+ (_this$options = this.options)[BootstrapTable.EVENTS[name]].apply(_this$options, [].concat(args, [this]));
- this.$el.trigger($.Event(name), args);
- this.options.onAll(name, args);
- this.$el.trigger($.Event('all.bs.table'), [name, args]);
+ this.$el.trigger($.Event(name, {
+ sender: this
+ }), args);
+
+ (_this$options2 = this.options).onAll.apply(_this$options2, [name].concat([].concat(args, [this])));
+
+ this.$el.trigger($.Event('all.bs.table', {
+ sender: this
+ }), [name, args]);
}
}, {
key: "resetHeader",
value: function resetHeader() {
var _this13 = this;
@@ -6132,11 +6400,11 @@
$thDetail.find('.fht-cell').width($this.innerWidth() - _zoomWidth);
return;
}
}
- var index = Utils.hasDetailViewIcon(_this14.options) && _this14.options.detailViewAlign !== 'right' ? i - 1 : i;
+ var index = i - Utils.getDetailViewIndexOffset(_this14.options);
var $th = _this14.$header_.find(Utils.sprintf('th[data-field="%s"]', visibleFields[index]));
if ($th.length > 1) {
$th = $($ths[$this[0].cellIndex]);
@@ -6179,11 +6447,11 @@
var valign = '';
var csses = [];
var style = {};
var class_ = Utils.sprintf(' class="%s"', column['class']);
- if (!column.visible) {
+ if (!column.visible || this.footerData && this.footerData.length > 0 && !(column.field in this.footerData[0])) {
continue;
}
if (this.options.cardView && !column.cardVisible) {
return;
@@ -6192,26 +6460,43 @@
falign = Utils.sprintf('text-align: %s; ', column.falign ? column.falign : column.align);
valign = Utils.sprintf('vertical-align: %s; ', column.valign);
style = Utils.calculateObjectValue(null, this.options.footerStyle, [column]);
if (style && style.css) {
- for (var _i8 = 0, _Object$entries7 = Object.entries(style.css); _i8 < _Object$entries7.length; _i8++) {
- var _Object$entries7$_i = _slicedToArray(_Object$entries7[_i8], 2),
- key = _Object$entries7$_i[0],
- value = _Object$entries7$_i[1];
+ for (var _i12 = 0, _Object$entries11 = Object.entries(style.css); _i12 < _Object$entries11.length; _i12++) {
+ var _Object$entries11$_i = _slicedToArray(_Object$entries11[_i12], 2),
+ key = _Object$entries11$_i[0],
+ _value3 = _Object$entries11$_i[1];
- csses.push("".concat(key, ": ").concat(value));
+ csses.push("".concat(key, ": ").concat(_value3));
}
}
if (style && style.classes) {
class_ = Utils.sprintf(' class="%s"', column['class'] ? [column['class'], style.classes].join(' ') : style.classes);
}
- html.push('<th', class_, Utils.sprintf(' style="%s"', falign + valign + csses.concat().join('; ')), '>');
+ html.push('<th', class_, Utils.sprintf(' style="%s"', falign + valign + csses.concat().join('; ')));
+ var colspan = 0;
+
+ if (this.footerData && this.footerData.length > 0) {
+ colspan = this.footerData[0]['_' + column.field + '_colspan'] || 0;
+ }
+
+ if (colspan) {
+ html.push(" colspan=\"".concat(colspan, "\" "));
+ }
+
+ html.push('>');
html.push('<div class="th-inner">');
- html.push(Utils.calculateObjectValue(column, column.footerFormatter, [data], this.footerData[0] && this.footerData[0][column.field] || ''));
+ var value = '';
+
+ if (this.footerData && this.footerData.length > 0) {
+ value = this.footerData[0][column.field] || '';
+ }
+
+ html.push(Utils.calculateObjectValue(column, column.footerFormatter, [data, value], value));
html.push('</div>');
html.push('<div class="fht-cell"></div>');
html.push('</div>');
html.push('</th>');
}
@@ -6258,10 +6543,11 @@
var scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth && fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ? Utils.getScrollBarWidth() : 0;
this.$tableFooter.css('margin-right', scrollWidth).find('table').css('width', this.$el.outerWidth()).attr('class', this.$el.attr('class'));
var visibleFields = this.getVisibleFields();
var $ths = this.$tableFooter.find('th');
var $tr = this.$body.find('>tr:first-child:not(.no-records-found)');
+ $ths.find('.fht-cell').width('auto');
while ($tr.length && $tr.find('>td[colspan]:not([colspan="1"])').length) {
$tr = $tr.next();
}
@@ -6376,11 +6662,11 @@
value: function getData(params) {
var _this17 = this;
var data = this.options.data;
- if ((this.searchText || this.options.customSearch || this.options.sortName || !Utils.isEmptyObject(this.filterColumns) || !Utils.isEmptyObject(this.filterColumnsPartial)) && (!params || !params.unfiltered)) {
+ if ((this.searchText || this.options.customSearch || this.options.sortName !== undefined || !Utils.isEmptyObject(this.filterColumns) || !Utils.isEmptyObject(this.filterColumnsPartial)) && (!params || !params.unfiltered)) {
data = this.data;
}
if (params && params.useCurrentPage) {
data = data.slice(this.pageFrom - 1, this.pageTo);
@@ -6393,14 +6679,14 @@
});
}
if (params && params.formatted) {
data.forEach(function (row) {
- for (var _i9 = 0, _Object$entries8 = Object.entries(row); _i9 < _Object$entries8.length; _i9++) {
- var _Object$entries8$_i = _slicedToArray(_Object$entries8[_i9], 2),
- key = _Object$entries8$_i[0],
- value = _Object$entries8$_i[1];
+ for (var _i13 = 0, _Object$entries12 = Object.entries(row); _i13 < _Object$entries12.length; _i13++) {
+ var _Object$entries12$_i = _slicedToArray(_Object$entries12[_i13], 2),
+ key = _Object$entries12$_i[0],
+ value = _Object$entries12$_i[1];
var column = _this17.columns[_this17.fieldsColumnsIndex[key]];
if (!column) {
return;
@@ -6416,36 +6702,24 @@
}, {
key: "getSelections",
value: function getSelections() {
var _this18 = this;
- // fix #2424: from html with checkbox
- return this.data.filter(function (row) {
+ return this.options.data.filter(function (row) {
return row[_this18.header.stateField] === true;
});
}
}, {
- key: "getAllSelections",
- value: function getAllSelections() {
- var _this19 = this;
-
- return this.options.data.filter(function (row) {
- return row[_this19.header.stateField] === true;
- });
- }
- }, {
key: "load",
value: function load(_data) {
var fixedScroll = false;
var data = _data; // #431: support pagination
if (this.options.pagination && this.options.sidePagination === 'server') {
this.options.totalRows = data[this.options.totalField];
- }
-
- if (this.options.pagination && this.options.sidePagination === 'server') {
this.options.totalNotFiltered = data[this.options.totalNotFilteredField];
+ this.footerData = data[this.options.footerField] ? [data[this.options.footerField]] : undefined;
}
fixedScroll = data.fixedScroll;
data = Array.isArray(data) ? data : data[this.options.dataField];
this.initData(data);
@@ -6702,25 +6976,25 @@
this.initBody(true);
}
}, {
key: "updateCellByUniqueId",
value: function updateCellByUniqueId(params) {
- var _this20 = this;
+ var _this19 = this;
var allParams = Array.isArray(params) ? params : [params];
allParams.forEach(function (_ref6) {
var id = _ref6.id,
field = _ref6.field,
value = _ref6.value;
- var rowId = _this20.options.data.indexOf(_this20.getRowByUniqueId(id));
+ var rowId = _this19.options.data.indexOf(_this19.getRowByUniqueId(id));
if (rowId === -1) {
return;
}
- _this20.options.data[rowId][field] = value;
+ _this19.options.data[rowId][field] = value;
});
if (params.reinit === false) {
return;
}
@@ -6807,25 +7081,25 @@
return rows;
}
}, {
key: "showColumn",
value: function showColumn(field) {
- var _this21 = this;
+ var _this20 = this;
var fields = Array.isArray(field) ? field : [field];
fields.forEach(function (field) {
- _this21._toggleColumn(_this21.fieldsColumnsIndex[field], true, true);
+ _this20._toggleColumn(_this20.fieldsColumnsIndex[field], true, true);
});
}
}, {
key: "hideColumn",
value: function hideColumn(field) {
- var _this22 = this;
+ var _this21 = this;
var fields = Array.isArray(field) ? field : [field];
fields.forEach(function (field) {
- _this22._toggleColumn(_this22.fieldsColumnsIndex[field], false, true);
+ _this21._toggleColumn(_this21.fieldsColumnsIndex[field], false, true);
});
}
}, {
key: "_toggleColumn",
value: function _toggleColumn(index, checked, needUpdate) {
@@ -6852,14 +7126,14 @@
}
}
}, {
key: "getVisibleColumns",
value: function getVisibleColumns() {
- var _this23 = this;
+ var _this22 = this;
return this.columns.filter(function (column) {
- return column.visible && !_this23.isSelectionColumn(column);
+ return column.visible && !_this22.isSelectionColumn(column);
});
}
}, {
key: "getHiddenColumns",
value: function getHiddenColumns() {
@@ -6884,11 +7158,11 @@
this._toggleAllColumns(false);
}
}, {
key: "_toggleAllColumns",
value: function _toggleAllColumns(visible) {
- var _this24 = this;
+ var _this23 = this;
var _iteratorNormalCompletion9 = true;
var _didIteratorError9 = false;
var _iteratorError9 = undefined;
@@ -6929,11 +7203,11 @@
if (visible) {
$items.prop('checked', visible);
} else {
$items.get().reverse().forEach(function (item) {
- if ($items.filter(':checked').length > _this24.options.minimumCountColumns) {
+ if ($items.filter(':checked').length > _this23.options.minimumCountColumns) {
$(item).prop('checked', visible);
}
});
}
@@ -6950,15 +7224,11 @@
var rowspan = options.rowspan || 1;
var colspan = options.colspan || 1;
var i;
var j;
var $tr = this.$body.find('>tr');
-
- if (Utils.hasDetailViewIcon(this.options)) {
- col += 1;
- }
-
+ col += Utils.getDetailViewIndexOffset(this.options);
var $td = $tr.eq(row).find('>td').eq(col);
if (row < 0 || col < 0 || row >= this.data.length) {
return;
}
@@ -6986,10 +7256,11 @@
value: function _toggleCheckAll(checked) {
var rowsBefore = this.getSelections();
this.$selectAll.add(this.$selectAll_).prop('checked', checked);
this.$selectItem.filter(':enabled').prop('checked', checked);
this.updateRows();
+ this.updateSelected();
var rowsAfter = this.getSelections();
if (checked) {
this.trigger('check-all', rowsAfter, rowsBefore);
return;
@@ -7023,11 +7294,11 @@
}
}, {
key: "_toggleCheck",
value: function _toggleCheck(checked, index) {
var $el = this.$selectItem.filter("[data-index=\"".concat(index, "\"]"));
- var row = this.data[index];
+ var row = this.options.data[index];
if ($el.is(':radio') || this.options.singleSelect || this.options.multipleSelectRow && !this.multipleSelectRowCtrlKey && !this.multipleSelectRowShiftKey) {
var _iteratorNormalCompletion10 = true;
var _didIteratorError10 = false;
var _iteratorError10 = undefined;
@@ -7087,11 +7358,11 @@
this._toggleCheckBy(false, obj);
}
}, {
key: "_toggleCheckBy",
value: function _toggleCheckBy(checked, obj) {
- var _this25 = this;
+ var _this24 = this;
if (!obj.hasOwnProperty('field') || !obj.hasOwnProperty('values')) {
return;
}
@@ -7100,23 +7371,23 @@
if (!row.hasOwnProperty(obj.field)) {
return false;
}
if (obj.values.includes(row[obj.field])) {
- var $el = _this25.$selectItem.filter(':enabled').filter(Utils.sprintf('[data-index="%s"]', i));
+ var $el = _this24.$selectItem.filter(':enabled').filter(Utils.sprintf('[data-index="%s"]', i));
$el = checked ? $el.not(':checked') : $el.filter(':checked');
if (!$el.length) {
return;
}
$el.prop('checked', checked);
- row[_this25.header.stateField] = checked;
+ row[_this24.header.stateField] = checked;
rows.push(row);
- _this25.trigger(checked ? 'check' : 'uncheck', row, $el);
+ _this24.trigger(checked ? 'check' : 'uncheck', row, $el);
}
});
this.updateSelected();
this.trigger(checked ? 'check-some' : 'uncheck-some', rows);
}
@@ -7218,11 +7489,11 @@
this.trigger('reset-view');
}
}, {
key: "showLoading",
value: function showLoading() {
- this.$tableLoading.css('display', 'flex');
+ this.$tableLoading.toggleClass('open', true);
var fontSize = this.options.loadingFontSize;
if (this.options.loadingFontSize === 'auto') {
fontSize = this.$tableLoading.width() * 0.04;
fontSize = Math.max(12, fontSize);
@@ -7233,11 +7504,11 @@
this.$tableLoading.find('.loading-text').css('font-size', fontSize);
}
}, {
key: "hideLoading",
value: function hideLoading() {
- this.$tableLoading.css('display', 'none');
+ this.$tableLoading.toggleClass('open', false);
}
}, {
key: "togglePagination",
value: function togglePagination() {
this.options.pagination = !this.options.pagination;
@@ -7264,11 +7535,11 @@
this.trigger('toggle', this.options.cardView);
}
}, {
key: "resetSearch",
value: function resetSearch(text) {
- var $search = this.$toolbar.find('.search input');
+ var $search = Utils.getSearchInput(this);
$search.val(text || '');
this.onSearch({
currentTarget: $search
});
}
@@ -7282,14 +7553,10 @@
this.updatePagination();
}
}, {
key: "scrollTo",
value: function scrollTo(params) {
- if (typeof params === 'undefined') {
- return this.$tableBody.scrollTop();
- }
-
var options = {
unit: 'px',
value: 0
};
@@ -7313,11 +7580,11 @@
this.$tableBody.scrollTop(scrollTo);
}
}, {
key: "getScrollPosition",
value: function getScrollPosition() {
- return this.scrollTo();
+ return this.$tableBody.scrollTop();
}
}, {
key: "selectPage",
value: function selectPage(page) {
if (page > 0 && page <= this.options.totalPages) {
@@ -7516,10 +7783,12 @@
$(el).removeData('bootstrap.table');
}
}
if (!data) {
- $(el).data('bootstrap.table', data = new $.BootstrapTable(el, options));
+ data = new $.BootstrapTable(el, options);
+ $(el).data('bootstrap.table', data);
+ data.init();
}
});
return typeof value === 'undefined' ? this : value;
};