From 38424bfdca4ce7c4f247d1b32055dcffc0cad550 Mon Sep 17 00:00:00 2001 From: Max Guglielmi Date: Fri, 2 Jun 2017 14:01:10 +1000 Subject: [PATCH] Started refactoring configuration options --- .eslintrc | 2 +- package.json | 2 +- src/modules/gridLayout.js | 26 ++++++++++++-------------- src/tablefilter.js | 8 ++++---- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.eslintrc b/.eslintrc index 2b56168f..554d88cf 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,7 +13,7 @@ "keyword-spacing": ["error", { "after": true, "before": true }], "max-depth": [2, 7], "max-statements": [2, 143], - "complexity": [2, 81], + "complexity": [2, 82], "no-unused-vars": 2, "no-eval": 2, "no-underscore-dangle": 0, diff --git a/package.json b/package.json index ffb099f5..05a793b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tablefilter", - "version": "0.5.19", + "version": "0.5.20", "description": "A Javascript library making HTML tables filterable and a bit more", "license": "MIT", "author": { diff --git a/src/modules/gridLayout.js b/src/modules/gridLayout.js index d73b0c60..8f1817fa 100644 --- a/src/modules/gridLayout.js +++ b/src/modules/gridLayout.js @@ -16,75 +16,73 @@ export class GridLayout extends Feature { constructor(tf) { super(tf, 'gridLayout'); - let f = this.config; + let f = this.config.grid_layout || {}; /** * Grid-layout container width as CSS string * @type {String} */ - this.width = f.grid_width || null; + this.width = f.width || null; /** * Grid-layout container height as CSS string * @type {String} */ - this.height = f.grid_height || null; + this.height = f.height || null; /** * Css class for main container element * @type {String} */ - this.mainContCssClass = f.grid_cont_css_class || 'grd_Cont'; + this.mainContCssClass = f.cont_css_class || 'grd_Cont'; /** * Css class for body table container element * @type {String} */ - this.contCssClass = f.grid_tbl_cont_css_class || 'grd_tblCont'; + this.contCssClass = f.tbl_cont_css_class || 'grd_tblCont'; /** * Css class for headers table container element * @type {String} */ - this.headContCssClass = f.grid_tblHead_cont_css_class || - 'grd_headTblCont'; + this.headContCssClass = f.tblHead_cont_css_class || 'grd_headTblCont'; /** * Css class for toolbar container element (rows counter, paging etc.) * @type {String} */ - this.infDivCssClass = f.grid_inf_grid_css_class || 'grd_inf'; + this.infDivCssClass = f.inf_grid_css_class || 'grd_inf'; /** * Index of the headers row, default: 0 * @type {Number} */ - this.headRowIndex = f.grid_headers_row_index || 0; + this.headRowIndex = f.headers_row_index || 0; /** * Collection of the header row indexes to be moved into headers table * @type {Array} */ - this.headRows = f.grid_headers_rows || [0]; + this.headRows = f.headers_rows || [0]; /** * Enable or disable column filters generation, default: true * @type {Boolean} */ - this.enableFilters = f.grid_enable_default_filters === false ? - false : true; + this.enableFilters = f.enable_default_filters === false ? false : true; /** * Enable or disable column headers, default: false * @type {Boolean} */ - this.noHeaders = Boolean(f.grid_no_headers); + this.noHeaders = Boolean(f.no_headers); /** * Grid-layout default column widht as CSS string * @type {String} */ - this.defaultColWidth = f.grid_default_col_width || '100px'; + this.defaultColWidth = f.default_col_width || '100px'; /** * List of column elements diff --git a/src/tablefilter.js b/src/tablefilter.js index 15127040..8e34c627 100644 --- a/src/tablefilter.js +++ b/src/tablefilter.js @@ -161,9 +161,9 @@ export class TableFilter { /** * Enable/disable grid layout (fixed headers) - * @type {Boolean} + * @type {Object|Boolean} */ - this.gridLayout = Boolean(f.grid_layout); + this.gridLayout = isObj(f.grid_layout) || Boolean(f.grid_layout); /** * Filters row index @@ -812,14 +812,14 @@ export class TableFilter { /** * Enable no results message UI component - * @type {Boolean} + * @type {Object|Boolean} */ this.noResults = isObj(f.no_results_message) || Boolean(f.no_results_message); /** * Enable state persistence - * @type {Boolean} + * @type {Object|Boolean} */ this.state = isObj(f.state) || Boolean(f.state);