1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-13 03:13:00 +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", "name": "tablefilter",
"version": "0.5.27", "version": "0.5.28",
"description": "A Javascript library making HTML tables filterable and a bit more", "description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT", "license": "MIT",
"author": { "author": {

View file

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

View file

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