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

Implemented Dom.remove

This commit is contained in:
Max Guglielmi 2015-12-06 00:37:59 +11:00
parent 0f3f94239f
commit 086e25ee76
21 changed files with 123 additions and 117 deletions

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.0.13 by Max Guglielmi
* build date: 2015-11-29T10:22:52.496Z
* build date: 2015-12-05T13:33:39.224Z
* 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.0.13 by Max Guglielmi
* build date: 2015-11-29T10:22:52.496Z
* build date: 2015-12-05T13:33:39.224Z
* 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.0.13 by Max Guglielmi
* build date: 2015-11-29T10:22:52.496Z
* build date: 2015-12-05T13:33:39.224Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.0.13 by Max Guglielmi
* build date: 2015-11-29T10:22:52.496Z
* build date: 2015-12-05T13:33:39.224Z
* MIT License
*/
table.TF{border-left:1px solid #ccc !important;border-top:none !important;border-right:none !important;border-bottom:none !important;}table.TF th{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;color:#333 !important}table.TF td{border-bottom:1px dotted #999 !important;padding:5px !important}.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}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.0.13 by Max Guglielmi
* build date: 2015-11-29T10:22:52.496Z
* build date: 2015-12-05T13:33:39.224Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b !important;border-top:none !important;border-right:0 !important;border-bottom:none !important;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;color:#fff !important}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px !important}.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}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.0.13 by Max Guglielmi
* build date: 2015-11-29T10:22:52.496Z
* build date: 2015-12-05T13:33:39.224Z
* 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

File diff suppressed because one or more lines are too long

View file

@ -42,6 +42,15 @@ export default {
return el;
},
/**
* Removes passed node from DOM
* @param {DOMElement} node
* @return {DOMElement} old node reference
*/
remove(node){
return node.parentNode.removeChild(node);
},
/**
* Returns a text node with given text
* @param {String} txt
@ -127,8 +136,8 @@ export default {
return li;
},
id(_id){
return document.getElementById(_id);
id(key){
return document.getElementById(key);
},
tag(o, tagname){

View file

@ -477,11 +477,11 @@ export default class ColsVisibility{
Dom.id(this.contElTgtId).innerHTML = '';
} else {
this.contEl.innerHTML = '';
this.contEl.parentNode.removeChild(this.contEl);
Dom.remove(this.contEl);
this.contEl = null;
}
this.btnEl.innerHTML = '';
this.btnEl.parentNode.removeChild(this.btnEl);
Dom.remove(this.btnEl);
this.btnEl = null;
this.initialized = false;
}

View file

@ -172,11 +172,11 @@ export default class FiltersVisibility{
}
this.btnEl.innerHTML = '';
this.btnEl.parentNode.removeChild(this.btnEl);
Dom.remove(this.btnEl);
this.btnEl = null;
this.contEl.innerHTML = '';
this.contEl.parentNode.removeChild(this.contEl);
Dom.remove(this.contEl);
this.contEl = null;
this.initialized = false;
}

View file

@ -86,7 +86,7 @@ export class ClearButton extends Feature{
var resetspan = Dom.id(this.prfxResetSpan+tf.id);
if(resetspan){
resetspan.parentNode.removeChild(resetspan);
Dom.remove(resetspan);
}
this.btnResetEl = null;
this.disable();

View file

@ -2,6 +2,7 @@ import {Feature} from './feature';
import Dom from '../dom';
import Types from '../types';
import Event from '../event';
import Str from '../string';
export class GridLayout extends Feature{
@ -121,16 +122,16 @@ export class GridLayout extends Feature{
this.tblCont.style.height = this.gridHeight;
}
tbl.parentNode.insertBefore(this.tblCont, tbl);
var t = tbl.parentNode.removeChild(tbl);
var t = Dom.remove(tbl);
this.tblCont.appendChild(t);
//In case table width is expressed in %
if(tbl.style.width === ''){
tbl.style.width = (tf._containsStr('%', tblW) ?
tbl.style.width = (Str.contains('%', tblW) ?
tbl.clientWidth : tblW) + 'px';
}
var d = this.tblCont.parentNode.removeChild(this.tblCont);
var d = Dom.remove(this.tblCont);
this.tblMainCont.appendChild(d);
//Headers table container: div wrapping headers table
@ -288,7 +289,7 @@ export class GridLayout extends Feature{
}
if(afterColResizedFn){
afterColResizedFn.call(null,o,colIndex);
afterColResizedFn.call(null, o, colIndex);
}
};
@ -313,9 +314,9 @@ export class GridLayout extends Feature{
if(!this.initialized){
return;
}
var t = tbl.parentNode.removeChild(tbl);
var t = Dom.remove(tbl);
this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont);
this.tblMainCont.parentNode.removeChild(this.tblMainCont);
Dom.remove(this.tblMainCont);
this.tblMainCont = null;
this.headTblCont = null;
@ -324,7 +325,7 @@ export class GridLayout extends Feature{
tbl.outerHTML = this.sourceTblHtml;
//needed to keep reference of table element
this.tf.tbl = Dom.id(tf.id); // ???
this.tf.tbl = t;/*Dom.id(tf.id);*/ // ???
this.initialized = false;
}

