Skip to content

Commit

Permalink
Renamed custom_cell_data option cell_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
max-nearmap committed Feb 26, 2017
1 parent b062d44 commit 90b5e3c
Show file tree
Hide file tree
Showing 17 changed files with 244 additions and 64 deletions.
4 changes: 2 additions & 2 deletions dist/starter.html
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>tablefilter v0.4.42 - Starter</title>
<title>tablefilter v0.5.0 - Starter</title>
</head>
<body>
<h1>tablefilter v0.4.42</h1>
<h1>tablefilter v0.5.0</h1>



Expand Down
4 changes: 2 additions & 2 deletions dist/tablefilter/style/colsVisibility.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/tablefilter/style/filtersVisibility.css
@@ -1,6 +1,6 @@
/**
* tablefilter v0.4.42 by Max Guglielmi
* build date: 2017-02-21T10:17:58.442Z
* tablefilter v0.5.0 by Max Guglielmi
* build date: 2017-02-26T09:46:08.161Z
* 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}
4 changes: 2 additions & 2 deletions dist/tablefilter/style/tablefilter.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/tablefilter/style/themes/default/default.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/tablefilter/style/themes/mytheme/mytheme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/tablefilter/style/themes/skyblue/skyblue.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/tablefilter/style/themes/transparent/transparent.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dist/tablefilter/tablefilter.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tablefilter/tablefilter.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/tablefilter/tf-0-202cbf5be111a5fa422a.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.4.42",
"version": "0.5.0",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {
Expand Down
32 changes: 21 additions & 11 deletions src/tablefilter.js
Expand Up @@ -459,15 +459,24 @@ export class TableFilter {
* List of columns implementing custom filtering
* @type {Array}
*/
this.customCellDataCols = f.custom_cell_data_cols ?
f.custom_cell_data_cols : [];

/**
* Delegate function for retrieving cell data with custom logic
* @type {Function}
// this.cellParserCols = f.custom_cell_data_cols ?
// f.custom_cell_data_cols : [];

/**
* Specify which column implements a custom cell parser to retrieve the
* cell value:
* cell_parser: {
* cols: [0, 2],
* parse: function(tf, cell, colIndex) {
* // custom cell parser logic here
* return cellValue;
* }
* }
* @type {Object}
*/
this.customCellData = isFn(f.custom_cell_data) ?
f.custom_cell_data : EMPTY_FN;
this.cellParser = isObj(f.cell_parser) && isFn(f.cell_parser.parse) &&
isArray(f.cell_parser.cols) ?
f.cell_parser : { cols: [], parse: EMPTY_FN };

/**
* Global watermark text for input filter type or watermark for each
Expand Down Expand Up @@ -2254,9 +2263,10 @@ export class TableFilter {
*/
getCellValue(cell) {
let idx = cell.cellIndex;
//CallcustomCellData callback
if (this.customCellDataCols.indexOf(idx) !== -1) {
return this.customCellData(this, cell, idx);
let cellParser = this.cellParser;
// Invoke cellParser for this column if any
if (cellParser.cols.indexOf(idx) !== -1) {
return cellParser.parse(this, cell, idx);
} else {
return getText(cell);
}
Expand Down
33 changes: 17 additions & 16 deletions static/templates/filter-images.html
Expand Up @@ -36,22 +36,23 @@ <h2>Filter and sort images demo</h2>
col_4: 'select',
col_5: 'select',

/* custom_cell_data delegate used for filtering
images in a column */
custom_cell_data_cols: [0, 4],
custom_cell_data: function(o, cell, colIndex){
if(colIndex === 0){
var img = cell.getElementsByTagName('img')[0];
if(!img){
return '';
}
return img.alt;
} else if(colIndex === 4){
var chk = cell.getElementsByTagName('input')[0];
if(chk.checked){
return 'yes';
} else {
return 'no';
/* cell parser for filtering images in a column */
cell_parser: {
cols: [0, 4],
parse: function(o, cell, colIndex){
if(colIndex === 0){
var img = cell.getElementsByTagName('img')[0];
if(!img){
return '';
}
return img.alt;
} else if(colIndex === 4){
var chk = cell.getElementsByTagName('input')[0];
if(chk.checked){
return 'yes';
} else {
return 'no';
}
}
}
},
Expand Down

0 comments on commit 90b5e3c

Please sign in to comment.