1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-17 05:46:39 +02:00

Compare commits

...

39 commits

Author SHA1 Message Date
koalyptus 7afe45f1e6
Merge pull request #787 from koalyptus/dependabot/npm_and_yarn/codecov-3.7.1
Bump codecov from 3.7.0 to 3.7.1
2020-07-22 19:51:17 +10:00
koalyptus 6e01e45dfb prepare dist 2020-07-22 19:45:07 +10:00
dependabot[bot] 12c30629af
Bump codecov from 3.7.0 to 3.7.1
Bumps [codecov](https://github.com/codecov/codecov-node) from 3.7.0 to 3.7.1.
- [Release notes](https://github.com/codecov/codecov-node/releases)
- [Commits](https://github.com/codecov/codecov-node/compare/v3.7.0...v3.7.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-21 12:35:35 +00:00
koalyptus 3e763efac9
Merge pull request #784 from koalyptus/769-refine-empty-cell-logic
769 refine empty nonempty operators logic
2020-06-16 13:03:27 +10:00
koalyptus 825b915ae8 769 refine empty nonempty operators logic 2020-06-16 12:28:12 +10:00
koalyptus 8e48bf2943
Merge pull request #783 from koalyptus/greenkeeper/monorepo.babel7-20200526215451
Update babel7 to the latest version 🚀
2020-06-15 15:20:26 +10:00
koalyptus be7a5e585f prepare dist for 0.7.1 2020-06-15 15:19:11 +10:00
greenkeeper[bot] c44bef22a2
chore(package): update lockfile package-lock.json 2020-05-26 23:57:32 +00:00
greenkeeper[bot] 6dcebbf67e
chore(package): update @babel/preset-env to version 7.10.0 2020-05-26 23:57:28 +00:00
greenkeeper[bot] 44cb6f9124
chore(package): update @babel/core to version 7.10.0 2020-05-26 23:57:25 +00:00
koalyptus 571c31e8da
Merge pull request #780 from koalyptus/772-fix
Fix for #772: help instructions pop-up position with responsive behaviour
2020-05-14 12:58:23 +10:00
koalyptus 8633891fdb add unit tests - prepare dist 2020-05-14 12:40:44 +10:00
koalyptus 8eddc6f35c introduce adjust_container_left_position option in help_instructions configuration 2020-05-13 20:46:23 +10:00
koalyptus 577fb0b90a
Merge pull request #768 from koalyptus/greenkeeper/monorepo.babel7-20200228094136
Update babel7 to the latest version 🚀
2020-05-07 20:56:13 +10:00
Max Guglielmi 88a5bfe425 bump dep - prepare dist 2020-05-07 20:23:53 +10:00
Max Guglielmi cac2900444 prepare dist 2020-05-07 20:21:35 +10:00
greenkeeper[bot] 5dad4dae8e
chore(package): update lockfile package-lock.json 2020-02-28 11:43:33 +00:00
greenkeeper[bot] 134851525c
chore(package): update @babel/preset-env to version 7.8.6 2020-02-28 11:43:28 +00:00
greenkeeper[bot] 9a66748bb8
chore(package): update @babel/core to version 7.8.6 2020-02-28 11:43:25 +00:00
koalyptus c52004421f
Merge pull request #762 from koalyptus/greenkeeper/codecov-3.6.3
Update codecov to the latest version 🚀
2020-02-04 14:16:41 +11:00
koalyptus f53b392c59 prepare dist 2020-02-04 14:03:29 +11:00
koalyptus c496b0916d Merge branch 'master' into greenkeeper/codecov-3.6.3 2020-02-04 13:50:04 +11:00
koalyptus 25b89b19e7
Merge pull request #760 from koalyptus/greenkeeper/monorepo.babel7-20200112133918
Update babel7 to the latest version 🚀
2020-02-03 14:11:32 +11:00
koalyptus 8b4a05be02 prepare dist 2020-02-03 13:50:29 +11:00
koalyptus 1c4961a25b Merge branch 'master' into greenkeeper/monorepo.babel7-20200112133918 2020-02-03 13:35:30 +11:00
greenkeeper[bot] 40daf54768
chore(package): update lockfile package-lock.json 2020-01-31 14:09:11 +00:00
greenkeeper[bot] c43debc7ac
chore(package): update codecov to version 3.6.3 2020-01-31 14:09:07 +00:00
koalyptus 3ac2603e47
Merge pull request #759 from koalyptus/dependabot/npm_and_yarn/handlebars-4.5.3
Bump handlebars from 4.1.2 to 4.5.3
2020-01-14 14:53:40 +11:00
koalyptus 185c119342 prepare dist 2020-01-14 13:44:44 +11:00
koalyptus 80c9b3d734 Merge branch 'master' into dependabot/npm_and_yarn/handlebars-4.5.3 2020-01-14 13:26:01 +11:00
greenkeeper[bot] e8605e5e19
chore(package): update lockfile package-lock.json 2020-01-12 15:47:37 +00:00
greenkeeper[bot] bd95afb3eb
chore(package): update @babel/preset-env to version 7.8.0 2020-01-12 15:47:33 +00:00
greenkeeper[bot] c16f885951
chore(package): update @babel/core to version 7.8.0 2020-01-12 15:47:30 +00:00
koalyptus 6be9ad491f
Merge pull request #758 from koalyptus/greenkeeper/monorepo.babel7-20191219010209
Update babel7 to the latest version 🚀
2020-01-09 09:56:14 +11:00
koalyptus 447a3119aa Prepare dist 2020-01-09 09:44:26 +11:00
dependabot[bot] 2025aa4010
Bump handlebars from 4.1.2 to 4.5.3
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.1.2...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-27 00:16:57 +00:00
greenkeeper[bot] bdc03755e8
chore(package): update lockfile package-lock.json 2019-12-19 02:28:44 +00:00
greenkeeper[bot] 2dceed888e
chore(package): update @babel/preset-env to version 7.7.7 2019-12-19 02:28:40 +00:00
greenkeeper[bot] 982769a020
chore(package): update @babel/core to version 7.7.7 2019-12-19 02:28:37 +00:00
14 changed files with 3213 additions and 3413 deletions

View file

@ -14,7 +14,7 @@
"keyword-spacing": ["error", { "after": true, "before": true }],
"max-depth": [2, 7],
"max-statements": [2, 133],
"complexity": [2, 42],
"complexity": [2, 45],
"no-unused-vars": 2,
"no-eval": 2,
"no-underscore-dangle": 0,

4
dist/starter.html vendored
View file

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>tablefilter v0.6.105 - Starter</title>
<title>tablefilter v0.7.3 - Starter</title>
</head>
<body>
<h1>tablefilter v0.6.105</h1>
<h1>tablefilter v0.7.3</h1>

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

6409
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.6.105",
"version": "0.7.3",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {
@ -40,13 +40,13 @@
"tag": "next"
},
"devDependencies": {
"@babel/core": "7.7.2",
"@babel/preset-env": "7.7.1",
"babel-eslint": "10.0.2",
"@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": "^3.0.0",
"codecov": "3.6.1",
"codecov": "3.7.1",
"diacritics": "1.3.0",
"esdoc": "1.1.0",
"esdoc-standard-plugin": "1.0.0",

View file

@ -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

View file

@ -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 = '';
}
}

View file

@ -1785,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);
@ -1875,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

View file

@ -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,

View file

@ -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() {

View 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>

View 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');
});