1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-01 21:42:20 +02:00

Merge pull request #124 from koalyptus/issue-91-eslint

Issue 91 eslint
This commit is contained in:
koalyptus 2016-02-22 18:52:27 +11:00
commit ea53940cca
40 changed files with 361 additions and 257 deletions

29
.eslintrc Normal file
View file

@ -0,0 +1,29 @@
{
"parser": "babel-eslint",
"rules": {
"max-len": [2, 80, 2, {"ignoreUrls": true}],
"max-depth": [2, 7],
"complexity": [2, 87],
"no-unused-vars": 2,
"no-eval": 2,
"no-underscore-dangle": 0,
"no-loop-func": 2,
"no-floating-decimal": 2,
"curly": 2,
//"eqeqeq": [2, "smart"],
"quotes": [2, "single"],
"indent": [2, 4, {"SwitchCase": 1}],
"no-trailing-spaces": 2,
"no-multi-spaces": 2,
"array-bracket-spacing": 2,
"new-cap": 2
},
"ecmaFeatures": {
"modules": true
},
"env": {
"es6": true,
"browser": true,
"node": false
}
}

View file

@ -1,17 +0,0 @@
{
"-W024": true,
"scripturl": true,
"evil": true,
"curly": true,
"indent": 4,
"es3": true,
"esnext": true,
"unused": true,
"maxlen" : 80,
"trailing": true,
"quotmark": "single",
"immed": true,
"maxstatements": 172,
"maxdepth": 7,
"maxcomplexity": 87
}

View file

