1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2026-03-17 16:10:04 +01:00

Added eqeqeq eslint rule

This commit is contained in:
Max Guglielmi 2016-05-15 13:33:16 +10:00
commit be3903d2eb
19 changed files with 107 additions and 109 deletions

View file

@ -5,10 +5,10 @@
import Str from './string';
export default {
has: function(arr, val, caseSensitive){
let sCase = caseSensitive===undefined ? false : caseSensitive;
for (var i=0; i<arr.length; i++){
if(Str.matchCase(arr[i].toString(), sCase) == val){
has: function (arr, val, caseSensitive) {
let sCase = Boolean(caseSensitive);
for (var i = 0, l = arr.length; i < l; i++) {
if (Str.matchCase(arr[i].toString(), sCase) === val) {
return true;
}
}

View file

@ -8,7 +8,7 @@ export default {
format = 'DMY';
}
format = format.toUpperCase();
if(format.length != 3) {
if(format.length !== 3) {
if(format === 'DDMMMYYYY'){
let d = this.format(dateStr, format);
dateStr = d.getDate() +'/'+ (d.getMonth()+1) +'/'+
@ -71,10 +71,10 @@ export default {
let dt = new Date(
parseInt(yy, 10), parseInt(mm, 10)-1, parseInt(dd, 10),
0, 0, 0, 0);
if(parseInt(dd, 10) != dt.getDate()){
if(parseInt(dd, 10) !== dt.getDate()){
return false;
}
if(parseInt(mm, 10)-1 != dt.getMonth()){
if(parseInt(mm, 10)-1 !== dt.getMonth()){
return false;
}
return true;

View file

@ -243,7 +243,7 @@ export default class AdapterEzEditTable extends Feature {
paging.currentPageNb !== paging.nbPages) {
paging.setPage('last');
}
else if ((rowIndex == validIndexes[0]) &&
else if ((rowIndex === validIndexes[0]) &&
paging.currentPageNb !== 1) {
paging.setPage('first');
}

View file

@ -1,7 +1,7 @@
import {Feature} from '../../feature';
import Dom from '../../dom';
import Str from '../../string';
import {isFn, isUndef} from '../../types';
import {isArray, isFn, isUndef} from '../../types';
export default class ColOps extends Feature {
@ -90,9 +90,7 @@ export default class ColOps extends Feature {
}
}
if (Str.lower(typeof labelId) == 'object' &&
Str.lower(typeof colIndex) == 'object' &&
Str.lower(typeof operation) == 'object') {
if (isArray(labelId) && isArray(colIndex) && isArray(operation)) {
var rows = tf.tbl.rows,
colvalues = [];
@ -134,8 +132,7 @@ export default class ColOps extends Feature {
opsThisCol[mThisCol] = Str.lower(operation[k]);
decThisCol[mThisCol] = decimalPrecision[k];
labThisCol[mThisCol] = labelId[k];
oTypeThisCol = outputType !== undefined &&
Str.lower(typeof outputType) === 'object' ?
oTypeThisCol = isArray(outputType) ?
outputType[k] : null;
switch (opsThisCol[mThisCol]) {
@ -166,7 +163,7 @@ export default class ColOps extends Feature {
for (var j = 0; j < colvalues[ucol].length; j++) {
//sort the list for calculation of median and quartiles
if ((q1Flag == 1) || (q3Flag == 1) || (medFlag == 1)) {
if ((q1Flag === 1) || (q3Flag === 1) || (medFlag === 1)) {
if (j < colvalues[ucol].length - 1) {
for (k = j + 1; k < colvalues[ucol].length; k++) {
/* eslint-disable */
@ -223,7 +220,7 @@ export default class ColOps extends Feature {
if (q1Flag === 1) {
posa = 0.0;
posa = Math.floor(nbvalues / 4);
if (4 * posa == nbvalues) {
if (4 * posa === nbvalues) {
q1Value = (theList[posa - 1] + theList[posa]) / 2;
} else {
q1Value = theList[posa];

View file

@ -158,7 +158,7 @@ export default class AdapterSortableTable extends Feature {
SortableTable.getCellIndex = function (oTd) {
let cells = oTd.parentNode.cells,
l = cells.length, i;
for (i = 0; cells[i] != oTd && i < l; i++) { }
for (i = 0; cells[i] !== oTd && i < l; i++) { }
return i;
};
@ -418,7 +418,7 @@ function ipAddress(value) {
function sortIP(a, b) {
let aa = ipAddress(a.value.toLowerCase());
let bb = ipAddress(b.value.toLowerCase());
if (aa == bb) {
if (aa === bb) {
return 0;
} else if (aa < bb) {
return -1;

View file

@ -180,8 +180,8 @@ export class CheckList extends Feature {
((rows[k].style.display === '' && !tf.paging) ||
(tf.paging && ((!activeIdx ||
activeIdx === colIndex) ||
(activeIdx != colIndex &&
tf.validRowsIndex.indexOf(k) != -1)))))) {
(activeIdx !== colIndex &&
tf.validRowsIndex.indexOf(k) !== -1)))))) {
let cellData = tf.getCellData(cells[j]);
//Vary Peter's patch
@ -226,7 +226,7 @@ export class CheckList extends Feature {
}
}
//asc sort
if (tf.sortNumAsc.indexOf(colIndex) != -1) {
if (tf.sortNumAsc.indexOf(colIndex) !== -1) {
try {
this.opts.sort(Sort.numSortAsc);
if (this.excludedOpts) {
@ -241,7 +241,7 @@ export class CheckList extends Feature {
}//in case there are alphanumeric values
}
//desc sort
if (tf.sortNumDesc.indexOf(colIndex) != -1) {
if (tf.sortNumDesc.indexOf(colIndex) !== -1) {
try {
this.opts.sort(Sort.numSortDesc);
if (this.excludedOpts) {

View file

@ -175,11 +175,11 @@ export class Dropdown extends Feature {
((rows[k].style.display === '' && !tf.paging) ||
(tf.paging && (!tf.validRowsIndex ||
(tf.validRowsIndex &&
tf.validRowsIndex.indexOf(k) != -1)) &&
tf.validRowsIndex.indexOf(k) !== -1)) &&
((activeIdx === undefined ||
activeIdx === colIndex) ||
(activeIdx != colIndex &&
tf.validRowsIndex.indexOf(k) != -1)))))) {
(activeIdx !== colIndex &&
tf.validRowsIndex.indexOf(k) !== -1)))))) {
let cellData = tf.getCellData(cell[j]),
//Vary Peter's patch
cellString = Str.matchCase(cellData, matchCase);
@ -224,7 +224,7 @@ export class Dropdown extends Feature {
}
//asc sort
if (tf.sortNumAsc.indexOf(colIndex) != -1) {
if (tf.sortNumAsc.indexOf(colIndex) !== -1) {
try {
this.opts.sort(Sort.numSortAsc);
if (excludedOpts) {
@ -239,7 +239,7 @@ export class Dropdown extends Feature {
}//in case there are alphanumeric values
}
//desc sort
if (tf.sortNumDesc.indexOf(colIndex) != -1) {
if (tf.sortNumDesc.indexOf(colIndex) !== -1) {
try {
this.opts.sort(Sort.numSortDesc);
if (excludedOpts) {

View file

@ -1,17 +1,17 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {isFn, isNull} from '../types';
import {isFn, isNull, isUndef} from '../types';
import Event from '../event';
import Str from '../string';
import {NONE} from '../const';
export class GridLayout extends Feature{
export class GridLayout extends Feature {
/**
* Grid layout, table with fixed headers
* @param {Object} tf TableFilter instance
*/
constructor(tf){
constructor(tf) {
super(tf, 'gridLayout');
let f = this.config;
@ -34,7 +34,7 @@ export class GridLayout extends Feature{
//array of headers row indexes to be placed in header table
this.gridHeadRows = f.grid_headers_rows || [0];
//generate filters in table headers
this.gridEnableFilters = f.grid_enable_default_filters!==undefined ?
this.gridEnableFilters = !isUndef(f.grid_enable_default_filters) ?
f.grid_enable_default_filters : true;
this.noHeaders = Boolean(f.grid_no_headers);
//default col width
@ -64,12 +64,12 @@ export class GridLayout extends Feature{
/**
* Generates a grid with fixed headers
*/
init(){
init() {
let tf = this.tf;
let f = this.config;
let tbl = tf.tbl;
if(this.initialized){
if (this.initialized) {
return;
}
@ -81,14 +81,14 @@ export class GridLayout extends Feature{
tf.isExternalFlt = true;
// default width of 100px if column widths not set
if(!tf.hasColWidths){
if (!tf.hasColWidths) {
tf.colWidths = [];
for(let k=0; k<tf.nbCells; k++){
for (let k = 0; k < tf.nbCells; k++) {
let colW,
cell = tbl.rows[this.gridHeadRowIndex].cells[k];
if(cell.width !== ''){
if (cell.width !== '') {
colW = cell.width;
} else if(cell.style.width !== ''){
} else if (cell.style.width !== '') {
colW = parseInt(cell.style.width, 10);
} else {
colW = this.gridDefaultColWidth;
@ -100,10 +100,10 @@ export class GridLayout extends Feature{
tf.setColWidths();
let tblW;//initial table width
if(tbl.width !== ''){
if (tbl.width !== '') {
tblW = tbl.width;
}
else if(tbl.style.width !== ''){
else if (tbl.style.width !== '') {
tblW = parseInt(tbl.style.width, 10);
} else {
tblW = tbl.clientWidth;
@ -113,7 +113,7 @@ export class GridLayout extends Feature{
this.tblMainCont = Dom.create('div',
['id', this.prfxMainTblCont + tf.id]);
this.tblMainCont.className = this.gridMainContCssClass;
if(this.gridWidth){
if (this.gridWidth) {
this.tblMainCont.style.width = this.gridWidth;
}
tbl.parentNode.insertBefore(this.tblMainCont, tbl);
@ -121,14 +121,14 @@ export class GridLayout extends Feature{
//Table container: div wrapping content table
this.tblCont = Dom.create('div', ['id', this.prfxTblCont + tf.id]);
this.tblCont.className = this.gridContCssClass;
if(this.gridWidth){
if(this.gridWidth.indexOf('%') != -1){
if (this.gridWidth) {
if (this.gridWidth.indexOf('%') !== -1) {
this.tblCont.style.width = '100%';
} else {
this.tblCont.style.width = this.gridWidth;
}
}
if(this.gridHeight){
if (this.gridHeight) {
this.tblCont.style.height = this.gridHeight;
}
tbl.parentNode.insertBefore(this.tblCont, tbl);
@ -136,7 +136,7 @@ export class GridLayout extends Feature{
this.tblCont.appendChild(t);
//In case table width is expressed in %
if(tbl.style.width === ''){
if (tbl.style.width === '') {
tbl.style.width = (Str.contains('%', tblW) ?
tbl.clientWidth : tblW) + 'px';
}
@ -146,10 +146,10 @@ export class GridLayout extends Feature{
//Headers table container: div wrapping headers table
this.headTblCont = Dom.create(
'div',['id', this.prfxHeadTblCont + tf.id]);
'div', ['id', this.prfxHeadTblCont + tf.id]);
this.headTblCont.className = this.gridHeadContCssClass;
if(this.gridWidth){
if(this.gridWidth.indexOf('%') != -1){
if (this.gridWidth) {
if (this.gridWidth.indexOf('%') !== -1) {
this.headTblCont.style.width = '100%';
} else {
this.headTblCont.style.width = this.gridWidth;
@ -164,11 +164,11 @@ export class GridLayout extends Feature{
//Those ids are used by the sort feature
let hRow = tbl.rows[this.gridHeadRowIndex];
let sortTriggers = [];
for(let n=0; n<tf.nbCells; n++){
for (let n = 0; n < tf.nbCells; n++) {
let c = hRow.cells[n];
let thId = c.getAttribute('id');
if(!thId || thId===''){
thId = this.prfxGridTh+n+'_'+tf.id;
if (!thId || thId === '') {
thId = this.prfxGridTh + n + '_' + tf.id;
c.setAttribute('id', thId);
}
sortTriggers.push(thId);
@ -176,10 +176,10 @@ export class GridLayout extends Feature{
//Filters row is created
let filtersRow = Dom.create('tr');
if(this.gridEnableFilters && tf.fltGrid){
if (this.gridEnableFilters && tf.fltGrid) {
tf.externalFltTgtIds = [];
for(let j=0; j<tf.nbCells; j++){
let fltTdId = tf.prfxFlt+j+ this.prfxGridFltTd +tf.id;
for (let j = 0; j < tf.nbCells; j++) {
let fltTdId = tf.prfxFlt + j + this.prfxGridFltTd + tf.id;
let cl = Dom.create(tf.fltCellTag, ['id', fltTdId]);
filtersRow.appendChild(cl);
tf.externalFltTgtIds[j] = fltTdId;
@ -187,8 +187,8 @@ export class GridLayout extends Feature{
}
//Headers row are moved from content table to headers table
if(!this.noHeaders) {
for(let i=0; i<this.gridHeadRows.length; i++){
if (!this.noHeaders) {
for (let i = 0; i < this.gridHeadRows.length; i++) {
let headRow = tbl.rows[this.gridHeadRows[0]];
tH.appendChild(headRow);
}
@ -199,7 +199,7 @@ export class GridLayout extends Feature{
}
this.headTbl.appendChild(tH);
if(tf.filtersRowIndex === 0){
if (tf.filtersRowIndex === 0) {
tH.insertBefore(filtersRow, hRow);
} else {
tH.appendChild(filtersRow);
@ -210,7 +210,7 @@ export class GridLayout extends Feature{
//THead needs to be removed in content table for sort feature
let thead = Dom.tag(tbl, 'thead');
if(thead.length>0){
if (thead.length > 0) {
tbl.removeChild(thead[0]);
}
@ -233,7 +233,7 @@ export class GridLayout extends Feature{
//
//scroll synchronisation
Event.add(this.tblCont, 'scroll', (evt)=> {
Event.add(this.tblCont, 'scroll', (evt) => {
let elm = Event.target(evt);
let scrollLeft = elm.scrollLeft;
this.headTblCont.scrollLeft = scrollLeft;
@ -255,10 +255,10 @@ export class GridLayout extends Feature{
});
//Configure sort extension if any
let sort = (f.extensions || []).filter(function(itm){
let sort = (f.extensions || []).filter(function (itm) {
return itm.name === 'sort';
});
if(sort.length === 1){
if (sort.length === 1) {
sort[0].async_sort = true;
sort[0].trigger_ids = sortTriggers;
}
@ -268,9 +268,9 @@ export class GridLayout extends Feature{
//Col elements are enough to keep column widths after sorting and
//filtering
let createColTags = function(){
for(let k=(tf.nbCells-1); k>=0; k--){
let col = Dom.create('col', ['id', tf.id+'_col_'+k]);
let createColTags = function () {
for (let k = (tf.nbCells - 1); k >= 0; k--) {
let col = Dom.create('col', ['id', tf.id + '_col_' + k]);
tbl.insertBefore(col, tbl.firstChild);
col.style.width = tf.colWidths[k];
this.gridColElms[k] = col;
@ -278,12 +278,12 @@ export class GridLayout extends Feature{
this.tblHasColTag = true;
};
if(!this.tblHasColTag){
if (!this.tblHasColTag) {
createColTags.call(this);
} else {
let cols = Dom.tag(tbl, 'col');
for(let ii=0; ii<tf.nbCells; ii++){
cols[ii].setAttribute('id', tf.id+'_col_'+ii);
for (let ii = 0; ii < tf.nbCells; ii++) {
cols[ii].setAttribute('id', tf.id + '_col_' + ii);
cols[ii].style.width = tf.colWidths[ii];
this.gridColElms.push(cols[ii]);
}
@ -291,8 +291,8 @@ export class GridLayout extends Feature{
let afterColResizedFn = isFn(f.on_after_col_resized) ?
f.on_after_col_resized : null;
f.on_after_col_resized = function(o, colIndex){
if(!colIndex){
f.on_after_col_resized = function (o, colIndex) {
if (!colIndex) {
return;
}
let w = o.crWColsRow.cells[colIndex].style.width;
@ -302,21 +302,21 @@ export class GridLayout extends Feature{
let thCW = o.crWColsRow.cells[colIndex].clientWidth;
let tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth;
if(thCW != tdCW){
o.headTbl.style.width = tbl.clientWidth+'px';
if (thCW !== tdCW) {
o.headTbl.style.width = tbl.clientWidth + 'px';
}
if(afterColResizedFn){
if (afterColResizedFn) {
afterColResizedFn.call(null, o, colIndex);
}
};
if(tf.popupFilters){
if (tf.popupFilters) {
filtersRow.style.display = NONE;
}
if(tbl.clientWidth !== this.headTbl.clientWidth){
tbl.style.width = this.headTbl.clientWidth+'px';
if (tbl.clientWidth !== this.headTbl.clientWidth) {
tbl.style.width = this.headTbl.clientWidth + 'px';
}
this.initialized = true;
@ -325,11 +325,11 @@ export class GridLayout extends Feature{
/**
* Removes the grid layout
*/
destroy(){
destroy() {
let tf = this.tf;
let tbl = tf.tbl;
if(!this.initialized){
if (!this.initialized) {
return;
}
let t = Dom.remove(tbl);

View file

@ -472,7 +472,7 @@ export class TableFilter {
if (!this.gridLayout) {
fltrow.appendChild(fltcell);
}
inpclass = (i == n - 1 && this.displayBtn) ?
inpclass = (i === n - 1 && this.displayBtn) ?
this.fltSmallCssClass : this.fltCssClass;
//only 1 input for single search
@ -499,7 +499,7 @@ export class TableFilter {
}
// this adds submit button
if (i == n - 1 && this.displayBtn) {
if (i === n - 1 && this.displayBtn) {
this._buildSubmitButton(i, fltcell);
}
@ -1092,7 +1092,7 @@ export class TableFilter {
*/
isCustomOptions(colIndex) {
return this.hasCustomOptions &&
this.customOptions.cols.indexOf(colIndex) != -1;
this.customOptions.cols.indexOf(colIndex) !== -1;
}
/**
@ -1252,12 +1252,12 @@ export class TableFilter {
// different date
else if (isDFDate) {
dte2 = DateHelper.format(sA.replace(re_d, ''), dtType);
occurence = dte1.toString() != dte2.toString();
occurence = dte1.toString() !== dte2.toString();
}
// equal date
else if (isEQDate) {
dte2 = DateHelper.format(sA.replace(re_eq, ''), dtType);
occurence = dte1.toString() == dte2.toString();
occurence = dte1.toString() === dte2.toString();
}
// searched keyword with * operator doesn't have to be a date
else if (re_lk.test(sA)) {// like date
@ -1515,7 +1515,7 @@ export class TableFilter {
let isExludedRow = false;
// checks if current row index appears in exclude array
if (exclude.length > 0) {
isExludedRow = exclude.indexOf(i) != -1;
isExludedRow = exclude.indexOf(i) !== -1;
}
let cell = row[i].cells,
nchilds = cell.length;
@ -1524,7 +1524,7 @@ export class TableFilter {
if (nchilds === this.nbCells && !isExludedRow) {
// this loop retrieves cell data
for (let j = 0; j < nchilds; j++) {
if (j != colIndex || row[i].style.display !== '') {
if (j !== colIndex || row[i].style.display !== '') {
continue;
}
let cellData = this.getCellData(cell[j]),
@ -1674,7 +1674,8 @@ export class TableFilter {
getCellData(cell) {
let idx = cell.cellIndex;
//Check for customCellData callback
if (this.customCellData && this.customCellDataCols.indexOf(idx) != -1) {
if (this.customCellData &&
this.customCellDataCols.indexOf(idx) !== -1) {
return this.customCellData.call(null, this, cell, idx);
} else {
return Dom.getText(cell);
@ -2058,10 +2059,10 @@ export class TableFilter {
// Welcome to cyclomatic complexity hell :)
// TODO: simplify/refactor if statement
if (activeIdx !== slcIndex[i] ||
(this.paging && slcA1.indexOf(slcIndex[i]) != -1 &&
(this.paging && slcA1.indexOf(slcIndex[i]) !== -1 &&
activeIdx === slcIndex[i]) ||
(!this.paging && (slcA3.indexOf(slcIndex[i]) != -1 ||
slcA2.indexOf(slcIndex[i]) != -1)) ||
(!this.paging && (slcA3.indexOf(slcIndex[i]) !== -1 ||
slcA2.indexOf(slcIndex[i]) !== -1)) ||
slcSelectedValue === this.displayAllText) {
//1st option needs to be inserted
@ -2071,7 +2072,7 @@ export class TableFilter {
curSlc.appendChild(opt0);
}
if (slcA3.indexOf(slcIndex[i]) != -1) {
if (slcA3.indexOf(slcIndex[i]) !== -1) {
this.emitter.emit('build-checklist-filter', this,
slcIndex[i]);
} else {
@ -2104,7 +2105,7 @@ export class TableFilter {
isImported(filePath, type) {
let imported = false,
importType = !type ? 'script' : type,
attr = importType == 'script' ? 'src' : 'href',
attr = importType === 'script' ? 'src' : 'href',
files = Dom.tag(doc, importType);
for (let i = 0, len = files.length; i < len; i++) {
if (files[i][attr] === undefined) {