tidy-up code

This commit is contained in:
koalyptus 2017-12-03 21:48:00 +11:00
parent 0b5160b45d
commit f2d54839c3
21 changed files with 96 additions and 27794 deletions

4
dist/starter.html vendored
View File

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

View File

@ -1,10 +1,6 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
<<<<<<< HEAD
* build date: 2017-11-12T10:42:56.580Z
=======
* build date: 2017-11-30T02:49:15.523Z
>>>>>>> master
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.995Z
* 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:inherit;}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-type: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,10 +1,6 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
<<<<<<< HEAD
* build date: 2017-11-12T10:42:56.580Z
=======
* build date: 2017-11-30T02:49:15.523Z
>>>>>>> master
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.995Z
* 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,10 +1,6 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
<<<<<<< HEAD
* build date: 2017-11-12T10:42:56.580Z
=======
* build date: 2017-11-30T02:49:15.523Z
>>>>>>> master
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.995Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}.activeCell{background-color:rgba(0,0,0,0.075)}

View File

@ -1,10 +1,6 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
<<<<<<< HEAD
* build date: 2017-11-12T10:42:56.580Z
=======
* build date: 2017-11-30T02:49:15.523Z
>>>>>>> master
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.995Z
* 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,10 +1,6 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
<<<<<<< HEAD
* build date: 2017-11-12T10:42:56.580Z
=======
* build date: 2017-11-30T02:49:15.523Z
>>>>>>> master
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.995Z
* 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,10 +1,6 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
<<<<<<< HEAD
* build date: 2017-11-12T10:42:56.580Z
=======
* build date: 2017-11-30T02:49:15.523Z
>>>>>>> master
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.995Z
* 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}

View File

