vendor/assets/javascripts/bootstrap-table/bootstrap-table.js in bootstrap-table-rails-1.16.0 vs vendor/assets/javascripts/bootstrap-table/bootstrap-table.js in bootstrap-table-rails-1.17.0

- old
+ new

@@ -2,11 +2,11 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) : typeof define === 'function' && define.amd ? define(['jquery'], factory) : (global = global || self, global.BootstrapTable = factory(global.jQuery)); }(this, (function ($) { 'use strict'; - $ = $ && $.hasOwnProperty('default') ? $['default'] : $; + $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $; var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; @@ -2849,11 +2849,11 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } - var VERSION = '1.16.0'; + var VERSION = '1.17.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). @@ -2862,10 +2862,20 @@ bootstrapVersion = parseInt(rawVersion, 10); } } catch (e) {// ignore } + try { + // eslint-disable-next-line no-undef + var _rawVersion = bootstrap.Tooltip.VERSION; + + if (_rawVersion !== undefined) { + bootstrapVersion = parseInt(_rawVersion, 10); + } + } catch (e) {// ignore + } + var CONSTANTS = { 3: { iconsPrefix: 'glyphicon', icons: { paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down', @@ -2954,10 +2964,56 @@ inputGroup: '<div class="input-group">%s<div class="input-group-append">%s</div></div>', searchInput: '<input class="%s%s" type="text" placeholder="%s">', searchButton: '<button class="%s" type="button" name="search" title="%s">%s %s</button>', searchClearButton: '<button class="%s" type="button" name="clearSearch" title="%s">%s %s</button>' } + }, + 5: { + iconsPrefix: 'fa', + icons: { + paginationSwitchDown: 'fa-caret-square-down', + paginationSwitchUp: 'fa-caret-square-up', + refresh: 'fa-sync', + toggleOff: 'fa-toggle-off', + toggleOn: 'fa-toggle-on', + columns: 'fa-th-list', + detailOpen: 'fa-plus', + detailClose: 'fa-minus', + fullscreen: 'fa-arrows-alt', + search: 'fa-search', + clearSearch: 'fa-trash' + }, + classes: { + buttonsPrefix: 'btn', + buttons: 'secondary', + buttonsGroup: 'btn-group', + buttonsDropdown: 'btn-group', + pull: 'float', + inputGroup: 'btn-group', + inputPrefix: 'form-control-', + input: 'form-control', + paginationDropdown: 'btn-group dropdown', + dropup: 'dropup', + dropdownActive: 'active', + paginationActive: 'active', + buttonActive: 'active' + }, + html: { + toolbarDropdown: ['<div class="dropdown-menu dropdown-menu-right">', '</div>'], + toolbarDropdownItem: '<label class="dropdown-item dropdown-item-marker">%s</label>', + pageDropdown: ['<div class="dropdown-menu">', '</div>'], + pageDropdownItem: '<a class="dropdown-item %s" href="#">%s</a>', + toolbarDropdownSeparator: '<div class="dropdown-divider"></div>', + dropdownCaret: '<span class="caret"></span>', + pagination: ['<ul class="pagination%s">', '</ul>'], + paginationItem: '<li class="page-item%s"><a class="page-link" aria-label="%s" href="javascript:void(0)">%s</a></li>', + icon: '<i class="%s %s"></i>', + inputGroup: '<div class="input-group">%s<div class="input-group-append">%s</div></div>', + searchInput: '<input class="%s%s" type="text" placeholder="%s">', + searchButton: '<button class="%s" type="button" name="search" title="%s">%s %s</button>', + searchClearButton: '<button class="%s" type="button" name="clearSearch" title="%s">%s %s</button>' + } } }[bootstrapVersion]; var DEFAULTS = { height: undefined, classes: 'table table-bordered table-hover', @@ -2977,11 +3033,12 @@ virtualScrollItemHeight: undefined, sortable: true, sortClass: undefined, silentSort: true, sortName: undefined, - sortOrder: 'asc', + sortOrder: undefined, + sortReset: false, sortStable: false, rememberOrder: false, serverSort: true, customSort: undefined, columns: [[]], @@ -3003,11 +3060,11 @@ }, totalField: 'total', totalNotFilteredField: 'totalNotFiltered', dataField: 'rows', pagination: false, - onlyInfoPagination: false, + paginationParts: ['pageInfo', 'pageSize', 'pageList'], showExtendedPagination: false, paginationLoop: true, sidePagination: 'client', // client or server totalRows: 0, @@ -3074,10 +3131,11 @@ uniqueId: undefined, cardView: false, detailView: false, detailViewIcon: true, detailViewByClick: false, + detailViewAlign: 'left', detailFormatter: function detailFormatter(index, row) { return ''; }, detailFilter: function detailFilter(index, row) { return true; @@ -3092,10 +3150,14 @@ icons: CONSTANTS.icons, html: CONSTANTS.html, iconSize: undefined, iconsPrefix: CONSTANTS.iconsPrefix, // glyphicon or fa(font-awesome) + loadingFontSize: 'auto', + loadingTemplate: function loadingTemplate(loadingMessage) { + return "<span class=\"loading-wrap\">\n <span class=\"loading-text\">".concat(loadingMessage, "</span>\n <span class=\"animation-wrap\"><span class=\"animation-dot\"></span></span>\n </span>\n "); + }, onAll: function onAll(name, args) { return false; }, onClickCell: function onClickCell(field, value, row, $element) { return false; @@ -3285,11 +3347,11 @@ detailFormatter: undefined, searchFormatter: true, 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', 'expandAllRows', 'collapseAllRows', 'updateColumnTitle', 'updateFormatText']; + 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 EVENTS = { 'all.bs.table': 'onAll', 'click-row.bs.table': 'onClickRow', 'dbl-click-row.bs.table': 'onDblClickRow', 'click-cell.bs.table': 'onClickCell', @@ -3652,10 +3714,17 @@ return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;').replace(/`/g, '&#x60;'); } return text; }, + unescapeHTML: function unescapeHTML(text) { + if (typeof text === 'string') { + return text.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&#039;/g, '\'').replace(/&#x60;/g, '`'); + } + + return text; + }, getRealDataAttr: function getRealDataAttr(dataAttr) { for (var _i3 = 0, _Object$entries = Object.entries(dataAttr); _i3 < _Object$entries.length; _i3++) { var _Object$entries$_i = _slicedToArray(_Object$entries[_i3], 2), attr = _Object$entries$_i[0], value = _Object$entries$_i[1]; @@ -3830,10 +3899,13 @@ }, getResizeEventName: function getResizeEventName() { var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; id = id || "".concat(+new Date()).concat(~~(Math.random() * 1000000)); return "resize.bootstrap-table-".concat(id); + }, + hasDetailViewIcon: function hasDetailViewIcon(options) { + return options.detailView && options.detailViewIcon && !options.cardView; } }; var BLOCK_ROWS = 50; var CLUSTER_BLOCKS = 4; @@ -4050,11 +4122,12 @@ }, { key: "initContainer", value: function initContainer() { var topPagination = ['top', 'both'].includes(this.options.paginationVAlign) ? '<div class="fixed-table-pagination clearfix"></div>' : ''; var bottomPagination = ['bottom', 'both'].includes(this.options.paginationVAlign) ? '<div class="fixed-table-pagination"></div>' : ''; - this.$container = $("\n <div class=\"bootstrap-table ".concat(this.constants.theme, "\">\n <div class=\"fixed-table-toolbar\"></div>\n ").concat(topPagination, "\n <div class=\"fixed-table-container\">\n <div class=\"fixed-table-header\"><table></table></div>\n <div class=\"fixed-table-body\">\n <div class=\"fixed-table-loading\">\n <span class=\"loading-wrap\">\n <span class=\"loading-text\">").concat(this.options.formatLoadingMessage(), "</span>\n <span class=\"animation-wrap\"><span class=\"animation-dot\"></span></span>\n </span>\n </div>\n </div>\n <div class=\"fixed-table-footer\"><table><thead><tr></tr></thead></table></div>\n </div>\n ").concat(bottomPagination, "\n </div>\n ")); + var loadingTemplate = Utils.calculateObjectValue(this.options, this.options.loadingTemplate, [this.options.formatLoadingMessage()]); + this.$container = $("\n <div class=\"bootstrap-table ".concat(this.constants.theme, "\">\n <div class=\"fixed-table-toolbar\"></div>\n ").concat(topPagination, "\n <div class=\"fixed-table-container\">\n <div class=\"fixed-table-header\"><table></table></div>\n <div class=\"fixed-table-body\">\n <div class=\"fixed-table-loading\">\n ").concat(loadingTemplate, "\n </div>\n </div>\n <div class=\"fixed-table-footer\"><table><thead><tr></tr></thead></table></div>\n </div>\n ").concat(bottomPagination, "\n </div>\n ")); this.$container.insertAfter(this.$el); this.$tableContainer = this.$container.find('.fixed-table-container'); this.$tableHeader = this.$container.find('.fixed-table-header'); this.$tableBody = this.$container.find('.fixed-table-body'); this.$tableLoading = this.$container.find('.fixed-table-loading'); @@ -4100,27 +4173,34 @@ this.$header = $("<thead class=\"".concat(this.options.theadClasses, "\"></thead>")).appendTo(this.$el); } else if (this.options.theadClasses) { this.$header.addClass(this.options.theadClasses); } + this._headerTrClasses = []; this.$header.find('tr').each(function (i, el) { + var $tr = $(el); var column = []; - $(el).find('th').each(function (i, el) { - // #2014: getFieldIndex and elsewhere assume this is string, causes issues if not - if (typeof $(el).data('field') !== 'undefined') { - $(el).data('field', "".concat($(el).data('field'))); + $tr.find('th').each(function (i, el) { + var $th = $(el); // #2014: getFieldIndex and elsewhere assume this is string, causes issues if not + + if (typeof $th.data('field') !== 'undefined') { + $th.data('field', "".concat($th.data('field'))); } column.push($.extend({}, { - title: $(el).html(), - 'class': $(el).attr('class'), - titleTooltip: $(el).attr('title'), - rowspan: $(el).attr('rowspan') ? +$(el).attr('rowspan') : undefined, - colspan: $(el).attr('colspan') ? +$(el).attr('colspan') : undefined - }, $(el).data())); + title: $th.html(), + 'class': $th.attr('class'), + titleTooltip: $th.attr('title'), + rowspan: $th.attr('rowspan') ? +$th.attr('rowspan') : undefined, + colspan: $th.attr('colspan') ? +$th.attr('colspan') : undefined + }, $th.data())); }); columns.push(column); + + if ($tr.attr('class')) { + _this._headerTrClasses.push($tr.attr('class')); + } }); if (!Array.isArray(this.options.columns[0])) { this.options.columns = [this.options.columns]; } @@ -4141,13 +4221,14 @@ _this.options.columns[i][j] = column; }); }); // if options.data is setting, do not process tbody and tfoot data if (!this.options.data.length) { - this.options.data = Utils.trToData(this.columns, this.$el.find('>tbody>tr')); + var htmlData = Utils.trToData(this.columns, this.$el.find('>tbody>tr')); - if (this.options.data.length) { + if (htmlData.length) { + this.options.data = htmlData; this.fromHtml = true; } } this.footerData = Utils.trToData(this.columns, this.$el.find('>tfoot>tr')); @@ -4181,16 +4262,21 @@ cellStyles: [], searchables: [] }; Utils.updateFieldGroup(this.options.columns); this.options.columns.forEach(function (columns, i) { - html.push('<tr>'); + html.push("<tr".concat(Utils.sprintf(' class="%s"', _this2._headerTrClasses[i]), ">")); + var detailViewTemplate = ''; - if (i === 0 && !_this2.options.cardView && _this2.options.detailView && _this2.options.detailViewIcon) { - html.push("<th class=\"detail\" rowspan=\"".concat(_this2.options.columns.length, "\">\n <div class=\"fht-cell\"></div>\n </th>\n ")); + 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>"); } + if (detailViewTemplate && _this2.options.detailViewAlign !== 'right') { + html.push(detailViewTemplate); + } + columns.forEach(function (column, j) { var class_ = Utils.sprintf(' class="%s"', column['class']); var unitWidth = column.widthUnit; var width = parseFloat(column.width); var halign = Utils.sprintf('text-align: %s; ', column.halign ? column.halign : column.align); @@ -4272,10 +4358,15 @@ html.push('</div>'); html.push('<div class="fht-cell"></div>'); html.push('</div>'); html.push('</th>'); }); + + if (detailViewTemplate && _this2.options.detailViewAlign === 'right') { + html.push(detailViewTemplate); + } + html.push('</tr>'); }); this.$header.html(html.join('')); this.$header.find('th[data-field]').each(function (i, el) { $(el).data(visibleColumns[$(el).data('field')]); @@ -4341,10 +4432,11 @@ } else { this.options.data = data || this.options.data; } this.data = this.options.data; + this.unsortedData = _toConsumableArray(this.data); if (this.options.sidePagination === 'server') { return; } @@ -4401,10 +4493,12 @@ var index = _this3.$header.find("[data-field=\"".concat(_this3.options.sortName, "\"]")).index(); _this3.$el.find("tr td:nth-child(".concat(index + 1, ")")).addClass(_this3.options.sortClass); }, 250); } + } else { + this.data = this.unsortedData; } } }, { key: "onSort", value: function onSort(_ref) { @@ -4413,11 +4507,23 @@ var $this = type === 'keypress' ? $(currentTarget) : $(currentTarget).parent(); var $this_ = this.$header.find('th').eq($this.index()); this.$header.add(this.$header_).find('span.order').remove(); if (this.options.sortName === $this.data('field')) { - this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc'; + var currentSortOrder = this.options.sortOrder; + + if (currentSortOrder === undefined) { + this.options.sortOrder = 'asc'; + } else if (currentSortOrder === 'asc') { + this.options.sortOrder = 'desc'; + } else if (this.options.sortOrder === 'desc') { + this.options.sortOrder = this.options.sortReset ? undefined : 'asc'; + } + + if (this.options.sortOrder === undefined) { + this.options.sortName = undefined; + } } else { this.options.sortName = $this.data('field'); if (this.options.rememberOrder) { this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc'; @@ -4865,13 +4971,13 @@ } } return false; }) : this.data; + this.unsortedData = _toConsumableArray(this.data); + this.initSort(); } - - this.initSort(); } }, { key: "initPagination", value: function initPagination() { var _this6 = this; @@ -4907,11 +5013,16 @@ return value.toLowerCase() === opts.formatAllRows().toLowerCase() || ['all', 'unlimited'].includes(value.toLowerCase()) ? opts.formatAllRows() : +value; } return value; }); + this.paginationParts = opts.paginationParts; + if (typeof this.paginationParts === 'string') { + this.paginationParts = this.paginationParts.replace(/\[|\]| |'/g, '').split(','); + } + if (opts.sidePagination !== 'server') { opts.totalRows = data.length; } this.totalPages = 0; @@ -4943,14 +5054,20 @@ if (!this.options.showExtendedPagination) { this.options.totalNotFiltered = undefined; } - var paginationInfo = opts.onlyInfoPagination ? opts.formatDetailPagination(opts.totalRows) : opts.formatShowingRows(this.pageFrom, this.pageTo, opts.totalRows, opts.totalNotFiltered); - html.push("<div class=\"".concat(this.constants.classes.pull, "-").concat(opts.paginationDetailHAlign, " pagination-detail\">\n <span class=\"pagination-info\">\n ").concat(paginationInfo, "\n </span>")); + if (this.paginationParts.includes('pageInfo') || this.paginationParts.includes('pageInfoShort') || this.paginationParts.includes('pageSize')) { + html.push("<div class=\"".concat(this.constants.classes.pull, "-").concat(opts.paginationDetailHAlign, " pagination-detail\">")); + } - if (!opts.onlyInfoPagination) { + if (this.paginationParts.includes('pageInfo') || this.paginationParts.includes('pageInfoShort')) { + var paginationInfo = this.paginationParts.includes('pageInfoShort') ? opts.formatDetailPagination(opts.totalRows) : opts.formatShowingRows(this.pageFrom, this.pageTo, opts.totalRows, opts.totalNotFiltered); + html.push("<span class=\"pagination-info\">\n ".concat(paginationInfo, "\n </span>")); + } + + if (this.paginationParts.includes('pageSize')) { html.push('<span class="page-list">'); var pageNumber = ["<span class=\"".concat(this.constants.classes.paginationDropdown, "\">\n <button class=\"").concat(this.constants.buttonsClass, " dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\">\n <span class=\"page-size\">\n ").concat(allSelected ? opts.formatAllRows() : opts.pageSize, "\n </span>\n ").concat(this.constants.html.dropdownCaret, "\n </button>\n ").concat(this.constants.html.pageDropdown[0])]; pageList.forEach(function (page, i) { if (!opts.smartDisplay || i === 0 || pageList[i - 1] < opts.totalRows) { var active; @@ -4964,11 +5081,17 @@ pageNumber.push(Utils.sprintf(_this6.constants.html.pageDropdownItem, active, page)); } }); pageNumber.push("".concat(this.constants.html.pageDropdown[1], "</span>")); html.push(opts.formatRecordsPerPage(pageNumber.join(''))); + } + + if (this.paginationParts.includes('pageInfo') || this.paginationParts.includes('pageInfoShort') || this.paginationParts.includes('pageSize')) { html.push('</span></div>'); + } + + if (this.paginationParts.includes('pageList')) { html.push("<div class=\"".concat(this.constants.classes.pull, "-").concat(opts.paginationHAlign, " pagination\">"), Utils.sprintf(this.constants.html.pagination[0], Utils.sprintf(' pagination-%s', opts.iconSize)), Utils.sprintf(this.constants.html.paginationItem, ' page-pre', opts.formatSRPaginationPreText(), opts.paginationPreText)); if (this.totalPages < opts.paginationSuccessivelySize) { from = 1; to = this.totalPages; @@ -5117,18 +5240,17 @@ if (!this.options.maintainMetaData) { this.resetRows(); } this.initPagination(); + this.trigger('page-change', this.options.pageNumber, this.options.pageSize); if (this.options.sidePagination === 'server') { this.initServer(); } else { this.initBody(); } - - this.trigger('page-change', this.options.pageNumber, this.options.pageSize); } }, { key: "onPageListChange", value: function onPageListChange(event) { event.preventDefault(); @@ -5233,26 +5355,32 @@ 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.cardView && 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)), " 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\">")); } - if (!this.options.cardView && this.options.detailView && this.options.detailViewIcon) { - html.push('<td>'); + var detailViewTemplate = ''; + if (Utils.hasDetailViewIcon(this.options)) { + detailViewTemplate = '<td>'; + if (Utils.calculateObjectValue(null, this.options.detailFilter, [i, item])) { - html.push("\n <a class=\"detail-icon\" href=\"#\">\n ".concat(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.detailOpen), "\n </a>\n ")); + detailViewTemplate += "\n <a class=\"detail-icon\" href=\"#\">\n ".concat(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.detailOpen), "\n </a>\n "); } - html.push('</td>'); + detailViewTemplate += '</td>'; } + if (detailViewTemplate && this.options.detailViewAlign !== 'right') { + html.push(detailViewTemplate); + } + this.header.fields.forEach(function (field, j) { var text = ''; var value_ = Utils.getItemField(item, field, _this7.options.escape); var value = ''; var type = ''; @@ -5284,11 +5412,11 @@ value_ = Utils.escapeHTML(value_); } if (csses.concat([_this7.header.styles[j]]).length) { style_ = " style=\"".concat(csses.concat([_this7.header.styles[j]]).join('; '), "\""); - } // handle td's id and class + } // handle id and class of td if (item["_".concat(field, "_id")]) { id_ = Utils.sprintf(' id="%s"', item["_".concat(field, "_id")]); } @@ -5370,10 +5498,14 @@ } html.push(text); }); + if (detailViewTemplate && this.options.detailViewAlign === 'right') { + html.push(detailViewTemplate); + } + if (this.options.cardView) { html.push('</div></td>'); } html.push('</tr>'); @@ -5416,11 +5548,11 @@ } } // show no records if (!hasTr) { - this.$body.html("<tr class=\"no-records-found\">".concat(Utils.sprintf('<td colspan="%s">%s</td>', this.$header.find('th').length, this.options.formatNoMatches()), "</tr>")); + this.$body.html("<tr class=\"no-records-found\">".concat(Utils.sprintf('<td colspan="%s">%s</td>', this.getVisibleFields().length, this.options.formatNoMatches()), "</tr>")); } else { if (!this.options.virtualScroll) { this.$body.html(trFragments); } else { if (this.virtualScroll) { @@ -5472,11 +5604,11 @@ var item = _this9.data[rowIndex]; var index = _this9.options.cardView ? $cardViewArr.index($cardViewTarget) : $td[0].cellIndex; var fields = _this9.getVisibleFields(); - var field = fields[_this9.options.detailView && _this9.options.detailViewIcon && !_this9.options.cardView ? index - 1 : index]; + var field = fields[Utils.hasDetailViewIcon(_this9.options) && _this9.options.detailViewAlign !== 'right' ? index - 1 : index]; var column = _this9.columns[_this9.fieldsColumnsIndex[field]]; var value = Utils.getItemField(item, field, _this9.options.escape); if ($td.find('.detail-icon').length) { return; @@ -5535,11 +5667,11 @@ if (fieldIndex === -1) { return; } - if (_this9.options.detailView && !_this9.options.cardView) { + if (Utils.hasDetailViewIcon(_this9.options) && _this9.options.detailViewAlign !== 'right') { fieldIndex += 1; } var _loop = function _loop(key) { if (!events.hasOwnProperty(key)) { @@ -5611,10 +5743,42 @@ delete params.limit; } } } + if (this.options.search && this.options.sidePagination === 'server' && this.columns.filter(function (column) { + return !column.searchable; + }).length) { + params.searchable = []; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = this.columns[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var column = _step2.value; + + if (!column.checkbox && column.searchable && (this.options.visibleSearch && column.visible || !this.options.visibleSearch)) { + params.searchable.push(column.field); + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return != null) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + } + if (!Utils.isEmptyObject(this.filterColumnsPartial)) { params.filter = JSON.stringify(this.filterColumnsPartial, null); } $.extend(params, query || {}); @@ -5723,35 +5887,35 @@ }); } }, { key: "resetRows", value: function resetRows() { - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; try { - for (var _iterator2 = this.data[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var row = _step2.value; + for (var _iterator3 = this.data[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var row = _step3.value; this.$selectAll.prop('checked', false); this.$selectItem.prop('checked', false); if (this.header.stateField) { row[this.header.stateField] = false; } } } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; + _didIteratorError3 = true; + _iteratorError3 = err; } finally { try { - if (!_iteratorNormalCompletion2 && _iterator2.return != null) { - _iterator2.return(); + if (!_iteratorNormalCompletion3 && _iterator3.return != null) { + _iterator3.return(); } } finally { - if (_didIteratorError2) { - throw _iteratorError2; + if (_didIteratorError3) { + throw _iteratorError3; } } } this.initHiddenRows(); @@ -5839,29 +6003,26 @@ while ($tr.length && $tr.find('>td[colspan]:not([colspan="1"])').length) { $tr = $tr.next(); } + var trLength = $tr.find('> *').length; $tr.find('> *').each(function (i, el) { var $this = $(el); - var index = i; - if (_this14.options.detailView && _this14.options.detailViewIcon && !_this14.options.cardView) { - if (i === 0) { + if (Utils.hasDetailViewIcon(_this14.options)) { + if (i === 0 && _this14.options.detailViewAlign !== 'right' || i === trLength - 1 && _this14.options.detailViewAlign === 'right') { var $thDetail = $ths.filter('.detail'); var _zoomWidth = $thDetail.innerWidth() - $thDetail.find('.fht-cell').width(); $thDetail.find('.fht-cell').width($this.innerWidth() - _zoomWidth); + return; } - - index = i - 1; } - if (index === -1) { - return; - } + var index = Utils.hasDetailViewIcon(_this14.options) && _this14.options.detailViewAlign !== 'right' ? i - 1 : i; var $th = _this14.$header_.find(Utils.sprintf('th[data-field="%s"]', visibleFields[index])); if ($th.length > 1) { $th = $($ths[$this[0].cellIndex]); @@ -5881,22 +6042,27 @@ return; } var data = this.getData(); var html = []; + var detailTemplate = ''; - if (!this.options.cardView && this.options.detailView && this.options.detailViewIcon) { - html.push('<th class="detail"><div class="th-inner"></div><div class="fht-cell"></div></th>'); + if (Utils.hasDetailViewIcon(this.options)) { + detailTemplate = '<th class="detail"><div class="th-inner"></div><div class="fht-cell"></div></th>'; } - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; + if (detailTemplate && this.options.detailViewAlign !== 'right') { + html.push(detailTemplate); + } + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + try { - for (var _iterator3 = this.columns[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var column = _step3.value; + for (var _iterator4 = this.columns[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var column = _step4.value; var falign = ''; var valign = ''; var csses = []; var style = {}; var class_ = Utils.sprintf(' class="%s"', column['class']); @@ -5934,24 +6100,28 @@ html.push('<div class="fht-cell"></div>'); html.push('</div>'); html.push('</th>'); } } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; + _didIteratorError4 = true; + _iteratorError4 = err; } finally { try { - if (!_iteratorNormalCompletion3 && _iterator3.return != null) { - _iterator3.return(); + if (!_iteratorNormalCompletion4 && _iterator4.return != null) { + _iterator4.return(); } } finally { - if (_didIteratorError3) { - throw _iteratorError3; + if (_didIteratorError4) { + throw _iteratorError4; } } } + if (detailTemplate && this.options.detailViewAlign === 'right') { + html.push(detailTemplate); + } + if (!this.options.height && !this.$tableFooter.length) { this.$el.append('<tfoot><tr></tr></tfoot>'); this.$tableFooter = this.$el.find('tfoot'); } @@ -5979,30 +6149,25 @@ while ($tr.length && $tr.find('>td[colspan]:not([colspan="1"])').length) { $tr = $tr.next(); } + var trLength = $tr.find('> *').length; $tr.find('> *').each(function (i, el) { var $this = $(el); - var index = i; - if (_this15.options.detailView && !_this15.options.cardView) { - if (i === 0) { + if (Utils.hasDetailViewIcon(_this15.options)) { + if (i === 0 && _this15.options.detailViewAlign === 'left' || i === trLength - 1 && _this15.options.detailViewAlign === 'right') { var $thDetail = $ths.filter('.detail'); var _zoomWidth2 = $thDetail.innerWidth() - $thDetail.find('.fht-cell').width(); $thDetail.find('.fht-cell').width($this.innerWidth() - _zoomWidth2); + return; } - - index = i - 1; } - if (index === -1) { - return; - } - var $th = $ths.eq(i); var zoomWidth = $th.innerWidth() - $th.find('.fht-cell').width(); $th.find('.fht-cell').width($this.innerWidth() - zoomWidth); }); this.horizontalScroll(); @@ -6030,36 +6195,36 @@ } }, { key: "getVisibleFields", value: function getVisibleFields() { var visibleFields = []; - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; + var _iteratorNormalCompletion5 = true; + var _didIteratorError5 = false; + var _iteratorError5 = undefined; try { - for (var _iterator4 = this.header.fields[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var field = _step4.value; + for (var _iterator5 = this.header.fields[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { + var field = _step5.value; var column = this.columns[this.fieldsColumnsIndex[field]]; if (!column || !column.visible) { continue; } visibleFields.push(field); } } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; + _didIteratorError5 = true; + _iteratorError5 = err; } finally { try { - if (!_iteratorNormalCompletion4 && _iterator4.return != null) { - _iterator4.return(); + if (!_iteratorNormalCompletion5 && _iterator5.return != null) { + _iterator5.return(); } } finally { - if (_didIteratorError4) { - throw _iteratorError4; + if (_didIteratorError5) { + throw _iteratorError5; } } } return visibleFields; @@ -6093,10 +6258,12 @@ this.init(); } }, { key: "getData", 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)) { data = this.data; } @@ -6110,29 +6277,47 @@ data = data.filter(function (row) { return Utils.findIndex(hiddenRows, row) === -1; }); } + 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]; + + var column = _this17.columns[_this17.fieldsColumnsIndex[key]]; + + if (!column) { + return; + } + + row[key] = Utils.calculateObjectValue(column, _this17.header.formatters[column.fieldIndex], [value, row, row.index, column.field], value); + } + }); + } + return data; } }, { key: "getSelections", value: function getSelections() { - var _this17 = this; + var _this18 = this; // fix #2424: from html with checkbox return this.data.filter(function (row) { - return row[_this17.header.stateField] === true; + return row[_this18.header.stateField] === true; }); } }, { key: "getAllSelections", value: function getAllSelections() { - var _this18 = this; + var _this19 = this; return this.options.data.filter(function (row) { - return row[_this18.header.stateField] === true; + return row[_this19.header.stateField] === true; }); } }, { key: "load", value: function load(_data) { @@ -6182,17 +6367,22 @@ if (!params.hasOwnProperty('field') || !params.hasOwnProperty('values')) { return; } for (i = len - 1; i >= 0; i--) { + var exists = false; row = this.options.data[i]; - if (!row.hasOwnProperty(params.field)) { + if (!row.hasOwnProperty(params.field) && params.field !== '$index') { continue; + } else if (!row.hasOwnProperty(params.field) && params.field === '$index') { + exists = params.values.includes(i); + } else { + exists = params.values.includes(row[params.field]); } - if (params.values.includes(row[params.field])) { + if (exists) { this.options.data.splice(i, 1); if (this.options.sidePagination === 'server') { this.options.totalRows -= 1; } @@ -6233,41 +6423,39 @@ } }, { key: "updateRow", value: function updateRow(params) { var allParams = Array.isArray(params) ? params : [params]; - var _iteratorNormalCompletion5 = true; - var _didIteratorError5 = false; - var _iteratorError5 = undefined; + var _iteratorNormalCompletion6 = true; + var _didIteratorError6 = false; + var _iteratorError6 = undefined; try { - for (var _iterator5 = allParams[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { - var _params = _step5.value; + for (var _iterator6 = allParams[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { + var _params = _step6.value; if (!_params.hasOwnProperty('index') || !_params.hasOwnProperty('row')) { continue; } - $.extend(this.options.data[_params.index], _params.row); - if (_params.hasOwnProperty('replace') && _params.replace) { this.options.data[_params.index] = _params.row; } else { $.extend(this.options.data[_params.index], _params.row); } } } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; + _didIteratorError6 = true; + _iteratorError6 = err; } finally { try { - if (!_iteratorNormalCompletion5 && _iterator5.return != null) { - _iterator5.return(); + if (!_iteratorNormalCompletion6 && _iterator6.return != null) { + _iterator6.return(); } } finally { - if (_didIteratorError5) { - throw _iteratorError5; + if (_didIteratorError6) { + throw _iteratorError6; } } } this.initSearch(); @@ -6319,17 +6507,17 @@ } }, { key: "updateByUniqueId", value: function updateByUniqueId(params) { var allParams = Array.isArray(params) ? params : [params]; - var _iteratorNormalCompletion6 = true; - var _didIteratorError6 = false; - var _iteratorError6 = undefined; + var _iteratorNormalCompletion7 = true; + var _didIteratorError7 = false; + var _iteratorError7 = undefined; try { - for (var _iterator6 = allParams[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { - var _params2 = _step6.value; + for (var _iterator7 = allParams[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { + var _params2 = _step7.value; if (!_params2.hasOwnProperty('id') || !_params2.hasOwnProperty('row')) { continue; } @@ -6344,20 +6532,20 @@ } else { $.extend(this.options.data[rowId], _params2.row); } } } catch (err) { - _didIteratorError6 = true; - _iteratorError6 = err; + _didIteratorError7 = true; + _iteratorError7 = err; } finally { try { - if (!_iteratorNormalCompletion6 && _iterator6.return != null) { - _iterator6.return(); + if (!_iteratorNormalCompletion7 && _iterator7.return != null) { + _iterator7.return(); } } finally { - if (_didIteratorError6) { - throw _iteratorError6; + if (_didIteratorError7) { + throw _iteratorError7; } } } this.initSearch(); @@ -6400,29 +6588,25 @@ this.initBody(true); } }, { key: "updateCellByUniqueId", value: function updateCellByUniqueId(params) { - var _this19 = this; + var _this20 = this; - if (!params.hasOwnProperty('id') || !params.hasOwnProperty('field') || !params.hasOwnProperty('value')) { - return; - } - var allParams = Array.isArray(params) ? params : [params]; allParams.forEach(function (_ref6) { var id = _ref6.id, field = _ref6.field, value = _ref6.value; - var rowId = _this19.options.data.indexOf(_this19.getRowByUniqueId(id)); + var rowId = _this20.options.data.indexOf(_this20.getRowByUniqueId(id)); if (rowId === -1) { return; } - _this19.options.data[rowId][field] = value; + _this20.options.data[rowId][field] = value; }); if (params.reinit === false) { return; } @@ -6461,76 +6645,73 @@ this.hiddenRows.push(row); } else if (visible && index > -1) { this.hiddenRows.splice(index, 1); } - if (visible) { - this.updatePagination(); - } else { - this.initBody(true); - this.initPagination(); - } + this.initBody(true); + this.initPagination(); } }, { key: "getHiddenRows", value: function getHiddenRows(show) { if (show) { this.initHiddenRows(); this.initBody(true); + this.initPagination(); return; } var data = this.getData(); var rows = []; - var _iteratorNormalCompletion7 = true; - var _didIteratorError7 = false; - var _iteratorError7 = undefined; + var _iteratorNormalCompletion8 = true; + var _didIteratorError8 = false; + var _iteratorError8 = undefined; try { - for (var _iterator7 = data[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { - var row = _step7.value; + for (var _iterator8 = data[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) { + var row = _step8.value; if (this.hiddenRows.includes(row)) { rows.push(row); } } } catch (err) { - _didIteratorError7 = true; - _iteratorError7 = err; + _didIteratorError8 = true; + _iteratorError8 = err; } finally { try { - if (!_iteratorNormalCompletion7 && _iterator7.return != null) { - _iterator7.return(); + if (!_iteratorNormalCompletion8 && _iterator8.return != null) { + _iterator8.return(); } } finally { - if (_didIteratorError7) { - throw _iteratorError7; + if (_didIteratorError8) { + throw _iteratorError8; } } } this.hiddenRows = rows; return rows; } }, { key: "showColumn", value: function showColumn(field) { - var _this20 = this; + var _this21 = this; var fields = Array.isArray(field) ? field : [field]; fields.forEach(function (field) { - _this20._toggleColumn(_this20.fieldsColumnsIndex[field], true, true); + _this21._toggleColumn(_this21.fieldsColumnsIndex[field], true, true); }); } }, { key: "hideColumn", value: function hideColumn(field) { - var _this21 = this; + var _this22 = this; var fields = Array.isArray(field) ? field : [field]; fields.forEach(function (field) { - _this21._toggleColumn(_this21.fieldsColumnsIndex[field], false, true); + _this22._toggleColumn(_this22.fieldsColumnsIndex[field], false, true); }); } }, { key: "_toggleColumn", value: function _toggleColumn(index, checked, needUpdate) { @@ -6557,14 +6738,14 @@ } } }, { key: "getVisibleColumns", value: function getVisibleColumns() { - var _this22 = this; + var _this23 = this; return this.columns.filter(function (column) { - return column.visible && !_this22.isSelectionColumn(column); + return column.visible && !_this23.isSelectionColumn(column); }); } }, { key: "getHiddenColumns", value: function getHiddenColumns() { @@ -6589,39 +6770,39 @@ this._toggleAllColumns(false); } }, { key: "_toggleAllColumns", value: function _toggleAllColumns(visible) { - var _this23 = this; + var _this24 = this; - var _iteratorNormalCompletion8 = true; - var _didIteratorError8 = false; - var _iteratorError8 = undefined; + var _iteratorNormalCompletion9 = true; + var _didIteratorError9 = false; + var _iteratorError9 = undefined; try { - for (var _iterator8 = this.columns.slice().reverse()[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) { - var column = _step8.value; + for (var _iterator9 = this.columns.slice().reverse()[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) { + var column = _step9.value; if (column.switchable) { if (!visible && this.options.showColumns && this.getVisibleColumns().length === this.options.minimumCountColumns) { continue; } column.visible = visible; } } } catch (err) { - _didIteratorError8 = true; - _iteratorError8 = err; + _didIteratorError9 = true; + _iteratorError9 = err; } finally { try { - if (!_iteratorNormalCompletion8 && _iterator8.return != null) { - _iterator8.return(); + if (!_iteratorNormalCompletion9 && _iterator9.return != null) { + _iterator9.return(); } } finally { - if (_didIteratorError8) { - throw _iteratorError8; + if (_didIteratorError9) { + throw _iteratorError9; } } } this.initHeader(); @@ -6634,11 +6815,11 @@ if (visible) { $items.prop('checked', visible); } else { $items.get().reverse().forEach(function (item) { - if ($items.filter(':checked').length > _this23.options.minimumCountColumns) { + if ($items.filter(':checked').length > _this24.options.minimumCountColumns) { $(item).prop('checked', visible); } }); } @@ -6656,11 +6837,11 @@ var colspan = options.colspan || 1; var i; var j; var $tr = this.$body.find('>tr'); - if (this.options.detailView && !this.options.cardView) { + if (Utils.hasDetailViewIcon(this.options)) { col += 1; } var $td = $tr.eq(row).find('>td').eq(col); @@ -6731,30 +6912,30 @@ value: function _toggleCheck(checked, index) { var $el = this.$selectItem.filter("[data-index=\"".concat(index, "\"]")); var row = this.data[index]; if ($el.is(':radio') || this.options.singleSelect || this.options.multipleSelectRow && !this.multipleSelectRowCtrlKey && !this.multipleSelectRowShiftKey) { - var _iteratorNormalCompletion9 = true; - var _didIteratorError9 = false; - var _iteratorError9 = undefined; + var _iteratorNormalCompletion10 = true; + var _didIteratorError10 = false; + var _iteratorError10 = undefined; try { - for (var _iterator9 = this.options.data[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) { - var r = _step9.value; + for (var _iterator10 = this.options.data[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) { + var r = _step10.value; r[this.header.stateField] = false; } } catch (err) { - _didIteratorError9 = true; - _iteratorError9 = err; + _didIteratorError10 = true; + _iteratorError10 = err; } finally { try { - if (!_iteratorNormalCompletion9 && _iterator9.return != null) { - _iterator9.return(); + if (!_iteratorNormalCompletion10 && _iterator10.return != null) { + _iterator10.return(); } } finally { - if (_didIteratorError9) { - throw _iteratorError9; + if (_didIteratorError10) { + throw _iteratorError10; } } } this.$selectItem.filter(':checked').not($el).prop('checked', false); @@ -6792,11 +6973,11 @@ this._toggleCheckBy(false, obj); } }, { key: "_toggleCheckBy", value: function _toggleCheckBy(checked, obj) { - var _this24 = this; + var _this25 = this; if (!obj.hasOwnProperty('field') || !obj.hasOwnProperty('values')) { return; } @@ -6805,23 +6986,23 @@ if (!row.hasOwnProperty(obj.field)) { return false; } if (obj.values.includes(row[obj.field])) { - var $el = _this24.$selectItem.filter(':enabled').filter(Utils.sprintf('[data-index="%s"]', i)); + var $el = _this25.$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[_this24.header.stateField] = checked; + row[_this25.header.stateField] = checked; rows.push(row); - _this24.trigger(checked ? 'check' : 'uncheck', row, $el); + _this25.trigger(checked ? 'check' : 'uncheck', row, $el); } }); this.updateSelected(); this.trigger(checked ? 'check-some' : 'uncheck-some', rows); } @@ -6883,18 +7064,23 @@ if (this.$container.hasClass('fullscreen')) { this.$tableContainer.css('height', ''); this.$tableContainer.css('width', ''); } else if (this.options.height) { + if (this.$tableBorder) { + this.$tableBorder.css('width', ''); + this.$tableBorder.css('height', ''); + } + var toolbarHeight = this.$toolbar.outerHeight(true); var paginationHeight = this.$pagination.outerHeight(true); var height = this.options.height - toolbarHeight - paginationHeight; var $bodyTable = this.$tableBody.find('>table'); var tableHeight = $bodyTable.outerHeight(); this.$tableContainer.css('height', "".concat(height, "px")); - if (this.$tableBorder) { + if (this.$tableBorder && $bodyTable.is(':visible')) { var tableBorderHeight = height - tableHeight - 2; if (this.$tableBody[0].scrollWidth - this.$tableBody.innerWidth()) { tableBorderHeight -= Utils.getScrollBarWidth(); } @@ -6919,10 +7105,20 @@ } }, { key: "showLoading", value: function showLoading() { this.$tableLoading.css('display', 'flex'); + var fontSize = this.options.loadingFontSize; + + if (this.options.loadingFontSize === 'auto') { + fontSize = this.$tableLoading.width() * 0.04; + fontSize = Math.max(12, fontSize); + fontSize = Math.min(32, fontSize); + fontSize = "".concat(fontSize, "px"); + } + + this.$tableLoading.find('.loading-text').css('font-size', fontSize); } }, { key: "hideLoading", value: function hideLoading() { this.$tableLoading.css('display', 'none'); @@ -6985,11 +7181,11 @@ if (_typeof(params) === 'object') { options = Object.assign(options, params); } else if (typeof params === 'string' && params === 'bottom') { options.value = this.$tableBody[0].scrollHeight; - } else if (typeof params === 'string') { + } else if (typeof params === 'string' || typeof params === 'number') { options.value = params; } var scrollTo = options.value; @@ -7068,10 +7264,21 @@ } this.trigger('expand-row', index, row, $element); } }, { + key: "expandRowByUniqueId", + value: function expandRowByUniqueId(uniqueId) { + var row = this.getRowByUniqueId(uniqueId); + + if (!row) { + return; + } + + this.expandRow(this.data.indexOf(row)); + } + }, { key: "collapseRow", value: function collapseRow(index) { var row = this.data[index]; var $tr = this.$body.find(Utils.sprintf('> tr[data-index="%s"][data-has-detail-view]', index)); @@ -7083,9 +7290,20 @@ $tr.find('a.detail-icon').html(Utils.sprintf(this.constants.html.icon, this.options.iconsPrefix, this.options.icons.detailOpen)); } this.trigger('collapse-row', index, row, $tr.next()); $tr.next().remove(); + } + }, { + key: "collapseRowByUniqueId", + value: function collapseRowByUniqueId(uniqueId) { + var row = this.getRowByUniqueId(uniqueId); + + if (!row) { + return; + } + + this.collapseRow(this.data.indexOf(row)); } }, { key: "expandAllRows", value: function expandAllRows() { var trs = this.$body.find('> tr[data-index][data-has-detail-view]');