mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-17 16:10:04 +01:00
Initial commit
This commit is contained in:
parent
1cd4f9e9b8
commit
e4ab8be82f
13 changed files with 10833 additions and 67 deletions
58
src/const.js
58
src/const.js
|
|
@ -1,28 +1,84 @@
|
|||
/**
|
||||
* Filter types
|
||||
*/
|
||||
|
||||
/**
|
||||
* Input filter type
|
||||
* @type {String}
|
||||
*/
|
||||
export const INPUT = 'input';
|
||||
/**
|
||||
* Select filter type
|
||||
* @type {String}
|
||||
*/
|
||||
export const SELECT = 'select';
|
||||
/**
|
||||
* Multiple select filter type
|
||||
* @type {String}
|
||||
*/
|
||||
export const MULTIPLE = 'multiple';
|
||||
/**
|
||||
* Checklist filter type
|
||||
* @type {String}
|
||||
*/
|
||||
export const CHECKLIST = 'checklist';
|
||||
/**
|
||||
* None filter type
|
||||
* @type {String}
|
||||
*/
|
||||
export const NONE = 'none';
|
||||
|
||||
/**
|
||||
* Key codes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enter key code
|
||||
* @type {Number}
|
||||
*/
|
||||
export const ENTER_KEY = 13;
|
||||
/**
|
||||
* Tab key code
|
||||
* @type {Number}
|
||||
*/
|
||||
export const TAB_KEY = 9;
|
||||
/**
|
||||
* Escape key code
|
||||
* @type {Number}
|
||||
*/
|
||||
export const ESC_KEY = 27;
|
||||
/**
|
||||
* Up arrow key code
|
||||
* @type {Number}
|
||||
*/
|
||||
export const UP_ARROW_KEY = 38;
|
||||
/**
|
||||
* Down arrow key code
|
||||
* @type {Number}
|
||||
*/
|
||||
export const DOWN_ARROW_KEY = 40;
|
||||
|
||||
/**
|
||||
* HTML tags
|
||||
*/
|
||||
|
||||
/**
|
||||
* Header tag
|
||||
* @type {String}
|
||||
*/
|
||||
export const HEADER_TAG = 'TH';
|
||||
/**
|
||||
* Cell tag
|
||||
* @type {String}
|
||||
*/
|
||||
export const CELL_TAG = 'TD';
|
||||
|
||||
/**
|
||||
* Numeric values
|
||||
* Misc values
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-filter delay in milliseconds
|
||||
* @type {Number}
|
||||
*/
|
||||
export const AUTO_FILTER_DELAY = 750;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export default class AdapterEzEditTable extends Feature {
|
|||
this._setAdvancedGrid();
|
||||
} else {
|
||||
var path = this.vendorPath + this.filename;
|
||||
tf.import(this.filename, path, () => { this._setAdvancedGrid(); });
|
||||
tf.import(this.filename, path, () => this._setAdvancedGrid());
|
||||
}
|
||||
if (this.loadStylesheet && !tf.isImported(this.stylesheet, 'link')) {
|
||||
tf.import(this.stylesheetName, this.stylesheet, null, 'link');
|
||||
|
|
|
|||
|
|
@ -1887,27 +1887,23 @@ export class TableFilter {
|
|||
}
|
||||
tbl = tbl || this.tbl;
|
||||
|
||||
setWidths.call(this);
|
||||
|
||||
function setWidths() {
|
||||
let nbCols = this.nbCells;
|
||||
let colWidths = this.colWidths;
|
||||
let colTags = tag(tbl, 'col');
|
||||
let tblHasColTag = colTags.length > 0;
|
||||
let frag = !tblHasColTag ? doc.createDocumentFragment() : null;
|
||||
for (let k = 0; k < nbCols; k++) {
|
||||
let col;
|
||||
if (tblHasColTag) {
|
||||
col = colTags[k];
|
||||
} else {
|
||||
col = createElm('col', ['id', this.id + '_col_' + k]);
|
||||
frag.appendChild(col);
|
||||
}
|
||||
col.style.width = colWidths[k];
|
||||
}
|
||||
if (!tblHasColTag) {
|
||||
tbl.insertBefore(frag, tbl.firstChild);
|
||||
let nbCols = this.nbCells;
|
||||
let colWidths = this.colWidths;
|
||||
let colTags = tag(tbl, 'col');
|
||||
let tblHasColTag = colTags.length > 0;
|
||||
let frag = !tblHasColTag ? doc.createDocumentFragment() : null;
|
||||
for (let k = 0; k < nbCols; k++) {
|
||||
let col;
|
||||
if (tblHasColTag) {
|
||||
col = colTags[k];
|
||||
} else {
|
||||
col = createElm('col', ['id', this.id + '_col_' + k]);
|
||||
frag.appendChild(col);
|
||||
}
|
||||
col.style.width = colWidths[k];
|
||||
}
|
||||
if (!tblHasColTag) {
|
||||
tbl.insertBefore(frag, tbl.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2084,13 +2080,12 @@ export class TableFilter {
|
|||
* @param {String} type Possible values: 'script' or 'link'
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isImported(filePath, type) {
|
||||
isImported(filePath, type = 'script') {
|
||||
let imported = false,
|
||||
importType = !type ? 'script' : type,
|
||||
attr = importType === 'script' ? 'src' : 'href',
|
||||
files = tag(doc, importType);
|
||||
attr = type === 'script' ? 'src' : 'href',
|
||||
files = tag(doc, type);
|
||||
for (let i = 0, len = files.length; i < len; i++) {
|
||||
if (files[i][attr] === undefined) {
|
||||
if (isUndef(files[i][attr])) {
|
||||
continue;
|
||||
}
|
||||
if (files[i][attr].match(filePath)) {
|
||||
|
|
@ -2108,10 +2103,8 @@ export class TableFilter {
|
|||
* @param {Function} callback Callback
|
||||
* @param {String} type Possible values: 'script' or 'link'
|
||||
*/
|
||||
import(fileId, filePath, callback, type) {
|
||||
let ftype = !type ? 'script' : type,
|
||||
imported = this.isImported(filePath, ftype);
|
||||
if (imported) {
|
||||
import(fileId, filePath, callback, type = 'script') {
|
||||
if (this.isImported(filePath, type)) {
|
||||
return;
|
||||
}
|
||||
let o = this,
|
||||
|
|
@ -2119,7 +2112,7 @@ export class TableFilter {
|
|||
file,
|
||||
head = tag(doc, 'head')[0];
|
||||
|
||||
if (ftype.toLowerCase() === 'link') {
|
||||
if (type.toLowerCase() === 'link') {
|
||||
file = createElm('link',
|
||||
['id', fileId], ['type', 'text/css'],
|
||||
['rel', 'stylesheet'], ['href', filePath]
|
||||
|
|
@ -2132,7 +2125,7 @@ export class TableFilter {
|
|||
}
|
||||
|
||||
//Browser <> IE onload event works only for scripts, not for stylesheets
|
||||
file.onload = file.onreadystatechange = function () {
|
||||
file.onload = file.onreadystatechange = () => {
|
||||
if (!isLoaded &&
|
||||
(!this.readyState || this.readyState === 'loaded' ||
|
||||
this.readyState === 'complete')) {
|
||||
|
|
@ -2143,7 +2136,7 @@ export class TableFilter {
|
|||
}
|
||||
};
|
||||
file.onerror = function () {
|
||||
throw new Error('TableFilter could not load: ' + filePath);
|
||||
throw new Error(`TableFilter could not load: ${filePath}`);
|
||||
};
|
||||
head.appendChild(file);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue