1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-23 00:32:21 +02:00

Changed var into let

This commit is contained in:
Max Guglielmi 2015-05-30 22:23:33 +10:00
parent ec79d1410a
commit 36dd10fda8
28 changed files with 723 additions and 739 deletions

View file

@ -2,11 +2,11 @@
* Array utilities * Array utilities
*/ */
import {Str} from './string'; import Str from './string';
var Arr = { export default {
has: function(arr, val, caseSensitive){ has: function(arr, val, caseSensitive){
var sCase = caseSensitive===undefined ? false : caseSensitive; let sCase = caseSensitive===undefined ? false : caseSensitive;
for (var i=0; i<arr.length; i++){ for (var i=0; i<arr.length; i++){
if(Str.matchCase(arr[i].toString(), sCase) == val){ if(Str.matchCase(arr[i].toString(), sCase) == val){
return true; return true;
@ -15,7 +15,7 @@ var Arr = {
return false; return false;
}, },
indexByValue: function(arr, val, caseSensitive){ indexByValue: function(arr, val, caseSensitive){
var sCase = caseSensitive===undefined ? false : caseSensitive; let sCase = caseSensitive===undefined ? false : caseSensitive;
for (var i=0; i<arr.length; i++){ for (var i=0; i<arr.length; i++){
if(Str.matchCase(arr[i].toString(), sCase) == val){ if(Str.matchCase(arr[i].toString(), sCase) == val){
return i; return i;
@ -24,5 +24,3 @@ var Arr = {
return -1; return -1;
} }
}; };
exports.Arr = Arr;

View file

@ -2,57 +2,57 @@
* Cookie utilities * Cookie utilities
*/ */
var Cookie = {}; export default {
Cookie.write = function(name, value, hours){ write(name, value, hours){
var expire = ''; let expire = '';
if(hours){ if(hours){
expire = new Date((new Date()).getTime() + hours * 3600000); expire = new Date((new Date()).getTime() + hours * 3600000);
expire = '; expires=' + expire.toGMTString(); expire = '; expires=' + expire.toGMTString();
}
document.cookie = name + '=' + escape(value) + expire;
};
Cookie.read = function(name){
var cookieValue = '',
search = name + '=';
if(document.cookie.length > 0){
var cookie = document.cookie,
offset = cookie.indexOf(search);
if(offset !== -1){
offset += search.length;
var end = cookie.indexOf(';', offset);
if(end === -1){
end = cookie.length;
}
cookieValue = unescape(cookie.substring(offset, end));
} }
document.cookie = name + '=' + escape(value) + expire;
},
read(name){
let cookieValue = '',
search = name + '=';
if(document.cookie.length > 0){
let cookie = document.cookie,
offset = cookie.indexOf(search);
if(offset !== -1){
offset += search.length;
let end = cookie.indexOf(';', offset);
if(end === -1){
end = cookie.length;
}
cookieValue = unescape(cookie.substring(offset, end));
}
}
return cookieValue;
},
remove(name){
this.write(name, '', -1);
},
valueToArray(name, separator){
if(!separator){
separator = ',';
}
//reads the cookie
let val = this.read(name);
//creates an array with filters' values
let arr = val.split(separator);
return arr;
},
getValueByIndex(name, index, separator){
if(!separator){
separator = ',';
}
//reads the cookie
let val = this.valueToArray(name, separator);
return val[index];
} }
return cookieValue;
};
Cookie.remove = function(name){
this.write(name, '', -1);
}; };
Cookie.valueToArray = function(name, separator){
if(!separator){
separator = ',';
}
//reads the cookie
var val = this.read(name);
//creates an array with filters' values
var arr = val.split(separator);
return arr;
};
Cookie.getValueByIndex = function(name, index, separator){
if(!separator){
separator = ',';
}
//reads the cookie
var val = this.valueToArray(name, separator);
return val[index];
};
exports.Cookie = Cookie;

View file

@ -2,15 +2,15 @@
* Date utilities * Date utilities
*/ */
var DateHelper = { export default {
isValid: function(dateStr, format){ isValid(dateStr, format){
if(!format) { if(!format) {
format = 'DMY'; format = 'DMY';
} }
format = format.toUpperCase(); format = format.toUpperCase();
if(format.length != 3) { if(format.length != 3) {
if(format==='DDMMMYYYY'){ if(format==='DDMMMYYYY'){
var d = this.format(dateStr, format); let d = this.format(dateStr, format);
dateStr = d.getDate() +'/'+ (d.getMonth()+1) +'/'+ dateStr = d.getDate() +'/'+ (d.getMonth()+1) +'/'+
d.getFullYear(); d.getFullYear();
format = 'DMY'; format = 'DMY';
@ -20,7 +20,7 @@ var DateHelper = {
(format.indexOf('Y') === -1)){ (format.indexOf('Y') === -1)){
format = 'DMY'; format = 'DMY';
} }
var reg1, reg2; let reg1, reg2;
// If the year is first // If the year is first
if(format.substring(0, 1) == 'Y') { if(format.substring(0, 1) == 'Y') {
reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/; reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;
@ -38,8 +38,8 @@ var DateHelper = {
return false; return false;
} }
// Split into 3 parts based on what the divider was // Split into 3 parts based on what the divider was
var parts = dateStr.split(RegExp.$1); let parts = dateStr.split(RegExp.$1);
var mm, dd, yy; let mm, dd, yy;
// Check to see if the 3 parts end up making a valid date // Check to see if the 3 parts end up making a valid date
if(format.substring(0, 1) === 'M'){ if(format.substring(0, 1) === 'M'){
mm = parts[0]; mm = parts[0];
@ -68,7 +68,7 @@ var DateHelper = {
if(parseInt(yy, 10) <= 99){ if(parseInt(yy, 10) <= 99){
yy = (parseInt(yy, 10) + 1900).toString(); yy = (parseInt(yy, 10) + 1900).toString();
} }
var dt = new Date( let dt = new Date(
parseInt(yy, 10), parseInt(mm, 10)-1, parseInt(dd, 10), parseInt(yy, 10), parseInt(mm, 10)-1, parseInt(dd, 10),
0, 0, 0, 0); 0, 0, 0, 0);
if(parseInt(dd, 10) != dt.getDate()){ if(parseInt(dd, 10) != dt.getDate()){
@ -79,16 +79,16 @@ var DateHelper = {
} }
return true; return true;
}, },
format: function(dateStr, format) { format(dateStr, formatStr) {
if(!format){ if(!formatStr){
format = 'DMY'; formatStr = 'DMY';
} }
if(!dateStr || dateStr === ''){ if(!dateStr || dateStr === ''){
return new Date(1001, 0, 1); return new Date(1001, 0, 1);
} }
var oDate; let oDate;
switch(format.toUpperCase()){ switch(formatStr.toUpperCase()){
case 'DDMMMYYYY': case 'DDMMMYYYY':
parts = dateStr.replace(/[- \/.]/g,' ').split(' '); parts = dateStr.replace(/[- \/.]/g,' ').split(' ');
oDate = new Date(y2kDate(parts[2]),mmm2mm(parts[1])-1,parts[0]); oDate = new Date(y2kDate(parts[2]),mmm2mm(parts[1])-1,parts[0]);
@ -131,7 +131,7 @@ function y2kDate(yr){
if(yr.length>2){ if(yr.length>2){
return yr; return yr;
} }
var y; let y;
//>50 belong to 1900 //>50 belong to 1900
if(yr <= 99 && yr>50){ if(yr <= 99 && yr>50){
y = '19' + yr; y = '19' + yr;
@ -147,15 +147,15 @@ function mmm2mm(mmm){
if(mmm === undefined){ if(mmm === undefined){
return 0; return 0;
} }
var mondigit; let mondigit;
var MONTH_NAMES = [ let MONTH_NAMES = [
'january','february','march','april','may','june','july', 'january','february','march','april','may','june','july',
'august','september','october','november','december', 'august','september','october','november','december',
'jan','feb','mar','apr','may','jun','jul','aug','sep','oct', 'jan','feb','mar','apr','may','jun','jul','aug','sep','oct',
'nov','dec' 'nov','dec'
]; ];
for(var m_i=0; m_i < MONTH_NAMES.length; m_i++){ for(let m_i=0; m_i < MONTH_NAMES.length; m_i++){
var month_name = MONTH_NAMES[m_i]; let month_name = MONTH_NAMES[m_i];
if (mmm.toLowerCase() === month_name){ if (mmm.toLowerCase() === month_name){
mondigit = m_i+1; mondigit = m_i+1;
break; break;
@ -169,5 +169,3 @@ function mmm2mm(mmm){
} }
return mondigit; return mondigit;
} }
exports.DateHelper = DateHelper;

View file

@ -2,158 +2,157 @@
* DOM utilities * DOM utilities
*/ */
var Dom = {}; export default {
/** /**
* Returns text + text of children of given node * Returns text + text of children of given node
* @param {NodeElement} node * @param {NodeElement} node
* @return {String} * @return {String}
*/ */
Dom.getText = function(node){ getText(node){
var s = node.textContent || node.innerText || let s = node.textContent || node.innerText ||
node.innerHTML.replace(/<[^<>]+>/g, ''); node.innerHTML.replace(/<[^<>]+>/g, '');
s = s.replace(/^\s+/, '').replace(/\s+$/, ''); s = s.replace(/^\s+/, '').replace(/\s+$/, '');
return s; return s;
}; },
/** /**
* Creates an html element with given collection of attributes * Creates an html element with given collection of attributes
* @param {String} tag a string of the html tag to create * @param {String} tag a string of the html tag to create
* @param {Array} an undetermined number of arrays containing the with 2 * @param {Array} an undetermined number of arrays containing the with 2
* items, the attribute name and its value ['id','myId'] * items, the attribute name and its value ['id','myId']
* @return {Object} created element * @return {Object} created element
*/ */
Dom.create = function(tag){ create(tag){
if(!tag || tag===''){ if(!tag || tag===''){
return; return;
} }
var el = document.createElement(tag), let el = document.createElement(tag),
args = arguments; args = arguments;
if(args.length > 1){ if(args.length > 1){
for(var i=0; i<args.length; i++){ for(let i=0; i<args.length; i++){
var argtype = typeof args[i]; let argtype = typeof args[i];
if(argtype.toLowerCase() === 'object' && args[i].length === 2){ if(argtype.toLowerCase() === 'object' && args[i].length === 2){
el.setAttribute(args[i][0], args[i][1]); el.setAttribute(args[i][0], args[i][1]);
}
} }
} }
return el;
},
/**
* Returns a text node with given text
* @param {String} text
* @return {Object}
*/
text(text){
return document.createTextNode(text);
},
/**
* Returns offset position of passed element
* @param {object} obj [description]
* @return {object} literal object with left and top values
*/
position(obj){
let l = 0, t = 0;
if (obj && obj.offsetParent){
do {
l += obj.offsetLeft;
t += obj.offsetTop;
} while (obj == obj.offsetParent);
}
return { 'left': l, 'top': t };
},
hasClass(ele, cls){
if(!ele){ return false; }
if(supportsClassList()){
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp('(\\s|^)'+ cls +'(\\s|$)'));
},
addClass(ele, cls){
if(!ele){ return; }
if(supportsClassList()){
ele.classList.add(cls);
return;
}
if(ele.className === ''){
ele.className = cls;
}
else if(!this.hasClass(ele, cls)){
ele.className += " " + cls;
}
},
removeClass(ele, cls){
if(!ele){ return; }
if(supportsClassList()){
ele.classList.remove(cls);
return;
}
let reg = new RegExp('(\\s|^)'+ cls +'(\\s|$)', 'g');
ele.className = ele.className.replace(reg, '');
},
/**
* Creates and returns an option element
* @param {String} text option text
* @param {String} value option value
* @param {Boolean} isSel whether option is selected
* @return {Object} option element
*/
createOpt(text, value, isSel){
let isSelected = isSel ? true : false,
opt = isSelected ?
this.create('option', ['value',value], ['selected','true']) :
this.create('option', ['value',value]);
opt.appendChild(this.text(text));
return opt;
},
/**
* Creates and returns a checklist item
* @param {Number} chkIndex index of check item
* @param {String} chkValue check item value
* @param {String} labelText check item label text
* @return {Object} li DOM element
*/
createCheckItem(chkIndex, chkValue, labelText){
let li = this.create('li'),
label = this.create('label', ['for', chkIndex]),
check = this.create('input',
['id', chkIndex],
['name', chkIndex],
['type', 'checkbox'],
['value', chkValue]
);
label.appendChild(check);
label.appendChild(this.text(labelText));
li.appendChild(label);
li.label = label;
li.check = check;
return li;
},
id(_id){
return document.getElementById(_id);
},
tag(o, tagname){
return o.getElementsByTagName(tagname);
} }
return el;
};
/**
* Returns a text node with given text
* @param {String} text
* @return {Object}
*/
Dom.text = function(text){
return document.createTextNode(text);
};
/**
* Returns offset position of passed element
* @param {object} obj [description]
* @return {object} literal object with left and top values
*/
Dom.position = function(obj){
var l = 0, t = 0;
if (obj && obj.offsetParent){
do {
l += obj.offsetLeft;
t += obj.offsetTop;
} while (obj == obj.offsetParent);
}
return { 'left': l, 'top': t };
};
Dom.hasClass = function (ele, cls){
if(!ele){ return false; }
if(supportsClassList()){
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp('(\\s|^)'+ cls +'(\\s|$)'));
};
Dom.addClass = function (ele, cls){
if(!ele){ return; }
if(supportsClassList()){
ele.classList.add(cls);
return;
}
if(ele.className === ''){
ele.className = cls;
}
else if(!this.hasClass(ele, cls)){
ele.className += " " + cls;
}
};
Dom.removeClass = function (ele, cls){
if(!ele){ return; }
if(supportsClassList()){
ele.classList.remove(cls);
return;
}
var reg = new RegExp('(\\s|^)'+ cls +'(\\s|$)', 'g');
ele.className = ele.className.replace(reg, '');
};
/**
* Creates and returns an option element
* @param {String} text option text
* @param {String} value option value
* @param {Boolean} isSel whether option is selected
* @return {Object} option element
*/
Dom.createOpt = function(text, value, isSel){
var isSelected = isSel ? true : false,
opt = isSelected ?
this.create('option', ['value',value], ['selected','true']) :
this.create('option', ['value',value]);
opt.appendChild(this.text(text));
return opt;
};
/**
* Creates and returns a checklist item
* @param {Number} chkIndex index of check item
* @param {String} chkValue check item value
* @param {String} labelText check item label text
* @return {Object} li DOM element
*/
Dom.createCheckItem = function(chkIndex, chkValue, labelText){
var li = this.create('li'),
label = this.create('label', ['for', chkIndex]),
check = this.create('input',
['id', chkIndex],
['name', chkIndex],
['type', 'checkbox'],
['value', chkValue]
);
label.appendChild(check);
label.appendChild(this.text(labelText));
li.appendChild(label);
li.label = label;
li.check = check;
return li;
};
Dom.id = function(id){
return document.getElementById(id);
};
Dom.tag = function(o, tagname){
return o.getElementsByTagName(tagname);
}; };
// HTML5 classList API // HTML5 classList API
function supportsClassList(){ function supportsClassList(){
return document.documentElement.classList; return document.documentElement.classList;
} }
exports.Dom = Dom;

View file

@ -2,7 +2,7 @@
* DOM event utilities * DOM event utilities
*/ */
export var Event = { export default {
add(obj, type, func, capture){ add(obj, type, func, capture){
if(obj.addEventListener){ if(obj.addEventListener){
obj.addEventListener(type, func, capture); obj.addEventListener(type, func, capture);

View file

@ -1,5 +1,5 @@
import {Dom} from '../../dom'; import Dom from '../../dom';
import {Arr} from '../../array'; import Arr from '../../array';
export default class AdapterEzEditTable { export default class AdapterEzEditTable {
/** /**

View file

@ -1,8 +1,8 @@
import {Dom} from '../../dom'; import Dom from '../../dom';
import {Types} from '../../types'; import Types from '../../types';
import {Event} from '../../event'; import Event from '../../event';
import {Helpers} from '../../helpers'; import Helpers from '../../helpers';
import {Arr} from '../../array'; import Arr from '../../array';
export default class ColsVisibility{ export default class ColsVisibility{

View file

@ -1,9 +1,9 @@
import {Types} from '../../types'; import Types from '../../types';
import {Dom} from '../../dom'; import Dom from '../../dom';
import {Arr} from '../../array'; import Arr from '../../array';
import {Event} from '../../event'; import Event from '../../event';
import {DateHelper} from '../../date'; import DateHelper from '../../date';
import {Helpers} from '../../helpers'; import Helpers from '../../helpers';
export default class AdapterSortableTable{ export default class AdapterSortableTable{

View file

@ -2,9 +2,9 @@
* Misc helpers * Misc helpers
*/ */
import {Str} from './string'; import Str from './string';
var Helpers = { export default {
isIE(){ isIE(){
return (/msie|MSIE/).test(navigator.userAgent); return (/msie|MSIE/).test(navigator.userAgent);
}, },
@ -16,7 +16,7 @@ var Helpers = {
if(!format){ if(!format){
format = 'us'; format = 'us';
} }
var n = data; let n = data;
if(Str.lower(format)==='us'){ if(Str.lower(format)==='us'){
n =+ n.replace(/[^\d\.-]/g,''); n =+ n.replace(/[^\d\.-]/g,'');
} else { } else {
@ -25,5 +25,3 @@ var Helpers = {
return n; return n;
} }
}; };
exports.Helpers = Helpers;

View file

@ -1,4 +1,4 @@
import {Dom} from '../dom'; import Dom from '../dom';
export class AlternateRows{ export class AlternateRows{

View file

@ -1,8 +1,8 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Arr as array} from '../array'; import Arr from '../array';
import {Str} from '../string'; import Str from '../string';
import {Sort} from '../sort'; import Sort from '../sort';
import {Event} from '../event'; import Event from '../event';
export class CheckList{ export class CheckList{
@ -96,7 +96,7 @@ export class CheckList{
var rows = tf.tbl.rows; var rows = tf.tbl.rows;
this.isCustom = (tf.hasCustomSlcOptions && this.isCustom = (tf.hasCustomSlcOptions &&
array.has(tf.customSlcOptions.cols, colIndex)); Arr.has(tf.customSlcOptions.cols, colIndex));
var activeFlt; var activeFlt;
if(tf.refreshFilters && tf.activeFilterId){ if(tf.refreshFilters && tf.activeFilterId){
@ -113,7 +113,7 @@ export class CheckList{
for(var k=tf.refRow; k<tf.nbRows; k++){ for(var k=tf.refRow; k<tf.nbRows; k++){
// always visible rows don't need to appear on selects as always // always visible rows don't need to appear on selects as always
// valid // valid
if(tf.hasVisibleRows && array.has(tf.visibleRows, k) && !tf.paging){ if(tf.hasVisibleRows && Arr.has(tf.visibleRows, k) && !tf.paging){
continue; continue;
} }
@ -133,13 +133,13 @@ export class CheckList{
((rows[k].style.display === '' && !tf.paging) || ((rows[k].style.display === '' && !tf.paging) ||
(tf.paging && ((!activeFlt || activeFlt===colIndex )|| (tf.paging && ((!activeFlt || activeFlt===colIndex )||
(activeFlt!=colIndex && (activeFlt!=colIndex &&
array.has(tf.validRowsIndex, k))) )))){ Arr.has(tf.validRowsIndex, k))) )))){
var cell_data = tf.getCellData(j, cells[j]); var cell_data = tf.getCellData(j, cells[j]);
//Vary Peter's patch //Vary Peter's patch
var cell_string = Str.matchCase( var cell_string = Str.matchCase(
cell_data, tf.matchCase); cell_data, tf.matchCase);
// checks if celldata is already in array // checks if celldata is already in array
if(!array.has(this.opts, cell_string, tf.matchCase)){ if(!Arr.has(this.opts, cell_string, tf.matchCase)){
this.opts.push(cell_data); this.opts.push(cell_data);
} }
var filteredCol = filteredDataCol[j]; var filteredCol = filteredDataCol[j];
@ -147,9 +147,9 @@ export class CheckList{
if(!filteredCol){ if(!filteredCol){
filteredDataCol[j] = tf.GetFilteredDataCol(j); filteredDataCol[j] = tf.GetFilteredDataCol(j);
} }
if(!array.has(filteredCol, if(!Arr.has(filteredCol,
cell_string, tf.matchCase) && cell_string, tf.matchCase) &&
!array.has(excludedOpts, !Arr.has(excludedOpts,
cell_string, tf.matchCase) && cell_string, tf.matchCase) &&
!tf.isFirstLoad){ !tf.isFirstLoad){
excludedOpts.push(cell_data); excludedOpts.push(cell_data);
@ -180,7 +180,7 @@ export class CheckList{
} }
} }
//asc sort //asc sort
if(tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)){ if(tf.sortNumAsc && Arr.has(tf.sortNumAsc, colIndex)){
try{ try{
this.opts.sort(numSortAsc); this.opts.sort(numSortAsc);
if(excludedOpts){ if(excludedOpts){
@ -200,7 +200,7 @@ export class CheckList{
}//in case there are alphanumeric values }//in case there are alphanumeric values
} }
//desc sort //desc sort
if(tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)){ if(tf.sortNumDesc && Arr.has(tf.sortNumDesc, colIndex)){
try{ try{
this.opts.sort(numSortDesc); this.opts.sort(numSortDesc);
if(excludedOpts){ if(excludedOpts){
@ -242,7 +242,7 @@ export class CheckList{
store.getFilterValues(tf.fltsValuesCookie)[colIndex] : null; store.getFilterValues(tf.fltsValuesCookie)[colIndex] : null;
if(tmpVal && Str.trim(tmpVal).length > 0){ if(tmpVal && Str.trim(tmpVal).length > 0){
if(tf.hasCustomSlcOptions && if(tf.hasCustomSlcOptions &&
array.has(tf.customSlcOptions.cols, colIndex)){ Arr.has(tf.customSlcOptions.cols, colIndex)){
fltArr.push(tmpVal); fltArr.push(tmpVal);
} else { } else {
fltArr = tmpVal.split(' '+tf.orOperator+' '); fltArr = tmpVal.split(' '+tf.orOperator+' ');
@ -256,7 +256,7 @@ export class CheckList{
tf.fltIds[colIndex]+'_'+(y+chkCt), val, lbl); tf.fltIds[colIndex]+'_'+(y+chkCt), val, lbl);
li.className = this.checkListItemCssClass; li.className = this.checkListItemCssClass;
if(tf.refreshFilters && tf.disableExcludedOptions && if(tf.refreshFilters && tf.disableExcludedOptions &&
array.has(excludedOpts, Arr.has(excludedOpts,
Str.matchCase(val, tf.matchCase), tf.matchCase)){ Str.matchCase(val, tf.matchCase), tf.matchCase)){
Dom.addClass(li, this.checkListItemDisabledCssClass); Dom.addClass(li, this.checkListItemDisabledCssClass);
li.check.disabled = true; li.check.disabled = true;
@ -276,9 +276,9 @@ export class CheckList{
/*** remember grid values ***/ /*** remember grid values ***/
if(tf.rememberGridValues){ if(tf.rememberGridValues){
if((tf.hasCustomSlcOptions && if((tf.hasCustomSlcOptions &&
array.has(tf.customSlcOptions.cols, colIndex) && Arr.has(tf.customSlcOptions.cols, colIndex) &&
fltArr.toString().indexOf(val)!= -1) || fltArr.toString().indexOf(val)!= -1) ||
array.has(fltArr, Arr.has(fltArr,
Str.matchCase(val, tf.matchCase), tf.matchCase)){ Str.matchCase(val, tf.matchCase), tf.matchCase)){
li.check.checked = true; li.check.checked = true;
this.setCheckListValues(li.check); this.setCheckListValues(li.check);

View file

@ -1,5 +1,5 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Event} from '../event'; import Event from '../event';
export class ClearButton{ export class ClearButton{

View file

@ -1,6 +1,6 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Str} from '../string'; import Str from '../string';
import {Types} from '../types'; import Types from '../types';
export class ColOps{ export class ColOps{

View file

@ -1,7 +1,7 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Arr as array} from '../array'; import Arr from '../array';
import {Str} from '../string'; import Str from '../string';
import {Sort} from '../sort'; import Sort from '../sort';
export class Dropdown{ export class Dropdown{
@ -79,7 +79,7 @@ export class Dropdown{
//custom select test //custom select test
this.isCustom = (tf.hasCustomSlcOptions && this.isCustom = (tf.hasCustomSlcOptions &&
array.has(tf.customSlcOptions.cols, colIndex)); Arr.has(tf.customSlcOptions.cols, colIndex));
//custom selects text //custom selects text
var activeFlt; var activeFlt;
@ -111,7 +111,7 @@ export class Dropdown{
for(var k=tf.refRow; k<tf.nbRows; k++){ for(var k=tf.refRow; k<tf.nbRows; k++){
// always visible rows don't need to appear on selects as always // always visible rows don't need to appear on selects as always
// valid // valid
if(tf.hasVisibleRows && array.has(tf.visibleRows, k) && if(tf.hasVisibleRows && Arr.has(tf.visibleRows, k) &&
!tf.paging){ !tf.paging){
continue; continue;
} }
@ -133,16 +133,16 @@ export class Dropdown{
((rows[k].style.display === '' && !tf.paging) || ((rows[k].style.display === '' && !tf.paging) ||
(tf.paging && (!tf.validRowsIndex || (tf.paging && (!tf.validRowsIndex ||
(tf.validRowsIndex && (tf.validRowsIndex &&
array.has(tf.validRowsIndex, k))) && Arr.has(tf.validRowsIndex, k))) &&
((activeFlt===undefined || activeFlt==colIndex) || ((activeFlt===undefined || activeFlt==colIndex) ||
(activeFlt!=colIndex && (activeFlt!=colIndex &&
array.has(tf.validRowsIndex, k) ))) ))){ Arr.has(tf.validRowsIndex, k) ))) ))){
var cell_data = tf.getCellData(j, cell[j]), var cell_data = tf.getCellData(j, cell[j]),
//Vary Peter's patch //Vary Peter's patch
cell_string = Str.matchCase(cell_data, matchCase); cell_string = Str.matchCase(cell_data, matchCase);
// checks if celldata is already in array // checks if celldata is already in array
if(!array.has(this.opts, cell_string, matchCase)){ if(!Arr.has(this.opts, cell_string, matchCase)){
this.opts.push(cell_data); this.opts.push(cell_data);
} }
@ -151,8 +151,8 @@ export class Dropdown{
if(!filteredCol){ if(!filteredCol){
filteredCol = this.GetFilteredDataCol(j); filteredCol = this.GetFilteredDataCol(j);
} }
if(!array.has(filteredCol, cell_string, matchCase) && if(!Arr.has(filteredCol, cell_string, matchCase) &&
!array.has( !Arr.has(
excludedOpts, cell_string, matchCase) && excludedOpts, cell_string, matchCase) &&
!this.isFirstLoad){ !this.isFirstLoad){
excludedOpts.push(cell_data); excludedOpts.push(cell_data);
@ -182,7 +182,7 @@ export class Dropdown{
} }
//asc sort //asc sort
if(tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)){ if(tf.sortNumAsc && Arr.has(tf.sortNumAsc, colIndex)){
try{ try{
this.opts.sort( numSortAsc ); this.opts.sort( numSortAsc );
if(excludedOpts){ if(excludedOpts){
@ -202,7 +202,7 @@ export class Dropdown{
}//in case there are alphanumeric values }//in case there are alphanumeric values
} }
//desc sort //desc sort
if(tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)){ if(tf.sortNumDesc && Arr.has(tf.sortNumDesc, colIndex)){
try{ try{
this.opts.sort(numSortDesc); this.opts.sort(numSortDesc);
if(excludedOpts){ if(excludedOpts){
@ -252,7 +252,7 @@ export class Dropdown{
var lbl = this.isCustom ? this.optsTxt[y] : val; //option text var lbl = this.isCustom ? this.optsTxt[y] : val; //option text
var isDisabled = false; var isDisabled = false;
if(isRefreshed && this.disableExcludedOptions && if(isRefreshed && this.disableExcludedOptions &&
array.has( Arr.has(
excludedOpts, excludedOpts,
Str.matchCase(val, tf.matchCase), Str.matchCase(val, tf.matchCase),
tf.matchCase tf.matchCase
@ -286,7 +286,7 @@ export class Dropdown{
opt = Dom.createOpt( opt = Dom.createOpt(
lbl, lbl,
val, val,
(array.has(fltArr, (Arr.has(fltArr,
Str.matchCase(this.opts[y], tf.matchCase), Str.matchCase(this.opts[y], tf.matchCase),
tf.matchCase) || tf.matchCase) ||
fltArr.toString().indexOf(val)!== -1) ? fltArr.toString().indexOf(val)!== -1) ?

View file

@ -1,6 +1,6 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Types} from '../types'; import Types from '../types';
import {Event} from '../event'; import Event from '../event';
export class GridLayout{ export class GridLayout{

View file

@ -1,5 +1,5 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Event} from '../event'; import Event from '../event';
export class Help{ export class Help{

View file

@ -1,5 +1,5 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Str} from '../string'; import Str from '../string';
export class HighlightKeyword{ export class HighlightKeyword{

View file

@ -1,6 +1,5 @@
import Dom from '../dom';
import {Dom} from '../dom'; import Types from '../types';
import {Types} from '../types';
var global = window; var global = window;

View file

@ -1,7 +1,7 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Types} from '../types'; import Types from '../types';
import {Str} from '../string'; import Str from '../string';
import {Event} from '../event'; import Event from '../event';
export class Paging{ export class Paging{

View file

@ -1,7 +1,7 @@
import {Types} from '../types'; import Types from '../types';
import {Dom} from '../dom'; import Dom from '../dom';
import {Event} from '../event'; import Event from '../event';
import {Helpers} from '../helpers'; import Helpers from '../helpers';
export class PopupFilter{ export class PopupFilter{

View file

@ -1,6 +1,6 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Types} from '../types'; import Types from '../types';
import {Helpers} from '../helpers'; import Helpers from '../helpers';
export class RowsCounter{ export class RowsCounter{

View file

@ -1,6 +1,6 @@
import {Dom} from '../dom'; import Dom from '../dom';
import {Types} from '../types'; import Types from '../types';
import {Helpers} from '../helpers'; import Helpers from '../helpers';
var global = window; var global = window;

View file

@ -1,4 +1,4 @@
import {Cookie} from '../cookie'; import Cookie from '../cookie';
export class Store{ export class Store{

View file

@ -1,15 +1,9 @@
/** import Str from './string';
* Sort helpers
*/
import {Str} from './string'; export default {
var Sort = {
ignoreCase(a, b){ ignoreCase(a, b){
var x = Str.lower(a); let x = Str.lower(a);
var y = Str.lower(b); let y = Str.lower(b);
return ((x < y) ? -1 : ((x > y) ? 1 : 0)); return ((x < y) ? -1 : ((x > y) ? 1 : 0));
} }
}; };
exports.Sort = Sort;

View file

@ -2,45 +2,45 @@
* String utilities * String utilities
*/ */
var Str = {}; export default {
Str.lower = function(text){ lower(text){
return text.toLowerCase(); return text.toLowerCase();
}; },
Str.upper = function(text){ upper(text){
return text.toUpperCase(); return text.toUpperCase();
}; },
Str.trim = function(text){ trim(text){
if (text.trim){ if (text.trim){
return text.trim(); return text.trim();
} }
return text.replace(/^\s*|\s*$/g, ''); return text.replace(/^\s*|\s*$/g, '');
}; },
Str.isEmpty = function(text){ isEmpty(text){
return this.trim(text) === ''; return this.trim(text) === '';
}; },
Str.rgxEsc = function(text){ rgxEsc(text){
function escape(e){ function escape(e){
var a = new RegExp('\\'+e, 'g'); let a = new RegExp('\\'+e, 'g');
text = text.replace(a, '\\'+e); text = text.replace(a, '\\'+e);
}
let chars = ['\\','[','^','$','.','|','?','*','+','(',')'];
for(let e=0, len=chars.length; e<len; e++){
escape(chars[e]);
}
return text;
},
matchCase(text, mc){
if(!mc){
return this.lower(text);
}
return text;
} }
var chars = ['\\','[','^','$','.','|','?','*','+','(',')'];
for(var e=0; e<chars.length; e++){
escape(chars[e]);
}
return text;
}; };
Str.matchCase = function(text, mc){
if(!mc){
return this.lower(text);
}
return text;
};
exports.Str = Str;

File diff suppressed because it is too large Load diff

View file

@ -2,54 +2,53 @@
* Types utilities * Types utilities
*/ */
var Types = {}; const UNDEFINED = void 0;
var UNDEFINED = void 0; export default {
/**
* Checks if var exists and is an object
* @param {String or Object} v
* @return {Boolean}
*/
isObj(v){
let isO = false;
if(typeof v === 'string'){
if(window[v] && typeof window[v] === 'object'){
isO = true;
}
} else {
if(v && typeof v === 'object'){
isO = true;
}
}
return isO;
},
/** /**
* Checks if var exists and is an object * Checks if passed parameter is a function
* @param {String or Object} v * @param {Function} fn
* @return {Boolean} * @return {Boolean}
*/ */
Types.isObj = function(v){ isFn(fn){
var isO = false; return (fn && fn.constructor == Function);
if(typeof v === 'string'){ },
if(window[v] && typeof window[v] === 'object'){
isO = true; /**
} * Checks if passed param is an array
} else { * @param {Array} obj
if(v && typeof v === 'object'){ * @return {Boolean}
isO = true; */
} isArray(obj){
return (obj && obj.constructor == Array);
},
/**
* Determines if passed param is undefined
* @param {Any} o
* @return {Boolean}
*/
isUndef(o){
return o === UNDEFINED;
} }
return isO;
};
/**
* Checks if passed parameter is a function
* @param {Function} fn
* @return {Boolean}
*/
Types.isFn = function(fn){
return (fn && fn.constructor == Function);
}; };
/**
* Checks if passed param is an array
* @param {Array} obj
* @return {Boolean}
*/
Types.isArray = function(obj){
return (obj && obj.constructor == Array);
};
/**
* Determines if passed param is undefined
* @param {Any} o
* @return {Boolean}
*/
Types.isUndef = function(o){
return o === UNDEFINED;
};
exports.Types = Types;

View file

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