mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-08 00:42:28 +02:00
Compare commits
153 commits
Author | SHA1 | Date | |
---|---|---|---|
7afe45f1e6 | |||
6e01e45dfb | |||
12c30629af | |||
3e763efac9 | |||
825b915ae8 | |||
8e48bf2943 | |||
be7a5e585f | |||
c44bef22a2 | |||
6dcebbf67e | |||
44cb6f9124 | |||
571c31e8da | |||
8633891fdb | |||
8eddc6f35c | |||
577fb0b90a | |||
88a5bfe425 | |||
cac2900444 | |||
5dad4dae8e | |||
134851525c | |||
9a66748bb8 | |||
c52004421f | |||
f53b392c59 | |||
c496b0916d | |||
25b89b19e7 | |||
8b4a05be02 | |||
1c4961a25b | |||
40daf54768 | |||
c43debc7ac | |||
3ac2603e47 | |||
185c119342 | |||
80c9b3d734 | |||
e8605e5e19 | |||
bd95afb3eb | |||
c16f885951 | |||
6be9ad491f | |||
447a3119aa | |||
2025aa4010 | |||
bdc03755e8 | |||
2dceed888e | |||
982769a020 | |||
4318826ead | |||
66b8fa9d94 | |||
79cea3e27f | |||
7af493da27 | |||
90c3b7f937 | |||
85dce5847a | |||
65863b635a | |||
3c001f52e2 | |||
e3957977b6 | |||
8923c4db94 | |||
c7d1a25467 | |||
ebdd817199 | |||
27365e25d4 | |||
2e960867ab | |||
3d35d53005 | |||
02bc5e3ae1 | |||
09c1f8ff52 | |||
6b339f7bd7 | |||
a1efe26a85 | |||
64e6c6597f | |||
9363a7a661 | |||
41e220efa9 | |||
64d3808a2b | |||
eb15788965 | |||
fede2f6e86 | |||
9738c8ed91 | |||
b285d01b54 | |||
37eed72f2c | |||
71103cd04b | |||
42a347550b | |||
bed04b5b9b | |||
43fc68df31 | |||
d116525f73 | |||
d7ff36514d | |||
0d0abf3206 | |||
4cd004e423 | |||
459829a214 | |||
b8c0c1bc3f | |||
5686e8a470 | |||
b04d4f55ed | |||
3004963058 | |||
3454187be6 | |||
1dac7736b1 | |||
2c7ad88346 | |||
6e41c4a8c6 | |||
859f6b1eeb | |||
7204c4b546 | |||
f29b59fdbd | |||
6cc887e806 | |||
f7ad9741ca | |||
323a80d1d7 | |||
fc46f0b4ae | |||
0471570985 | |||
20243b641f | |||
99722cbdb0 | |||
64cc6825c5 | |||
bcb541fcad | |||
1c3c1bbb0a | |||
bba009c505 | |||
48659ec1d5 | |||
1d32dcea7d | |||
0e1c617b06 | |||
5c705fe591 | |||
3c501e3aef | |||
78ae09c861 | |||
2e1af5efb3 | |||
da270df5d6 | |||
8a8419bf02 | |||
a6c24c7885 | |||
ed2fef999a | |||
47c66d71bb | |||
f99f850c4d | |||
10c06b5100 | |||
1cc810c341 | |||
c707978e19 | |||
32b541239e | |||
2963962250 | |||
bbec44cc15 | |||
352a700fb2 | |||
fae4ec9e07 | |||
226f18a6f6 | |||
1d58191127 | |||
1559c74fd9 | |||
2cd30b1bfb | |||
cd5e5589a4 | |||
5499093810 | |||
df54ddda33 | |||
80ebc0aa8c | |||
a5fa336a08 | |||
36d4f85f6c | |||
e886a6f1a8 | |||
7204746e5f | |||
ecd33d0631 | |||
f97394fc32 | |||
eef0ab3bbd | |||
c48b48f924 | |||
d699d02914 | |||
09b3f7875d | |||
9c54974338 | |||
b89a52fb77 | |||
ef46fd4295 | |||
8d8c8ae74c | |||
fafa983dac | |||
a19c5a106f | |||
1e391233dc | |||
aade342976 | |||
0443442916 | |||
ed4979331c | |||
0e1a1ff3d1 | |||
e71b3a5c93 | |||
a22b009c57 | |||
f6a9a058c9 | |||
f7c231b99f | |||
6f4e5a91ab |
|
@ -14,7 +14,7 @@
|
|||
"keyword-spacing": ["error", { "after": true, "before": true }],
|
||||
"max-depth": [2, 7],
|
||||
"max-statements": [2, 133],
|
||||
"complexity": [2, 41],
|
||||
"complexity": [2, 45],
|
||||
"no-unused-vars": 2,
|
||||
"no-eval": 2,
|
||||
"no-underscore-dangle": 0,
|
||||
|
|
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Reproduction steps:**
|
||||
Steps to reproduce the behavior:
|
||||
1. [First Step]
|
||||
2. [Second Step]
|
||||
3. [Other Steps...]
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Observed behavior:**
|
||||
A clear and concise description of observed behavior.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
![Screenshots and GIFs which follow reproduction steps to demonstrate the problem](url)
|
||||
|
||||
**TableFilter version:** [Enter TableFilter version here]
|
||||
**Browser and version:** [Enter Browser name and version here]
|
||||
**OS and version:** [Enter OS name and version here]
|
||||
**Device:** [e.g. iPhone6]
|
||||
|
||||
**Additional information/context:**
|
||||
Add any other context about the problem here.
|
||||
|
||||
* Problem started happening recently, didn't happen in an older version of TableFilter: [Yes/No] if yes [version here]
|
||||
* Problem can be reliably reproduced, doesn't happen randomly: [Yes/No]
|
36
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
36
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Enhancement/feature description**
|
||||
[A clear and concise description of what the problem is. Ex. I'm always frustrated when ...]
|
||||
|
||||
**Steps which explain the enhancement/feature**
|
||||
1. [First Step]
|
||||
2. [Second Step]
|
||||
3. [Other Steps...]
|
||||
|
||||
**Current and suggested behavior**
|
||||
[Describe current and suggested behavior here]
|
||||
|
||||
**Why would the enhancement be useful to most users**
|
||||
[Explain why the enhancement would be useful to most users]
|
||||
|
||||
**Screenshots and GIFs**
|
||||
![Screenshots and GIFs which demonstrate the steps or part of TableFilter the enhancement suggestion is related to](url)
|
||||
|
||||
**Additional context**
|
||||
[Add any other context or screenshots about the feature request here.]
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**TableFilter Version:** [Enter TableFilter version here]
|
||||
**Browser and version:** [Enter Browser name and version here]
|
||||
**OS and version:** [Enter OS name and version here]
|
||||
**Device:** [e.g. iPhone6]
|
17
.github/ISSUE_TEMPLATE/support.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/support.md
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
name: Support
|
||||
about: I need support with TableFilter
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
For usage and support questions, please check out resources below, you might find an answer:
|
||||
|
||||
- https://www.tablefilter.com/
|
||||
- https://www.tablefilter.com/docs/
|
||||
- https://www.tablefilter.com/examples.html
|
||||
- https://github.com/koalyptus/TableFilter/wiki/
|
||||
- https://github.com/koalyptus/TableFilter/issues?q=is%3Aissue+is%3Aclosed
|
||||
- https://codepen.io/koalyptus/pens/public/
|
|
@ -13,7 +13,7 @@ module.exports = function (grunt) {
|
|||
coverage: {
|
||||
disposeCollector: true,
|
||||
src: ['dist/tablefilter/*.js'],
|
||||
instrumentedFiles: 'temp/',
|
||||
instrumentedFiles: 'report/temp/',
|
||||
htmlReport: 'report/coverage',
|
||||
coberturaReport: 'report/',
|
||||
lcovReport: 'report/',
|
||||
|
|
|
@ -24,7 +24,7 @@ users to filter and limit the data displayed within a long table. By default, th
|
|||
* Attach to an existing HTML table
|
||||
* Integration with any server-side technology as this is a pure client-side
|
||||
solution
|
||||
* Exhaustive documentation and poweful API
|
||||
* Exhaustive documentation and powerful API
|
||||
|
||||
## Getting started
|
||||
* Clone the repo using Git:
|
||||
|
|
4
dist/starter.html
vendored
4
dist/starter.html
vendored
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>tablefilter v0.6.86 - Starter</title>
|
||||
<title>tablefilter v0.7.3 - Starter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>tablefilter v0.6.86</h1>
|
||||
<h1>tablefilter v0.7.3</h1>
|
||||
|
||||
|
||||
|
||||
|
|
2
dist/tablefilter/style/tablefilter.css
vendored
2
dist/tablefilter/style/tablefilter.css
vendored
File diff suppressed because one or more lines are too long
3
dist/tablefilter/tablefilter.js
vendored
3
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
1
dist/tablefilter/tablefilter.js.map
vendored
1
dist/tablefilter/tablefilter.js.map
vendored
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
1
dist/tablefilter/tf-1-2aa33b10e0e549020c12.js
vendored
Normal file
1
dist/tablefilter/tf-1-2aa33b10e0e549020c12.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11162
package-lock.json
generated
11162
package-lock.json
generated
File diff suppressed because it is too large
Load diff
20
package.json
20
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tablefilter",
|
||||
"version": "0.6.86",
|
||||
"version": "0.7.3",
|
||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
|
@ -40,17 +40,17 @@
|
|||
"tag": "next"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.4.0",
|
||||
"@babel/preset-env": "7.4.0",
|
||||
"babel-eslint": "10.0.0",
|
||||
"@babel/core": "7.10.0",
|
||||
"@babel/preset-env": "7.10.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-loader": "^8.0.2",
|
||||
"babel-preset-env": "1.7.0",
|
||||
"clean-webpack-plugin": "^2.0.1",
|
||||
"codecov": "3.2.0",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"codecov": "3.7.1",
|
||||
"diacritics": "1.3.0",
|
||||
"esdoc": "1.1.0",
|
||||
"esdoc-standard-plugin": "1.0.0",
|
||||
"eslint": "5.15.2",
|
||||
"eslint": "6.5.0",
|
||||
"format-number": "3.0.0",
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-cli": "1.3.2",
|
||||
|
@ -58,7 +58,7 @@
|
|||
"grunt-contrib-connect": "^2.0.0",
|
||||
"grunt-contrib-copy": "^1.0.0",
|
||||
"grunt-contrib-watch": "^1.0.0",
|
||||
"grunt-qunit-istanbul": "1.0.0",
|
||||
"grunt-qunit-istanbul": "1.1.0",
|
||||
"grunt-shell": "3.0.0",
|
||||
"grunt-string-replace": "^1.3.1",
|
||||
"isparta-loader": "2.0.0",
|
||||
|
@ -66,8 +66,8 @@
|
|||
"string-replace-webpack-plugin": "^0.1.3",
|
||||
"stylus": "^0.54.5",
|
||||
"sugar-date": "2.0.6",
|
||||
"uglifyjs-webpack-plugin": "2.1.2",
|
||||
"webpack": "^4.0.1",
|
||||
"uglifyjs-webpack-plugin": "2.2.0",
|
||||
"webpack": "^4.38.0",
|
||||
"webpack-cli": "^3.0.8",
|
||||
"webpack-dev-server": "^3.1.11"
|
||||
},
|
||||
|
|
|
@ -36,7 +36,7 @@ export const getFirstTextNode = (node) => {
|
|||
|
||||
/**
|
||||
* Creates an html element with given collection of attributes
|
||||
* @param {String} tag a string of the html tag to create
|
||||
* @param {String} tag html tag name
|
||||
* @param {Array} an undetermined number of arrays containing the with 2
|
||||
* items, the attribute name and its value ['id','myId']
|
||||
* @return {Object} created element
|
||||
|
|
|
@ -513,6 +513,7 @@ AdapterSortableTable.meta = {altName: 'sort'};
|
|||
//Converters
|
||||
function ipAddress(value) {
|
||||
let vals = value.split('.');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
for (let x in vals) {
|
||||
let val = vals[x];
|
||||
while (3 > val.length) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Feature} from '../feature';
|
||||
import {
|
||||
ignoreCase, numSortAsc, numSortDesc,
|
||||
dateSortAsc, sortNumberStr, sortDateStr
|
||||
dateSortAsc, dateSortDesc, sortNumberStr, sortDateStr
|
||||
} from '../sort';
|
||||
import {isArray, isObj, isEmpty} from '../types';
|
||||
import {NUMBER, FORMATTED_NUMBER, DATE} from '../const';
|
||||
|
@ -72,14 +72,15 @@ export class BaseDropdown extends Feature {
|
|||
* @private
|
||||
*/
|
||||
sortOptions(colIndex, options = []) {
|
||||
let tf = this.tf;
|
||||
let {tf} = this;
|
||||
|
||||
if (tf.isCustomOptions(colIndex) || !tf.sortSlc ||
|
||||
(isArray(tf.sortSlc) && tf.sortSlc.indexOf(colIndex) === -1)) {
|
||||
return options;
|
||||
}
|
||||
|
||||
let { caseSensitive, sortNumDesc } = tf;
|
||||
let { caseSensitive, sortFilterOptionsDesc } = tf;
|
||||
let isSortDesc = sortFilterOptionsDesc.indexOf(colIndex) !== -1;
|
||||
let compareFn;
|
||||
|
||||
if (this.customSorter &&
|
||||
|
@ -89,18 +90,18 @@ export class BaseDropdown extends Feature {
|
|||
}
|
||||
else if (tf.hasType(colIndex, [NUMBER, FORMATTED_NUMBER])) {
|
||||
let decimal = tf.getDecimal(colIndex);
|
||||
let comparer = numSortAsc;
|
||||
if (sortNumDesc === true || sortNumDesc.indexOf(colIndex) !== -1) {
|
||||
comparer = numSortDesc;
|
||||
}
|
||||
let comparer = isSortDesc ? numSortDesc : numSortAsc;
|
||||
compareFn = sortNumberStr(comparer, decimal);
|
||||
}
|
||||
else if (tf.hasType(colIndex, [DATE])) {
|
||||
let locale = tf.feature('dateType').getLocale(colIndex);
|
||||
let comparer = dateSortAsc;
|
||||
let comparer = isSortDesc ? dateSortDesc : dateSortAsc;
|
||||
compareFn = sortDateStr(comparer, locale);
|
||||
} else { // string
|
||||
compareFn = caseSensitive ? undefined : ignoreCase;
|
||||
if (isSortDesc) {
|
||||
return options.sort(compareFn).reverse();
|
||||
}
|
||||
}
|
||||
|
||||
return options.sort(compareFn);
|
||||
|
|
|
@ -4,7 +4,7 @@ import {addEvt, targetEvt, removeEvt} from '../event';
|
|||
import {NONE} from '../const';
|
||||
import {root} from '../root';
|
||||
import {isEmpty, isNull} from '../types';
|
||||
import {defaultsStr} from '../settings';
|
||||
import {defaultsStr, defaultsNb} from '../settings';
|
||||
import {RIGHT} from './toolbar';
|
||||
|
||||
const WIKI_URL = 'https://github.com/koalyptus/TableFilter/wiki/' +
|
||||
|
@ -92,6 +92,15 @@ export class Help extends Feature {
|
|||
*/
|
||||
this.cont = null;
|
||||
|
||||
/**
|
||||
* Adjust container left position when table's horizontal scroll is
|
||||
* on, typically when `responsive` option is enabled.
|
||||
* @type {Number}
|
||||
* @defaultValue 25
|
||||
*/
|
||||
this.contAdjustLeftPosition =
|
||||
defaultsNb(f.container_adjust_left_position, 25);
|
||||
|
||||
/**
|
||||
* Bound mouseup wrapper
|
||||
* @private
|
||||
|
@ -214,9 +223,21 @@ export class Help extends Feature {
|
|||
let divDisplay = this.cont.style.display;
|
||||
if (divDisplay === '' || divDisplay === NONE) {
|
||||
this.cont.style.display = 'inline';
|
||||
|
||||
// if table element has an horizontal scrollbar adjust container
|
||||
// left position accordingly
|
||||
if (this.tf.dom().scrollLeft > 0) {
|
||||
this.cont.style.left = `${
|
||||
this.btn.offsetLeft
|
||||
- this.tf.dom().scrollLeft
|
||||
+ this.contAdjustLeftPosition
|
||||
}px`;
|
||||
}
|
||||
|
||||
addEvt(root, 'mouseup', this.boundMouseup);
|
||||
} else {
|
||||
this.cont.style.display = NONE;
|
||||
this.cont.style.left = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ export class TableFilter {
|
|||
this.onAfterFilter = defaultsFn(f.on_after_filter, EMPTY_FN);
|
||||
|
||||
/**
|
||||
* Enable/disable case sensitivity filtering
|
||||
* Enable/disable case sensitivity for filtering, default false
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.caseSensitive = Boolean(f.case_sensitive);
|
||||
|
@ -493,7 +493,9 @@ export class TableFilter {
|
|||
* Text for clear option in drop-down filter types (1st option)
|
||||
* @type {String|Array}
|
||||
*/
|
||||
this.clearFilterText = defaultsStr(f.clear_filter_text, 'Clear');
|
||||
this.clearFilterText = isArray(f.clear_filter_text)
|
||||
? f.clear_filter_text
|
||||
: defaultsStr(f.clear_filter_text, 'Clear');
|
||||
|
||||
/**
|
||||
* Indicate whether empty option is enabled in drop-down filter types
|
||||
|
@ -532,38 +534,24 @@ export class TableFilter {
|
|||
* by default globally or on a column basis
|
||||
* @type {Boolean|Array}
|
||||
*/
|
||||
this.sortSlc = isUndef(f.sort_select) ? true :
|
||||
isArray(f.sort_select) ? f.sort_select : Boolean(f.sort_select);
|
||||
this.sortSlc = isUndef(f.sort_select)
|
||||
? true
|
||||
: defaultsArr(f.sort_select, Boolean(f.sort_select));
|
||||
|
||||
/**
|
||||
* Indicate whether options in drop-down filter types are sorted in a
|
||||
* ascending numeric manner
|
||||
* @type {Boolean}
|
||||
* @private
|
||||
*/
|
||||
this.isSortNumAsc = Boolean(f.sort_num_asc);
|
||||
|
||||
/**
|
||||
* List of columns implementing options sorting in a ascending numeric
|
||||
* manner
|
||||
* List of columns implementing filter options sorting in ascending
|
||||
* manner based on column data type
|
||||
* @type {Array}
|
||||
*/
|
||||
this.sortNumAsc = this.isSortNumAsc ? f.sort_num_asc : [];
|
||||
this.sortFilterOptionsAsc = defaultsArr(f.sort_filter_options_asc, []);
|
||||
|
||||
/**
|
||||
* Indicate whether options in drop-down filter types are sorted in a
|
||||
* descending numeric manner
|
||||
* @type {Boolean}
|
||||
* @private
|
||||
*/
|
||||
this.isSortNumDesc = Boolean(f.sort_num_desc);
|
||||
|
||||
/**
|
||||
* List of columns implementing options sorting in a descending numeric
|
||||
* manner
|
||||
* List of columns implementing filter options sorting in descending
|
||||
* manner based on column data type
|
||||
* @type {Array}
|
||||
*/
|
||||
this.sortNumDesc = this.isSortNumDesc ? f.sort_num_desc : [];
|
||||
this.sortFilterOptionsDesc =
|
||||
defaultsArr(f.sort_filter_options_desc, []);
|
||||
|
||||
/**
|
||||
* Indicate whether drop-down filter types are populated on demand at
|
||||
|
@ -1797,11 +1785,11 @@ export class TableFilter {
|
|||
}
|
||||
//empty
|
||||
else if (hasEM) {
|
||||
occurence = !cell.hasChildNodes();
|
||||
occurence = !cell.hasChildNodes() || isEmpty(cellValue);
|
||||
}
|
||||
//non-empty
|
||||
else if (hasNM) {
|
||||
occurence = cell.hasChildNodes();
|
||||
occurence = cell.hasChildNodes() && !isEmpty(cellValue);
|
||||
} else {
|
||||
occurence = contains(term, cellValue,
|
||||
this.isExactMatch(colIdx), this.caseSensitive);
|
||||
|
@ -1887,11 +1875,11 @@ export class TableFilter {
|
|||
}
|
||||
//empty
|
||||
else if (hasEM) {
|
||||
occurence = !cell.hasChildNodes();
|
||||
occurence = !cell.hasChildNodes() || isEmpty(cellValue);
|
||||
}
|
||||
//non-empty
|
||||
else if (hasNM) {
|
||||
occurence = cell.hasChildNodes();
|
||||
occurence = cell.hasChildNodes() && !isEmpty(cellValue);
|
||||
} else {
|
||||
// If numeric type data, perform a strict equality test and
|
||||
// fallback to unformatted number string comparison
|
||||
|
|
|
@ -32,6 +32,7 @@ table.TF
|
|||
&.resp
|
||||
display block
|
||||
overflow-x auto
|
||||
overflow-y hidden
|
||||
|
||||
.sort-arrow
|
||||
position initial
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
highlight_column: true
|
||||
},
|
||||
no_results_message: true,
|
||||
responsive: true,
|
||||
custom_options: {
|
||||
cols:[3],
|
||||
texts: [
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
page_length: true,
|
||||
sort: true
|
||||
},
|
||||
responsive: true,
|
||||
help_instructions: {
|
||||
container_adjust_left_position: 30
|
||||
},
|
||||
alternate_rows: true,
|
||||
btn_reset: true,
|
||||
rows_counter: true,
|
||||
|
|
|
@ -100,19 +100,43 @@ test('Can sort options', function() {
|
|||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_0: 'checklist',
|
||||
col_1: 'checklist',
|
||||
col_2: 'checklist',
|
||||
col_3: 'checklist',
|
||||
col_4: 'checklist',
|
||||
col_types: ['string', 'string', 'number', 'number', 'number'],
|
||||
sort_num_asc: [2, 3],
|
||||
sort_num_desc: [4]
|
||||
sort_filter_options_asc: [0, 2, 3],
|
||||
sort_filter_options_desc: [1, 4]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var flt0 = id(tf.fltIds[0]);
|
||||
var flt1 = id(tf.fltIds[1]);
|
||||
var flt2 = id(tf.fltIds[2]);
|
||||
var flt3 = id(tf.fltIds[3]);
|
||||
var flt4 = id(tf.fltIds[4]);
|
||||
|
||||
deepEqual(
|
||||
flt0.getElementsByTagName('li')[1].firstChild.firstChild.value,
|
||||
'Adelaide',
|
||||
'First option value for column 0'
|
||||
);
|
||||
deepEqual(
|
||||
flt0.getElementsByTagName('li')[2].firstChild.firstChild.value,
|
||||
'Sydney',
|
||||
'Last option value for column 0'
|
||||
);
|
||||
deepEqual(
|
||||
flt1.getElementsByTagName('li')[1].firstChild.firstChild.value,
|
||||
'Perth',
|
||||
'First option value for column 1'
|
||||
);
|
||||
deepEqual(
|
||||
flt1.getElementsByTagName('li')[6].firstChild.firstChild.value,
|
||||
'Adelaide',
|
||||
'Last option value for column 1'
|
||||
);
|
||||
deepEqual(
|
||||
flt2.getElementsByTagName('li')[1].firstChild.firstChild.value,
|
||||
'286',
|
||||
|
@ -182,6 +206,55 @@ test('Can select empty and non-empty options', function() {
|
|||
'Filter 3 options values attribute');
|
||||
});
|
||||
|
||||
// issue 714, clear filter text
|
||||
module('Clear filter text');
|
||||
test('Can define clear filter text for each column', function() {
|
||||
tf.clearFilters();
|
||||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_2: 'checklist',
|
||||
col_3: 'checklist',
|
||||
col_4: 'checklist',
|
||||
clear_filter_text: [null, null, 'clear 2', 'clear 3', 'clear 4']
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var flt2 = tf.getFilterElement(2).getElementsByTagName('li');
|
||||
var flt3 = tf.getFilterElement(3).getElementsByTagName('li');
|
||||
var flt4 = tf.getFilterElement(4).getElementsByTagName('li');
|
||||
|
||||
deepEqual(flt2[0].getElementsByTagName('label')[0].innerText,
|
||||
'clear 2', 'clear text filter 2');
|
||||
deepEqual(flt3[0].getElementsByTagName('label')[0].innerText,
|
||||
'clear 3', 'clear text filter 3');
|
||||
deepEqual(flt4[0].getElementsByTagName('label')[0].innerText,
|
||||
'clear 4', 'clear text filter 4');
|
||||
});
|
||||
test('Can define clear filter text globally', function() {
|
||||
tf.clearFilters();
|
||||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_2: 'checklist',
|
||||
col_3: 'checklist',
|
||||
col_4: 'checklist',
|
||||
clear_filter_text: 'reset'
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var flt2 = tf.getFilterElement(2).getElementsByTagName('li');
|
||||
var flt3 = tf.getFilterElement(3).getElementsByTagName('li');
|
||||
var flt4 = tf.getFilterElement(4).getElementsByTagName('li');
|
||||
|
||||
deepEqual(flt2[0].getElementsByTagName('label')[0].innerText,
|
||||
'reset', 'clear text filter 2');
|
||||
deepEqual(flt3[0].getElementsByTagName('label')[0].innerText,
|
||||
'reset', 'clear text filter 3');
|
||||
deepEqual(flt4[0].getElementsByTagName('label')[0].innerText,
|
||||
'reset', 'clear text filter 4');
|
||||
});
|
||||
|
||||
module('Tear down');
|
||||
test('TableFilter removed', function() {
|
||||
tf.destroy();
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
(function(win, TableFilter){
|
||||
(function(TableFilter) {
|
||||
var id = function (id) { return document.getElementById(id); };
|
||||
|
||||
// TODO: add sort to test it with different column types
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
|
@ -17,7 +19,6 @@
|
|||
]
|
||||
});
|
||||
tf.init();
|
||||
window.tf = tf;
|
||||
|
||||
module('Sanity checks');
|
||||
test('Data types', function() {
|
||||
|
@ -300,10 +301,92 @@
|
|||
deepEqual(result, '.', 'Decimal separator for given column');
|
||||
});
|
||||
|
||||
module('Data types filters options sorting');
|
||||
test('Can sort date types', function () {
|
||||
// setup
|
||||
tf.clearFilters();
|
||||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_6: 'checklist',
|
||||
col_7: 'multiple',
|
||||
col_8: 'checklist',
|
||||
col_10: 'select',
|
||||
col_types: [
|
||||
null, null, null,
|
||||
{type: 'formatted-number', decimal: ',', thousands: ','},
|
||||
'formatted-number', null,
|
||||
{type: 'date', locale: 'fr',},
|
||||
{type: 'date', locale: 'en', format: '{dd}-{MM}-{yyyy|yy}'},
|
||||
{
|
||||
type: 'date', locale: 'en',
|
||||
format: ['{dd}-{months}-{yyyy|yy}']
|
||||
},
|
||||
'IpAddress',
|
||||
{
|
||||
type: 'date', locale: 'en',
|
||||
format: ['{yyyy|yy}-{MM}-{dd} {HH}:{mm}:{ss}']
|
||||
}
|
||||
],
|
||||
sort_filter_options_asc: [6, 7],
|
||||
sort_filter_options_desc: [8, 10]
|
||||
});
|
||||
|
||||
// act
|
||||
tf.init();
|
||||
|
||||
var flt6 = id(tf.fltIds[6]);
|
||||
var flt7 = id(tf.fltIds[7]);
|
||||
var flt8 = id(tf.fltIds[8]);
|
||||
var flt10 = id(tf.fltIds[10]);
|
||||
|
||||
// assert
|
||||
deepEqual(
|
||||
flt6.getElementsByTagName('li')[1].firstChild.firstChild.value,
|
||||
'19/1/1984',
|
||||
'First option value for column 6'
|
||||
);
|
||||
deepEqual(
|
||||
flt6.getElementsByTagName('li')[20].firstChild.firstChild.value,
|
||||
'3/7/2002',
|
||||
'Last option value for column 6'
|
||||
);
|
||||
deepEqual(
|
||||
flt7.options[1].value,
|
||||
'1/19/1984',
|
||||
'First option value for column 7'
|
||||
);
|
||||
deepEqual(
|
||||
flt7.options[20].value,
|
||||
'7/3/2002',
|
||||
'Last option value for column 7'
|
||||
);
|
||||
deepEqual(
|
||||
flt8.getElementsByTagName('li')[1].firstChild.firstChild.value,
|
||||
'3-Jul-2002',
|
||||
'First option value for column 8'
|
||||
);
|
||||
deepEqual(
|
||||
flt8.getElementsByTagName('li')[20].firstChild.firstChild.value,
|
||||
'19-Jan-1984',
|
||||
'Last option value for column 8'
|
||||
);
|
||||
deepEqual(
|
||||
flt10.options[1].value,
|
||||
'03-11-21 12:02:04',
|
||||
'First option value for column 10'
|
||||
);
|
||||
deepEqual(
|
||||
flt10.options[19].value,
|
||||
'1899-11-27 02:02:04',
|
||||
'Last option value for column 10'
|
||||
);
|
||||
});
|
||||
|
||||
module('Tear-down');
|
||||
test('can destroy TableFilter DOM elements', function() {
|
||||
tf.destroy();
|
||||
deepEqual(tf.isInitialized(), false, 'Filters removed');
|
||||
});
|
||||
|
||||
})(window, TableFilter);
|
||||
})(TableFilter);
|
||||
|
|
|
@ -157,24 +157,31 @@ test('Can enable options sorting on a column basis', function() {
|
|||
deepEqual(flt4.options[7].value, '40', 'Last option value for column 4');
|
||||
});
|
||||
|
||||
test('Can sort numeric options in asc and desc manner', function() {
|
||||
test('Can sort options in asc and desc manner', function() {
|
||||
tf.clearFilters();
|
||||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_0: 'select',
|
||||
col_2: 'multiple',
|
||||
col_3: 'select',
|
||||
col_4: 'multiple',
|
||||
col_types: ['string', 'string', 'number', 'number', 'number'],
|
||||
sort_num_asc: [2, 3],
|
||||
sort_num_desc: [4]
|
||||
case_sensitive: true,
|
||||
sort_filter_options_asc: [2, 3],
|
||||
sort_filter_options_desc: [0, 4]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var flt0 = id(tf.fltIds[0]);
|
||||
var flt2 = id(tf.fltIds[2]);
|
||||
var flt3 = id(tf.fltIds[3]);
|
||||
var flt4 = id(tf.fltIds[4]);
|
||||
|
||||
deepEqual(flt0.options[1].value, 'Sydney',
|
||||
'First option value for column 0');
|
||||
deepEqual(flt0.options[2].value, 'Adelaide',
|
||||
'Last option value for column 0');
|
||||
deepEqual(flt2.options[1].value, '286', 'First option value for column 2');
|
||||
deepEqual(flt2.options[7].value, '2781', 'Last option value for column 2');
|
||||
deepEqual(flt3.options[1].value, '.6', 'First option value for column 3');
|
||||
|
@ -183,6 +190,51 @@ test('Can sort numeric options in asc and desc manner', function() {
|
|||
deepEqual(flt4.options[7].value, '4.3', 'Last option value for column 4');
|
||||
});
|
||||
|
||||
// issue 714, clear filter text
|
||||
module('Clear filter text');
|
||||
test('Can define clear filter text for each column', function() {
|
||||
tf.clearFilters();
|
||||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_2: 'multiple',
|
||||
col_3: 'select',
|
||||
col_4: 'multiple',
|
||||
clear_filter_text: [null, null, 'clear 2', 'clear 3', 'clear 4']
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var flt2 = tf.getFilterElement(2);
|
||||
var flt3 = tf.getFilterElement(3);
|
||||
var flt4 = tf.getFilterElement(4);
|
||||
|
||||
deepEqual(flt2.options[0].innerHTML, 'clear 2', 'clear text filter 2');
|
||||
deepEqual(flt3.options[0].innerHTML, 'clear 3', 'clear text filter 3');
|
||||
deepEqual(flt4.options[0].innerHTML, 'clear 4', 'clear text filter 4');
|
||||
});
|
||||
test('Can define clear filter text globally', function() {
|
||||
tf.clearFilters();
|
||||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_2: 'multiple',
|
||||
col_3: 'select',
|
||||
col_4: 'multiple',
|
||||
clear_filter_text: 'reset'
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var flt2 = tf.getFilterElement(2);
|
||||
var flt3 = tf.getFilterElement(3);
|
||||
var flt4 = tf.getFilterElement(4);
|
||||
|
||||
deepEqual(flt2.options[0].innerHTML, 'reset', 'clear text filter 2');
|
||||
deepEqual(flt3.options[0].innerHTML, 'reset', 'clear text filter 3');
|
||||
deepEqual(flt4.options[0].innerHTML, 'reset', 'clear text filter 4');
|
||||
});
|
||||
|
||||
|
||||
module('Tear down');
|
||||
test('TableFilter removed', function() {
|
||||
tf.destroy();
|
||||
deepEqual(id(tf.fltIds[3]), null, 'Filter is removed');
|
||||
|
|
|
@ -72,7 +72,14 @@
|
|||
tf.clearFilters();
|
||||
tf.setFilterValue(4, '[empty]');
|
||||
tf.filter();
|
||||
deepEqual(tf.getValidRows().length, 0, 'No matches expected');
|
||||
var filteredData = tf.getFilteredData();
|
||||
|
||||
deepEqual(tf.getValidRows().length, 1, 'Expected match');
|
||||
deepEqual(
|
||||
filteredData[0],
|
||||
[6, ['Adelaide', 'Perth', '2781', '3.1', '']],
|
||||
'Expected row data'
|
||||
);
|
||||
});
|
||||
|
||||
test('Non-empty operator - [nonempty]', function() {
|
||||
|
@ -96,7 +103,7 @@
|
|||
tf.setFilterValue(4, '[nonempty]');
|
||||
tf.filter();
|
||||
|
||||
deepEqual(tf.getValidRows().length, 7, 'Expected number of matches');
|
||||
deepEqual(tf.getValidRows().length, 6, 'Expected number of matches');
|
||||
});
|
||||
|
||||
test('Or operator - ||', function() {
|
||||
|
|
79
test/test-help-responsive.html
Normal file
79
test/test-help-responsive.html
Normal file
|
@ -0,0 +1,79 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>TableFilter help pop-up with responsive behaviour</title>
|
||||
<link rel="stylesheet" href="libs/qunit/qunit.css">
|
||||
<script src="libs/qunit/qunit.js"></script>
|
||||
<script src="libs/polyfill.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div style="float: right; width: 80%; border: 1px solid #f4f4f4;"></div>
|
||||
<table id="demo" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>From</th>
|
||||
<th>Destination</th>
|
||||
<th>Road Distance (km)</th>
|
||||
<th>By Air (hrs)</th>
|
||||
<th>By Rail (hrs)</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Adelaide</td>
|
||||
<td>1412</td>
|
||||
<td>1.4</td>
|
||||
<td>25.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Brisbane</td>
|
||||
<td>982</td>
|
||||
<td>1.5</td>
|
||||
<td>16</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Canberra</td>
|
||||
<td>286</td>
|
||||
<td>.6</td>
|
||||
<td>4.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Sydney</strong></td>
|
||||
<td>Melbourne</td>
|
||||
<td>872</td>
|
||||
<td>1.1</td>
|
||||
<td>10.5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Adelaide</strong></td>
|
||||
<td>Perth</td>
|
||||
<td>2781</td>
|
||||
<td>3.1</td>
|
||||
<td>38</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Adelaide</strong></td>
|
||||
<td>Alice Springs</td>
|
||||
<td>1533</td>
|
||||
<td>2</td>
|
||||
<td>20.25</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Adelaide</strong></td>
|
||||
<td>Brisbane</td>
|
||||
<td>2045</td>
|
||||
<td>2.15</td>
|
||||
<td>40</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script src="../dist/tablefilter/tablefilter.js"></script>
|
||||
<script src="test-help-responsive.js"></script>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
70
test/test-help-responsive.js
Normal file
70
test/test-help-responsive.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
help_instructions: {
|
||||
container_adjust_left_position: 20
|
||||
},
|
||||
responsive: true
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var help = tf.feature('help');
|
||||
module('Sanity checks');
|
||||
test('Button element', function() {
|
||||
deepEqual(typeof help, 'object', 'Help instanciated');
|
||||
notEqual(help.btn, null, 'btn property');
|
||||
});
|
||||
|
||||
module('Pop-up container position');
|
||||
test('Help UI elements', function() {
|
||||
var container = help.cont,
|
||||
helpBtn = help.btn;
|
||||
deepEqual(container.nodeName, 'DIV', 'Help container');
|
||||
deepEqual(helpBtn.nodeName, 'SPAN', 'Help button');
|
||||
});
|
||||
|
||||
// 772 issue: pop-up container position when table feature horizontal scroll
|
||||
test('When table has horizontal scroll', function() {
|
||||
// setup
|
||||
tf.dom().scrollLeft = 10000;
|
||||
|
||||
// act
|
||||
help.toggle();
|
||||
|
||||
// assert
|
||||
deepEqual(
|
||||
parseFloat(help.cont.style.left),
|
||||
(help.btn.offsetLeft
|
||||
- tf.dom().scrollLeft
|
||||
+ help.contAdjustLeftPosition),
|
||||
'Pop-up container position'
|
||||
);
|
||||
});
|
||||
|
||||
test('When table does not have horizontal scroll', function() {
|
||||
tf.destroy();
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
help_instructions: true,
|
||||
responsive: false
|
||||
});
|
||||
tf.init();
|
||||
var help = tf.feature('help');
|
||||
|
||||
// act
|
||||
help.toggle();
|
||||
|
||||
// assert
|
||||
deepEqual(help.cont.style.left, '', 'Pop-up container position');
|
||||
});
|
||||
|
||||
module('Tear-down');
|
||||
test('can destroy Help UI component', function() {
|
||||
// act
|
||||
tf.destroy();
|
||||
var help = tf.feature('help');
|
||||
|
||||
// assert
|
||||
deepEqual(help.btn, null, 'Help button removed');
|
||||
deepEqual(help.cont, null, 'Help pop-up container removed');
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const Clean = require('clean-webpack-plugin');
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
||||
const StringReplacePlugin = require('string-replace-webpack-plugin');
|
||||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||
const fs = require('fs');
|
||||
|
@ -52,14 +52,14 @@ module.exports = {
|
|||
}
|
||||
]
|
||||
},
|
||||
devtool: 'source-map',
|
||||
// devtool: 'source-map',
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new UglifyJsPlugin({
|
||||
sourceMap: true,
|
||||
// sourceMap: true,
|
||||
uglifyOptions: {
|
||||
beautify: false,
|
||||
compress: {warnings: false},
|
||||
warnings: false,
|
||||
comments: false,
|
||||
keep_fnames: true
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ module.exports = {
|
|||
]
|
||||
},
|
||||
plugins: [
|
||||
new Clean({
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), 'dist')]
|
||||
}),
|
||||
new webpack.optimize.AggressiveMergingPlugin(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const webpack = require('webpack');
|
||||
const webpackConfig = require('./webpack.config.js');
|
||||
const path = require('path');
|
||||
const Clean = require('clean-webpack-plugin');
|
||||
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
|
@ -23,7 +23,7 @@ module.exports = {
|
|||
},
|
||||
devtool: 'source-map',
|
||||
plugins: [
|
||||
new Clean({
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), 'dist')]
|
||||
}),
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
|
|
Loading…
Reference in a new issue