1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-09 18:06:53 +02:00

Remove hasExtensions and hasColWidths properties on TableFilter

This commit is contained in:
koalyptus 2017-07-08 10:53:19 +10:00
parent 761c3730ed
commit 2f1e065571
3 changed files with 16 additions and 30 deletions

View file

@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.5.27",
"version": "0.5.28",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {

View file

@ -301,7 +301,7 @@ export class GridLayout extends Feature {
*/
setDefaultColWidths() {
let tf = this.tf;
if (tf.hasColWidths) {
if (tf.colWidths.length > 0) {
return;
}
for (let k = 0, len = tf.getCellsNb(); k < len; k++) {
@ -316,7 +316,6 @@ export class GridLayout extends Feature {
}
tf.colWidths[k] = colW;
}
tf.hasColWidths = true;
tf.setColWidths();
}

View file

@ -153,7 +153,11 @@ export class TableFilter {
//Start row
this.refRow = isUndef(startRow) ? 2 : (startRow + 1);
// get the collection of filter type by column
/**
* Collection of filter type by column
* @type {Array}
* @private
*/
this.filterTypes = [].map.call(
(this.dom().rows[this.refRow] || this.dom().rows[0]).cells,
(cell, idx) => {
@ -307,18 +311,11 @@ export class TableFilter {
*/
this.alternateRows = Boolean(f.alternate_rows);
/**
* Indicate whether columns widths are set
* @type {Boolean}
* @private
*/
this.hasColWidths = isArray(f.col_widths);
/**
* Columns widths array
* @type {Array}
*/
this.colWidths = this.hasColWidths ? f.col_widths : [];
this.colWidths = f.col_widths || [];
/**
* Css class for a filter element
@ -938,14 +935,7 @@ export class TableFilter {
* @type {Array}
* @private
*/
this.extensions = f.extensions;
/**
* Determine whether extensions are loaded
* @type {Boolean}
* @private
*/
this.hasExtensions = isArray(this.extensions);
this.extensions = f.extensions || [];
/*** themes ***/
/**
@ -1107,9 +1097,7 @@ export class TableFilter {
paging
]);
if (this.hasColWidths && !this.gridLayout) {
this.setColWidths();
}
this.setColWidths();
//TF css class is added to table
if (!this.gridLayout) {
@ -1381,11 +1369,11 @@ export class TableFilter {
* Initialise all the extensions defined in the configuration object
*/
initExtensions() {
if (!this.hasExtensions) {
let exts = this.extensions;
if (exts.length === 0) {
return;
}
let exts = this.extensions;
// Set config's publicPath dynamically for Webpack...
__webpack_public_path__ = this.basePath;
@ -1531,9 +1519,7 @@ export class TableFilter {
this.removeToolbar();
if (this.hasExtensions) {
this.destroyExtensions();
}
this.destroyExtensions();
this.validateAllRows();
@ -2674,13 +2660,14 @@ export class TableFilter {
* @param {Element} tbl DOM element
*/
setColWidths(tbl) {
if (!this.hasColWidths) {
let colWidths = this.colWidths;
if (colWidths.length === 0 || this.gridLayout) {
return;
}
tbl = tbl || this.dom();
let nbCols = this.nbCells;
let colWidths = this.colWidths;
let colTags = tag(tbl, 'col');
let tblHasColTag = colTags.length > 0;
let frag = !tblHasColTag ? doc.createDocumentFragment() : null;