@ -11,15 +11,16 @@ module.exports = function (grunt) {
grunt.initConfig({
jshint: {
src: [
eslint: {
options: {
configFile: '.eslintrc'
},
target: [
'Gruntfile.js',
'webpack.config.js',
'src/**/*.js'
],
options: {
jshintrc: '.jshintrc'
}
'src/**/*.js',
'test/*.js'
]
},
qunit: {
@ -282,7 +283,7 @@ module.exports = function (grunt) {
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
@ -302,11 +303,11 @@ module.exports = function (grunt) {
// Dev dev/build/watch cycle
grunt.registerTask('dev',
['jshint', 'webpack:dev', 'copy:dist', 'stylus:compile', 'watch:app']);
['eslint', 'webpack:dev', 'copy:dist', 'stylus:compile', 'watch:app']);
// Production build
grunt.registerTask('build',
['jshint', 'webpack:build', 'copy:dist', 'stylus:compile']);
['eslint', 'webpack:build', 'copy:dist', 'stylus:compile']);
// Build demos
grunt.registerTask('dev-demos', ['build-demos', 'watch:templates']);
@ -317,7 +318,7 @@ module.exports = function (grunt) {
grunt.registerTask('dev-modules', ['babel', 'copy:dist']);
// Tests
grunt.registerTask('test', ['jshint', 'connect', 'qunit:all']);
grunt.registerTask('test', ['eslint', 'connect', 'qunit:all']);
// Publish to gh-pages
grunt.registerTask('publish', 'Publish from CLI', [
@ -350,7 +351,8 @@ module.exports = function (grunt) {
grunt.task.run('connect');
grunt.config('qunit.only.options.urls', res);
grunt.task.run('qunit:only');
});
}
);
function isTestFile(pth) {
var allowedExts = ['.html', '.htm'];
@ -428,7 +430,7 @@ module.exports = function (grunt) {
ret += 'branch: ' + env.TRAVIS_BRANCH + '\n';
ret += 'SHA: ' + env.TRAVIS_COMMIT + '\n';
ret += 'range SHA: ' + env.TRAVIS_COMMIT_RANGE + '\n';
ret += 'build id: ' + env.TRAVIS_BUILD_ID + '\n';
ret += 'build id: ' + env.TRAVIS_BUILD_ID + '\n';
ret += 'build number: ' + env.TRAVIS_BUILD_NUMBER + '\n';
return ret;
}

4
dist/starter.html vendored
View file

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

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.14 by Max Guglielmi
* build date: 2016-02-13T12:24:12.171Z
* tablefilter v0.1.15 by Max Guglielmi
* build date: 2016-02-22T07:38:22.550Z
* 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.1.14 by Max Guglielmi
* build date: 2016-02-13T12:24:12.171Z
* tablefilter v0.1.15 by Max Guglielmi
* build date: 2016-02-22T07:38:22.550Z
* 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.1.14 by Max Guglielmi
* build date: 2016-02-13T12:24:12.171Z
* tablefilter v0.1.15 by Max Guglielmi
* build date: 2016-02-22T07:38:22.550Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.14 by Max Guglielmi
* build date: 2016-02-13T12:24:12.171Z
* tablefilter v0.1.15 by Max Guglielmi
* build date: 2016-02-22T07:38:22.550Z
* 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.1.14 by Max Guglielmi
* build date: 2016-02-13T12:24:12.171Z
* tablefilter v0.1.15 by Max Guglielmi
* build date: 2016-02-22T07:38:22.550Z
* 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.1.14 by Max Guglielmi
* build date: 2016-02-13T12:24:12.171Z
* tablefilter v0.1.15 by Max Guglielmi
* build date: 2016-02-22T07:38:22.550Z
* 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}

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.14 by Max Guglielmi
* build date: 2016-02-13T12:24:12.104Z
* tablefilter v0.1.15 by Max Guglielmi
* build date: 2016-02-22T07:38:22.473Z
* MIT License
*/

View file

@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.1.14",
"version": "0.1.15",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {
@ -29,6 +29,7 @@
},
"devDependencies": {
"babel-core": "^6.1.2",
"babel-eslint": "4.1.8",
"babel-loader": "^6.0.1",
"babel-preset-es2015": "^6.3.13",
"clean-webpack-plugin": "^0.1.3",
@ -37,11 +38,11 @@
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-connect": "^0.10.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-qunit": "^0.7.0",
"grunt-contrib-stylus": "^0.22.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-esdoc": "^0.0.1",
"grunt-eslint": "18.0.0",
"grunt-gh-pages": "^0.10.0",
"grunt-string-replace": "^1.2.0",
"grunt-webpack": "^1.0.8",

View file

@ -93,33 +93,33 @@ export default {
case 'DDMMMYYYY':
parts = dateStr.replace(/[- \/.]/g,' ').split(' ');
oDate = new Date(y2kDate(parts[2]),mmm2mm(parts[1])-1,parts[0]);
break;
break;
case 'DMY':
/* jshint ignore:start */
/* eslint-disable */
parts = dateStr.replace(
/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/,'$1 $3 $5').split(' ');
oDate = new Date(y2kDate(parts[2]),parts[1]-1,parts[0]);
/* jshint ignore:end */
break;
/* eslint-enable */
break;
case 'MDY':
/* jshint ignore:start */
/* eslint-disable */
parts = dateStr.replace(
/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/,'$1 $3 $5').split(' ');
oDate = new Date(y2kDate(parts[2]),parts[0]-1,parts[1]);
/* jshint ignore:end */
break;
/* eslint-enable */
break;
case 'YMD':
/* jshint ignore:start */
/* eslint-disable */
parts = dateStr.replace(/^((\d\d)?\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/,'$1 $4 $6').split(' ');
oDate = new Date(y2kDate(parts[0]),parts[1]-1,parts[2]);
/* jshint ignore:end */
break;
/* eslint-enable */
break;
default: //in case format is not correct
/* jshint ignore:start */
/* eslint-disable */
parts = dateStr.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/,'$1 $3 $5').split(' ');
oDate = new Date(y2kDate(parts[2]),parts[1]-1,parts[0]);
/* jshint ignore:end */
break;
/* eslint-enable */
break;
}
return oDate;
}
@ -156,11 +156,11 @@ function mmm2mm(mmm){
'nov','dec'
];
for(let m_i=0; m_i < MONTH_NAMES.length; m_i++){
let month_name = MONTH_NAMES[m_i];
if (mmm.toLowerCase() === month_name){
mondigit = m_i+1;
break;
}
let month_name = MONTH_NAMES[m_i];
if (mmm.toLowerCase() === month_name){
mondigit = m_i+1;
break;
}
}
if(mondigit > 11 || mondigit < 23){
mondigit = mondigit - 12;

View file

@ -20,7 +20,7 @@ export default class AdapterEzEditTable {
this.err = 'Failed to instantiate EditTable object.\n"ezEditTable" ' +
'dependency not found.';
// Enable the ezEditTable's scroll into view behaviour if grid layout on
cfg.scroll_into_view = cfg.scroll_into_view===false ?
cfg.scroll_into_view = cfg.scroll_into_view===false ?
false : tf.gridLayout;
this._ezEditTable = null;
@ -72,7 +72,7 @@ export default class AdapterEzEditTable {
startRow = cfg.startRow || tf.refRow;
}
cfg.base_path = cfg.base_path || tf.basePath + 'ezEditTable/';
cfg.base_path = cfg.base_path || tf.basePath + 'ezEditTable/';
var editable = cfg.editable;
var selectable = cfg.selection;
@ -93,16 +93,24 @@ export default class AdapterEzEditTable {
//Next valid filtered row needs to be selected
var doSelect = function(nextRowIndex){
if(et.defaultSelection === 'row'){
/* eslint-disable */
slc.SelectRowByIndex(nextRowIndex);
/* eslint-enable */
} else {
/* eslint-disable */
et.ClearSelections();
/* eslint-enable */
var cellIndex = selectedElm.cellIndex,
row = tf.tbl.rows[nextRowIndex];
if(et.defaultSelection === 'both'){
/* eslint-disable */
slc.SelectRowByIndex(nextRowIndex);
/* eslint-enable */
}
if(row){
/* eslint-disable */
slc.SelectCell(row.cells[cellIndex]);
/* eslint-enable */
}
}
//Table is filtered
@ -135,7 +143,9 @@ export default class AdapterEzEditTable {
selectedElm.parentNode : selectedElm,
//cell for default_selection = 'both' or 'cell'
cell = selectedElm.nodeName==='TD' ? selectedElm : null,
/* eslint-disable */
keyCode = e !== undefined ? et.Event.GetKey(e) : 0,
/* eslint-enable */
isRowValid = validIndexes.indexOf(row.rowIndex) !== -1,
nextRowIndex,
paging = tf.feature('paging'),
@ -244,11 +254,15 @@ export default class AdapterEzEditTable {
var advGrid = paging.tf.extension('advancedGrid');
var et = advGrid._ezEditTable;
var slc = et.Selection;
/* eslint-disable */
var row = slc.GetActiveRow();
/* eslint-enable */
if(row){
row.scrollIntoView(false);
}
/* eslint-disable */
var cell = slc.GetActiveCell();
/* eslint-enable */
if(cell){
cell.scrollIntoView(false);
}
@ -342,8 +356,10 @@ export default class AdapterEzEditTable {
}
try{
/* eslint-disable */
this._ezEditTable = new EditTable(tf.id, cfg, startRow);
this._ezEditTable.Init();
/* eslint-enable */
} catch(e) { throw new Error(this.err); }
this.initialized = true;
@ -356,10 +372,14 @@ export default class AdapterEzEditTable {
var ezEditTable = this._ezEditTable;
if(ezEditTable){
if(this.cfg.selection){
/* eslint-disable */
ezEditTable.Selection.Set();
/* eslint-enable */
}
if(this.cfg.editable){
/* eslint-disable */
ezEditTable.Editable.Set();
/* eslint-enable */
}
}
}
@ -370,14 +390,22 @@ export default class AdapterEzEditTable {
toggle(){
var ezEditTable = this._ezEditTable;
if(ezEditTable.editable){
/* eslint-disable */
ezEditTable.Editable.Remove();
/* eslint-enable */
} else {
/* eslint-disable */
ezEditTable.Editable.Set();
/* eslint-enable */
}
if(ezEditTable.selection){
/* eslint-disable */
ezEditTable.Selection.Remove();
/* eslint-enable */
} else {
/* eslint-disable */
ezEditTable.Selection.Set();
/* eslint-enable */
}
}
@ -400,11 +428,15 @@ export default class AdapterEzEditTable {
var ezEditTable = this._ezEditTable;
if(ezEditTable){
if(this.cfg.selection){
/* eslint-disable */
ezEditTable.Selection.ClearSelections();
ezEditTable.Selection.Remove();
/* eslint-enable */
}
if(this.cfg.editable){
/* eslint-disable */
ezEditTable.Editable.Remove();
/* eslint-enable */
}
}

View file

@ -123,7 +123,7 @@ export default class ColOps{
mThisCol=-1;
for(var k=0; k<colIndex.length; k++){
if(colIndex[k] === ucolIndex[ucol]){
if(colIndex[k] === ucolIndex[ucol]){
mThisCol++;
opsThisCol[mThisCol]=Str.lower(operation[k]);
decThisCol[mThisCol]=decimalPrecision[k];
@ -135,25 +135,25 @@ export default class ColOps{
switch(opsThisCol[mThisCol]){
case 'mean':
meanFlag=1;
break;
break;
case 'sum':
sumFlag=1;
break;
break;
case 'min':
minFlag=1;
break;
break;
case 'max':
maxFlag=1;
break;
break;
case 'median':
medFlag=1;
break;
case 'q1':
q1Flag=1;
break;
break;
case 'q3':
q3Flag=1;
break;
break;
}
}
}
@ -163,8 +163,10 @@ export default class ColOps{
if((q1Flag==1)|| (q3Flag==1) || (medFlag==1)){
if (j<colvalues[ucol].length -1){
for(k=j+1; k<colvalues[ucol].length; k++) {
/* eslint-disable */
if(eval(colvalues[ucol][k]) <
eval(colvalues[ucol][j])){
/* eslint-enable */
temp = colvalues[ucol][j];
colvalues[ucol][j] = colvalues[ucol][k];
colvalues[ucol][k] = temp;
@ -237,25 +239,25 @@ export default class ColOps{
switch( opsThisCol[i] ){
case 'mean':
result=meanValue;
break;
break;
case 'sum':
result=sumValue;
break;
break;
case 'min':
result=minValue;
break;
break;
case 'max':
result=maxValue;
break;
break;
case 'median':
result=medValue;
break;
case 'q1':
result=q1Value;
break;
break;
case 'q3':
result=q3Value;
break;
break;
}
var precision = !isNaN(decThisCol[i]) ? decThisCol[i] : 2;
@ -273,17 +275,17 @@ export default class ColOps{
} else{
Dom.id(labThisCol[i]).innerHTML= result;
}
break;
break;
case 'setvalue':
Dom.id( labThisCol[i] ).value = result;
break;
break;
case 'createtextnode':
var oldnode = Dom.id(labThisCol[i])
.firstChild;
var txtnode = Dom.text(result);
Dom.id(labThisCol[i])
.replaceChild(txtnode, oldnode);
break;
break;
}//switch
}
} else {

View file

@ -55,7 +55,7 @@ export default class ColsVisibility{
//span containing show/hide cols button
this.prfx = 'colVis_';
//defines css class span containing show/hide cols
this.spanCssClass = f.span_css_class || 'colVisSpan';
this.spanCssClass = f.span_css_class || 'colVisSpan';
this.prfxCont = this.prfx + 'Cont_';
//defines css class div containing show/hide cols
this.contCssClass = f.cont_css_class || 'colVisCont';

View file

@ -32,7 +32,7 @@ export default class FiltersVisibility{
this.defaultText = 'Toggle filters';
//id of container element
this.targetId = f.target_id || null;
this.targetId = f.target_id || null;
//enables/disables expand/collapse icon
this.enableIcon = f.enable_icon===false ? false : true;
this.btnText = f.btn_text || '';
@ -41,7 +41,7 @@ export default class FiltersVisibility{
this.collapseBtnHtml = this.enableIcon ?
this.icnCollapseHtml + this.btnText :
this.btnText || this.defaultText;
this.expandBtnHtml = this.enableIcon ?
this.expandBtnHtml = this.enableIcon ?
this.icnExpandHtml + this.btnText :
this.btnText || this.defaultText;

View file

@ -161,6 +161,8 @@ export class CheckList extends Feature{
this.excludedOpts = [];
}
flt.innerHTML = '';
for(let k=tf.refRow; k<tf.nbRows; k++){
// always visible rows don't need to appear on selects as always
// valid

View file

@ -25,7 +25,7 @@ export class Dropdown extends Feature{
//defines empty option text
this.nonEmptyText = f.non_empty_text || '(Non empty)';
//IE only, tooltip text appearing on select before it is populated
this.activateSlcTooltip = f.activate_slc_tooltip ||
this.activateSlcTooltip = f.activate_slc_tooltip ||
'Click to activate';
//tooltip text appearing on multiple select
this.multipleSlcTooltip = f.multiple_slc_tooltip ||
@ -183,7 +183,7 @@ export class Dropdown extends Feature{
(tf.paging && (!tf.validRowsIndex ||
(tf.validRowsIndex &&
tf.validRowsIndex.indexOf(k) != -1)) &&
((activeFlt===undefined || activeFlt==colIndex) ||
((activeFlt===undefined || activeFlt==colIndex) ||
(activeFlt!=colIndex &&
tf.validRowsIndex.indexOf(k) != -1 ))) ))){
let cell_data = tf.getCellData(cell[j]),

View file

@ -95,7 +95,7 @@ export class GridLayout extends Feature{
}
tf.hasColWidths = true;
}
tf.setColWidths(this.gridHeadRowIndex);
tf.setColWidths();
let tblW;//initial table width
if(tbl.width !== ''){
@ -212,7 +212,7 @@ export class GridLayout extends Feature{
// this.headTbl.style.width = tbl.style.width;
//content table without headers needs col widths to be reset
tf.setColWidths(0, this.headTbl);
tf.setColWidths(this.headTbl);
//Headers container width
// this.headTblCont.style.width = this.tblCont.clientWidth+'px';

View file

@ -24,7 +24,7 @@ export class Help extends Feature{
this.contTgtId = f.help_instructions_container_target_id ||
null;
//defines help text
this.instrText = f.help_instructions_text ?
this.instrText = f.help_instructions_text ?
f.help_instructions_text :
'Use the filters above each column to filter and limit table ' +
'data. Advanced searches can be performed by using the following ' +

View file

@ -67,29 +67,27 @@ export class Loader extends Feature{
// Subscribe to events
emitter.on([
'before-filtering',
'before-populating-filter',
'before-changing-page',
'before-clearing-filters',
'before-changing-results-per-page',
'before-reset-page',
'before-reset-page-length',
'before-loading-extensions',
'before-loading-themes'
],
'before-filtering',
'before-populating-filter',
'before-changing-page',
'before-clearing-filters',
'before-changing-results-per-page',
'before-reset-page',
'before-reset-page-length',
'before-loading-extensions',
'before-loading-themes'],
()=> this.show('')
);
emitter.on([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'],
()=> this.show('none')
);
@ -130,29 +128,27 @@ export class Loader extends Feature{
// Unsubscribe to events
emitter.off([
'before-filtering',
'before-populating-filter',
'before-changing-page',
'before-clearing-filters',
'before-changing-results-per-page',
'before-reset-page',
'before-reset-page-length',
'before-loading-extensions',
'before-loading-themes'
],
'before-filtering',
'before-populating-filter',
'before-changing-page',
'before-clearing-filters',
'before-changing-results-per-page',
'before-reset-page',
'before-reset-page-length',
'before-loading-extensions',
'before-loading-themes'],
()=> this.show('')
);
emitter.off([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'],
()=> this.show('none')
);

View file

@ -470,19 +470,19 @@ export class Paging extends Feature{
switch(Str.lower(cmd)){
case 'next':
btnEvt.next();
break;
break;
case 'previous':
btnEvt.prev();
break;
break;
case 'last':
btnEvt.last();
break;
break;
case 'first':
btnEvt.first();
break;
break;
default:
btnEvt.next();
break;
break;
}
}
else if(cmdtype === 'number'){

View file

@ -69,7 +69,7 @@ export class PopupFilter extends Feature{
var popUpDiv = this.popUpFltElms[colIndex],
header = this.tf.getHeaderElement(colIndex),
headerWidth = header.clientWidth * 0.95;
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
}
Event.cancel(evt);
Event.stop(evt);

View file

@ -29,7 +29,7 @@ export class StatusBar extends Feature{
//defines css class status bar
this.statusBarCssClass = f.status_bar_css_class || 'status';
//delay for status bar clearing
this.statusBarCloseDelay = 250;
this.statusBarCloseDelay = 250;
//calls function before message is displayed
this.onBeforeShowMsg = Types.isFn(f.on_before_show_msg) ?
@ -133,16 +133,15 @@ export class StatusBar extends Feature{
()=> this.message(this.msgLoadThemes));
emitter.on([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'],
()=> this.message('')
);
@ -205,16 +204,15 @@ export class StatusBar extends Feature{
()=> this.message(this.msgLoadThemes));
emitter.off([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'],
()=> this.message('')
);

View file

@ -1,7 +1,7 @@
import Str from './string';
export default {
ignoreCase(a, b){
ignoreCase(a, b){
let x = Str.lower(a);
let y = Str.lower(b);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));

View file

@ -133,7 +133,7 @@ export class TableFilter {
//defines css class for left div
this.lDivCssClass = f.left_div_css_class || 'ldiv';
//defines css class for right div
this.rDivCssClass = f.right_div_css_class || 'rdiv';
this.rDivCssClass = f.right_div_css_class || 'rdiv';
//defines css class for mid div
this.mDivCssClass = f.middle_div_css_class || 'mdiv';
//table container div css class
@ -609,7 +609,7 @@ export class TableFilter {
Mod.paging = new Paging(this);
Mod.paging.init();
} else{
Mod.paging.reset();
Mod.paging.reset();
}
}
if(this.btnReset){
@ -821,7 +821,9 @@ export class TableFilter {
// Require pattern for Webpack
require(['./' + modulePath], (mod)=> {
/* eslint-disable */
let inst = new mod.default(this, ext);
/* eslint-enable */
inst.init();
this.ExtRegistry[name] = inst;
});
@ -1415,12 +1417,12 @@ export class TableFilter {
//multiple search parameter operator ||
let sAOrSplit = sA.toString().split(this.orOperator),
//multiple search || parameter boolean
hasMultiOrSA = sAOrSplit.length > 1,
//multiple search parameter operator &&
sAAndSplit = sA.toString().split(this.anOperator),
//multiple search && parameter boolean
hasMultiAndSA = sAAndSplit.length > 1;
//multiple search || parameter boolean
hasMultiOrSA = sAOrSplit.length > 1,
//multiple search parameter operator &&
sAAndSplit = sA.toString().split(this.anOperator),
//multiple search && parameter boolean
hasMultiAndSA = sAAndSplit.length > 1;
//detect operators or array query
if(Types.isArray(sA) || hasMultiOrSA || hasMultiAndSA){
@ -1784,7 +1786,7 @@ export class TableFilter {
if(Types.isUndef(colIndex)){
return [];
}
let data = this.getFilteredData(),
let data = this.getFilteredData(),
colData = [];
if(includeHeaders){
colData.push(this.getHeadersText()[colIndex]);
@ -1914,25 +1916,17 @@ export class TableFilter {
/**
* Set them columns' widths as per configuration
* @param {Number} rowIndex Optional row index to apply the widths to
* @param {Element} tbl DOM element
*/
setColWidths(rowIndex, tbl){
setColWidths(tbl){
if(!this.hasColWidths){
return;
}
tbl = tbl || this.tbl;
let rIndex;
if(rowIndex === undefined){
rIndex = tbl.rows[0].style.display!='none' ? 0 : 1;
} else{
rIndex = rowIndex;
}
setWidths.call(this);
function setWidths(){
/*jshint validthis:true */
let nbCols = this.nbCells;
let colWidths = this.colWidths;
let colTags = Dom.tag(tbl, 'col');
@ -2051,18 +2045,17 @@ export class TableFilter {
slcA2.indexOf(slcIndex[i]) != -1)) ||
slcSelectedValue === this.displayAllText ){
if(slcA3.indexOf(slcIndex[i]) != -1){
this.Mod.checkList.checkListDiv[slcIndex[i]].innerHTML = '';
} else {
curSlc.innerHTML = '';
}
// if(slcA3.indexOf(slcIndex[i]) != -1){
// this.Mod.checkList.checkListDiv[slcIndex[i]].innerHTML = '';
// } else {
// curSlc.innerHTML = '';
// }
//1st option needs to be inserted
if(this.loadFltOnDemand) {
let opt0 = Dom.createOpt(this.displayAllText, '');
if(curSlc){
curSlc.appendChild(opt0);
}
curSlc.innerHTML = '';
curSlc.appendChild(opt0);
}
if(slcA3.indexOf(slcIndex[i]) != -1){

View file

@ -48,7 +48,7 @@ export default {
* @return {Boolean}
*/
isUndef(o){
return o === UNDEFINED;
return o === UNDEFINED;
},
/**

View file

@ -8,9 +8,9 @@
var tf1 = new TableFilter('demo1', {
base_path: '../dist/tablefilter/',
extensions: [{
name: 'colsVisibility',
at_start: [1, 2],
on_loaded: colsVisibilityTests
name: 'colsVisibility',
at_start: [1, 2],
on_loaded: colsVisibilityTests
}]
});
tf1.init();

View file

@ -11,14 +11,16 @@ var checkList = tf.feature('checkList');
module('Sanity checks');
test('CheckList component', function() {
deepEqual(typeof checkList, 'object', 'CheckList instanciated');
deepEqual(checkList.checkListDiv instanceof Array, true, 'Type of checkListDiv property');
deepEqual(checkList.checkListDiv instanceof Array, true,
'Type of checkListDiv property');
});
module('UI elements');
test('CheckList UI elements', function() {
var flt = id(tf.fltIds[3]);
notEqual(flt, null, 'CheckList UL element');
deepEqual(flt.firstChild.nodeName, 'LI', 'First CheckList option element name');
deepEqual(flt.firstChild.nodeName, 'LI',
'First CheckList option element name');
deepEqual(flt.childNodes.length, 8, 'number of checklist options');
});

View file

@ -22,15 +22,21 @@
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.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(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');
@ -90,15 +96,21 @@
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.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');
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');
@ -156,15 +168,21 @@
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.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');
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');

View file

@ -1,8 +1,6 @@
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_date_type: [
null, null, 'ddmmmyyyy'
]
col_date_type: [null, null, 'ddmmmyyyy']
});
tf.init();
@ -27,15 +25,15 @@ test('can filter values in this format: 21.1.18 as date', function(){
});
test('can filter values in this format: 21.1.18 as date with operator',
function(){
tf.clearFilters();
tf.setFilterValue(1, '>21.1.04');
tf.filter();
deepEqual(tf.getValidRows().length, 1, 'Expected number of matches');
});
tf.clearFilters();
tf.setFilterValue(1, '>21.1.04');
tf.filter();
deepEqual(tf.getValidRows().length, 1, 'Expected number of matches');
}
);
module('Issue 72');
test('can filter values in this format: 21-Jul-2010 as date',
function(){
test('can filter values in this format: 21-Jul-2010 as date', function(){
tf.clearFilters();
tf.setFilterValue(2, '14-Mar-2009');
tf.filter();
@ -43,11 +41,12 @@ test('can filter values in this format: 21-Jul-2010 as date',
});
test('can filter values in this format: 21-Jul-2010 as date with operator',
function(){
tf.clearFilters();
tf.setFilterValue(2, '<21-Jul-2010');
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Expected number of matches');
});
tf.clearFilters();
tf.setFilterValue(2, '<21-Jul-2010');
tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Expected number of matches');
}
);
module('Tear-down');
test('can destroy TableFilter DOM elements', function() {

View file

@ -10,8 +10,10 @@ module('Sanity checks');
test('GridLayout component', function() {
deepEqual(typeof gridLayout, 'object', 'GridLayout instanciated');
notEqual(gridLayout.tblMainCont, null, 'GridLayout main container element');
notEqual(gridLayout.tblCont, null, 'GridLayout main HTML table container element');
notEqual(gridLayout.headTblCont, null, 'GridLayout headers container element');
notEqual(gridLayout.tblCont, null,
'GridLayout main HTML table container element');
notEqual(gridLayout.headTblCont, null,
'GridLayout headers container element');
notEqual(gridLayout.headTbl, null, 'GridLayout headers HTML table');
deepEqual(tf.startRow, null, 'Optional startRow row index');
deepEqual(tf.refRow, 0, 'Reference row index');
@ -22,8 +24,10 @@ test('GridLayout component', function() {
test('Destroy TableFilter', function() {
gridLayout.destroy();
deepEqual(gridLayout.tblMainCont, null, 'Main container element removed');
deepEqual(gridLayout.tblCont, null, 'Main HTML table container element removed');
deepEqual(gridLayout.headTblCont, null, 'Headers container element removed');
deepEqual(gridLayout.tblCont, null,
'Main HTML table container element removed');
deepEqual(gridLayout.headTblCont, null,
'Headers container element removed');
deepEqual(gridLayout.headTbl, null, 'Headers HTML table element removed');
notEqual(gridLayout.sourceTblHtml, null, 'Table reference is kept');
});

View file

@ -42,10 +42,11 @@ test('can destroy and init TableFilter', function() {
module('Tear-down');
test('can destroy TableFilter DOM elements and clean highlighted words',
function() {
tf.setFilterValue(1, 'Perth');
tf.filter();
tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed');
deepEqual(highlightKeyword.highlightedNodes.length,
0, 'Number of highlighted words');
});
tf.setFilterValue(1, 'Perth');
tf.filter();
tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed');
deepEqual(highlightKeyword.highlightedNodes.length,
0, 'Number of highlighted words');
}
);

View file

@ -1,6 +1,3 @@
var id = function (id){ return document.getElementById(id); };
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
paging: true,

View file

@ -5,7 +5,7 @@
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
linked_filters: true,
col_0: 'multiple',
col_0: 'checklist',
col_1: 'checklist',
on_after_reset: testClearFilters
});
@ -23,7 +23,7 @@
tf.onAfterFilter = null;
tf.destroy();
tf = null;
setExcludedOptions();
setWithChecklistFilters();
});
// function testLinked(tf) {
@ -84,6 +84,42 @@
deepEqual(tf.getFilterableRowsNb(), 7,
'Nb of valid rows after filters are cleared');
});
tf.destroy();
}
function setWithChecklistFilters() {
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
linked_filters: true,
col_0: 'checklist',
col_1: 'checklist'
});
tf.init();
var flt0 = id(tf.fltIds[0]);
var flt1 = id(tf.fltIds[1]);
var evObj = document.createEvent('HTMLEvents');
evObj.initEvent('change', true, true);
tf.setFilterValue(0, 'Sydney');
flt0.dispatchEvent(evObj);
tf.setFilterValue(1, 'Adelaide');
flt1.dispatchEvent(evObj);
setTimeout(testWithChecklistFilters.call(null, tf), 50);
}
// Tests for issue 113
function testWithChecklistFilters(tf){
var flt0 = id(tf.fltIds[0]);
var flt1 = id(tf.fltIds[1]);
deepEqual(flt0.getElementsByTagName('li').length, 2, 'Nb of options');
deepEqual(flt1.getElementsByTagName('li').length, 2, 'Nb of options');
tf.clearFilters();
tf.destroy();
tf = null;
setExcludedOptions();
}
})(window, TableFilter);

View file

@ -44,7 +44,8 @@
deepEqual(tf.refRow, 0, 'Reference row index');
tf.setFilterValue(1, 'Bris');
deepEqual(tf.getValidRows().length, 0, 'does not fail on setFilterValue');
deepEqual(tf.getValidRows().length, 0,
'does not fail on setFilterValue');
});
module('Tear-down');

View file

@ -45,7 +45,7 @@ function start(tf, sort){
});
test('Sort behaviour', function() {
validRows = tf.getValidRows();
validRows = tf.getValidRows();
sort.sortByColumnIndex(1);
deepEqual(sort.sorted, true, 'Table column sorted');

View file

@ -79,8 +79,10 @@ test('Filters value in cookie', function() {
tf.setFilterValue(3, '1.5');
tf.filter();
deepEqual(tf.feature('store').getFilterValues()[0], 'Sydney', 'Filter 0 value');
deepEqual(tf.feature('store').getFilterValues()[3], '1.5', 'Filter 3 value');
deepEqual(tf.feature('store').getFilterValues()[0],
'Sydney', 'Filter 0 value');
deepEqual(tf.feature('store').getFilterValues()[3],
'1.5', 'Filter 3 value');
});
test('Filters value in cookie', function() {
@ -88,8 +90,10 @@ test('Filters value in cookie', function() {
tf.setFilterValue(3, '1.5');
tf.filter();
deepEqual(tf.feature('store').getFilterValues()[0], 'Sydney', 'Filter 0 value');
deepEqual(tf.feature('store').getFilterValues()[3], '1.5', 'Filter 3 value');
deepEqual(tf.feature('store').getFilterValues()[0], 'Sydney',
'Filter 0 value');
deepEqual(tf.feature('store').getFilterValues()[3], '1.5',
'Filter 3 value');
});
test('Filters value with operators in cookie', function() {
@ -99,8 +103,10 @@ test('Filters value with operators in cookie', function() {
tf.filter();
deepEqual(tf.feature('store').getFilterValues()[0], ' ', 'Filter 0 value');
deepEqual(tf.feature('store').getFilterValues()[1], 'Canberra || Perth', 'Filter 1 value');
deepEqual(tf.feature('store').getFilterValues()[3], '>.6', 'Filter 3 value');
deepEqual(tf.feature('store').getFilterValues()[1],
'Canberra || Perth', 'Filter 1 value');
deepEqual(tf.feature('store').getFilterValues()[3], '>.6',
'Filter 3 value');
deepEqual(tf.getValidRows().length, 1, 'Expected nb of filtered rows');
});
@ -139,8 +145,10 @@ test('Filters value in cookie', function() {
tf.setFilterValue(1, ['Alice Springs', 'Brisbane']);
tf.filter();
deepEqual(tf.feature('store').getFilterValues()[0], 'Adelaide || Sydney', 'Filter 0 value');
deepEqual(tf.feature('store').getFilterValues()[1], 'Alice Springs || Brisbane', 'Filter 1 value');
deepEqual(tf.feature('store').getFilterValues()[0],
'Adelaide || Sydney', 'Filter 0 value');
deepEqual(tf.feature('store').getFilterValues()[1],
'Alice Springs || Brisbane', 'Filter 1 value');
deepEqual(tf.getValidRows().length, 3, 'Expected nb of filtered rows');
});