View file

@ -140,12 +140,12 @@ export class Help extends Feature{
if(!this.initialized){
return;
}
this.btn.parentNode.removeChild(this.btn);
Dom.remove(this.btn);
this.btn = null;
if(!this.cont){
return;
}
this.cont.parentNode.removeChild(this.cont);
Dom.remove(this.cont);
this.cont = null;
this.disable();

View file

@ -93,7 +93,7 @@ export class Loader extends Feature{
return;
}
this.loaderDiv.parentNode.removeChild(this.loaderDiv);
Dom.remove(this.loaderDiv);
this.loaderDiv = null;
this.disable();

View file

@ -561,10 +561,10 @@ export class Paging extends Feature{
var slcR = this.resultsPerPageSlc,
slcRSpan = Dom.id(this.prfxSlcResultsTxt+tf.id);
if(slcR){
slcR.parentNode.removeChild(slcR);
Dom.remove(slcR);
}
if(slcRSpan){
slcRSpan.parentNode.removeChild(slcRSpan);
Dom.remove(slcRSpan);
}
this.resultsPerPageSlc = null;
}
@ -737,39 +737,39 @@ export class Paging extends Feature{
else if(this.pageSelectorType === tf.fltTypeInp){
Event.remove(this.pagingSlc, 'keypress', evt._detectKey);
}
this.pagingSlc.parentNode.removeChild(this.pagingSlc);
Dom.remove(this.pagingSlc);
}
if(btnNextSpan){
Event.remove(btnNextSpan, 'click', evt.next);
btnNextSpan.parentNode.removeChild(btnNextSpan);
Dom.remove(btnNextSpan);
}
if(btnPrevSpan){
Event.remove(btnPrevSpan, 'click', evt.prev);
btnPrevSpan.parentNode.removeChild(btnPrevSpan);
Dom.remove(btnPrevSpan);
}
if(btnLastSpan){
Event.remove(btnLastSpan, 'click', evt.last);
btnLastSpan.parentNode.removeChild(btnLastSpan);
Dom.remove(btnLastSpan);
}
if(btnFirstSpan){
Event.remove(btnFirstSpan, 'click', evt.first);
btnFirstSpan.parentNode.removeChild(btnFirstSpan);
Dom.remove(btnFirstSpan);
}
if(pgBeforeSpan){
pgBeforeSpan.parentNode.removeChild(pgBeforeSpan);
Dom.remove(pgBeforeSpan);
}
if(pgAfterSpan){
pgAfterSpan.parentNode.removeChild(pgAfterSpan);
Dom.remove(pgAfterSpan);
}
if(pgspan){
pgspan.parentNode.removeChild(pgspan);
Dom.remove(pgspan);
}
if(this.hasResultsPerPage){

View file

@ -229,16 +229,16 @@ export class PopupFilter extends Feature{
popUpFltSpan = this.popUpFltSpans[i],
popUpFltImg = this.popUpFltImgs[i];
if(popUpFltElm){
popUpFltElm.parentNode.removeChild(popUpFltElm);
Dom.remove(popUpFltElm);
this.popUpFltElmCache[i] = popUpFltElm;
}
popUpFltElm = null;
if(popUpFltSpan){
popUpFltSpan.parentNode.removeChild(popUpFltSpan);
Dom.remove(popUpFltSpan);
}
popUpFltSpan = null;
if(popUpFltImg){
popUpFltImg.parentNode.removeChild(popUpFltImg);
Dom.remove(popUpFltImg);
}
popUpFltImg = null;
}

View file

@ -126,7 +126,7 @@ export class RowsCounter extends Feature{
}
if(!this.rowsCounterTgtId && this.rowsCounterDiv){
this.rowsCounterDiv.parentNode.removeChild(this.rowsCounterDiv);
Dom.remove(this.rowsCounterDiv);
} else {
Dom.id(this.rowsCounterTgtId).innerHTML = '';
}

View file

@ -113,7 +113,7 @@ export class StatusBar extends Feature{
}
this.statusBarDiv.innerHTML = '';
this.statusBarDiv.parentNode.removeChild(this.statusBarDiv);
Dom.remove(this.statusBarDiv);
this.statusBarSpan = null;
this.statusBarSpanText = null;
this.statusBarDiv = null;

View file

@ -29,11 +29,33 @@ export default {
return String(text).replace(chars, escMatch);
},
matchCase(text, mc){
if(!mc){
matchCase(text, caseSensitive){
if(!caseSensitive){
return this.lower(text);
}
return text;
},
/**
* Checks if passed data contains the searched term
* @param {String} term Searched term
* @param {String} data Data string
* @param {Boolean} exactMatch Exact match
* @param {Boolean} caseSensitive Case sensitive
* @return {Boolean}
*/
contains(term, data, exactMatch=false, caseSensitive=false){
// Improved by Cedric Wartel (cwl) automatic exact match for selects and
// special characters are now filtered
let regexp,
modifier = caseSensitive ? 'g' : 'gi';
if(exactMatch){
regexp = new RegExp(
'(^\\s*)'+ this.rgxEsc(term) +'(\\s*$)', modifier);
} else {
regexp = new RegExp(this.rgxEsc(term), modifier);
}
return regexp.test(data);
}
};

View file

@ -735,8 +735,8 @@ export class TableFilter{
slc.multiple = this.fltTypeMulti;
slc.title = dropdown.multipleSlcTooltip;
}
slc.className = Str.lower(col)===this.fltTypeSlc ?
inpclass : this.fltMultiCssClass;// for ie<=6
slc.className = Str.lower(col) === this.fltTypeSlc ?
inpclass : this.fltMultiCssClass;
//filter is appended in desired external element
if(externalFltTgtId){
@ -1285,7 +1285,7 @@ export class TableFilter{
if(!this.infDiv){
return;
}
this.infDiv.parentNode.removeChild(this.infDiv);
Dom.remove(this.infDiv);
this.infDiv = null;
let tbl = this.tbl;
@ -1505,7 +1505,7 @@ export class TableFilter{
// search args re-init
this.searchArgs = this.getFiltersValue();
var num_cell_data, nbFormat;
var numCellData, nbFormat;
var re_le = new RegExp(this.leOperator),
re_ge = new RegExp(this.geOperator),
re_l = new RegExp(this.lwOperator),
@ -1542,7 +1542,7 @@ export class TableFilter{
}
//looks for search argument in current row
function hasArg(sA, cell_data, j){
function hasArg(sA, cellData, j){
/*jshint validthis:true */
let occurence,
removeNbFormat = Helpers.removeNbFormat;
@ -1571,8 +1571,8 @@ export class TableFilter{
let dte1, dte2;
//dates
if(isValidDate(cell_data,dtType)){
dte1 = formatDate(cell_data,dtType);
if(isValidDate(cellData, dtType)){
dte1 = formatDate(cellData, dtType);
// lower date
if(isLDate){
dte2 = formatDate(sA.replace(re_l,''), dtType);
@ -1605,36 +1605,36 @@ export class TableFilter{
}
// searched keyword with * operator doesn't have to be a date
else if(re_lk.test(sA)){// like date
occurence = this._containsStr(
sA.replace(re_lk,''), cell_data, false);
occurence = Str.contains(sA.replace(re_lk,''), cellData,
false, this.caseSensitive);
}
else if(isValidDate(sA,dtType)){
dte2 = formatDate(sA,dtType);
occurence = dte1.toString() == dte2.toString();
occurence = dte1.toString() === dte2.toString();
}
//empty
else if(hasEM){
occurence = Str.isEmpty(cell_data);
occurence = Str.isEmpty(cellData);
}
//non-empty
else if(hasNM){
occurence = !Str.isEmpty(cell_data);
occurence = !Str.isEmpty(cellData);
}
}
else{
//first numbers need to be formated
if(this.hasColNbFormat && this.colNbFormat[j]){
num_cell_data = removeNbFormat(
cell_data, this.colNbFormat[j]);
numCellData = removeNbFormat(
cellData, this.colNbFormat[j]);
nbFormat = this.colNbFormat[j];
} else {
if(this.thousandsSeparator === ',' &&
this.decimalSeparator === '.'){
num_cell_data = removeNbFormat(cell_data, 'us');
numCellData = removeNbFormat(cellData, 'us');
nbFormat = 'us';
} else {
num_cell_data = removeNbFormat(cell_data, 'eu');
numCellData = removeNbFormat(cellData, 'eu');
nbFormat = 'eu';
}
}
@ -1643,60 +1643,60 @@ export class TableFilter{
// rgx:)
// lower equal
if(hasLE){
occurence = num_cell_data <= removeNbFormat(
occurence = numCellData <= removeNbFormat(
sA.replace(re_le, ''), nbFormat);
}
//greater equal
else if(hasGE){
occurence = num_cell_data >= removeNbFormat(
occurence = numCellData >= removeNbFormat(
sA.replace(re_ge, ''), nbFormat);
}
//lower
else if(hasLO){
occurence = num_cell_data < removeNbFormat(
occurence = numCellData < removeNbFormat(
sA.replace(re_l, ''), nbFormat);
}
//greater
else if(hasGR){
occurence = num_cell_data > removeNbFormat(
occurence = numCellData > removeNbFormat(
sA.replace(re_g, ''), nbFormat);
}
//different
else if(hasDF){
occurence = this._containsStr(
sA.replace(re_d, ''), cell_data) ? false : true;
occurence = Str.contains(sA.replace(re_d, ''), cellData,
false, this.caseSensitive) ? false : true;
}
//like
else if(hasLK){
occurence = this._containsStr(
sA.replace(re_lk, ''), cell_data, false);
occurence = Str.contains(sA.replace(re_lk, ''), cellData,
false, this.caseSensitive);
}
//equal
else if(hasEQ){
occurence = this._containsStr(
sA.replace(re_eq, ''), cell_data, true);
occurence = Str.contains(sA.replace(re_eq, ''), cellData,
true, this.caseSensitive);
}
//starts with
else if(hasST){
occurence = cell_data.indexOf(sA.replace(re_st, ''))===0 ?
occurence = cellData.indexOf(sA.replace(re_st, '')) === 0 ?
true : false;
}
//ends with
else if(hasEN){
let searchArg = sA.replace(re_en, '');
occurence =
cell_data.lastIndexOf(searchArg,cell_data.length-1) ===
(cell_data.length-1)-(searchArg.length-1) &&
cell_data.lastIndexOf(
searchArg, cell_data.length-1) > -1 ? true : false;
cellData.lastIndexOf(searchArg, cellData.length-1) ===
(cellData.length-1)-(searchArg.length-1) &&
cellData.lastIndexOf(
searchArg, cellData.length-1) > -1 ? true : false;
}
//empty
else if(hasEM){
occurence = Str.isEmpty(cell_data);
occurence = Str.isEmpty(cellData);
}
//non-empty
else if(hasNM){
occurence = !Str.isEmpty(cell_data);
occurence = !Str.isEmpty(cellData);
}
//regexp
else if(hasRE){
@ -1705,11 +1705,11 @@ export class TableFilter{
//operator is removed
let srchArg = sA.replace(re_re,'');
let rgx = new RegExp(srchArg);
occurence = rgx.test(cell_data);
occurence = rgx.test(cellData);
} catch(e) { occurence = false; }
} else {
occurence = this._containsStr(sA, cell_data,
this.isExactMatch(j));
occurence = Str.contains(sA, cellData, this.isExactMatch(j),
this.caseSensitive);
}
}//else
@ -1745,7 +1745,7 @@ export class TableFilter{
continue;
}
let cell_data = Str.matchCase(this.getCellData(cell[j]),
let cellData = Str.matchCase(this.getCellData(cell[j]),
this.caseSensitive);
//multiple search parameter operator ||
@ -1764,7 +1764,7 @@ export class TableFilter{
s = hasMultiOrSA ? sAOrSplit : sAAndSplit;
for(let w=0, len=s.length; w<len; w++){
cS = Str.trim(s[w]);
occur = hasArg.call(this, cS, cell_data, j);
occur = hasArg.call(this, cS, cellData, j);
highlight.call(this, cS, occur, cell[j]);
if(hasMultiOrSA && occur){
break;
@ -1777,8 +1777,7 @@ export class TableFilter{
}
//single search parameter
else {
occurence[j] =
hasArg.call(this, Str.trim(sA), cell_data, j);
occurence[j] = hasArg.call(this, Str.trim(sA), cellData, j);
highlight.call(this, sA, occurence[j], cell[j]);
}//else single param
@ -1922,12 +1921,12 @@ export class TableFilter{
if(j != colIndex || row[i].style.display !== ''){
continue;
}
let cell_data = this.getCellData(cell[j]),
let cellData = this.getCellData(cell[j]),
nbFormat = this.colNbFormat ?
this.colNbFormat[colIndex] : null,
data = num ?
Helpers.removeNbFormat(cell_data, nbFormat) :
cell_data;
Helpers.removeNbFormat(cellData, nbFormat) :
cellData;
colValues.push(data);
}
}
@ -2513,32 +2512,7 @@ export class TableFilter{
isExactMatch(colIndex){
let fltType = this.getFilterType(colIndex);
return this.exactMatchByCol[colIndex] || this.exactMatch ||
(fltType!==this.fltTypeInp);
}
/**
* Checks if passed data contains the searched arg
* @param {String} arg Search term
* @param {String} data Data string
* @param {Boolean} exactMatch Exact match
* @return {Boolean]}
*
* TODO: move into string module, remove fltType in order to decouple it
* from TableFilter module
*/
_containsStr(arg, data, exactMatch){
// Improved by Cedric Wartel (cwl)
// automatic exact match for selects and special characters are now
// filtered
let regexp,
modifier = this.caseSensitive ? 'g' : 'gi';
if(exactMatch){
regexp = new RegExp(
'(^\\s*)'+ Str.rgxEsc(arg) +'(\\s*$)', modifier);
} else {
regexp = new RegExp(Str.rgxEsc(arg), modifier);
}
return regexp.test(data);
(fltType !== this.fltTypeInp);
}
/**