mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-10 10:26:38 +02:00
Refactored types module
This commit is contained in:
parent
25b1a6cd5b
commit
0d58349432
4
dist/starter.html
vendored
4
dist/starter.html
vendored
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>tablefilter v0.2.25 - Starter</title>
|
||||
<title>tablefilter v0.2.26 - Starter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>tablefilter v0.2.25</h1>
|
||||
<h1>tablefilter v0.2.26</h1>
|
||||
|
||||
|
||||
|
||||
|
|
4
dist/tablefilter/style/colsVisibility.css
vendored
4
dist/tablefilter/style/colsVisibility.css
vendored
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.25 by Max Guglielmi
|
||||
* build date: 2016-05-14T12:05:12.318Z
|
||||
* tablefilter v0.2.26 by Max Guglielmi
|
||||
* build date: 2016-05-15T02:51:02.911Z
|
||||
* 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}
|
4
dist/tablefilter/style/filtersVisibility.css
vendored
4
dist/tablefilter/style/filtersVisibility.css
vendored
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.25 by Max Guglielmi
|
||||
* build date: 2016-05-14T12:05:12.318Z
|
||||
* tablefilter v0.2.26 by Max Guglielmi
|
||||
* build date: 2016-05-15T02:51:02.911Z
|
||||
* 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
dist/tablefilter/style/tablefilter.css
vendored
4
dist/tablefilter/style/tablefilter.css
vendored
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.25 by Max Guglielmi
|
||||
* build date: 2016-05-14T12:05:12.318Z
|
||||
* tablefilter v0.2.26 by Max Guglielmi
|
||||
* build date: 2016-05-15T02:51:02.911Z
|
||||
* MIT License
|
||||
*/
|
||||
.activeHeader{background-color:#66afe9 !important;color:#fff !important}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.25 by Max Guglielmi
|
||||
* build date: 2016-05-14T12:05:12.318Z
|
||||
* tablefilter v0.2.26 by Max Guglielmi
|
||||
* build date: 2016-05-15T02:51:02.911Z
|
||||
* 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}
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.25 by Max Guglielmi
|
||||
* build date: 2016-05-14T12:05:12.318Z
|
||||
* tablefilter v0.2.26 by Max Guglielmi
|
||||
* build date: 2016-05-15T02:51:02.911Z
|
||||
* 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}
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.25 by Max Guglielmi
|
||||
* build date: 2016-05-14T12:05:12.318Z
|
||||
* tablefilter v0.2.26 by Max Guglielmi
|
||||
* build date: 2016-05-15T02:51:02.911Z
|
||||
* 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}
|
12
dist/tablefilter/tablefilter.js
vendored
12
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
8
dist/tablefilter/tf-1.js
vendored
8
dist/tablefilter/tf-1.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tablefilter",
|
||||
"version": "0.2.25",
|
||||
"version": "0.2.26",
|
||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
|
|
66
src/dom.js
66
src/dom.js
|
@ -1,4 +1,4 @@
|
|||
import Types from './types';
|
||||
import {isUndef} from './types';
|
||||
import Str from './string';
|
||||
|
||||
/**
|
||||
|
@ -12,8 +12,8 @@ export default {
|
|||
* @param {NodeElement} node
|
||||
* @return {String}
|
||||
*/
|
||||
getText(node){
|
||||
if(Types.isUndef(node.textContent)) {
|
||||
getText(node) {
|
||||
if (isUndef(node.textContent)) {
|
||||
return Str.trim(node.innerText);
|
||||
}
|
||||
return Str.trim(node.textContent);
|
||||
|
@ -24,10 +24,10 @@ export default {
|
|||
* @param {NodeElement} node node
|
||||
* @return {String}
|
||||
*/
|
||||
getFirstTextNode(node){
|
||||
for(let i=0; i<node.childNodes.length; i++){
|
||||
getFirstTextNode(node) {
|
||||
for (let i = 0; i < node.childNodes.length; i++) {
|
||||
let n = node.childNodes[i];
|
||||
if(n.nodeType === 3){
|
||||
if (n.nodeType === 3) {
|
||||
return n.data;
|
||||
}
|
||||
}
|
||||
|
@ -40,18 +40,18 @@ export default {
|
|||
* items, the attribute name and its value ['id','myId']
|
||||
* @return {Object} created element
|
||||
*/
|
||||
create(tag){
|
||||
if(!tag || tag===''){
|
||||
create(tag) {
|
||||
if (!tag || tag === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
let el = document.createElement(tag),
|
||||
args = arguments;
|
||||
|
||||
if(args.length > 1){
|
||||
for(let i=0; i<args.length; i++){
|
||||
if (args.length > 1) {
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
let argtype = typeof args[i];
|
||||
if(argtype.toLowerCase() === 'object' && args[i].length === 2){
|
||||
if (argtype === 'object' && args[i].length === 2) {
|
||||
el.setAttribute(args[i][0], args[i][1]);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export default {
|
|||
* @param {DOMElement} node
|
||||
* @return {DOMElement} old node reference
|
||||
*/
|
||||
remove(node){
|
||||
remove(node) {
|
||||
return node.parentNode.removeChild(node);
|
||||
},
|
||||
|
||||
|
@ -73,43 +73,43 @@ export default {
|
|||
* @param {String} txt
|
||||
* @return {Object}
|
||||
*/
|
||||
text(txt){
|
||||
text(txt) {
|
||||
return document.createTextNode(txt);
|
||||
},
|
||||
|
||||
hasClass(ele, cls){
|
||||
if(!ele){ return false; }
|
||||
hasClass(ele, cls) {
|
||||
if (!ele) { return false; }
|
||||
|
||||
if(supportsClassList()){
|
||||
if (supportsClassList()) {
|
||||
return ele.classList.contains(cls);
|
||||
}
|
||||
return ele.className.match(new RegExp('(\\s|^)'+ cls +'(\\s|$)'));
|
||||
return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
|
||||
},
|
||||
|
||||
addClass(ele, cls){
|
||||
if(!ele){ return; }
|
||||
addClass(ele, cls) {
|
||||
if (!ele) { return; }
|
||||
|
||||
if(supportsClassList()){
|
||||
if (supportsClassList()) {
|
||||
ele.classList.add(cls);
|
||||
return;
|
||||
}
|
||||
|
||||
if(ele.className === ''){
|
||||
if (ele.className === '') {
|
||||
ele.className = cls;
|
||||
}
|
||||
else if(!this.hasClass(ele, cls)){
|
||||
else if (!this.hasClass(ele, cls)) {
|
||||
ele.className += ' ' + cls;
|
||||
}
|
||||
},
|
||||
|
||||
removeClass(ele, cls){
|
||||
if(!ele){ return; }
|
||||
removeClass(ele, cls) {
|
||||
if (!ele) { return; }
|
||||
|
||||
if(supportsClassList()){
|
||||
if (supportsClassList()) {
|
||||
ele.classList.remove(cls);
|
||||
return;
|
||||
}
|
||||
let reg = new RegExp('(\\s|^)'+ cls +'(\\s|$)', 'g');
|
||||
let reg = new RegExp('(\\s|^)' + cls + '(\\s|$)', 'g');
|
||||
ele.className = ele.className.replace(reg, '');
|
||||
},
|
||||
|
||||
|
@ -120,11 +120,11 @@ export default {
|
|||
* @param {Boolean} isSel whether option is selected
|
||||
* @return {Object} option element
|
||||
*/
|
||||
createOpt(text, value, isSel){
|
||||
createOpt(text, value, isSel) {
|
||||
let isSelected = isSel ? true : false,
|
||||
opt = isSelected ?
|
||||
this.create('option', ['value',value], ['selected','true']) :
|
||||
this.create('option', ['value',value]);
|
||||
this.create('option', ['value', value], ['selected', 'true']) :
|
||||
this.create('option', ['value', value]);
|
||||
opt.appendChild(this.text(text));
|
||||
return opt;
|
||||
},
|
||||
|
@ -136,7 +136,7 @@ export default {
|
|||
* @param {String} labelText check item label text
|
||||
* @return {Object} li DOM element
|
||||
*/
|
||||
createCheckItem(chkIndex, chkValue, labelText){
|
||||
createCheckItem(chkIndex, chkValue, labelText) {
|
||||
let li = this.create('li'),
|
||||
label = this.create('label', ['for', chkIndex]),
|
||||
check = this.create('input',
|
||||
|
@ -153,16 +153,16 @@ export default {
|
|||
return li;
|
||||
},
|
||||
|
||||
id(key){
|
||||
id(key) {
|
||||
return document.getElementById(key);
|
||||
},
|
||||
|
||||
tag(o, tagname){
|
||||
tag(o, tagname) {
|
||||
return o.getElementsByTagName(tagname);
|
||||
}
|
||||
};
|
||||
|
||||
// HTML5 classList API
|
||||
function supportsClassList(){
|
||||
function supportsClassList() {
|
||||
return document.documentElement.classList;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Feature} from '../../feature';
|
||||
import Dom from '../../dom';
|
||||
import Str from '../../string';
|
||||
import Types from '../../types';
|
||||
import {isFn, isUndef} from '../../types';
|
||||
|
||||
export default class ColOps extends Feature {
|
||||
|
||||
|
@ -13,10 +13,10 @@ export default class ColOps extends Feature {
|
|||
super(tf, opts.name);
|
||||
|
||||
//calls function before col operation
|
||||
this.onBeforeOperation = Types.isFn(opts.on_before_operation) ?
|
||||
this.onBeforeOperation = isFn(opts.on_before_operation) ?
|
||||
opts.on_before_operation : null;
|
||||
//calls function after col operation
|
||||
this.onAfterOperation = Types.isFn(opts.on_after_operation) ?
|
||||
this.onAfterOperation = isFn(opts.on_after_operation) ?
|
||||
opts.on_after_operation : null;
|
||||
|
||||
this.opts = opts;
|
||||
|
@ -67,7 +67,7 @@ export default class ColOps extends Feature {
|
|||
outputType = opts.write_method,
|
||||
totRowIndex = opts.tot_row_index,
|
||||
excludeRow = opts.exclude_row,
|
||||
decimalPrecision = Types.isUndef(opts.decimal_precision) ?
|
||||
decimalPrecision = isUndef(opts.decimal_precision) ?
|
||||
2 : opts.decimal_precision;
|
||||
|
||||
//nuovella: determine unique list of columns to operate on
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../../feature';
|
||||
import Dom from '../../dom';
|
||||
import Types from '../../types';
|
||||
import {isFn} from '../../types';
|
||||
import Event from '../../event';
|
||||
|
||||
export default class ColsVisibility extends Feature {
|
||||
|
@ -83,30 +83,27 @@ export default class ColsVisibility extends Feature {
|
|||
this.tblHasColTag = (Dom.tag(tf.tbl, 'col').length > 0);
|
||||
|
||||
//callback invoked just after cols manager is loaded
|
||||
this.onLoaded = Types.isFn(f.on_loaded) ? f.on_loaded : null;
|
||||
this.onLoaded = isFn(f.on_loaded) ? f.on_loaded : null;
|
||||
//calls function before cols manager is opened
|
||||
this.onBeforeOpen = Types.isFn(f.on_before_open) ?
|
||||
f.on_before_open : null;
|
||||
this.onBeforeOpen = isFn(f.on_before_open) ? f.on_before_open : null;
|
||||
//calls function after cols manager is opened
|
||||
this.onAfterOpen = Types.isFn(f.on_after_open) ? f.on_after_open : null;
|
||||
this.onAfterOpen = isFn(f.on_after_open) ? f.on_after_open : null;
|
||||
//calls function before cols manager is closed
|
||||
this.onBeforeClose = Types.isFn(f.on_before_close) ?
|
||||
f.on_before_close : null;
|
||||
this.onBeforeClose = isFn(f.on_before_close) ? f.on_before_close : null;
|
||||
//calls function after cols manager is closed
|
||||
this.onAfterClose = Types.isFn(f.on_after_close) ?
|
||||
f.on_after_close : null;
|
||||
this.onAfterClose = isFn(f.on_after_close) ? f.on_after_close : null;
|
||||
|
||||
//callback before col is hidden
|
||||
this.onBeforeColHidden = Types.isFn(f.on_before_col_hidden) ?
|
||||
this.onBeforeColHidden = isFn(f.on_before_col_hidden) ?
|
||||
f.on_before_col_hidden : null;
|
||||
//callback after col is hidden
|
||||
this.onAfterColHidden = Types.isFn(f.on_after_col_hidden) ?
|
||||
this.onAfterColHidden = isFn(f.on_after_col_hidden) ?
|
||||
f.on_after_col_hidden : null;
|
||||
//callback before col is displayed
|
||||
this.onBeforeColDisplayed = Types.isFn(f.on_before_col_displayed) ?
|
||||
this.onBeforeColDisplayed = isFn(f.on_before_col_displayed) ?
|
||||
f.on_before_col_displayed : null;
|
||||
//callback after col is displayed
|
||||
this.onAfterColDisplayed = Types.isFn(f.on_after_col_displayed) ?
|
||||
this.onAfterColDisplayed = isFn(f.on_after_col_displayed) ?
|
||||
f.on_after_col_displayed : null;
|
||||
|
||||
//Grid layout compatibility
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../../feature';
|
||||
import Dom from '../../dom';
|
||||
import Types from '../../types';
|
||||
import {isFn, isUndef} from '../../types';
|
||||
import Event from '../../event';
|
||||
|
||||
export default class FiltersVisibility extends Feature {
|
||||
|
@ -52,26 +52,23 @@ export default class FiltersVisibility extends Feature {
|
|||
this.btnCssClass = f.btn_css_class || 'btnExpClpFlt';
|
||||
//defines css class span containing expand/collapse filters
|
||||
this.contCssClass = f.cont_css_class || 'expClpFlt';
|
||||
this.filtersRowIndex = !Types.isUndef(f.filters_row_index) ?
|
||||
this.filtersRowIndex = !isUndef(f.filters_row_index) ?
|
||||
f.filters_row_index : tf.getFiltersRowIndex();
|
||||
|
||||
this.visibleAtStart = !Types.isUndef(f.visible_at_start) ?
|
||||
this.visibleAtStart = !isUndef(f.visible_at_start) ?
|
||||
Boolean(f.visible_at_start) : true;
|
||||
|
||||
// Prefix
|
||||
this.prfx = 'fltsVis_';
|
||||
|
||||
//callback before filters row is shown
|
||||
this.onBeforeShow = Types.isFn(f.on_before_show) ?
|
||||
f.on_before_show : null;
|
||||
this.onBeforeShow = isFn(f.on_before_show) ? f.on_before_show : null;
|
||||
//callback after filters row is shown
|
||||
this.onAfterShow = Types.isFn(f.on_after_show) ?
|
||||
f.on_after_show : null;
|
||||
this.onAfterShow = isFn(f.on_after_show) ? f.on_after_show : null;
|
||||
//callback before filters row is hidden
|
||||
this.onBeforeHide = Types.isFn(f.on_before_hide) ?
|
||||
f.on_before_hide : null;
|
||||
this.onBeforeHide = isFn(f.on_before_hide) ? f.on_before_hide : null;
|
||||
//callback after filters row is hidden
|
||||
this.onAfterHide = Types.isFn(f.on_after_hide) ? f.on_after_hide : null;
|
||||
this.onAfterHide = isFn(f.on_after_hide) ? f.on_after_hide : null;
|
||||
|
||||
//Loads extension stylesheet
|
||||
tf.import(f.name + 'Style', tf.stylePath + this.stylesheet, null,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Feature} from '../../feature';
|
||||
import Types from '../../types';
|
||||
import {isArray, isFn, isUndef} from '../../types';
|
||||
import Dom from '../../dom';
|
||||
import Event from '../../event';
|
||||
import DateHelper from '../../date';
|
||||
|
@ -21,12 +21,11 @@ export default class AdapterSortableTable extends Feature {
|
|||
//indicates if table previously sorted
|
||||
this.sorted = false;
|
||||
|
||||
this.sortTypes = Types.isArray(opts.types) ? opts.types : [];
|
||||
this.sortColAtStart = Types.isArray(opts.sort_col_at_start) ?
|
||||
this.sortTypes = isArray(opts.types) ? opts.types : [];
|
||||
this.sortColAtStart = isArray(opts.sort_col_at_start) ?
|
||||
opts.sort_col_at_start : null;
|
||||
this.asyncSort = Boolean(opts.async_sort);
|
||||
this.triggerIds = Types.isArray(opts.trigger_ids) ?
|
||||
opts.trigger_ids : [];
|
||||
this.triggerIds = isArray(opts.trigger_ids) ? opts.trigger_ids : [];
|
||||
|
||||
// edit .sort-arrow.descending / .sort-arrow.ascending in
|
||||
// tablefilter.css to reflect any path change
|
||||
|
@ -39,14 +38,13 @@ export default class AdapterSortableTable extends Feature {
|
|||
this.customKey = opts.custom_key || 'data-tf-sortKey';
|
||||
|
||||
// callback invoked after sort is loaded and instanciated
|
||||
this.onSortLoaded = Types.isFn(opts.on_sort_loaded) ?
|
||||
this.onSortLoaded = isFn(opts.on_sort_loaded) ?
|
||||
opts.on_sort_loaded : null;
|
||||
// callback invoked before table is sorted
|
||||
this.onBeforeSort = Types.isFn(opts.on_before_sort) ?
|
||||
this.onBeforeSort = isFn(opts.on_before_sort) ?
|
||||
opts.on_before_sort : null;
|
||||
// callback invoked after table is sorted
|
||||
this.onAfterSort = Types.isFn(opts.on_after_sort) ?
|
||||
opts.on_after_sort : null;
|
||||
this.onAfterSort = isFn(opts.on_after_sort) ? opts.on_after_sort : null;
|
||||
|
||||
this.enable();
|
||||
}
|
||||
|
@ -59,7 +57,7 @@ export default class AdapterSortableTable extends Feature {
|
|||
let adpt = this;
|
||||
|
||||
// SortableTable class sanity check (sortabletable.js)
|
||||
if (Types.isUndef(SortableTable)) {
|
||||
if (isUndef(SortableTable)) {
|
||||
throw new Error('SortableTable class not found.');
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import Arr from '../array';
|
|||
import Str from '../string';
|
||||
import Sort from '../sort';
|
||||
import Event from '../event';
|
||||
import Types from '../types';
|
||||
import {isEmpty} from '../types';
|
||||
import {CHECKLIST, NONE} from '../const';
|
||||
|
||||
const SORT_ERROR = 'Filter options for column {0} cannot be sorted in ' +
|
||||
|
@ -465,7 +465,7 @@ export class CheckList extends Feature {
|
|||
let tf = this.tf;
|
||||
let flt = tf.getFilterElement(colIndex);
|
||||
let fltAttr = flt.getAttribute('value');
|
||||
let values = Types.isEmpty(fltAttr) ? '' : fltAttr;
|
||||
let values = isEmpty(fltAttr) ? '' : fltAttr;
|
||||
|
||||
//removes last operator ||
|
||||
values = values.substr(0, values.length - 3);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {isFn, isNull} from '../types';
|
||||
import Event from '../event';
|
||||
import Str from '../string';
|
||||
import {NONE} from '../const';
|
||||
|
@ -74,7 +74,7 @@ export class GridLayout extends Feature{
|
|||
}
|
||||
|
||||
// Override reference rows indexes
|
||||
tf.refRow = Types.isNull(tf.startRow) ? 0 : tf.startRow;
|
||||
tf.refRow = isNull(tf.startRow) ? 0 : tf.startRow;
|
||||
tf.headersRow = 0;
|
||||
tf.filtersRowIndex = 1;
|
||||
|
||||
|
@ -289,7 +289,7 @@ export class GridLayout extends Feature{
|
|||
}
|
||||
}
|
||||
|
||||
let afterColResizedFn = Types.isFn(f.on_after_col_resized) ?
|
||||
let afterColResizedFn = isFn(f.on_after_col_resized) ?
|
||||
f.on_after_col_resized : null;
|
||||
f.on_after_col_resized = function(o, colIndex){
|
||||
if(!colIndex){
|
||||
|
|
|
@ -6,7 +6,7 @@ const location = root.location;
|
|||
const decodeURIComponent = root.decodeURIComponent;
|
||||
|
||||
export const hasHashChange = () => {
|
||||
var docMode = root.documentMode;
|
||||
let docMode = root.documentMode;
|
||||
return ('onhashchange' in root) && (docMode === undefined || docMode > 7);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Dom from '../dom';
|
||||
import Str from '../string';
|
||||
import Types from '../types';
|
||||
import {isArray} from '../types';
|
||||
|
||||
export class HighlightKeyword {
|
||||
|
||||
|
@ -100,7 +100,7 @@ export class HighlightKeyword {
|
|||
}
|
||||
// iterate filters values to unhighlight all values
|
||||
this.tf.getFiltersValue().forEach((val) => {
|
||||
if (Types.isArray(val)) {
|
||||
if (isArray(val)) {
|
||||
val.forEach((item) =>
|
||||
this.unhighlight(item, this.highlightCssClass));
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {isFn} from '../types';
|
||||
import {root} from '../root';
|
||||
import {NONE} from '../const';
|
||||
|
||||
|
@ -29,11 +29,9 @@ export class Loader extends Feature {
|
|||
//delay for hiding loader
|
||||
this.loaderCloseDelay = 250;
|
||||
//callback function before loader is displayed
|
||||
this.onShowLoader = Types.isFn(f.on_show_loader) ?
|
||||
f.on_show_loader : null;
|
||||
this.onShowLoader = isFn(f.on_show_loader) ? f.on_show_loader : null;
|
||||
//callback function after loader is closed
|
||||
this.onHideLoader = Types.isFn(f.on_hide_loader) ?
|
||||
f.on_hide_loader : null;
|
||||
this.onHideLoader = isFn(f.on_hide_loader) ? f.on_hide_loader : null;
|
||||
//loader div
|
||||
this.prfxLoader = 'load_';
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {isEmpty, isFn} from '../types';
|
||||
import {NONE} from '../const';
|
||||
|
||||
export class NoResults extends Feature{
|
||||
|
@ -18,23 +18,23 @@ export class NoResults extends Feature{
|
|||
this.content = f.content || 'No results';
|
||||
this.customContainer = f.custom_container || null;
|
||||
this.customContainerId = f.custom_container_id || null;
|
||||
this.isExternal = !Types.isEmpty(this.customContainer) ||
|
||||
!Types.isEmpty(this.customContainerId);
|
||||
this.isExternal = !isEmpty(this.customContainer) ||
|
||||
!isEmpty(this.customContainerId);
|
||||
this.cssClass = f.css_class || 'no-results';
|
||||
|
||||
this.cont = null;
|
||||
|
||||
//callback before message is displayed
|
||||
this.onBeforeShowMsg = Types.isFn(f.on_before_show_msg) ?
|
||||
this.onBeforeShowMsg = isFn(f.on_before_show_msg) ?
|
||||
f.on_before_show_msg : null;
|
||||
//callback after message is displayed
|
||||
this.onAfterShowMsg = Types.isFn(f.on_after_show_msg) ?
|
||||
this.onAfterShowMsg = isFn(f.on_after_show_msg) ?
|
||||
f.on_after_show_msg : null;
|
||||
//callback before message is hidden
|
||||
this.onBeforeHideMsg = Types.isFn(f.on_before_hide_msg) ?
|
||||
this.onBeforeHideMsg = isFn(f.on_before_hide_msg) ?
|
||||
f.on_before_hide_msg : null;
|
||||
//callback after message is hidden
|
||||
this.onAfterHideMsg = Types.isFn(f.on_after_hide_msg) ?
|
||||
this.onAfterHideMsg = isFn(f.on_after_hide_msg) ?
|
||||
f.on_after_hide_msg : null;
|
||||
|
||||
this.prfxNoResults = 'nores_';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {isArray, isFn, isNull} from '../types';
|
||||
import Str from '../string';
|
||||
import Event from '../event';
|
||||
import {INPUT, SELECT, NONE, ENTER_KEY} from '../const';
|
||||
|
@ -36,7 +36,7 @@ export class Paging extends Feature {
|
|||
//stores results per page text and values
|
||||
this.resultsPerPage = f.results_per_page || null;
|
||||
//enables/disables results per page drop-down
|
||||
this.hasResultsPerPage = Types.isArray(this.resultsPerPage);
|
||||
this.hasResultsPerPage = isArray(this.resultsPerPage);
|
||||
//defines css class for results per page select
|
||||
this.resultsSlcCssClass = f.results_slc_css_class || 'rspg';
|
||||
//css class for label preceding results per page select
|
||||
|
@ -86,10 +86,10 @@ export class Paging extends Feature {
|
|||
//defines previous page button html
|
||||
this.pageSelectorType = f.page_selector_type || SELECT;
|
||||
//calls function before page is changed
|
||||
this.onBeforeChangePage = Types.isFn(f.on_before_change_page) ?
|
||||
this.onBeforeChangePage = isFn(f.on_before_change_page) ?
|
||||
f.on_before_change_page : null;
|
||||
//calls function before page is changed
|
||||
this.onAfterChangePage = Types.isFn(f.on_after_change_page) ?
|
||||
this.onAfterChangePage = isFn(f.on_after_change_page) ?
|
||||
f.on_after_change_page : null;
|
||||
|
||||
//pages select
|
||||
|
@ -428,8 +428,7 @@ export class Paging extends Feature {
|
|||
var rowDisplayed = false;
|
||||
|
||||
if (h >= startPagingRow && h < endPagingRow) {
|
||||
if (Types.isNull(isRowValid) ||
|
||||
Boolean(isRowValid === 'true')) {
|
||||
if (isNull(isRowValid) || Boolean(isRowValid === 'true')) {
|
||||
r.style.display = '';
|
||||
rowDisplayed = true;
|
||||
}
|
||||
|
@ -505,7 +504,7 @@ export class Paging extends Feature {
|
|||
ev.target.blur();
|
||||
};
|
||||
|
||||
var slcR = Dom.create( SELECT, ['id', this.prfxSlcResults + tf.id]);
|
||||
var slcR = Dom.create(SELECT, ['id', this.prfxSlcResults + tf.id]);
|
||||
slcR.className = this.resultsSlcCssClass;
|
||||
var slcRText = this.resultsPerPage[0],
|
||||
slcROpts = this.resultsPerPage[1];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Feature} from '../feature';
|
||||
import Types from '../types';
|
||||
import {isFn} from '../types';
|
||||
import Dom from '../dom';
|
||||
import Event from '../event';
|
||||
import {INPUT, NONE} from '../const';
|
||||
|
@ -31,17 +31,16 @@ export class PopupFilter extends Feature{
|
|||
//defines css class for popup div containing filter
|
||||
this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter';
|
||||
//callback function before popup filtes is opened
|
||||
this.onBeforePopUpOpen = Types.isFn(f.on_before_popup_filter_open) ?
|
||||
this.onBeforePopUpOpen = isFn(f.on_before_popup_filter_open) ?
|
||||
f.on_before_popup_filter_open : null;
|
||||
//callback function after popup filtes is opened
|
||||
this.onAfterPopUpOpen = Types.isFn(f.on_after_popup_filter_open) ?
|
||||
this.onAfterPopUpOpen = isFn(f.on_after_popup_filter_open) ?
|
||||
f.on_after_popup_filter_open : null;
|
||||
//callback function before popup filtes is closed
|
||||
this.onBeforePopUpClose =
|
||||
Types.isFn(f.on_before_popup_filter_close) ?
|
||||
this.onBeforePopUpClose = isFn(f.on_before_popup_filter_close) ?
|
||||
f.on_before_popup_filter_close : null;
|
||||
//callback function after popup filtes is closed
|
||||
this.onAfterPopUpClose = Types.isFn(f.on_after_popup_filter_close) ?
|
||||
this.onAfterPopUpClose = isFn(f.on_after_popup_filter_close) ?
|
||||
f.on_after_popup_filter_close : null;
|
||||
|
||||
//stores filters spans
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Feature} from '../feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {isFn} from '../types';
|
||||
|
||||
export class RowsCounter extends Feature{
|
||||
|
||||
|
@ -33,10 +33,10 @@ export class RowsCounter extends Feature{
|
|||
//label preceding nb rows label
|
||||
this.prfxTotRowsTxt = 'totRowsTextSpan_';
|
||||
//callback raised before counter is refreshed
|
||||
this.onBeforeRefreshCounter = Types.isFn(f.on_before_refresh_counter) ?
|
||||
this.onBeforeRefreshCounter = isFn(f.on_before_refresh_counter) ?
|
||||
f.on_before_refresh_counter : null;
|
||||
//callback raised after counter is refreshed
|
||||
this.onAfterRefreshCounter = Types.isFn(f.on_after_refresh_counter) ?
|
||||
this.onAfterRefreshCounter = isFn(f.on_after_refresh_counter) ?
|
||||
f.on_after_refresh_counter : null;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import {Feature} from '../feature';
|
|||
import {Hash} from './hash';
|
||||
import {Storage} from './storage';
|
||||
import Str from '../string';
|
||||
import Types from '../types';
|
||||
import {isArray, isNull, isString, isUndef} from '../types';
|
||||
|
||||
/**
|
||||
* Reflects the state of features to be persisted via hash, localStorage or
|
||||
|
@ -25,10 +25,10 @@ export class State extends Feature {
|
|||
let cfg = this.config.state;
|
||||
|
||||
this.enableHash = cfg === true ||
|
||||
(Types.isObj(cfg.types) && cfg.types.indexOf('hash') !== -1);
|
||||
this.enableLocalStorage = Types.isObj(cfg.types) &&
|
||||
(isArray(cfg.types) && cfg.types.indexOf('hash') !== -1);
|
||||
this.enableLocalStorage = isArray(cfg.types) &&
|
||||
cfg.types.indexOf('local_storage') !== -1;
|
||||
this.enableCookie = Types.isObj(cfg.types) &&
|
||||
this.enableCookie = isArray(cfg.types) &&
|
||||
cfg.types.indexOf('cookie') !== -1;
|
||||
this.persistFilters = cfg.filters === false ? false : true;
|
||||
this.persistPageNumber = Boolean(cfg.page_number);
|
||||
|
@ -107,7 +107,7 @@ export class State extends Feature {
|
|||
filterValues.forEach((val, idx) => {
|
||||
let key = `${this.prfxCol}${idx}`;
|
||||
|
||||
if (Types.isString(val) && Str.isEmpty(val)) {
|
||||
if (isString(val) && Str.isEmpty(val)) {
|
||||
if (state.hasOwnProperty(key)) {
|
||||
state[key].flt = undefined;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ export class State extends Feature {
|
|||
}
|
||||
|
||||
if (this.persistPageNumber) {
|
||||
if (Types.isNull(this.pageNb)) {
|
||||
if (isNull(this.pageNb)) {
|
||||
state[this.pageNbKey] = undefined;
|
||||
} else {
|
||||
state[this.pageNbKey] = this.pageNb;
|
||||
|
@ -127,7 +127,7 @@ export class State extends Feature {
|
|||
}
|
||||
|
||||
if (this.persistPageLength) {
|
||||
if (Types.isNull(this.pageLength)) {
|
||||
if (isNull(this.pageLength)) {
|
||||
state[this.pageLengthKey] = undefined;
|
||||
} else {
|
||||
state[this.pageLengthKey] = this.pageLength;
|
||||
|
@ -135,7 +135,7 @@ export class State extends Feature {
|
|||
}
|
||||
|
||||
if (this.persistSort) {
|
||||
if (!Types.isNull(this.sort)) {
|
||||
if (!isNull(this.sort)) {
|
||||
// Remove previuosly sorted column
|
||||
Object.keys(state).forEach((key) => {
|
||||
if (key.indexOf(this.prfxCol) !== -1 && state[key]) {
|
||||
|
@ -150,7 +150,7 @@ export class State extends Feature {
|
|||
}
|
||||
|
||||
if (this.persistColsVisibility) {
|
||||
if (!Types.isNull(this.hiddenCols)) {
|
||||
if (!isNull(this.hiddenCols)) {
|
||||
// Clear previuosly hidden columns
|
||||
Object.keys(state).forEach((key) => {
|
||||
if (key.indexOf(this.prfxCol) !== -1 && state[key]) {
|
||||
|
@ -167,7 +167,7 @@ export class State extends Feature {
|
|||
}
|
||||
|
||||
if (this.persistFiltersVisibility) {
|
||||
if (Types.isNull(this.filtersVisibility)) {
|
||||
if (isNull(this.filtersVisibility)) {
|
||||
state[this.filtersVisKey] = undefined;
|
||||
} else {
|
||||
state[this.filtersVisKey] = this.filtersVisibility;
|
||||
|
@ -319,7 +319,7 @@ export class State extends Feature {
|
|||
Object.keys(state).forEach((key) => {
|
||||
if (key.indexOf(this.prfxCol) !== -1) {
|
||||
let colIdx = parseInt(key.replace(this.prfxCol, ''), 10);
|
||||
if (!Types.isUndef(state[key].sort)) {
|
||||
if (!isUndef(state[key].sort)) {
|
||||
let sort = state[key].sort;
|
||||
this.emitter.emit('sort', tf, colIdx, sort.descending);
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ export class State extends Feature {
|
|||
Object.keys(state).forEach((key) => {
|
||||
if (key.indexOf(this.prfxCol) !== -1) {
|
||||
let colIdx = parseInt(key.replace(this.prfxCol, ''), 10);
|
||||
if (!Types.isUndef(state[key].hidden)) {
|
||||
if (!isUndef(state[key].hidden)) {
|
||||
hiddenCols.push(colIdx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Feature} from '../feature';
|
||||
import {root} from '../root';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {isFn} from '../types';
|
||||
|
||||
export class StatusBar extends Feature{
|
||||
|
||||
|
@ -31,10 +31,10 @@ export class StatusBar extends Feature{
|
|||
this.statusBarCloseDelay = 250;
|
||||
|
||||
//calls function before message is displayed
|
||||
this.onBeforeShowMsg = Types.isFn(f.on_before_show_msg) ?
|
||||
this.onBeforeShowMsg = isFn(f.on_before_show_msg) ?
|
||||
f.on_before_show_msg : null;
|
||||
//calls function after message is displayed
|
||||
this.onAfterShowMsg = Types.isFn(f.on_after_show_msg) ?
|
||||
this.onAfterShowMsg = isFn(f.on_after_show_msg) ?
|
||||
f.on_after_show_msg : null;
|
||||
|
||||
//status messages
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import Event from './event';
|
||||
import Dom from './dom';
|
||||
import Str from './string';
|
||||
import Types from './types';
|
||||
import {isArray, isEmpty, isFn, isNumber, isObj, isString, isUndef}
|
||||
from './types';
|
||||
import DateHelper from './date';
|
||||
import Helpers from './helpers';
|
||||
|
||||
|
@ -54,28 +55,25 @@ export class TableFilter {
|
|||
this.nbCells = null;
|
||||
this._hasGrid = false;
|
||||
|
||||
// TODO: use for-of with babel plug-in
|
||||
// TODO: use for-of
|
||||
args.forEach((arg) => {
|
||||
// for (let arg of args) {
|
||||
let argtype = typeof arg;
|
||||
if (argtype === 'object' && arg && arg.nodeName === 'TABLE') {
|
||||
if (typeof arg === 'object' && arg.nodeName === 'TABLE') {
|
||||
this.tbl = arg;
|
||||
this.id = arg.id || `tf_${new Date().getTime()}_`;
|
||||
} else if (argtype === 'string') {
|
||||
} else if (isString(arg)) {
|
||||
this.id = arg;
|
||||
this.tbl = Dom.id(arg);
|
||||
} else if (argtype === 'number') {
|
||||
} else if (isNumber(arg)) {
|
||||
this.startRow = arg;
|
||||
} else if (argtype === 'object') {
|
||||
} else if (isObj(arg)) {
|
||||
this.cfg = arg;
|
||||
}
|
||||
// }
|
||||
});
|
||||
|
||||
if (!this.tbl || this.tbl.nodeName !== 'TABLE' ||
|
||||
this.getRowsNb() === 0) {
|
||||
throw new Error('Could not instantiate TableFilter: HTML table ' +
|
||||
'DOMElement not found.');
|
||||
throw new Error(`Could not instantiate TableFilter: HTML table
|
||||
DOM element not found.`);
|
||||
}
|
||||
|
||||
// configuration object
|
||||
|
@ -104,7 +102,7 @@ export class TableFilter {
|
|||
(this.filtersRowIndex === 0 ? 1 : 0) : f.headers_row_index;
|
||||
|
||||
//defines tag of the cells containing filters (td/th)
|
||||
this.fltCellTag = Types.isString(f.filters_cell_tag) ?
|
||||
this.fltCellTag = isString(f.filters_cell_tag) ?
|
||||
f.filters_cell_tag : CELL_TAG;
|
||||
|
||||
//stores filters ids
|
||||
|
@ -147,7 +145,7 @@ export class TableFilter {
|
|||
//enables/disbles rows alternating bg colors
|
||||
this.alternateRows = Boolean(f.alternate_rows);
|
||||
//defines widths of columns
|
||||
this.hasColWidths = Types.isArray(f.col_widths);
|
||||
this.hasColWidths = isArray(f.col_widths);
|
||||
this.colWidths = this.hasColWidths ? f.col_widths : null;
|
||||
//defines css class for filters
|
||||
this.fltCssClass = f.flt_css_class || 'flt';
|
||||
|
@ -162,15 +160,14 @@ export class TableFilter {
|
|||
//enables/disables enter key
|
||||
this.enterKey = f.enter_key === false ? false : true;
|
||||
//calls function before filtering starts
|
||||
this.onBeforeFilter = Types.isFn(f.on_before_filter) ?
|
||||
this.onBeforeFilter = isFn(f.on_before_filter) ?
|
||||
f.on_before_filter : null;
|
||||
//calls function after filtering
|
||||
this.onAfterFilter = Types.isFn(f.on_after_filter) ?
|
||||
f.on_after_filter : null;
|
||||
this.onAfterFilter = isFn(f.on_after_filter) ? f.on_after_filter : null;
|
||||
//enables/disables case sensitivity
|
||||
this.caseSensitive = Boolean(f.case_sensitive);
|
||||
//has exact match per column
|
||||
this.hasExactMatchByCol = Types.isArray(f.columns_exact_match);
|
||||
this.hasExactMatchByCol = isArray(f.columns_exact_match);
|
||||
this.exactMatchByCol = this.hasExactMatchByCol ?
|
||||
f.columns_exact_match : [];
|
||||
//enables/disbles exact match for search
|
||||
|
@ -192,26 +189,26 @@ export class TableFilter {
|
|||
//stores filters elements if isExternalFlt is true
|
||||
this.externalFltEls = [];
|
||||
//calls function when filters grid loaded
|
||||
this.onFiltersLoaded = Types.isFn(f.on_filters_loaded) ?
|
||||
this.onFiltersLoaded = isFn(f.on_filters_loaded) ?
|
||||
f.on_filters_loaded : null;
|
||||
//enables/disables single filter search
|
||||
this.singleSearchFlt = Boolean(f.single_filter);
|
||||
//calls function after row is validated
|
||||
this.onRowValidated = Types.isFn(f.on_row_validated) ?
|
||||
this.onRowValidated = isFn(f.on_row_validated) ?
|
||||
f.on_row_validated : null;
|
||||
//array defining columns for customCellData event
|
||||
this.customCellDataCols = f.custom_cell_data_cols ?
|
||||
f.custom_cell_data_cols : [];
|
||||
//calls custom function for retrieving cell data
|
||||
this.customCellData = Types.isFn(f.custom_cell_data) ?
|
||||
this.customCellData = isFn(f.custom_cell_data) ?
|
||||
f.custom_cell_data : null;
|
||||
//input watermark text array
|
||||
this.watermark = f.watermark || '';
|
||||
this.isWatermarkArray = Types.isArray(this.watermark);
|
||||
this.isWatermarkArray = isArray(this.watermark);
|
||||
//id of toolbar container element
|
||||
this.toolBarTgtId = f.toolbar_target_id || null;
|
||||
//enables/disables help div
|
||||
this.help = Types.isUndef(f.help_instructions) ?
|
||||
this.help = isUndef(f.help_instructions) ?
|
||||
undefined : Boolean(f.help_instructions);
|
||||
//popup filters
|
||||
this.popupFilters = Boolean(f.popup_filters);
|
||||
|
@ -221,10 +218,10 @@ export class TableFilter {
|
|||
this.activeColumnsCssClass = f.active_columns_css_class ||
|
||||
'activeHeader';
|
||||
//calls function before active column header is marked
|
||||
this.onBeforeActiveColumn = Types.isFn(f.on_before_active_column) ?
|
||||
this.onBeforeActiveColumn = isFn(f.on_before_active_column) ?
|
||||
f.on_before_active_column : null;
|
||||
//calls function after active column header is marked
|
||||
this.onAfterActiveColumn = Types.isFn(f.on_after_active_column) ?
|
||||
this.onAfterActiveColumn = isFn(f.on_after_active_column) ?
|
||||
f.on_after_active_column : null;
|
||||
|
||||
/*** select filter's customisation and behaviours ***/
|
||||
|
@ -250,7 +247,7 @@ export class TableFilter {
|
|||
this.sortNumDesc = this.isSortNumDesc ? f.sort_num_desc : [];
|
||||
//Select filters are populated on demand
|
||||
this.loadFltOnDemand = Boolean(f.load_filters_on_demand);
|
||||
this.hasCustomOptions = Types.isObj(f.custom_options);
|
||||
this.hasCustomOptions = isObj(f.custom_options);
|
||||
this.customOptions = f.custom_options;
|
||||
|
||||
/*** Filter operators ***/
|
||||
|
@ -296,11 +293,10 @@ export class TableFilter {
|
|||
//defines css class for reset button
|
||||
this.btnResetCssClass = f.btn_reset_css_class || 'reset';
|
||||
//callback function before filters are cleared
|
||||
this.onBeforeReset = Types.isFn(f.on_before_reset) ?
|
||||
this.onBeforeReset = isFn(f.on_before_reset) ?
|
||||
f.on_before_reset : null;
|
||||
//callback function after filters are cleared
|
||||
this.onAfterReset = Types.isFn(f.on_after_reset) ?
|
||||
f.on_after_reset : null;
|
||||
this.onAfterReset = isFn(f.on_after_reset) ? f.on_after_reset : null;
|
||||
|
||||
/*** paging ***/
|
||||
//enables/disables table paging
|
||||
|
@ -323,11 +319,11 @@ export class TableFilter {
|
|||
this.highlightKeywords = Boolean(f.highlight_keywords);
|
||||
|
||||
/*** No results feature ***/
|
||||
this.noResults = Types.isObj(f.no_results_message) ||
|
||||
this.noResults = isObj(f.no_results_message) ||
|
||||
Boolean(f.no_results_message);
|
||||
|
||||
// stateful
|
||||
this.state = Types.isObj(f.state) || Boolean(f.state);
|
||||
this.state = isObj(f.state) || Boolean(f.state);
|
||||
|
||||
/*** data types ***/
|
||||
//defines default date type (european DMY)
|
||||
|
@ -338,11 +334,11 @@ export class TableFilter {
|
|||
//US & javascript = '.' EU = ','
|
||||
this.decimalSeparator = f.decimal_separator || '.';
|
||||
//enables number format per column
|
||||
this.hasColNbFormat = Types.isArray(f.col_number_format);
|
||||
this.hasColNbFormat = isArray(f.col_number_format);
|
||||
//array containing columns nb formats
|
||||
this.colNbFormat = this.hasColNbFormat ? f.col_number_format : null;
|
||||
//enables date type per column
|
||||
this.hasColDateType = Types.isArray(f.col_date_type);
|
||||
this.hasColDateType = isArray(f.col_date_type);
|
||||
//array containing columns date type
|
||||
this.colDateType = this.hasColDateType ? f.col_date_type : null;
|
||||
|
||||
|
@ -372,12 +368,12 @@ export class TableFilter {
|
|||
/*** extensions ***/
|
||||
//imports external script
|
||||
this.extensions = f.extensions;
|
||||
this.hasExtensions = Types.isArray(this.extensions);
|
||||
this.hasExtensions = isArray(this.extensions);
|
||||
|
||||
/*** themes ***/
|
||||
this.enableDefaultTheme = Boolean(f.enable_default_theme);
|
||||
//imports themes
|
||||
this.hasThemes = (this.enableDefaultTheme || Types.isArray(f.themes));
|
||||
this.hasThemes = (this.enableDefaultTheme || isArray(f.themes));
|
||||
this.themes = f.themes || [];
|
||||
//themes path
|
||||
this.themesPath = f.themes_path || this.stylePath + 'themes/';
|
||||
|
@ -848,7 +844,7 @@ export class TableFilter {
|
|||
* @return {Boolean}
|
||||
*/
|
||||
hasExtension(name) {
|
||||
return !Types.isEmpty(this.ExtRegistry[name]);
|
||||
return !isEmpty(this.ExtRegistry[name]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -879,7 +875,7 @@ export class TableFilter {
|
|||
let defaultTheme = { name: 'default' };
|
||||
this.themes.push(defaultTheme);
|
||||
}
|
||||
if (Types.isArray(themes)) {
|
||||
if (isArray(themes)) {
|
||||
for (let i = 0, len = themes.length; i < len; i++) {
|
||||
let theme = themes[i];
|
||||
let name = theme.name;
|
||||
|
@ -971,7 +967,7 @@ export class TableFilter {
|
|||
// TODO: subcribe modules to destroy event instead
|
||||
Object.keys(Mod).forEach(function (key) {
|
||||
let feature = Mod[key];
|
||||
if (feature && Types.isFn(feature.destroy)) {
|
||||
if (feature && isFn(feature.destroy)) {
|
||||
feature.destroy();
|
||||
}
|
||||
});
|
||||
|
@ -1046,7 +1042,7 @@ export class TableFilter {
|
|||
this.mDiv = Dom.id(this.prfxMDiv + this.id);
|
||||
|
||||
// emit help initialisation only if undefined
|
||||
if (Types.isUndef(this.help)) {
|
||||
if (isUndef(this.help)) {
|
||||
// explicitily set enabled field to true to initialise help by
|
||||
// default, only if setting is undefined
|
||||
this.Mod.help.enabled = true;
|
||||
|
@ -1106,7 +1102,7 @@ export class TableFilter {
|
|||
* @return {Array}
|
||||
*/
|
||||
getCustomOptions(colIndex) {
|
||||
if (Types.isEmpty(colIndex) || !this.isCustomOptions(colIndex)) {
|
||||
if (isEmpty(colIndex) || !this.isCustomOptions(colIndex)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1429,11 +1425,11 @@ export class TableFilter {
|
|||
hasMultiAndSA = sAAndSplit.length > 1;
|
||||
|
||||
//detect operators or array query
|
||||
if (Types.isArray(sA) || hasMultiOrSA || hasMultiAndSA) {
|
||||
if (isArray(sA) || hasMultiOrSA || hasMultiAndSA) {
|
||||
let cS,
|
||||
s,
|
||||
occur = false;
|
||||
if (Types.isArray(sA)) {
|
||||
if (isArray(sA)) {
|
||||
s = sA;
|
||||
} else {
|
||||
s = hasMultiOrSA ? sAOrSplit : sAAndSplit;
|
||||
|
@ -1447,7 +1443,7 @@ export class TableFilter {
|
|||
(hasMultiAndSA && !occur)) {
|
||||
break;
|
||||
}
|
||||
if (Types.isArray(sA) && occur) {
|
||||
if (isArray(sA) && occur) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1573,7 +1569,7 @@ export class TableFilter {
|
|||
}
|
||||
//return an empty string if collection is empty or contains a single
|
||||
//empty string
|
||||
if (Types.isArray(fltValue) && fltValue.length === 0 ||
|
||||
if (isArray(fltValue) && fltValue.length === 0 ||
|
||||
(fltValue.length === 1 && fltValue[0] === '')) {
|
||||
fltValue = '';
|
||||
}
|
||||
|
@ -1592,7 +1588,7 @@ export class TableFilter {
|
|||
let searchArgs = [];
|
||||
for (let i = 0, len = this.fltIds.length; i < len; i++) {
|
||||
let fltValue = this.getFilterValue(i);
|
||||
if (Types.isArray(fltValue)) {
|
||||
if (isArray(fltValue)) {
|
||||
searchArgs.push(fltValue);
|
||||
} else {
|
||||
searchArgs.push(Str.trim(fltValue));
|
||||
|
@ -1664,7 +1660,7 @@ export class TableFilter {
|
|||
* @return {Number} Number of filterable rows
|
||||
*/
|
||||
getRowsNb(includeHeaders) {
|
||||
let s = Types.isUndef(this.refRow) ? 0 : this.refRow,
|
||||
let s = isUndef(this.refRow) ? 0 : this.refRow,
|
||||
ntrs = this.tbl.rows.length;
|
||||
if (includeHeaders) { s = 0; }
|
||||
return parseInt(ntrs - s, 10);
|
||||
|
@ -1771,7 +1767,7 @@ export class TableFilter {
|
|||
* TODO: provide an API returning data in JSON format
|
||||
*/
|
||||
getFilteredDataCol(colIndex, includeHeaders = false) {
|
||||
if (Types.isUndef(colIndex)) {
|
||||
if (isUndef(colIndex)) {
|
||||
return [];
|
||||
}
|
||||
let data = this.getFilteredData(),
|
||||
|
@ -1792,13 +1788,10 @@ export class TableFilter {
|
|||
|
||||
/**
|
||||
* Get the display value of a row
|
||||
* @param {RowElement} row DOM element of the row
|
||||
* @param {HTMLTableRowElement} row DOM element of the row
|
||||
* @return {String} Usually 'none' or ''
|
||||
*/
|
||||
getRowDisplay(row) {
|
||||
if (!Types.isObj(row)) {
|
||||
return null;
|
||||
}
|
||||
return row.style.display;
|
||||
}
|
||||
|
||||
|
@ -1873,7 +1866,7 @@ export class TableFilter {
|
|||
}
|
||||
//multiple selects
|
||||
else if (fltColType === MULTIPLE) {
|
||||
let values = Types.isArray(query) ? query :
|
||||
let values = isArray(query) ? query :
|
||||
query.split(' ' + this.orOperator + ' ');
|
||||
|
||||
if (this.loadFltOnDemand && !this.initialized) {
|
||||
|
@ -1890,7 +1883,7 @@ export class TableFilter {
|
|||
this.emitter.emit('build-checklist-filter', this, index,
|
||||
this.isExternalFlt);
|
||||
}
|
||||
if (Types.isArray(query)) {
|
||||
if (isArray(query)) {
|
||||
values = query;
|
||||
} else {
|
||||
query = Str.matchCase(query, this.caseSensitive);
|
||||
|
@ -2036,7 +2029,7 @@ export class TableFilter {
|
|||
* @param colIndex Index of a column
|
||||
*/
|
||||
activateFilter(colIndex) {
|
||||
if (Types.isUndef(colIndex)) {
|
||||
if (isUndef(colIndex)) {
|
||||
return;
|
||||
}
|
||||
this.setActiveFilterId(this.getFilterId(colIndex));
|
||||
|
|
131
src/types.js
131
src/types.js
|
@ -1,4 +1,3 @@
|
|||
import {root} from './root';
|
||||
|
||||
/**
|
||||
* Types utilities
|
||||
|
@ -6,87 +5,63 @@ import {root} from './root';
|
|||
|
||||
const UNDEFINED = void 0;
|
||||
|
||||
export default {
|
||||
/**
|
||||
* Check if argument is an object or a global object
|
||||
* @param {String or Object} v
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isObj(v) {
|
||||
let isO = false;
|
||||
if (typeof v === 'string') {
|
||||
if (root[v] && typeof root[v] === 'object') {
|
||||
isO = true;
|
||||
}
|
||||
} else {
|
||||
if (v && typeof v === 'object') {
|
||||
isO = true;
|
||||
}
|
||||
}
|
||||
return isO;
|
||||
},
|
||||
/**
|
||||
* Check passed argument is an object
|
||||
* @param {Object} obj
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export const isObj =
|
||||
obj => Object.prototype.toString.call(obj) === '[object Object]';
|
||||
|
||||
/**
|
||||
* Check if argument is a function
|
||||
* @param {Function} fn
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isFn(fn) {
|
||||
return (fn && fn.constructor == Function);
|
||||
},
|
||||
/**
|
||||
* Check passed argument is a function
|
||||
* @param {Function} obj
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export const isFn =
|
||||
obj => Object.prototype.toString.call(obj) === '[object Function]';
|
||||
|
||||
/**
|
||||
* Check if argument is an array
|
||||
* @param {Array} obj
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isArray(obj) {
|
||||
return (obj && obj.constructor == Array);
|
||||
},
|
||||
/**
|
||||
* Check passed argument is an array
|
||||
* @param {Array} obj
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export const isArray =
|
||||
obj => Object.prototype.toString.call(obj) === '[object Array]';
|
||||
|
||||
/**
|
||||
* Check argument is a string
|
||||
* @param {String} val Value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isString(val) {
|
||||
return Object.prototype.toString.call(val) === '[object String]';
|
||||
},
|
||||
/**
|
||||
* Check passed argument is a string
|
||||
* @param {String} obj objue
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export const isString =
|
||||
obj => Object.prototype.toString.call(obj) === '[object String]';
|
||||
|
||||
/**
|
||||
* Check passed argument is a number
|
||||
* @param {Number} obj
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export const isNumber =
|
||||
obj => Object.prototype.toString.call(obj) === '[object Number]';
|
||||
|
||||
/**
|
||||
* Check argument is a number
|
||||
* @param {Number} val
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isNumber(val) {
|
||||
return Object.prototype.toString.call(val) === '[object Number]';
|
||||
},
|
||||
/**
|
||||
* Check passed argument is undefined
|
||||
* @param {Any} obj
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export const isUndef = obj => obj === UNDEFINED;
|
||||
|
||||
/**
|
||||
* Determine if argument is undefined
|
||||
* @param {Any} o
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isUndef(o) {
|
||||
return o === UNDEFINED;
|
||||
},
|
||||
/**
|
||||
* Check passed argument is null
|
||||
* @param {Any} obj
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export const isNull = obj => obj === null;
|
||||
|
||||
/**
|
||||
* Determine if argument is null
|
||||
* @param {Any} o
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isNull(o) {
|
||||
return o === null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine if argument is empty (undefined, null or empty string)
|
||||
* @param {Any} o
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isEmpty(o) {
|
||||
return this.isUndef(o) || this.isNull(o) || o.length === 0;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Check passed argument is empty (undefined, null or empty string)
|
||||
* @param {Any} obj
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export const isEmpty = obj => isUndef(obj) || isNull(obj) || obj.length === 0;
|
||||
|
|
|
@ -17,7 +17,7 @@ var hash = state.hash;
|
|||
module('Sanity checks');
|
||||
test('State instance', function() {
|
||||
deepEqual(typeof hash, 'object', 'Hash is instantiated');
|
||||
deepEqual(hash.lastHash, '', 'Last store hash');
|
||||
deepEqual(hash.lastHash, '', 'Last stored hash');
|
||||
deepEqual(hash.state, state, 'State instance');
|
||||
deepEqual(hash.emitter, state.emitter, 'Emitter instance');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue