1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-18 14:26:40 +02:00

Merge branch 'master' into issue-319-todos

This commit is contained in:
Max Guglielmi 2016-12-11 09:37:00 +11:00
commit 558236a6ac
51 changed files with 1362 additions and 605 deletions

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
demos
docs
node_modules
report
.grunt
npm-debug.log

View file

@ -1,10 +1,13 @@
language: node_js
node_js:
- '4.4.5'
- '6.3.0'
before_script:
- npm install grunt-cli -g
- npm install codecov -g
script:
- grunt test deploy
- npm test
- npm run codecov
- npm run deploy
branches:
only:
- master

130
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,130 @@
# Contributing to TableFilter
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
## Reporting bugs
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/).
Create an issue and provide the following information.
Explain the problem and include additional details to help maintainers reproduce
the problem:
* **Use a clear, concise and descriptive title** for the issue to identify the
problem.
* **Describe the exact steps which reproduce the problem** in as many details
as possible.
* **Provide specific examples to demonstrate the steps**. Include links to
files or GitHub projects, or copy/pasteable snippets, which you use in those
examples. If you're providing snippets in the issue, use
[Markdown code blocks](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown).
Do not paste large snippets completely unrelated to the issue.
* **Describe the behavior you observed after following the steps** and point
out what exactly is the problem with that behavior.
* **Explain which behavior you expected to see instead and why.**
* Do not hesitate to **include screenshots and animated GIFs** which show you
following the described steps and clearly demonstrate the problem.
You can use [this tool](http://www.cockos.com/licecap/) to record GIFs on macOS
and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or
[this tool](https://github.com/GNOME/byzanz) on Linux.
### Template for submitting bug reports
[Short description of problem here]
**Reproduction steps:**
1. [First Step]
2. [Second Step]
3. [Other Steps...]
**Expected behavior:**
[Describe expected behavior here]
**Observed behavior:**
[Describe observed behavior here]
**Screenshots and GIFs**
![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]
**Additional information:**
* Problem started happening recently, didn't happen in an older version of
TableFilter: [Yes/No]
* Problem can be reliably reproduced, doesn't happen randomly: [Yes/No]
## Suggesting enhancements and features
Enhancement and feature suggestions are tracked as
[GitHub issues](https://guides.github.com/features/issues/).
Create an issue and provide the following information:
* **Use a clear and descriptive title** for the issue to identify the
suggestion.
* **Provide a step-by-step description of the suggested enhancement/feature**
in as many details as possible.
* When applicable **describe the current behavior** and
**explain which behavior you expected to see instead** and why.
* **Include screenshots and animated GIFs** which help you demonstrate the
steps or point out the part of TableFilter which the suggestion is related to.
You can use [this tool](http://www.cockos.com/licecap/) to record GIFs on macOS
and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or
[this tool](https://github.com/GNOME/byzanz) on Linux.
* **Explain why this enhancement would be useful** to most TableFilter users.
### Template for submitting enhancement and feature suggestions
[Short description of suggestion]
**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)
**TableFilter Version:** [Enter TableFilter version here]
**Browser and version:** [Enter Browser name and version here]
**OS and version:** [Enter OS name and version here]
## Code contribution
TableFilter welcomes contributions from anyone and everyone. If you want to get
your hands dirty:
### Pull requests
In general, we follow the "fork-and-pull" Git workflow.
1. **Fork** the repo on GitHub
2. **Clone** the project to your own machine
3. **Commit** changes to your own branch
- 3.1. **Add** unit tests covering your change in the `test` folder
- 3.2. **Run** the tests with the `npm run eslint test` command
- 3.3. **Ensure** build is working with `npm run build-all` command
4. **Push** your work back up to your fork
5. Submit a **Pull request** so that we can review your changes
NOTE: Be sure to merge the latest from "upstream" before making a pull request!
## Donations
To support this project simply locate the `Donate` button in the [project's
website](http://koalyptus.github.io/TableFilter/)
which points to PayPal.
Thanks to all those who supported this project in the past and to those who will
in the future!

View file

@ -2,12 +2,14 @@ module.exports = function (grunt) {
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');
var webpackTestConfig = require('./webpack.test.config.js');
var fs = require('fs');
var path = require('path');
var testDir = 'test';
var testHost = 'http://localhost:8000/';
var pkg = grunt.file.readJSON('package.json');
var repo = 'github.com/koalyptus/TableFilter';
var styleDirDist = 'dist/tablefilter/style/';
grunt.initConfig({
@ -24,6 +26,19 @@ module.exports = function (grunt) {
},
qunit: {
options: {
'--web-security': 'no',
coverage: {
disposeCollector: true,
src: ['dist/tablefilter/*.js'],
instrumentedFiles: 'temp/',
htmlReport: 'report/coverage',
coberturaReport: 'report/',
lcovReport: 'report/',
jsonReport: 'report',
linesThresholdPct: 80
}
},
all: {
options: {
urls: getTestFiles(testDir, testHost)
@ -127,7 +142,8 @@ module.exports = function (grunt) {
webpack: {
options: webpackConfig,
build: webpackConfig.build,
dev: webpackConfig.dev
dev: webpackConfig.dev,
test: webpackTestConfig
},
watch: {
@ -187,25 +203,26 @@ module.exports = function (grunt) {
files: [
{
src: ['static/style/*.styl'],
dest: 'dist/tablefilter/style/tablefilter.css'
dest: styleDirDist + 'tablefilter.css'
}, {
src: ['static/style/extensions/colsVisibility.styl'],
dest: 'dist/tablefilter/style/colsVisibility.css'
dest: styleDirDist + 'colsVisibility.css'
}, {
src: ['static/style/extensions/filtersVisibility.styl'],
dest: 'dist/tablefilter/style/filtersVisibility.css'
dest: styleDirDist + 'filtersVisibility.css'
}, {
src: ['static/style/themes/default/*.styl'],
dest:
'dist/tablefilter/style/themes/default/default.css'
dest: styleDirDist + 'themes/default/default.css'
}, {
src: ['static/style/themes/mytheme/*.styl'],
dest:
'dist/tablefilter/style/themes/mytheme/mytheme.css'
dest: styleDirDist + 'themes/mytheme/mytheme.css'
}, {
src: ['static/style/themes/skyblue/*.styl'],
dest: styleDirDist + 'themes/skyblue/skyblue.css'
}, {
src: ['static/style/themes/transparent/*.styl'],
dest:
'dist/tablefilter/style/themes/skyblue/skyblue.css'
styleDirDist + 'themes/transparent/transparent.css'
}
]
}
@ -284,7 +301,6 @@ module.exports = function (grunt) {
});
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
@ -293,10 +309,11 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-webpack');
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-esdoc');
grunt.loadNpmTasks('grunt-qunit-istanbul');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-gh-pages');
grunt.registerTask('default', ['build', 'test', 'build-demos']);
grunt.registerTask('default', ['test', 'build', 'build-demos']);
// Development server
grunt.registerTask('server', ['webpack-dev-server:start']);
@ -314,11 +331,15 @@ module.exports = function (grunt) {
grunt.registerTask('build-demos', ['copy:templates', 'copy:assets',
'string-replace:demos', 'copy:starter', 'clean']);
// Build tests
grunt.registerTask('build-test',
['eslint', 'webpack:test', 'copy:dist', 'stylus:compile']);
// Transpile with Babel
grunt.registerTask('dev-modules', ['babel', 'copy:dist']);
// Tests
grunt.registerTask('test', ['eslint', 'connect', 'qunit:all']);
// Tests with coverage
grunt.registerTask('test', ['build-test', 'connect', 'qunit:all']);
// Publish to gh-pages
grunt.registerTask('publish', 'Publish from CLI', [
@ -374,7 +395,6 @@ module.exports = function (grunt) {
// Returns the list of test files from the test folder for qunit task
function getTestFiles(testDir, host) {
var getFiles = function (dir, host) {
var res = [];
var items = fs.readdirSync(dir);

View file

@ -1,5 +1,6 @@
[![Build Status](https://api.travis-ci.org/koalyptus/TableFilter.svg?branch=master)](https://travis-ci.org/koalyptus/TableFilter)
[![Document](http://koalyptus.github.io/TableFilter/docs/badge.svg)](https://koalyptus.github.io/TableFilter/docs/source)
[![codecov](https://codecov.io/gh/koalyptus/TableFilter/branch/master/graph/badge.svg)](https://codecov.io/gh/koalyptus/TableFilter)
# TableFilter
@ -12,7 +13,7 @@ users to filter and limit the data displayed within a long table. By default, th
## Features
* Convert a regular HTML table into an advanced grid component providing:
* Advanced columns filtering model
* Sorting and pagination facilities
* Sorting and pagination capabilities
* Complete selection model ([ezEditTable](http://codecanyon.net/item/ezedittable-enhance-html-tables/2425123?ref=koalyptus) extension)
* Extended keyboard navigation ([ezEditTable](http://codecanyon.net/item/ezedittable-enhance-html-tables/2425123?ref=koalyptus) extension)
* Inline cell or row editing ([ezEditTable](http://codecanyon.net/item/ezedittable-enhance-html-tables/2425123?ref=koalyptus) extension)
@ -26,7 +27,7 @@ solution
## Getting started
* Clone the repo using Git:
```shell
git clone --bare https://github.com/koalyptus/TableFilter.git
git clone https://github.com/koalyptus/TableFilter.git
```
* You can [download](https://github.com/koalyptus/TableFilter/archive/master.zip) this repository.
@ -76,46 +77,52 @@ Start by installing any dependencies.
```shell
npm install
```
Use the Grunt ``dev`` task to launch a build / watch cycle and start the local
sever on port ``8080``:
Use
```shell
npm run dev
```
command to launch a build / watch cycle and start the local
sever on port ``8080``.
Use
```shell
npm run build
```
command to generate a production build.
The
```shell
npm run build-all
```
command will create a production build, run the tests and finally generate
the demos:
To run all the tests and generate the coverage report:
```shell
grunt dev
npm test
```
Use the ``build`` task to generate a production build:
```shell
grunt build
```
The ``default`` Grunt task will create a production build, run the tests and finally generate the demos:
```shell
grunt
```
To run all the tests:
```shell
grunt test
```
and to run specific test(s):
or to run specific test(s):
```shell
grunt test-only:test.html
grunt test-only:test.html,test-sort.html
```
to view the coverage report(s), open the `index.html` under the
`report/coverage` folder or
[online](https://codecov.io/gh/koalyptus/TableFilter).
## Demos
Check out the online [examples](http://koalyptus.github.io/TableFilter/examples) or generate the demos locally:
Check out the online [examples](http://koalyptus.github.io/TableFilter/examples)
or generate the demos locally:
```shell
grunt build-demos
npm run build-demos
```
then run the local webserver:
```shell
grunt server
npm start
```
then pick a demo from:
```shell
@ -132,7 +139,7 @@ options you are using are still supported: [Obsolete](https://github.com/koalypt
Run this task to generate the documentation in the ``docs/docs`` directory:
```shell
grunt esdoc
npm run esdoc
```
## Support

4
dist/starter.html vendored
View file

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

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.10 by Max Guglielmi
* build date: 2016-11-15T10:07:54.981Z
* tablefilter v0.4.21 by Max Guglielmi
* build date: 2016-12-09T12:28:56.305Z
* MIT License
*/
span.colVisSpan{text-align:left;}span.colVisSpan a.colVis{display:inline-block;padding:7px 5px 0;font-size:inherit;font-weight:inherit;vertical-align:top}div.colVisCont{position:relative;background:#fff;-webkit-box-shadow:3px 3px 2px #888;-moz-box-shadow:3px 3px 2px #888;box-shadow:3px 3px 2px #888;position:absolute;display:none;border:1px solid #ccc;height:auto;width:250px;background-color:#fff;margin:35px 0 0 -100px;z-index:10000;padding:10px 10px 10px 10px;text-align:left;font-size:12px;}div.colVisCont:after,div.colVisCont:before{bottom:100%;left:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.colVisCont:after{border-color:rgba(255,255,255,0);border-bottom-color:#fff;border-width:10px;margin-left:-10px}div.colVisCont:before{border-color:rgba(255,255,255,0);border-bottom-color:#ccc;border-width:12px;margin-left:-12px}div.colVisCont p{margin:6px auto 6px auto}div.colVisCont a.colVis{display:initial;font-weight:inherit}ul.cols_checklist{padding:0;margin:0;list-style:none;}ul.cols_checklist label{display:block}ul.cols_checklist input{vertical-align:middle;margin:2px 5px 2px 1px}li.cols_checklist_item{padding:4px;margin:0;}li.cols_checklist_item:hover{background-color:#335ea8;color:#fff}.cols_checklist_slc_item{background-color:#335ea8;color:#fff}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.10 by Max Guglielmi
* build date: 2016-11-15T10:07:54.981Z
* tablefilter v0.4.21 by Max Guglielmi
* build date: 2016-12-09T12:28:56.305Z
* MIT License
*/
span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.10 by Max Guglielmi
* build date: 2016-11-15T10:07:54.981Z
* tablefilter v0.4.21 by Max Guglielmi
* build date: 2016-12-09T12:28:56.305Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.10 by Max Guglielmi
* build date: 2016-11-15T10:07:54.981Z
* tablefilter v0.4.21 by Max Guglielmi
* build date: 2016-12-09T12:28:56.305Z
* MIT License
*/
table.TF{border-left:1px solid #ccc;border-top:none;border-right:none;border-bottom:none;}table.TF th{background:#ebecee url("images/bg_th.jpg") left top repeat-x;border-bottom:1px solid #d0d0d0;border-right:1px solid #d0d0d0;border-left:1px solid #fff;border-top:1px solid #fff;color:#333}table.TF td{border-bottom:1px dotted #999;padding:5px}.fltrow{background-color:#ebecee !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #666 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #999 !important}input.flt{width:99% !important}.inf{height:$min-height;background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important}input.reset{background:transparent url("images/btn_eraser.gif") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;}.nextPage:hover{background:transparent url("images/btn_over_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important;}.previousPage:hover{background:transparent url("images/btn_over_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;}.firstPage:hover{background:transparent url("images/btn_over_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;}.lastPage:hover{background:transparent url("images/btn_over_last_page.gif") center center no-repeat !important}div.grd_Cont{background-color:#ebecee !important;border:1px solid #ccc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#d5d5d5}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important;}div.grd_headTblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#ebecee url("images/bg_th.jpg") left top repeat-x !important;border-bottom:1px solid #d0d0d0 !important;border-right:1px solid #d0d0d0 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #999 !important}.grd_inf{background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important;border-top:1px solid #d0d0d0 !important}.loader{border:1px solid #999}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#fff}.odd{background-color:#d5d5d5}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#999 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.10 by Max Guglielmi
* build date: 2016-11-15T10:07:54.981Z
* tablefilter v0.4.21 by Max Guglielmi
* build date: 2016-12-09T12:28:56.305Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b;border-top:none;border-right:0;border-bottom:none;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x;border-bottom:0;border-right:1px dotted #d0d0d0;border-left:0;border-top:0;color:#fff}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px}.fltrow{background-color:#81963b !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #687830 !important}input.flt{width:99% !important}.inf{background:#d8d8d8;height:$min-height}input.reset{width:53px;background:transparent url("images/btn_filter.png") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important}div.grd_Cont{background:#81963b url("images/bg_headers.jpg") left top repeat-x !important;border:1px solid #ccc !important;padding:0 1px 1px 1px !important;}div.grd_Cont .even{background-color:#bccd83}div.grd_Cont .odd{background-color:#fff}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important;}div.grd_tblCont table td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b}div.grd_tblCont table th,div.grd_headTblCont table th{background:transparent url("images/bg_headers.jpg") 0 0 repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;padding:0 4px 0 4px !important;color:#fff !important;height:35px !important}div.grd_headTblCont table td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;background-color:#81963b !important;padding:1px 3px 1px 3px !important}.grd_inf{background-color:#d8d8d8;border-top:1px solid #d0d0d0 !important}.loader{border:0 !important;background:#81963b !important}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#bccd83}.odd{background-color:#fff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#81963b !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.10 by Max Guglielmi
* build date: 2016-11-15T10:07:54.981Z
* tablefilter v0.4.21 by Max Guglielmi
* build date: 2016-12-09T12:28:56.305Z
* MIT License
*/
table.TF{padding:0;color:#000;border-right:1px solid #a4bed4;border-top:1px solid #a4bed4;border-left:1px solid #a4bed4;border-bottom:0;}table.TF th{margin:0;color:inherit;background:#d1e5fe url("images/bg_skyblue.gif") 0 0 repeat-x;border-color:#fdfdfd #a4bed4 #a4bed4 #fdfdfd;border-width:1px;border-style:solid}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid #a4bed4;border-left:0;border-top:0;border-right:0}.fltrow{background-color:#d1e5fe !important;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4 !important}input.flt{width:99% !important}.inf{background-color:#e3efff !important;border:1px solid #a4bed4;height:$min-height;color:#004a6f}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#ffe4ab url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#ffe4ab url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#ffe4ab url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#ffe4ab url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.activeHeader{background:#ffe4ab !important;border:1px solid #ffb552 !important;color:inherit !important}div.grd_Cont{background-color:#d9eaed !important;border:1px solid #9cc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#e3efff}div.grd_headTblCont{background-color:#d9eaed !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#d9eaed url("images/bg_skyblue.gif") left top repeat-x;border-bottom:1px solid #a4bed4;border-right:1px solid #a4bed4 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #a4bed4 !important;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:#cce2fe;color:#004a6f;border-top:1px solid #9cc !important;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#2d8eef;border:1px solid #cce2fe;border-radius:5px}.even{background-color:#fff}.odd{background-color:#e3efff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ffdc61 !important;color:inherit}.ezSelectedRow{background-color:#ffe4ab !important;color:inherit}.ezActiveCell{background-color:#fff !important;color:#000 !important;font-weight:bold}.ezETSelectedCell{background-color:#fff !important;font-weight:bold;color:#000 !important}

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

View file

@ -0,0 +1,6 @@
/**
* tablefilter v0.4.21 by Max Guglielmi
* build date: 2016-12-09T12:28:56.305Z
* MIT License
*/
table.TF{padding:0;color:inherit;border-right:1px solid transparent;border-top:1px solid transparent;border-left:1px solid transparent;border-bottom:0;}table.TF th{margin:0;color:inherit;background-color:transparent;border-color:transparent;border-width:1px;border-style:solid;}table.TF th:last-child{border-right:1px solid transparent}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid transparent;border-left:0;border-top:0;border-right:0}.fltrow{background-color:transparent;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px;border-bottom:1px solid transparent !important;}.fltrow th:last-child,.fltrow td:last-child{border-right:1px solid transparent}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4}input.flt{width:99% !important}.inf{background-color:transparent;border:1px solid transparent;height:$min-height;color:inherit}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#f7f7f7 url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#f7f7f7 url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#f7f7f7 url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#f7f7f7 url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.activeHeader{background:#f7f7f7 !important;border:1px solid transparent;color:inherit !important}div.grd_Cont{-webkit-box-shadow:0 0 0 0 rgba(50,50,50,0.75);-moz-box-shadow:0 0 0 0 rgba(50,50,50,0.75);box-shadow:0 0 0 0 rgba(50,50,50,0.75);background-color:transparent;border:1px solid transparent;padding:0 !important;}div.grd_Cont .even{background-color:transparent}div.grd_Cont .odd{background-color:#f7f7f7}div.grd_headTblCont{background-color:transparent;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:transparent;border-bottom:1px solid transparent;border-right:1px solid transparent !important;border-left:1px solid transparent;border-top:1px solid transparent}div.grd_tblCont table td{border-bottom:1px solid transparent;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:transparent;color:inherit;border-top:1px solid transparent;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#f7f7f7;border:1px solid #f7f7f7;border-radius:5px;color:#000;text-shadow:none}.even{background-color:transparent}.odd{background-color:#f7f7f7}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ccc !important;color:inherit}.ezSelectedRow{background-color:#ccc !important;color:inherit}.ezActiveCell{background-color:transparent;color:inherit;font-weight:bold}.ezETSelectedCell{background-color:transparent;font-weight:bold;color:inherit}

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.4.10",
"version": "0.4.21",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {
@ -28,37 +28,43 @@
"server": "grunt server",
"eslint": "grunt eslint",
"test": "grunt test",
"codecov": "./node_modules/.bin/codecov",
"esdoc": "grunt esdoc",
"all": "grunt"
"build-all": "grunt",
"deploy": "grunt deploy",
"start": "npm run server"
},
"publishConfig": {
"tag": "next"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-eslint": "7.1.0",
"babel-loader": "^6.2.6",
"babel-core": "^6.20.0",
"babel-eslint": "7.1.1",
"babel-loader": "^6.2.9",
"babel-plugin-transform-es2015-classes": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"clean-webpack-plugin": "^0.1.14",
"codecov": "1.0.1",
"diacritics": "1.2.3",
"grunt": "^1.0.1",
"grunt-babel": "^6.0.0",
"grunt-cli": "1.2.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-qunit": "^1.1.0",
"grunt-contrib-stylus": "^1.2.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-esdoc": "^0.0.4",
"grunt-eslint": "19.0.0",
"grunt-gh-pages": "^2.0.0",
"grunt-qunit-istanbul": "1.0.0",
"grunt-string-replace": "^1.3.1",
"grunt-webpack": "^1.0.18",
"isparta-loader": "2.0.0",
"script-loader": "^0.7.0",
"string-replace-webpack-plugin": "^0.0.4",
"sugar-date": "2.0.2",
"webpack": "^1.13.3",
"sugar-date": "2.0.4",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
},
"dependencies": {},

View file

@ -33,7 +33,7 @@ export const addEvt = (obj, type, func, capture) => {
* @param {Boolean} capture Specifiy whether the event should be executed in
* the capturing or in the bubbling phase
*/
export const removeEvt = (obj, type, func, capture) =>{
export const removeEvt = (obj, type, func, capture) => {
if (obj.detachEvent) {
obj.detachEvent('on' + type, func);
}

View file

@ -470,7 +470,9 @@ export default class AdapterSortableTable extends Feature {
let colType = `${DATE}-${locale}`;
this.addSortType(colType, (value) => {
return dateType.parse(value, locale);
let parsedDate = dateType.parse(value, locale);
// Invalid date defaults to Wed Feb 04 -768 11:00:00
return isNaN(+parsedDate) ? new Date(-86400000000000) : parsedDate;
});
return colType;
}

View file

@ -44,9 +44,7 @@ export class AlternateRows extends Feature {
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.on(['column-sorted'], () => this.processAll());
/**
* @inherited
*/
/** @inherited */
this.initialized = true;
}

View file

@ -384,7 +384,8 @@ export class CheckList extends Feature {
let tf = this.tf;
let chkCt = 1;
let fltId = tf.fltIds[colIndex];
let li0 = createCheckItem(`${fltId}_0`, '', tf.displayAllText);
let li0 = createCheckItem(`${fltId}_0`, '',
tf.getClearFilterText(colIndex));
li0.className = this.itemCssClass;
ul.appendChild(li0);

View file

@ -129,7 +129,7 @@ export class Dropdown extends Feature {
this.build(colIndex);
} else {
//1st option is created here since build isn't invoked
let opt0 = createOpt(tf.displayAllText, '');
let opt0 = createOpt(tf.getClearFilterText(colIndex), '');
slc.appendChild(opt0);
}
@ -342,9 +342,9 @@ export class Dropdown extends Feature {
*/
addFirstOption(slc) {
let tf = this.tf;
let opt0 = createOpt(
(!this.enableSlcResetFilter ? '' : tf.displayAllText), '');
let colIdx = tf.getColumnIndexFromFilterId(slc.id);
let opt0 = createOpt((!this.enableSlcResetFilter ?
'' : tf.getClearFilterText(colIdx)), '');
if (!this.enableSlcResetFilter) {
opt0.style.display = NONE;
}

View file

@ -1,8 +1,9 @@
import {Feature} from '../feature';
import {isFn} from '../types';
import {isFn, isUndef} from '../types';
import {createElm, removeElm} from '../dom';
import {addEvt, cancelEvt, stopEvt, targetEvt} from '../event';
import {INPUT, NONE} from '../const';
import {addEvt, cancelEvt, stopEvt, targetEvt, removeEvt} from '../event';
import {INPUT, NONE, CHECKLIST, MULTIPLE} from '../const';
import {root} from '../root';
/**
* Pop-up filter component
@ -26,6 +27,13 @@ export class PopupFilter extends Feature {
tf.isExternalFlt = true;
tf.externalFltTgtIds = [];
/**
* Close active popup filter upon filtering, enabled by default
* @type {Boolean}
*/
this.closeOnFiltering = f.popup_filters_close_on_filtering === false ?
false : true;
/**
* Filter icon path
* @type {String}
@ -53,6 +61,14 @@ export class PopupFilter extends Feature {
*/
this.containerCssClass = f.popup_div_css_class || 'popUpFilter';
/**
* Ensure filter's container element width matches column width, enabled
* by default
* @type {Boolean}
*/
this.adjustToContainer =
f.popup_filters_adjust_to_container === false ? false : true;
/**
* Callback fired before a popup filter is opened
* @type {Function}
@ -109,18 +125,19 @@ export class PopupFilter extends Feature {
*/
this.fltElms = this.filtersCache || [];
/**
* Ensure filter's container element width matches column width
* @type {Boolean}
*/
this.adjustToContainer = true;
/**
* Prefix for pop-up filter container ID
* @type {String}
* @private
*/
this.prfxDiv = 'popup_';
/**
* Column index of popup filter currently active
* @type {Number}
* @private
*/
this.activeFilterIdx = -1;
}
/**
@ -128,22 +145,49 @@ export class PopupFilter extends Feature {
* @private
*/
onClick(evt) {
let elm = targetEvt(evt).parentNode,
colIndex = parseInt(elm.getAttribute('ci'), 10);
let elm = targetEvt(evt).parentNode;
let colIndex = parseInt(elm.getAttribute('ci'), 10);
this.closeAll(colIndex);
this.toggle(colIndex);
if (this.adjustToContainer) {
let popUpDiv = this.fltElms[colIndex],
let cont = this.fltElms[colIndex],
header = this.tf.getHeaderElement(colIndex),
headerWidth = header.clientWidth * 0.95;
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
cont.style.width = parseInt(headerWidth, 10) + 'px';
}
cancelEvt(evt);
stopEvt(evt);
}
/**
* Mouse-up event handler handling popup filter auto-close behaviour
* @private
*/
onMouseup(evt) {
if (this.activeFilterIdx === -1) {
return;
}
let targetElm = targetEvt(evt);
let activeFlt = this.fltElms[this.activeFilterIdx];
let icon = this.fltIcons[this.activeFilterIdx];
if (icon === targetElm) {
return;
}
while (targetElm && targetElm !== activeFlt) {
targetElm = targetElm.parentNode;
}
if (targetElm !== activeFlt) {
this.close(this.activeFilterIdx);
}
return;
}
/**
* Initialize DOM elements
*/
@ -178,9 +222,7 @@ export class PopupFilter extends Feature {
this.emitter.on(['before-filter-init'],
(tf, colIndex) => this.build(colIndex));
/**
* @inherited
*/
/** @inherited */
this.initialized = true;
}
@ -190,6 +232,7 @@ export class PopupFilter extends Feature {
reset() {
this.enable();
this.init();
this.buildIcons();
this.buildAll();
}
@ -207,13 +250,13 @@ export class PopupFilter extends Feature {
if (tf.getFilterType(i) === NONE) {
continue;
}
let popUpSpan = createElm('span', ['ci', i]);
popUpSpan.innerHTML = this.iconHtml;
let icon = createElm('span', ['ci', i]);
icon.innerHTML = this.iconHtml;
let header = tf.getHeaderElement(i);
header.appendChild(popUpSpan);
addEvt(popUpSpan, 'click', (evt) => this.onClick(evt));
this.fltSpans[i] = popUpSpan;
this.fltIcons[i] = popUpSpan.firstChild;
header.appendChild(icon);
addEvt(icon, 'click', (evt) => this.onClick(evt));
this.fltSpans[i] = icon;
this.fltIcons[i] = icon.firstChild;
}
}
@ -234,52 +277,80 @@ export class PopupFilter extends Feature {
build(colIndex, div) {
let tf = this.tf;
let contId = `${this.prfxDiv}${tf.id}_${colIndex}`;
let popUpDiv = div || createElm('div', ['id', contId]);
popUpDiv.className = this.containerCssClass;
tf.externalFltTgtIds.push(popUpDiv.id);
let cont = div || createElm('div', ['id', contId]);
cont.className = this.containerCssClass;
tf.externalFltTgtIds.push(cont.id);
let header = tf.getHeaderElement(colIndex);
header.insertBefore(popUpDiv, header.firstChild);
addEvt(popUpDiv, 'click', (evt) => stopEvt(evt));
this.fltElms[colIndex] = popUpDiv;
header.insertBefore(cont, header.firstChild);
addEvt(cont, 'click', (evt) => stopEvt(evt));
this.fltElms[colIndex] = cont;
}
/**
* Toogle visibility of specified filter
* Toggle visibility of specified filter
* @param {Number} colIndex Column index
*/
toggle(colIndex) {
let tf = this.tf,
popUpFltElm = this.fltElms[colIndex];
if (popUpFltElm.style.display === NONE ||
popUpFltElm.style.display === '') {
if (this.onBeforeOpen) {
this.onBeforeOpen.call(
null, this, this.fltElms[colIndex], colIndex);
}
popUpFltElm.style.display = 'block';
if (tf.getFilterType(colIndex) === INPUT) {
let flt = tf.getFilterElement(colIndex);
if (flt) {
flt.focus();
}
}
if (this.onAfterOpen) {
this.onAfterOpen.call(
null, this, this.fltElms[colIndex], colIndex);
}
if (!this.isOpen(colIndex)) {
this.open(colIndex);
} else {
if (this.onBeforeClose) {
this.onBeforeClose.call(
null, this, this.fltElms[colIndex], colIndex);
}
popUpFltElm.style.display = NONE;
if (this.onAfterClose) {
this.onAfterClose.call(
null, this, this.fltElms[colIndex], colIndex);
this.close(colIndex);
}
}
/**
* Open popup filter of specified column
* @param {Number} colIndex Column index
*/
open(colIndex) {
let tf = this.tf,
container = this.fltElms[colIndex];
if (this.onBeforeOpen) {
this.onBeforeOpen.call(null, this, container, colIndex);
}
container.style.display = 'block';
this.activeFilterIdx = colIndex;
addEvt(root, 'mouseup', (evt) => this.onMouseup(evt));
if (tf.getFilterType(colIndex) === INPUT) {
let flt = tf.getFilterElement(colIndex);
if (flt) {
flt.focus();
}
}
if (this.onAfterOpen) {
this.onAfterOpen.call(null, this, container, colIndex);
}
}
/**
* Close popup filter of specified column
* @param {Number} colIndex Column index
*/
close(colIndex) {
let container = this.fltElms[colIndex];
if (this.onBeforeClose) {
this.onBeforeClose.call(null, this, container, colIndex);
}
container.style.display = NONE;
if (this.activeFilterIdx === colIndex) {
this.activeFilterIdx = -1;
}
removeEvt(root, 'mouseup', (evt) => this.onMouseup(evt));
if (this.onAfterClose) {
this.onAfterClose.call(null, this, container, colIndex);
}
}
/**
* Check if popup filter for specified column is open
* @param {Number} colIndex Column index
* @returns {Boolean}
*/
isOpen(colIndex) {
return this.fltElms[colIndex].style.display === 'block';
}
/**
@ -287,13 +358,23 @@ export class PopupFilter extends Feature {
* @param {Number} exceptIdx Column index of the filter to not close
*/
closeAll(exceptIdx) {
// Do not close filters only if argument is undefined and close on
// filtering option is disabled
if (isUndef(exceptIdx) && !this.closeOnFiltering) {
return;
}
for (let i = 0; i < this.fltElms.length; i++) {
if (i === exceptIdx) {
continue;
}
let popUpFltElm = this.fltElms[i];
if (popUpFltElm) {
popUpFltElm.style.display = NONE;
let fltType = tf.getFilterType(i);
let isMultipleFilter =
(fltType === CHECKLIST || fltType === MULTIPLE);
// Always hide all single selection filter types but hide multiple
// selection filter types only if index set
if (!isMultipleFilter || !isUndef(exceptIdx)) {
this.close(i);
}
}
}
@ -313,9 +394,9 @@ export class PopupFilter extends Feature {
* @param {Boolean} active Apply active state
*/
changeState(colIndex, active) {
if (this.fltIcons[colIndex]) {
this.fltIcons[colIndex].src = active ?
this.activeIconPath : this.iconPath;
let icon = this.fltIcons[colIndex];
if (icon) {
icon.src = active ? this.activeIconPath : this.iconPath;
}
}
@ -329,27 +410,30 @@ export class PopupFilter extends Feature {
this.filtersCache = [];
for (let i = 0; i < this.fltElms.length; i++) {
let popUpFltElm = this.fltElms[i],
popUpFltSpan = this.fltSpans[i],
popUpFltImg = this.fltIcons[i];
if (popUpFltElm) {
removeElm(popUpFltElm);
this.filtersCache[i] = popUpFltElm;
let container = this.fltElms[i],
icon = this.fltSpans[i],
iconImg = this.fltIcons[i];
if (container) {
removeElm(container);
this.filtersCache[i] = container;
}
popUpFltElm = null;
if (popUpFltSpan) {
removeElm(popUpFltSpan);
container = null;
if (icon) {
removeElm(icon);
}
popUpFltSpan = null;
if (popUpFltImg) {
removeElm(popUpFltImg);
icon = null;
if (iconImg) {
removeElm(iconImg);
}
popUpFltImg = null;
iconImg = null;
}
this.fltElms = [];
this.fltSpans = [];
this.fltIcons = [];
// TODO: expose an API to handle external filter IDs
tf.externalFltTgtIds = [];
// unsubscribe to events
this.emitter.off(['before-filtering'], () => this.setIconsState());
this.emitter.off(['after-filtering'], () => this.closeAll());

View file

@ -148,8 +148,7 @@ export class TableFilter {
//Start row et cols nb
this.refRow = isUndef(startRow) ? 2 : (startRow + 1);
try { this.nbCells = this.getCellsNb(this.refRow); }
catch (e) { this.nbCells = this.getCellsNb(0); }
this.nbCells = this.getCellsNb(this.refRow);
/**
* Base path for static assets
@ -529,9 +528,9 @@ export class TableFilter {
/*** select filter's customisation and behaviours ***/
/**
* Text for clear option in drop-down filter types (1st option)
* @type {String}
* @type {String|Array}
*/
this.displayAllText = f.display_all_text || 'Clear';
this.clearFilterText = f.clear_filter_text || 'Clear';
/**
* Indicate whether empty option is enabled in drop-down filter types
@ -1021,37 +1020,27 @@ export class TableFilter {
}
// Instanciate sugar date wrapper
if (!Mod.dateType) {
Mod.dateType = new DateType(this);
}
Mod.dateType = Mod.dateType || new DateType(this);
Mod.dateType.init();
// Instantiate help feature and initialise only if set true
if (!Mod.help) {
Mod.help = new Help(this);
}
Mod.help = Mod.help || new Help(this);
if (this.help) {
Mod.help.init();
}
if (this.state) {
if (!Mod.state) {
Mod.state = new State(this);
}
Mod.state = Mod.state || new State(this);
Mod.state.init();
}
if (this.gridLayout) {
if (!Mod.gridLayout) {
Mod.gridLayout = new GridLayout(this);
}
Mod.gridLayout = Mod.gridLayout || new GridLayout(this);
Mod.gridLayout.init();
}
if (this.loader) {
if (!Mod.loader) {
Mod.loader = new Loader(this);
}
Mod.loader = Mod.loader || new Loader(this);
Mod.loader.init();
}
@ -1061,9 +1050,7 @@ export class TableFilter {
}
if (this.popupFilters) {
if (!Mod.popupFilter) {
Mod.popupFilter = new PopupFilter(this);
}
Mod.popupFilter = Mod.popupFilter || new PopupFilter(this);
Mod.popupFilter.init();
}
@ -1162,9 +1149,7 @@ export class TableFilter {
Mod.alternateRows.init();
}
if (this.noResults) {
if (!Mod.noResults) {
Mod.noResults = new NoResults(this);
}
Mod.noResults = Mod.noResults || new NoResults(this);
Mod.noResults.init();
}
@ -2270,7 +2255,7 @@ export class TableFilter {
* @return {Number} Number of cells
*/
getCellsNb(rowIndex = 0) {
let tr = this.tbl.rows[rowIndex];
let tr = this.tbl.rows[rowIndex >= 0 ? rowIndex : 0];
return tr.cells.length;
}
@ -2683,34 +2668,35 @@ export class TableFilter {
let activeIdx = this.getColumnIndexFromFilterId(this.activeFilterId);
for (let i = 0, len = slcIndex.length; i < len; i++) {
let curSlc = elm(this.fltIds[slcIndex[i]]);
let slcSelectedValue = this.getFilterValue(slcIndex[i]);
let colIdx = slcIndex[i];
let curSlc = elm(this.fltIds[colIdx]);
let slcSelectedValue = this.getFilterValue(colIdx);
// Welcome to cyclomatic complexity hell :)
// TODO: simplify/refactor if statement
if (activeIdx !== slcIndex[i] ||
(this.paging && slcA1.indexOf(slcIndex[i]) !== -1 &&
activeIdx === slcIndex[i]) ||
(!this.paging && (slcA3.indexOf(slcIndex[i]) !== -1 ||
slcA2.indexOf(slcIndex[i]) !== -1)) ||
slcSelectedValue === this.displayAllText) {
if (activeIdx !== colIdx ||
(this.paging && slcA1.indexOf(colIdx) !== -1 &&
activeIdx === colIdx) ||
(!this.paging && (slcA3.indexOf(colIdx) !== -1 ||
slcA2.indexOf(colIdx) !== -1)) ||
slcSelectedValue === this.getClearFilterText(colIdx)) {
//1st option needs to be inserted
if (this.loadFltOnDemand) {
let opt0 = createOpt(this.displayAllText, '');
let opt0 = createOpt(this.getClearFilterText(colIdx), '');
curSlc.innerHTML = '';
curSlc.appendChild(opt0);
}
if (slcA3.indexOf(slcIndex[i]) !== -1) {
this.emitter.emit('build-checklist-filter', this,
slcIndex[i], true);
if (slcA3.indexOf(colIdx) !== -1) {
this.emitter.emit('build-checklist-filter', this, colIdx,
true);
} else {
this.emitter.emit('build-select-filter', this, slcIndex[i],
this.emitter.emit('build-select-filter', this,colIdx,
true);
}
this.setFilterValue(slcIndex[i], slcSelectedValue);
this.setFilterValue(colIdx, slcSelectedValue);
}
}
}
@ -2748,7 +2734,7 @@ export class TableFilter {
/**
* Checks if specified column filter ignores diacritics.
* Note this is only valid for input filter types.
* @param {any} colIndex Column index
* @param {Number} colIndex Column index
* @returns {Boolean}
*/
ignoresDiacritics(colIndex) {
@ -2759,6 +2745,19 @@ export class TableFilter {
return Boolean(ignoreDiac);
}
/**
* Returns clear all text for specified filter column
* @param {Number} colIndex Column index
* @returns {String}
*/
getClearFilterText(colIndex) {
let clearText = this.clearFilterText;
if (isArray(clearText)) {
return clearText[colIndex];
}
return clearText;
}
/**
* Check if passed script or stylesheet is already imported
* @param {String} filePath Ressource path

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

View file

@ -0,0 +1,205 @@
/**
* transparent theme overrides
*/
@import '../../mixins/box-shadow'
// table
table.TF
padding 0
color inherit
border-right 1px solid transparent
border-top 1px solid transparent
border-left 1px solid transparent
border-bottom 0
th
margin 0
color inherit
background-color transparent
border-color transparent
border-width 1px
border-style solid
&:last-child
border-right 1px solid transparent
td
margin 0
padding 5px
color inherit
border-bottom 1px solid transparent
border-left 0
border-top 0
border-right 0
// filters
.fltrow
background-color transparent
th, td
padding 1px 3px 1px 3px
border-bottom 1px solid transparent !important
&:last-child
border-right 1px solid transparent
.flt,
select.flt,
select.flt_multi,
.flt_s,
.single_flt,
.div_checklist
border 1px solid #A4BED4
input.flt
width 99% !important
// toolbar
.inf
background-color transparent
border 1px solid transparent
height $min-height
color inherit
div.tot,
div.status
border-right 0 !important
// help
.helpBtn
&:hover
background-color transparent
// reset button
input.reset
background transparent url(images/icn_clear_filters.png) center center no-repeat !important
.nextPage
background transparent url(images/btn_next_page.gif) center center no-repeat !important
border 1px solid transparent !important
&:hover
background #F7F7F7 url(images/btn_next_page.gif) center center no-repeat !important
border 1px solid #F7F7F7 !important
.previousPage
background transparent url(images/btn_prev_page.gif) center center no-repeat !important
border 1px solid transparent !important
&:hover
background #F7F7F7 url(images/btn_prev_page.gif) center center no-repeat !important
border 1px solid #F7F7F7 !important
.firstPage
background transparent url(images/btn_first_page.gif) center center no-repeat !important
border 1px solid transparent !important
&:hover
background #F7F7F7 url(images/btn_first_page.gif) center center no-repeat !important
border 1px solid #F7F7F7 !important
.lastPage
background transparent url(images/btn_last_page.gif) center center no-repeat !important
border 1px solid transparent !important
&:hover
background #F7F7F7 url(images/btn_last_page.gif) center center no-repeat !important
border 1px solid #F7F7F7 !important
// active header
.activeHeader
background #F7F7F7 !important
border 1px solid transparent
color inherit !important
// grid-layout
// main container
div.grd_Cont
box-shadow(0 0 0 0 rgba(50, 50, 50, 0.75))
background-color transparent
border 1px solid transparent
padding 0 !important
// alternating background colors
.even
background-color transparent
.odd
background-color #F7F7F7
// headers' table container
div.grd_headTblCont
background-color transparent
border-bottom none !important
div.grd_tblCont table
border-right none !important
// headers
div.grd_tblCont table th,
div.grd_headTblCont table th,
div.grd_headTblCont table td
background transparent
border-bottom 1px solid transparent
border-right 1px solid transparent !important
border-left 1px solid transparent
border-top 1px solid transparent
div.grd_tblCont table td
border-bottom 1px solid transparent
border-right 0 !important
border-left 0 !important
border-top 0 !important
// toolbar containing left, middle and right divs
.grd_inf
background-color transparent
color inherit
border-top 1px solid transparent
a
text-decoration none
font-weight bold
// loader
.loader
background-color #F7F7F7
border 1px solid #F7F7F7
border-radius 5px
color #000000
text-shadow none
// alternating background colors
.even
background-color transparent
.odd
background-color #F7F7F7
// filters visibility
span.expClpFlt
a.btnExpClpFlt
&:hover
background-color transparent !important
// ezedittable
// selection
.ezActiveRow
background-color #CCCCCC !important
color inherit
.ezSelectedRow
background-color #CCCCCC !important
color inherit
.ezActiveCell
background-color transparent
color inherit
font-weight bold
.ezETSelectedCell
background-color transparent
font-weight bold
color inherit

View file

@ -93,7 +93,11 @@ var tfConfig = {
'number', 'number', 'number',
'number', 'number', 'number'
],
display_all_text: " [ Show all ] ",
clear_filter_text: [
' [ Show all ] ',
'<Clear>',
'Clear:'
],
col_0: "multiple",
col_1: "select",
col_2: "checklist",

View file

@ -29,21 +29,21 @@ var filtersConfig = {
disable_excluded_options: true,
col_1: 'multiple',
col_2: 'checklist',
col_types: [
'number', 'string', 'string',
'formatted-number', 'none', 'string'
],
col_widths: [
'60px', '160px', '160px',
'85px', '70px', '270px'
],
btn_reset: true,
display_all_text: '< Clear >',
clear_filter_text: '< Clear >',
alternate_rows: true,
rows_counter: true,
enable_default_theme: true,
extensions:[{
name: 'sort',
types: [
'number', 'string', 'string',
'US', 'none', 'string'
]
name: 'sort'
}]
};

View file

@ -24,7 +24,7 @@ var filtersConfig = {
col_1: 'multiple',
col_2: 'checklist',
btn_reset: true,
display_all_text: '< Clear >',
clear_filter_text: '< Clear >',
alternate_rows: true,
rows_counter: true,
enable_default_theme: true,

View file

@ -19,6 +19,7 @@
<option value="default" selected="selected">default</option>
<option value="mytheme">mytheme</option>
<option value="skyblue">skyblue</option>
<option value="transparent">transparent</option>
</select>
</div>
<!-- @import partials/books.html -->
@ -85,7 +86,8 @@ tf.init();
var THEMES = {
'default': tf.themesPath + 'default/default.css',
'mytheme': tf.themesPath + 'mytheme/mytheme.css',
'skyblue': tf.themesPath + 'skyblue/skyblue.css'
'skyblue': tf.themesPath + 'skyblue/skyblue.css',
'transparent': tf.themesPath + 'transparent/transparent.css'
};
function changeTheme(name){

View file

@ -86,8 +86,91 @@ test('Remove background on a row', function() {
0, 'Bg set on expected row');
});
test('Remove alternating rows', function() {
test('Cannot init if initialised', function() {
// setup
var processAll = altRows.processAll;
var hit = 0;
altRows.processAll = function() { hit++ };
altRows.initialized = true;
// act
altRows.init();
// assert
deepEqual(hit, 0, 'processAll not called');
altRows.processAll = processAll;
});
test('Cannot processAll if not enabled', function() {
// setup
var setRowBg = altRows.setRowBg;
var hit = 0;
altRows.setRowBg = function() { hit++ };
altRows.enabled = false;
// act
altRows.processAll();
// assert
deepEqual(hit, 0, 'setRowBg not called');
altRows.setRowBg = setRowBg;
});
test('Cannot setRowBg if not enabled', function() {
// setup
var removeRowBg = altRows.removeRowBg;
var hit = 0;
altRows.removeRowBg = function() { hit++ };
altRows.enabled = false;
// act
altRows.setRowBg(3, 5);
// assert
deepEqual(hit, 0, 'removeRowBg not called');
altRows.removeRowBg = removeRowBg;
});
test('Cannot removeRowBg if row index is NaN', function() {
// setup
tf.clearFilters();
tf.filter();
// act
altRows.removeRowBg('hello');
// assert
deepEqual(tbl.querySelectorAll('tr.odd').length, 3, 'Expected odd bgs');
deepEqual(tbl.querySelectorAll('tr.even').length, 3, 'Expected even bg');
});
test('Cannot destroy if not initialised', function() {
// setup
var getRowsNb = altRows.tf.getRowsNb;
var hit = 0;
altRows.tf.getRowsNb = function() { hit++ };
altRows.initialized = false;
// act
altRows.destroy();
// assert
deepEqual(hit, 0, 'tf.getRowsNb not called');
altRows.tf.getRowsNb = getRowsNb;
});
test('Remove alternating rows', function() {
// setup
altRows.initialized = true;
// act
altRows.destroy();
// assert
deepEqual(tbl.querySelectorAll('tr.odd').length, 0, 'Odd bgs removed');
deepEqual(tbl.querySelectorAll('tr.even').length, 0, 'Even bg removed');
});

View file

@ -127,6 +127,12 @@ test('Clear filters', function() {
deepEqual(tf.getFiltersValue(), ['', '', '', '', '']);
});
test('Can get feature', function() {
var feature = tf.feature('help');
deepEqual(typeof feature, 'object', 'Feature instance');
deepEqual(feature.feature, 'help', 'Feature name');
});
test('Get table data', function() {
deepEqual(tf.getColValues(0),
[

View file

@ -108,6 +108,18 @@
deepEqual(tf.getValidRows(), [6], 'Expected rows');
});
test('Can filter a number', function() {
// setup
tf.clearFilters();
// act
tf.setFilterValue(4, 1836.09);
tf.filter();
// assert
deepEqual(tf.getValidRows(), [6], 'Expected rows');
});
test('Can filter a formatted number column with a number', function() {
// setup
tf.clearFilters();

View file

@ -74,6 +74,7 @@ test('Can parse date', function() {
var date3 = dateType.parse('14-Jul-2005', 'fr');
var date4 = dateType.parse(null);
var date5 = dateType.parse(undefined);
var date6 = dateType.parse('');
deepEqual(date0, new Date(2017, 9, 25, 0, 0, 0, 0), 'en-US date');
deepEqual(date1, new Date(2017, 9, 25, 0, 0, 0, 0), 'en-GB date');
@ -81,6 +82,7 @@ test('Can parse date', function() {
deepEqual(date3, new Date(2005, 6, 14, 0, 0, 0, 0), 'fr date');
deepEqual(date4.toISOString(), '1970-01-01T00:00:00.000Z', 'null date');
deepEqual(date5 instanceof Date, true, 'undefined date');
deepEqual(isNaN(date6), true, 'Invalid date');
});
test('Can validate date', function() {

View file

@ -1,7 +1,82 @@
(function(win, TableFilter){
var id = function (id){ return document.getElementById(id); };
var tf = new TableFilter('demo', {
var id = function (id){ return document.getElementById(id); };
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_2: 'select',
col_3: 'multiple',
col_4: 'checklist',
/* external filters */
external_flt_grid: true,
external_flt_grid_ids: [
'extFrom',
'extDestination',
'extRoadDistance',
'extAirDistance',
'extRailDistance'
]
});
tf.init();
module('Sanity checks');
test('External filters', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 1, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 2, 'Reference row index');
deepEqual(id('extFrom').childNodes.length>0, true,
'Col0 filter is external');
deepEqual(id('extDestination').childNodes.length>0, true,
'Col1 filter is external');
deepEqual(id('extRoadDistance').childNodes.length>0, true,
'Col2 filter is external');
deepEqual(id('extAirDistance').childNodes.length>0, true,
'Col3 filter is external');
deepEqual(id('extRailDistance').childNodes.length>0, true,
'Col4 filter is external');
});
module('Filter columns');
test('Can filter column 0', function() {
tf.setFilterValue(0, 'Syd');
tf.filter();
deepEqual(tf.getValidRows().length, 4, 'Filtered rows length');
});
test('Can filter column 1', function() {
tf.clearFilters();
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [2], 'Filtered rows');
});
test('Can filter column 2', function() {
tf.clearFilters();
tf.setFilterValue(2, '1533');
tf.filter();
deepEqual(tf.getValidRows(), [7], 'Filtered rows');
});
test('Can filter column 3', function() {
tf.clearFilters();
tf.setFilterValue(3, ['2', '3.1', '1.5']);
tf.filter();
deepEqual(tf.getValidRows().length, 3, 'Filtered rows');
});
test('Can filter column 4', function() {
tf.clearFilters();
tf.setFilterValue(4, ['16', '40']);
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows');
});
// Filters in grid-layout mode are already considered as `external` as
// generated in headers container
module('Grid-layout');
test('Sanity checks', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_2: 'select',
col_3: 'multiple',
@ -14,211 +89,134 @@
'extRoadDistance',
'extAirDistance',
'extRailDistance'
]
],
grid_layout: true
});
tf.init();
module('Sanity checks');
test('External filters', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 1, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 2, 'Reference row index');
deepEqual(id('extFrom').childNodes.length>0, true,
'Col0 filter is external');
deepEqual(id('extDestination').childNodes.length>0, true,
'Col1 filter is external');
deepEqual(id('extRoadDistance').childNodes.length>0, true,
'Col2 filter is external');
deepEqual(id('extAirDistance').childNodes.length>0, true,
'Col3 filter is external');
deepEqual(id('extRailDistance').childNodes.length>0, true,
'Col4 filter is external');
});
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 1, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 0, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 0, 'Reference row index');
deepEqual(id('extFrom').childNodes.length, 0,
'Col0 filter is external');
deepEqual(id('extDestination').childNodes.length, 0,
'Col1 filter is external');
deepEqual(id('extRoadDistance').childNodes.length, 0,
'Col2 filter is external');
deepEqual(id('extAirDistance').childNodes.length, 0,
'Col3 filter is external');
deepEqual(id('extRailDistance').childNodes.length, 0,
'Col4 filter is external');
});
test('Can filter column 0', function() {
tf.setFilterValue(0, 'Syd');
tf.filter();
deepEqual(tf.getValidRows().length, 4, 'Filtered rows length');
});
test('Can filter column 1', function() {
tf.clearFilters();
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [0], 'Filtered rows');
});
test('Can filter column 2', function() {
tf.clearFilters();
tf.setFilterValue(2, '1533');
tf.filter();
deepEqual(tf.getValidRows(), [5], 'Filtered rows');
});
test('Can filter column 3', function() {
tf.clearFilters();
tf.setFilterValue(3, ['2', '3.1', '1.5']);
tf.filter();
deepEqual(tf.getValidRows().length, 3, 'Filtered rows');
});
test('Can filter column 4', function() {
tf.clearFilters();
tf.setFilterValue(4, ['16', '40']);
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows');
});
module('Filter columns');
test('Can filter column 0', function() {
tf.setFilterValue(0, 'Syd');
tf.filter();
deepEqual(tf.getValidRows().length, 4, 'Filtered rows length');
});
test('Can filter column 1', function() {
tf.clearFilters();
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [2], 'Filtered rows');
});
test('Can filter column 2', function() {
tf.clearFilters();
tf.setFilterValue(2, '1533');
tf.filter();
deepEqual(tf.getValidRows(), [7], 'Filtered rows');
});
test('Can filter column 3', function() {
tf.clearFilters();
tf.setFilterValue(3, ['2', '3.1', '1.5']);
tf.filter();
deepEqual(tf.getValidRows().length, 3, 'Filtered rows');
});
test('Can filter column 4', function() {
tf.clearFilters();
tf.setFilterValue(4, ['16', '40']);
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows');
// In popup filters mode are already considered as `external` as
// generated in headers container
module('Pop-up filters');
test('Sanity checks', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_2: 'select',
col_3: 'multiple',
col_4: 'checklist',
/* external filters */
external_flt_grid: true,
external_flt_grid_ids: [
'extFrom',
'extDestination',
'extRoadDistance',
'extAirDistance',
'extRailDistance'
],
popup_filters: true
});
tf.init();
// Filters in grid-layout mode are already considered as `external` as
// generated in headers container
module('Grid-layout');
test('Sanity checks', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_2: 'select',
col_3: 'multiple',
col_4: 'checklist',
/* external filters */
external_flt_grid: true,
external_flt_grid_ids: [
'extFrom',
'extDestination',
'extRoadDistance',
'extAirDistance',
'extRailDistance'
],
grid_layout: true
});
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 1, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 2, 'Reference row index');
deepEqual(id('extFrom').childNodes.length, 0,
'Col0 filter is external');
deepEqual(id('extDestination').childNodes.length, 0,
'Col1 filter is external');
deepEqual(id('extRoadDistance').childNodes.length, 0,
'Col2 filter is external');
deepEqual(id('extAirDistance').childNodes.length, 0,
'Col3 filter is external');
deepEqual(id('extRailDistance').childNodes.length, 0,
'Col4 filter is external');
});
test('Can filter column 0', function() {
tf.setFilterValue(0, 'Syd');
tf.filter();
deepEqual(tf.getValidRows().length, 4, 'Filtered rows length');
});
test('Can filter column 1', function() {
tf.clearFilters();
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [2], 'Filtered rows');
});
test('Can filter column 2', function() {
tf.clearFilters();
tf.setFilterValue(2, '1533');
tf.filter();
deepEqual(tf.getValidRows(), [7], 'Filtered rows');
});
test('Can filter column 3', function() {
tf.clearFilters();
tf.setFilterValue(3, ['2', '3.1', '1.5']);
tf.filter();
deepEqual(tf.getValidRows().length, 3, 'Filtered rows');
});
test('Can filter column 4', function() {
tf.clearFilters();
tf.setFilterValue(4, ['16', '40']);
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows');
});
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 1, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 0, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 0, 'Reference row index');
deepEqual(id('extFrom').childNodes.length, 0,
'Col0 filter is external');
deepEqual(id('extDestination').childNodes.length, 0,
'Col1 filter is external');
deepEqual(id('extRoadDistance').childNodes.length, 0,
'Col2 filter is external');
deepEqual(id('extAirDistance').childNodes.length, 0,
'Col3 filter is external');
deepEqual(id('extRailDistance').childNodes.length, 0,
'Col4 filter is external');
});
test('Can filter column 0', function() {
tf.setFilterValue(0, 'Syd');
tf.filter();
deepEqual(tf.getValidRows().length, 4, 'Filtered rows length');
});
test('Can filter column 1', function() {
tf.clearFilters();
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [0], 'Filtered rows');
});
test('Can filter column 2', function() {
tf.clearFilters();
tf.setFilterValue(2, '1533');
tf.filter();
deepEqual(tf.getValidRows(), [5], 'Filtered rows');
});
test('Can filter column 3', function() {
tf.clearFilters();
tf.setFilterValue(3, ['2', '3.1', '1.5']);
tf.filter();
deepEqual(tf.getValidRows().length, 3, 'Filtered rows');
});
test('Can filter column 4', function() {
tf.clearFilters();
tf.setFilterValue(4, ['16', '40']);
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows');
});
// In popup filters mode are already considered as `external` as
// generated in headers container
module('Pop-up filters');
test('Sanity checks', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_2: 'select',
col_3: 'multiple',
col_4: 'checklist',
/* external filters */
external_flt_grid: true,
external_flt_grid_ids: [
'extFrom',
'extDestination',
'extRoadDistance',
'extAirDistance',
'extRailDistance'
],
popup_filters: true
});
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 1, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 2, 'Reference row index');
deepEqual(id('extFrom').childNodes.length, 0,
'Col0 filter is external');
deepEqual(id('extDestination').childNodes.length, 0,
'Col1 filter is external');
deepEqual(id('extRoadDistance').childNodes.length, 0,
'Col2 filter is external');
deepEqual(id('extAirDistance').childNodes.length, 0,
'Col3 filter is external');
deepEqual(id('extRailDistance').childNodes.length, 0,
'Col4 filter is external');
});
test('Can filter column 0', function() {
tf.setFilterValue(0, 'Syd');
tf.filter();
deepEqual(tf.getValidRows().length, 4, 'Filtered rows length');
});
test('Can filter column 1', function() {
tf.clearFilters();
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [2], 'Filtered rows');
});
test('Can filter column 2', function() {
tf.clearFilters();
tf.setFilterValue(2, '1533');
tf.filter();
deepEqual(tf.getValidRows(), [7], 'Filtered rows');
});
test('Can filter column 3', function() {
tf.clearFilters();
tf.setFilterValue(3, ['2', '3.1', '1.5']);
tf.filter();
deepEqual(tf.getValidRows().length, 3, 'Filtered rows');
});
test('Can filter column 4', function() {
tf.clearFilters();
tf.setFilterValue(4, ['16', '40']);
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows');
});
module('Tear-down');
test('TableFilter removed', function() {
tf.clearFilters();
tf.destroy();
deepEqual(tf.isInitialized(), false, 'Filters removed');
});
})(window, TableFilter);
module('Tear-down');
test('TableFilter removed', function() {
tf.clearFilters();
tf.destroy();
deepEqual(tf.isInitialized(), false, 'Filters removed');
});

View file

@ -1,109 +1,106 @@
(function(win, TableFilter){
var tf = new TableFilter('demo', 3, {
var tf = new TableFilter('demo', 3, {
base_path: '../dist/tablefilter/',
filters_row_index: 3,
headers_row_index: 2
});
tf.init();
module('Sanity checks');
test('Grouped headers', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 3, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 2, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 4, 'Reference row index');
});
test('Can perform a search', function() {
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [4], 'Filtered row');
});
module('Paging');
test('Sanity checks', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', 3, {
base_path: '../dist/tablefilter/',
filters_row_index: 3,
headers_row_index: 2
headers_row_index: 2,
paging: true,
paging_length: 3
});
tf.init();
module('Sanity checks');
test('Grouped headers', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 3, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 2, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 4, 'Reference row index');
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 3, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 2, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 4, 'Reference row index');
});
test('Can perform a search', function() {
tf.setFilterValue(2, '>100');
tf.filter();
deepEqual(tf.getValidRows(), [4, 5, 6, 7, 8, 9, 10], 'Filtered rows');
deepEqual(
tf.feature('paging').nbPages,
3,
'Number of pages for filtered rows'
);
});
module('Pop-up filters');
test('Sanity checks', function() {
tf.clearFilters();
tf.feature('paging').destroy();
tf.destroy();
tf = new TableFilter('demo', 3, {
base_path: '../dist/tablefilter/',
headers_row_index: 2,
popup_filters: true
});
tf.init();
test('Can perform a search', function() {
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [4], 'Filtered row');
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getHeadersRowIndex(), 3, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 4, 'Reference row index');
});
test('Can perform a search', function() {
tf.setFilterValue(1, 'Melb');
tf.filter();
deepEqual(tf.getValidRows(), [7], 'Filtered rows');
});
module('Pop-up filters, issue #295');
test('Sanity checks', function() {
var tf2 = new TableFilter('demo2', 2, {
base_path: '../dist/tablefilter/',
headers_row_index: 1,
popup_filters: true
});
tf2.init();
tf2.setFilterValue(1, 'Melb');
tf2.filter();
module('Paging');
test('Sanity checks', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', 3, {
base_path: '../dist/tablefilter/',
filters_row_index: 3,
headers_row_index: 2,
paging: true,
paging_length: 3
});
tf.init();
deepEqual(tf2 instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf2.getHeadersRowIndex(), 2, 'Headers row index');
deepEqual(tf2.getStartRowIndex(), 3, 'Reference row index');
deepEqual(tf2.getValidRows(), [6], 'Filtered rows');
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 3, 'Filters row index');
deepEqual(tf.getHeadersRowIndex(), 2, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 4, 'Reference row index');
});
tf2.clearFilters();
tf2.destroy();
deepEqual(tf2.isInitialized(), false, 'Filters removed');
});
test('Can perform a search', function() {
tf.setFilterValue(2, '>100');
tf.filter();
//Grid-layout currently does not support grouped headers
deepEqual(tf.getValidRows(), [4, 5, 6, 7, 8, 9, 10], 'Filtered rows');
deepEqual(
tf.feature('paging').nbPages,
3,
'Number of pages for filtered rows'
);
});
module('Pop-up filters');
test('Sanity checks', function() {
tf.clearFilters();
tf.feature('paging').destroy();
tf.destroy();
tf = new TableFilter('demo', 3, {
base_path: '../dist/tablefilter/',
headers_row_index: 2,
popup_filters: true
});
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getHeadersRowIndex(), 3, 'Headers row index');
deepEqual(tf.getStartRowIndex(), 4, 'Reference row index');
});
test('Can perform a search', function() {
tf.setFilterValue(1, 'Melb');
tf.filter();
deepEqual(tf.getValidRows(), [7], 'Filtered rows');
});
module('Pop-up filters, issue #295');
test('Sanity checks', function() {
var tf2 = new TableFilter('demo2', 2, {
base_path: '../dist/tablefilter/',
headers_row_index: 1,
popup_filters: true
});
tf2.init();
tf2.setFilterValue(1, 'Melb');
tf2.filter();
deepEqual(tf2 instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf2.getHeadersRowIndex(), 2, 'Headers row index');
deepEqual(tf2.getStartRowIndex(), 3, 'Reference row index');
deepEqual(tf2.getValidRows(), [6], 'Filtered rows');
tf2.clearFilters();
tf2.destroy();
deepEqual(tf2.isInitialized(), false, 'Filters removed');
});
//Grid-layout currently does not support grouped headers
module('Tear-down');
test('TableFilter removed', function() {
tf.clearFilters();
tf.destroy();
deepEqual(tf.isInitialized(), false, 'Filters removed');
});
})(window, TableFilter);
module('Tear-down');
test('TableFilter removed', function() {
tf.clearFilters();
tf.destroy();
deepEqual(tf.isInitialized(), false, 'Filters removed');
});

View file

@ -1,101 +1,98 @@
(function(win, TableFilter){
var tf = new TableFilter('demo', 0, {
base_path: '../dist/tablefilter/'
var tf = new TableFilter('demo', 0, {
base_path: '../dist/tablefilter/'
});
tf.init();
module('Sanity checks');
test('No headers', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.refRow, 1, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
});
test('Can perform a search', function() {
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [1], 'Filtered row');
});
test('Paging with no headers', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', 0, {
base_path: '../dist/tablefilter/',
paging: true,
paging_length: 3
});
tf.init();
module('Sanity checks');
test('No headers', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.refRow, 1, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.refRow, 1, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
});
test('Can perform a search', function() {
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [1], 'Filtered row');
});
// Grid layout currently does not handle a table with no headers...
// Raised in issue 110 (https://github.com/koalyptus/TableFilter/issues/110)
test('Grid layout with no header', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
grid_layout: true,
grid_no_headers: true
});
tf.init();
test('Can perform a search', function() {
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 1, 'Filters row index');
deepEqual(tf.refRow, 0, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
deepEqual(tf.getRowsNb(), 7, 'Filterable rows number');
});
test('Can perform a search', function() {
tf.setFilterValue(2, '<900');
tf.filter();
deepEqual(tf.getValidRows(), [1], 'Filtered row');
deepEqual(tf.getValidRows(), [2,3], 'Filtered row');
});
// With no toolbar cannot clear filters :)
test('Popup filters with no header', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', 0, {
base_path: '../dist/tablefilter/',
popup_filters: true
});
tf.init();
test('Paging with no headers', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', 0, {
base_path: '../dist/tablefilter/',
paging: true,
paging_length: 3
});
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.refRow, 1, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
});
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.refRow, 1, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
});
test('Can perform a search', function() {
tf.setFilterValue(1, 'Melbourne');
tf.filter();
test('Can perform a search', function() {
tf.setFilterValue(1, 'Ade');
tf.filter();
deepEqual(tf.getValidRows(), [4], 'Filtered row');
});
deepEqual(tf.getValidRows(), [1], 'Filtered row');
});
// Grid layout currently does not handle a table with no headers...
// Raised in issue 110 (https://github.com/koalyptus/TableFilter/issues/110)
test('Grid layout with no header', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
grid_layout: true,
grid_no_headers: true
});
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 1, 'Filters row index');
deepEqual(tf.refRow, 0, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
deepEqual(tf.getRowsNb(), 7, 'Filterable rows number');
});
test('Can perform a search', function() {
tf.setFilterValue(2, '<900');
tf.filter();
deepEqual(tf.getValidRows(), [2,3], 'Filtered row');
});
// With no toolbar cannot clear filters :)
test('Popup filters with no header', function() {
tf.clearFilters();
tf.destroy();
tf = new TableFilter('demo', 0, {
base_path: '../dist/tablefilter/',
popup_filters: true
});
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
deepEqual(tf.refRow, 1, 'Reference row index');
notEqual(tf.getFilterElement(0), null, 'Filter element for column 0');
});
test('Can perform a search', function() {
tf.setFilterValue(1, 'Melbourne');
tf.filter();
deepEqual(tf.getValidRows(), [4], 'Filtered row');
});
module('Tear-down');
test('TableFilter removed', function() {
tf.clearFilters();
tf.destroy();
deepEqual(tf.isInitialized(), false, 'Filters removed');
});
})(window, TableFilter);
module('Tear-down');
test('TableFilter removed', function() {
tf.clearFilters();
tf.destroy();
deepEqual(tf.isInitialized(), false, 'Filters removed');
});

View file

@ -16,6 +16,11 @@ test('Pop-up filter component', function() {
notEqual(popupFilter, null, 'PopupFilter instanciated');
deepEqual(popupFilter.fltElms instanceof Array,
true, 'Type of fltElms property');
deepEqual(
popupFilter.adjustToContainer,
true,
'Popup filter width adjusts to container'
);
deepEqual(tf.headersRow, 1, 'Headers row index');
// issue 99: getHeadersText for pick-list filter types
deepEqual(
@ -72,6 +77,106 @@ test('Pop-up filter state after clearing', function(){
true, 'Icon state');
});
test('Can open pop-up filter', function(){
// act
popupFilter.open(1);
// assert
deepEqual(popupFilter.fltElms[1].style.display, 'block',
'Popup filter is open');
});
test('Can close pop-up filter', function(){
// act
popupFilter.close(1);
// assert
deepEqual(popupFilter.fltElms[1].style.display, 'none',
'Popup filter is open');
});
test('Can toggle pop-up filter (initially closed)', function(){
// setup
popupFilter.close(2);
// act
popupFilter.toggle(2);
// assert
deepEqual(popupFilter.fltElms[2].style.display, 'block',
'Popup filter is toggled');
});
test('Can toggle pop-up filter (initially opened)', function(){
// setup
popupFilter.open(2);
// act
popupFilter.toggle(2);
// assert
deepEqual(popupFilter.fltElms[2].style.display, 'none',
'Popup filter is toggled');
});
test('Multiple selection pop-up filter remains open upon filtering', function(){
// setup
popupFilter.open(2);
// act
tf.setFilterValue(2, ['1412', '982']);
tf.filter();
// assert
deepEqual(
popupFilter.isOpen(2),
true,
'Multiple selection pop-up filter still open after filtering'
);
});
test('Pop-up filter closes upon filtering', function(){
// setup
popupFilter.open(1);
// act
tf.setFilterValue(1, 'Adelaide');
tf.filter();
// assert
deepEqual(popupFilter.isOpen(1), false,
'Pop-up filter closed after filtering'
);
});
test('Pop-up filter auto-closes when user clicks away', function(){
// setup
popupFilter.open(0);
// act
var evObj = document.createEvent('HTMLEvents');
evObj.initEvent('mouseup', true, true);
tf.tbl.rows[4].cells[2].dispatchEvent(evObj);
// assert
deepEqual(popupFilter.isOpen(0), false,
'Pop-up filter closed after user clicks away'
);
});
test('Can destroy and reset', function(){
// setup
popupFilter.destroy();
// act
popupFilter.reset();
// assert
deepEqual(popupFilter.fltElms.length, 5, 'Filters are generated');
deepEqual(popupFilter.fltIcons.length, 4, 'Icons are generated');
deepEqual(popupFilter.fltSpans.length, 4, 'Icon containers are generated');
});
test('TableFilter removed', function() {
tf.destroy();
var fltIcn1 = popupFilter.fltIcons[3];

View file

@ -75,4 +75,4 @@
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>
</html>

View file

@ -70,4 +70,42 @@
deepEqual(tf1.getValidRows().length, 2, 'Filter button event result');
});
test('Cannot init if initialised', function() {
// setup
var importFile = tf1.import;
var hit = 0;
tf1.import = function() { hit++ };
tf1.initialized = true;
// act
tf1.init();
// assert
deepEqual(hit, 0, 'import not called');
tf1.import = importFile;
});
module('Tear-down');
test('can destroy TableFilter DOM elements', function() {
tf.destroy();
tf1.destroy();
deepEqual(tf.isInitialized(), false, 'Instance no longer initialised');
deepEqual(tf1.getFilterElement(0), null, 'Filter 0 removed');
});
module('Edge cases');
test('throws when no working DOM element', function() {
throws(
function() { new TableFilter('xyz'); },
Error,
'Throws Error when no DOM table'
);
});
test('Can instantiate with wrong refRow', function() {
var tf2 = new TableFilter('demo', -9);
deepEqual(tf2.nbCells, 5, 'Expected number of columns');
});
})(window, TableFilter);

51
webpack.test.config.js Normal file
View file

@ -0,0 +1,51 @@
var webpackConfig = require('./webpack.config.js');
var path = require('path');
var Clean = require('clean-webpack-plugin');
var StringReplacePlugin = require('string-replace-webpack-plugin');
var fs = require('fs');
var pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
module.exports = {
cache: true,
entry: webpackConfig.entry,
output: webpackConfig.output,
resolve: webpackConfig.resolve,
isparta: {
embedSource: true,
noAutoWrap: true,
babel: {
compact: false,
presets: ['es2015'],
plugins: [['transform-es2015-classes', {loose: true}]]
}
},
module: {
loaders: [
{
test: /\.js$/,
include: path.join(__dirname, 'src'),
exclude: /tablefilter\/node_modules/,
loader: 'isparta'
},
{
test: path.join(__dirname, 'src'),
loader: StringReplacePlugin.replace({
replacements: [{
pattern: /{VERSION}/ig,
replacement: function () {
return pkg.version;
}
},{
pattern: /{AUTHOR}/ig,
replacement: function () {
return pkg.author.name;
}
}]
})
}
]
},
devtool: 'sourcemap',
debug: true,
plugins: [new Clean(['dist'])].concat(webpackConfig.dev.plugins)
};