@ -1,10 +1,6 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
<<<<<<< HEAD
* build date: 2017-11-12T10:42:56.580Z
=======
* build date: 2017-11-30T02:49:15.523Z
>>>>>>> master
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.995Z
* 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

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 @@
/**
* tablefilter v0.6.3 by Max Guglielmi
* build date: 2017-11-30T02:49:15.503Z
* tablefilter v0.6.4 by Max Guglielmi
* build date: 2017-12-03T10:41:49.979Z
* MIT License
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -123,10 +123,7 @@ export class AlternateRows extends Feature {
if (!this.initialized) {
return;
}
// let nbRows = this.tf.getRowsNb(true);
// for (let i = 0; i < nbRows; i++) {
// this.removeRowBg(i);
// }
let eachRow = this.tf.eachRow(0);
eachRow((row, i) => this.removeRowBg(i));

View File

@ -205,8 +205,6 @@ export class CheckList extends BaseDropdown {
['colIndex', colIndex]);
ul.className = this.filterCssClass;
// let rows = tf.dom().rows;
// let nbRows = tf.getRowsNb(true);
let caseSensitive = tf.caseSensitive;
/** @inherited */
this.isCustom = tf.isCustomOptions(colIndex);
@ -233,45 +231,6 @@ export class CheckList extends BaseDropdown {
flt.innerHTML = '';
// for (let k = tf.refRow; k < nbRows; k++) {
// // always visible rows don't need to appear on selects as always
// // valid
// if (tf.excludeRows.indexOf(k) !== -1) {
// continue;
// }
// let cells = rows[k].cells;
// let ncells = cells.length;
// // checks if row has exact cell #
// if (ncells !== tf.nbCells || this.isCustom) {
// continue;
// }
// if (isLinked && !this.isValidLinkedValue(k, activeIdx)) {
// continue;
// }
// let cellValue = tf.getCellValue(cells[colIndex]);
// //Vary Peter's patch
// let cellString = matchCase(cellValue, caseSensitive);
// // checks if celldata is already in array
// if (!has(this.opts, cellString, caseSensitive)) {
// this.opts.push(cellValue);
// }
// let filteredCol = filteredDataCol[colIndex];
// if (isLinked && tf.disableExcludedOptions) {
// if (!filteredCol) {
// filteredCol = tf.getVisibleColumnValues(colIndex);
// }
// if (!has(filteredCol, cellString, caseSensitive) &&
// !has(this.excludedOpts, cellString,
// caseSensitive)) {
// this.excludedOpts.push(cellValue);
// }
// }
// }
let eachRow = tf.eachRow();
eachRow(
(row) => {

View File

@ -157,11 +157,6 @@ export class Dropdown extends BaseDropdown {
/** @inherited */
this.optsTxt = [];
// let slcId = tf.fltIds[colIndex];
// let slc = elm(slcId);
// let rows = tf.dom().rows;
// let nbRows = tf.getRowsNb(true);
let slc = tf.getFilterElement(colIndex);
//custom select test
@ -189,46 +184,6 @@ export class Dropdown extends BaseDropdown {
filteredDataCol = [];
}
// for (let k = tf.refRow; k < nbRows; k++) {
// // always visible rows don't need to appear on selects as always
// // valid
// if (tf.excludeRows.indexOf(k) !== -1) {
// continue;
// }
// let cell = rows[k].cells,
// nchilds = cell.length;
// // checks if row has exact cell #
// if (nchilds !== tf.nbCells || this.isCustom) {
// continue;
// }
// if (isLinked && !this.isValidLinkedValue(k, activeIdx)) {
// continue;
// }
// let cellValue = tf.getCellValue(cell[colIndex]),
// //Vary Peter's patch
// cellString = matchCase(cellValue, tf.caseSensitive);
// // checks if celldata is already in array
// if (!has(this.opts, cellString, tf.caseSensitive)) {
// this.opts.push(cellValue);
// }
// if (isLinked && tf.disableExcludedOptions) {
// let filteredCol = filteredDataCol[colIndex];
// if (!filteredCol) {
// filteredCol = tf.getVisibleColumnValues(colIndex);
// }
// if (!has(filteredCol, cellString, tf.caseSensitive) &&
// !has(excludedOpts, cellString, tf.caseSensitive)) {
// excludedOpts.push(cellValue);
// }
// }
// }
let eachRow = tf.eachRow();
eachRow(
(row) => {

View File

@ -345,12 +345,6 @@ export class TableFilter {
*/
this.ignoreDiacritics = f.ignore_diacritics;
/**
* Filter rows with uneven number of cells (rowspan, cellspan)
* @type {Boolean}
*/
this.allowUnevenRows = Boolean(f.allow_uneven_rows);
/**
* Enable/disable linked filters filtering mode
* @type {Boolean}
@ -1316,8 +1310,6 @@ export class TableFilter {
return;
}
// let name = ext.name;
// let path = ext.path;
let {name, path} = ext;
let modulePath;
@ -1393,12 +1385,8 @@ export class TableFilter {
let defaultTheme = { name: 'default' };
this.themes.push(defaultTheme);
}
// if (isArray(themes)) {
themes.forEach((theme, i) => {
// for (let i = 0, len = themes.length; i < len; i++) {
// let theme = themes[i];
// let name = theme.name;
// let path = theme.path;
let {name, path} = theme;
let styleId = this.prfxTf + name;
if (name && !path) {
@ -1412,7 +1400,6 @@ export class TableFilter {
this.import(styleId, path, null, 'link');
}
});
// }
// Enable loader indicator
this.loader = true;
@ -1479,12 +1466,9 @@ export class TableFilter {
if (!this.isExternalFlt()) {
return;
}
let ids = this.externalFltTgtIds/*,
len = ids.length*/;
let ids = this.externalFltTgtIds;
ids.forEach((id) => {
// for (let ct = 0; ct < len; ct++) {
let /*externalFltTgtId = ids[ct],*/
externalFlt = elm(id);
let externalFlt = elm(id);
if (externalFlt) {
externalFlt.innerHTML = '';
}
@ -1548,29 +1532,21 @@ export class TableFilter {
this.onBeforeFilter(this);
this.emitter.emit('before-filtering', this);
let /*row = this.dom().rows,
nbRows = this.getRowsNb(true),*/
hiddenRows = 0;
let hiddenRows = 0;
this.validRowsIndex = [];
// search args re-init
// search args
let searchArgs = this.getFiltersValue();
let eachRow = this.eachRow();
eachRow(
(row, k) => {
// for (let k = this.refRow; k < nbRows; k++) {
// already filtered rows display re-init
row.style.display = '';
let cells = row.cells;
let nbCells = cells.length;
// // checks if row has exact cell #
// if (nbCells !== this.nbCells) {
// continue;
// }
let occurence = [],
isRowValid = true,
//only for single filter search
@ -1610,7 +1586,7 @@ export class TableFilter {
// isolate search term and check occurence in cell data
for (let w = 0, len = s.length; w < len; w++) {
cS = trim(s[w]);
occur = this._matcth(cS, cellValue, j);
occur = this._match(cS, cellValue, j);
if (occur) {
this.emitter.emit('highlight-keyword', this,
@ -1629,12 +1605,12 @@ export class TableFilter {
}
//single search parameter
else {
occurence[j] = this._matcth(trim(sA), cellValue, j);
occurence[j] = this._match(trim(sA), cellValue, j);
if (occurence[j]) {
this.emitter.emit('highlight-keyword', this,
cells[j], sA);
}
}//else single param
}
if (!occurence[j]) {
isRowValid = false;
@ -1659,7 +1635,7 @@ export class TableFilter {
this.validRowsIndex.length, isRowValid);
},
// continue condition
(row) => !this.allowUnevenRows && row.cells.length !== this.nbCells
(row) => row.cells.length !== this.nbCells
);
this.nbHiddenRows = hiddenRows;
@ -1942,8 +1918,6 @@ export class TableFilter {
typed = false,
exclude = []
) {
// let row = this.dom().rows;
// let nbRows = this.getRowsNb(true);
let colValues = [];
let getContent = typed ? this.getCellData.bind(this) :
this.getCellValue.bind(this);
@ -1952,28 +1926,10 @@ export class TableFilter {
colValues.push(this.getHeadersText()[colIndex]);
}
// for (let i = this.refRow; i < nbRows; i++) {
// let isExludedRow = false;
// // checks if current row index appears in exclude array
// if (exclude.length > 0) {
// isExludedRow = exclude.indexOf(i) !== -1;
// }
// let cell = row[i].cells,
// nbCells = cell.length;
// // checks if row has exact cell # and is not excluded
// if (nbCells === this.nbCells && !isExludedRow) {
// let data = getContent(cell[colIndex]);
// colValues.push(data);
// }
// }
let eachRow = this.eachRow();
eachRow((row, i) => {
let isExludedRow = exclude.indexOf(i) !== -1;
// checks if current row index appears in exclude array
// if (exclude.length > 0) {
// isExludedRow = exclude.indexOf(i) !== -1;
// }
let isExludedRow = exclude.indexOf(i) !== -1;
let cells = row.cells;
// checks if row has exact cell # and is not excluded
@ -2031,7 +1987,7 @@ export class TableFilter {
return;
}
let searchArgs = [];
// for (let i = 0, len = this.fltIds.length; i < len; i++) {
this.fltIds.forEach((id, i) => {
let fltValue = this.getFilterValue(i);
if (isArray(fltValue)) {
@ -2210,8 +2166,6 @@ export class TableFilter {
excludeHiddenCols = false,
typed = false
) {
// let rows = this.dom().rows;
// let nbRows = this.getRowsNb(true);
let tblData = [];
let getContent = typed ? this.getCellData.bind(this) :
this.getCellValue.bind(this);
@ -2220,20 +2174,7 @@ export class TableFilter {
let headers = this.getHeadersText(excludeHiddenCols);
tblData.push([this.getHeadersRowIndex(), headers]);
}
// for (let k = this.refRow; k < nbRows; k++) {
// let rowData = [k, []];
// let cells = rows[k].cells;
// for (let j = 0, len = cells.length; j < len; j++) {
// if (excludeHiddenCols && this.hasExtension('colsVisibility')) {
// if (this.extension('colsVisibility').isColHidden(j)) {
// continue;
// }
// }
// let cellValue = getContent(cells[j]);
// rowData[1].push(cellValue);
// }
// tblData.push(rowData);
// }
let eachRow = this.eachRow();
eachRow((row, k) => {
let rowData = [k, []];
@ -2713,8 +2654,6 @@ export class TableFilter {
slcIndex = slcIndex.concat(slcA3);
slcIndex.forEach((colIdx) => {
// for (let i = 0, len = slcIndex.length; i < len; i++) {
// let colIdx = slcIndex[i];
let curSlc = this.getFilterElement(colIdx);
let slcSelectedValue = this.getFilterValue(colIdx);
@ -2814,6 +2753,12 @@ export class TableFilter {
}
}
/**
* Rows iterator starting from supplied row index or defaulting to reference
* row index. Closure function accepts a callback function and optional
* continue and break callbacks.
* @param {Number} startIdx Row index from which filtering starts
*/
eachRow(startIdx = this.refRow) {
return (fn = EMPTY_FN, continueFn = EMPTY_FN, breakFn = EMPTY_FN) => {
let rows = this.dom().rows;
@ -2923,25 +2868,10 @@ export class TableFilter {
return this.validRowsIndex;
}
// let nbRows = this.getRowsNb(true);
this.validRowsIndex = [];
// for (let k = this.refRow; k < nbRows; k++) {
// let r = this.dom().rows[k];
// if (!this.paging) {
// if (this.getRowDisplay(r) !== NONE) {
// this.validRowsIndex.push(r.rowIndex);
// }
// } else {
// if (r.getAttribute('validRow') === 'true' ||
// r.getAttribute('validRow') === null) {
// this.validRowsIndex.push(r.rowIndex);
// }
// }
// }
let eachRow = this.eachRow();
eachRow((row) => {
// for (let k = this.refRow; k < nbRows; k++) {
// let r = this.dom().rows[k];
if (!this.paging) {
if (this.getRowDisplay(row) !== NONE) {
this.validRowsIndex.push(row.rowIndex);

View File

@ -18,14 +18,14 @@
<th>By Rail (hrs)</th>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Sydney</td>
<td>Adelaide</td>
<td>1412</td>
<td>1.4</td>
<td>25.3</td>
</tr>
<tr>
<td rowspan="3"><strong>Sydney</strong></td>
<td rowspan="3">Sydney</td>
<td>Adelaide</td>
<td>1412</td>
<td>1.4</td>
@ -44,42 +44,41 @@
<td>25.3</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Sydney</td>
<td>Brisbane</td>
<td>982</td>
<td>1.5</td>
<td>16</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Canberra</td>
<td colspan="2">Sydney</td>
<td>286</td>
<td>.6</td>
<td>4.3</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Sydney</td>
<td>Melbourne</td>
<td>872</td>
<td>1.1</td>
<td>10.5</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Adelaide</td>
<td>Perth</td>
<td>2781</td>
<td>3.1</td>
<td>38</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Adelaide</td>
<td>Alice Springs</td>
<td>1533</td>
<td>2</td>
<td>20.25</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Adelaide</td>
<td>Brisbane</td>
<td>2045</td>
<td>2.15</td>

View File

@ -1,221 +1,61 @@
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
rows_counter: true,
allow_uneven_rows: true
base_path: '../dist/tablefilter/'
});
tf.init();
// var toolbar = tf.feature('toolbar');
module('filtering');
test('ignore uneven rows', function() {
// act
tf.setFilterValue(1, 'Perth');
tf.filter();
module('Sanity checks');
test('toolbar component', function() {
// assert
notEqual(toolbar, null, 'toolbar instanciated');
equal(toolbar.contCssClass, 'inf', 'container css class');
equal(toolbar.lContCssClass, 'ldiv', 'left container css class');
equal(toolbar.cContCssClass, 'mdiv', 'middle container css class');
equal(toolbar.rContCssClass, 'rdiv', 'right container css class');
equal(toolbar.tgtId, null, 'external container id null');
notEqual(toolbar.cont, null, 'container created');
notEqual(toolbar.lCont, null, 'left inner container created');
notEqual(toolbar.cCont, null, 'middle inner container created');
notEqual(toolbar.rCont, null, 'right inner container created');
equal(toolbar.emitter.events['initializing-feature'].length, 1,
'subscribed to `initializing-feature` event');
equal(toolbar.emitter.events['initializing-extension'].length, 1,
'subscribed to `initializing-extension` event');
deepEqual(tf.getValidRows(), [9], 'uneven row');
deepEqual(tf.getRowDisplay(tf.dom().rows[4]), '', 'uneven row displayed');
deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
});
// module('Feature interface');
// test('Properties', function() {
// deepEqual(toolbar.tf instanceof TableFilter, true,
// 'TableFilter instance');
// deepEqual(toolbar.feature, 'toolbar', 'Feature name');
// deepEqual(toolbar.enabled, true, 'Feature enabled');
// deepEqual(toolbar.initialized, true, 'Feature enabled');
// deepEqual(typeof toolbar.config, 'object', 'TF configuration object');
// deepEqual(typeof toolbar.init, 'function', 'Feature init method');
// deepEqual(typeof toolbar.destroy, 'function', 'Feature destroy method');
// deepEqual(typeof toolbar.reset, 'function', 'Feature reset method');
// deepEqual(typeof toolbar.enable, 'function', 'Feature enable method');
// deepEqual(typeof toolbar.disable, 'function', 'Feature enable method');
// deepEqual(typeof toolbar.isEnabled, 'function', 'Feature enable method');
// });
// test('Can destroy', function() {
// toolbar.destroy();
// deepEqual(toolbar.initialized, false, 'not initialised');
// });
// test('Can reset', function() {
// toolbar.reset();
// deepEqual(toolbar.enabled, true, 'enabled');
// });
// test('Can disable', function() {
// toolbar.disable();
// deepEqual(toolbar.enabled, false, 'disabled');
// });
// test('Can enable', function() {
// toolbar.enable();
// deepEqual(toolbar.enabled, true, 'enabled');
// });
// test('Can init', function() {
// toolbar.destroy();
// toolbar.enable();
// toolbar.init();
// deepEqual(toolbar.enabled, true, 'enabled');
// });
// test('Can check is enabled', function() {
// toolbar.isEnabled();
// deepEqual(toolbar.enabled, true, 'enabled');
// });
test('display uneven rows when no matches', function() {
// act
tf.clearFilters();
tf.setFilterValue(0, '123');
tf.filter();
// module('Behaviour');
// test('Does not init if initialised', function() {
// // setup
// var createContainer = toolbar.createContainer;
// var hit = 0;
// toolbar.createContainer = function() {
// hit++;
// };
// assert
deepEqual(tf.getValidRows(), [], 'uneven row');
deepEqual(tf.getRowDisplay(tf.dom().rows[4]), '', 'uneven row displayed');
deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
});
// // act
// toolbar.init();
module('re-initialise');
test('can re-initialise', function() {
// act
tf.destroy();
tf.init();
// // assert
// deepEqual(hit, 0, 'does not initialise');
// assert
deepEqual(tf.isInitialized(), true, 'Filters re-initialised');
});
// toolbar.createContainer = createContainer;
// });
test('can filter', function() {
// act
tf.setFilterValue(1, 'Perth');
tf.filter();
// test('Does not init if external', function() {
// // setup
// toolbar.initialized = false;
// var createContainer = toolbar.createContainer;
// var hit = 0;
// toolbar.createContainer = function() {
// hit++;
// };
// assert
deepEqual(tf.getValidRows(), [9], 'uneven row');
deepEqual(tf.getRowDisplay(tf.dom().rows[4]), '', 'uneven row displayed');
deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
});
// // act
// toolbar.init(true);
module('tear-down');
test('can destroy', function() {
// act
tf.destroy();
// // assert
// deepEqual(hit, 0, 'does not initialise');
// toolbar.createContainer = createContainer;
// toolbar.initialized = true;
// });
// test('Can get container', function() {
// // act
// var result = toolbar.container('left');
// // assert
// deepEqual(result, toolbar.cont.querySelector('.ldiv'),
// 'left inner container');
// });
// test('Can get default container', function() {
// // act
// var result = toolbar.container();
// // assert
// deepEqual(result, toolbar.cont.querySelector('.rdiv'),
// 'left inner container');
// });
// test('Can get container with appended element', function() {
// // act
// var result = toolbar.container('center',
// document.createElement('span')
// .appendChild(document.createTextNode('test')));
// // assert
// deepEqual(result.firstChild, toolbar.cont.querySelector('.mdiv')
// .firstChild,
// 'center inner container with appended element');
// });
// test('Can create container with css class', function() {
// // act
// var result = toolbar.createContainer(toolbar.cont, 'test');
// // assert
// deepEqual(result, toolbar.cont.querySelector('.test'),
// 'inner container created');
// });
// module('Custom css');
// test('config with custom css', function() {
// // setup
// tf.destroy();
// tf = new TableFilter('demo', {
// base_path: '../dist/tablefilter/',
// toolbar: {
// container_css_class: 'cont-css',
// left_cont_css_class: 'left-cont-css',
// right_cont_css_class: 'right-cont-css',
// center_cont_css_class: 'center-cont-css'
// }
// });
// // act
// tf.init();
// var toolbar = tf.feature('toolbar');
// deepEqual(toolbar.cont, document.querySelector('.cont-css'),
// 'container with custom css class');
// deepEqual(toolbar.lCont, toolbar.cont.querySelector('.left-cont-css'),
// 'left inner container with custom css class');
// deepEqual(toolbar.rCont, document.querySelector('.right-cont-css'),
// 'right inner container with custom css class');
// deepEqual(toolbar.cCont, document.querySelector('.center-cont-css'),
// 'middle inner container with custom css class');
// });
// module('External container');
// test('config with external container id', function() {
// // setup
// tf.destroy();
// tf = new TableFilter('demo', {
// base_path: '../dist/tablefilter/',
// toolbar: {
// target_id: 'ext-cont'
// }
// });
// // act
// tf.init();
// var toolbar = tf.feature('toolbar');
// // assert
// deepEqual(toolbar.cont, document.querySelector('#ext-cont').firstChild,
// 'external container element');
// });
// module('Grid-layout');
// test('config with grid-layout', function() {
// // setup
// tf.destroy();
// tf = new TableFilter('demo', {
// base_path: '../dist/tablefilter/',
// grid_layout: true,
// toolbar: true
// });
// // act
// tf.init();
// var toolbar = tf.feature('toolbar');
// // assert
// deepEqual(toolbar.cont, document.querySelector('.grd_inf'),
// 'container element with grid-layout mode');
// });
// module('tear-down');
// test('destroy TableFilter', function() {
// // act
// tf.destroy();
// // assert
// deepEqual(tf.feature('toolbar').initialized, false, 'toolbar removed');
// });
// assert
deepEqual(tf.isInitialized(), false, 'Filters removed');
});