1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-02 06:43:08 +02:00
This commit is contained in:
koalyptus 2019-01-15 23:29:13 +11:00
parent bfa440b265
commit 37f6db7025
20 changed files with 38016 additions and 7 deletions

View file

@ -13,7 +13,7 @@
"array-bracket-spacing": 2,
"keyword-spacing": ["error", { "after": true, "before": true }],
"max-depth": [2, 7],
"max-statements": [2, 133],
"max-statements": [2, 134],
"complexity": [2, 41],
"no-unused-vars": 2,
"no-eval": 2,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

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

View file

@ -1,16 +1,19 @@
import {TfBase} from './tfBase';
const NOT_IMPLEMENTED = 'Not implemented.';
/**
* Base class defining the interface of a TableFilter feature
*/
export class Feature {
export class Feature extends TfBase {
/**
* Creates an instance of Feature
* @param {Object} tf TableFilter instance
* @param {String} feature Feature name known by TableFilter
*/
constructor(tf, feature) {
constructor(tf, feature, cls) {
super(tf, cls);
/**
* TableFilter instance
* @type {TableFilter}

View file

@ -137,3 +137,6 @@ export class ClearButton extends Feature {
this.initialized = false;
}
}
// TODO: remove as soon as feature name is fixed
ClearButton.altName = 'btnReset';

View file

@ -238,3 +238,6 @@ export class Help extends Feature {
}
}
// TODO: remove as soon as feature name is fixed
Help.alwaysInstantiate = true;

View file

@ -172,3 +172,6 @@ export class HighlightKeyword {
this.highlight(cell, term, this.highlightCssClass);
}
}
// TODO: remove as soon as feature name is fixed
HighlightKeyword.altName = 'highlightKeywords';

View file

@ -456,3 +456,6 @@ export class PopupFilter extends Feature {
}
}
// TODO: remove as soon as feature name is fixed
PopupFilter.altName = 'popupFilters';

View file

@ -17,7 +17,7 @@ export class RowsCounter extends Feature {
* @param {TableFilter} tf TableFilter instance
*/
constructor(tf) {
super(tf, 'rowsCounter');
super(tf, 'rowsCounter', RowsCounter);
// TableFilter configuration
let f = this.config.rows_counter || {};

View file

@ -219,3 +219,6 @@ export class Toolbar extends Feature {
this.initialized = false;
}
}
// TODO: remove as soon as feature name is fixed
Toolbar.alwaysInstantiate = true;

View file

@ -74,3 +74,18 @@ export const contains = (term, data, exactMatch = false, caseSensitive = false,
}
return regexp.test(data);
};
/**
* Camelize a string, cutting the string by multiple separators like
* hyphens, underscores and spaces.
* @param {String} text text to camelize
* @return {String} camelized text
*/
export const toCamelCase = (text = '') => {
return text.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2) => {
if (p2) {
return p2.toUpperCase();
}
return p1.toLowerCase();
});
};

View file

@ -919,6 +919,7 @@ export class TableFilter {
* @private
*/
this.Mod = {};
this._mod_ = [];
/**
* Extensions registry

21
src/tfBase.js Normal file
View file

@ -0,0 +1,21 @@
import {defaultsStr} from './settings';
import {toCamelCase} from './string';
export class TfBase {
constructor(tf, cls = {}) {
/**
* TableFilter instance
* @type {TableFilter}
*/
this.tf = tf;
/**
* Feature name, retrieved from alternate class name if found or from
* camelised class name
* @type {String}
*/
this.feature = defaultsStr(cls.altName, toCamelCase(cls.name));
this.tf._mod_.push(this.feature);
}
}