1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-17 22:06:41 +02:00

Started refactoring Dom module

This commit is contained in:
Max Guglielmi 2016-05-24 18:42:11 +10:00
parent 35f23d46eb
commit 9fec6eb6ef
29 changed files with 11079 additions and 635 deletions

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.30 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z
* tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-24T08:24:39.404Z
* MIT License
*/
span.colVisSpan{text-align:left;}span.colVisSpan a.colVis{display:inline-block;padding:7px 5px 0;font-size:inherit;font-weight:inherit;vertical-align:top}div.colVisCont{position:relative;background:#fff;-webkit-box-shadow:3px 3px 2px #888;-moz-box-shadow:3px 3px 2px #888;box-shadow:3px 3px 2px #888;position:absolute;display:none;border:1px solid #ccc;height:auto;width:250px;background-color:#fff;margin:35px 0 0 -100px;z-index:10000;padding:10px 10px 10px 10px;text-align:left;font-size:12px;}div.colVisCont:after,div.colVisCont:before{bottom:100%;left:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.colVisCont:after{border-color:rgba(255,255,255,0);border-bottom-color:#fff;border-width:10px;margin-left:-10px}div.colVisCont:before{border-color:rgba(255,255,255,0);border-bottom-color:#ccc;border-width:12px;margin-left:-12px}div.colVisCont p{margin:6px auto 6px auto}div.colVisCont a.colVis{display:initial;font-weight:inherit}ul.cols_checklist{padding:0;margin:0;list-style:none;}ul.cols_checklist label{display:block}ul.cols_checklist input{vertical-align:middle;margin:2px 5px 2px 1px}li.cols_checklist_item{padding:4px;margin:0;}li.cols_checklist_item:hover{background-color:#335ea8;color:#fff}.cols_checklist_slc_item{background-color:#335ea8;color:#fff}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.30 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z
* tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-24T08:24:39.404Z
* MIT License
*/
span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.30 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z
* tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-24T08:24:39.404Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.30 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z
* tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-24T08:24:39.404Z
* 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}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.30 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z
* tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-24T08:24:39.404Z
* 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}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.30 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z
* tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-24T08:24:39.404Z
* MIT License
*/
table.TF{padding:0;color:#000;border-right:1px solid #a4bed4;border-top:1px solid #a4bed4;border-left:1px solid #a4bed4;border-bottom:0;}table.TF th{margin:0;color:inherit;background:#d1e5fe url("images/bg_skyblue.gif") 0 0 repeat-x;border-color:#fdfdfd #a4bed4 #a4bed4 #fdfdfd;border-width:1px;border-style:solid}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid #a4bed4;border-left:0;border-top:0;border-right:0}.fltrow{background-color:#d1e5fe !important;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4 !important}input.flt{width:99% !important}.inf{background-color:#e3efff !important;border:1px solid #a4bed4;height:$min-height;color:#004a6f}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#ffe4ab url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#ffe4ab url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#ffe4ab url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#ffe4ab url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.activeHeader{background:#ffe4ab !important;border:1px solid #ffb552 !important;color:inherit !important}div.grd_Cont{background-color:#d9eaed !important;border:1px solid #9cc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#e3efff}div.grd_headTblCont{background-color:#d9eaed !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#d9eaed url("images/bg_skyblue.gif") left top repeat-x;border-bottom:1px solid #a4bed4;border-right:1px solid #a4bed4 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #a4bed4 !important;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:#cce2fe;color:#004a6f;border-top:1px solid #9cc !important;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#2d8eef;border:1px solid #cce2fe;border-radius:5px}.even{background-color:#fff}.odd{background-color:#e3efff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ffdc61 !important;color:inherit}.ezSelectedRow{background-color:#ffe4ab !important;color:inherit}.ezActiveCell{background-color:#fff !important;color:#000 !important;font-weight:bold}.ezETSelectedCell{background-color:#fff !important;font-weight:bold;color:#000 !important}

File diff suppressed because one or more lines are too long

2351
dist/tablefilter/tf-1.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.2.30",
"version": "0.2.31",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {

View file

@ -5,162 +5,155 @@ import {trim} from './string';
* DOM utilities
*/
export default {
// export default {
/**
* Returns text + text of children of given node
* @param {NodeElement} node
* @return {String}
*/
getText(node) {
if (isUndef(node.textContent)) {
return trim(node.innerText);
}
return trim(node.textContent);
},
/**
* Returns the first text node contained in the supplied node
* @param {NodeElement} node node
* @return {String}
*/
getFirstTextNode(node) {
for (let i = 0; i < node.childNodes.length; i++) {
let n = node.childNodes[i];
if (n.nodeType === 3) {
return n.data;
}
}
},
/**
* Creates an html element with given collection of attributes
* @param {String} tag a string of the html tag to create
* @param {Array} an undetermined number of arrays containing the with 2
* items, the attribute name and its value ['id','myId']
* @return {Object} created element
*/
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++) {
let argtype = typeof args[i];
if (argtype === 'object' && args[i].length === 2) {
el.setAttribute(args[i][0], args[i][1]);
}
}
}
return el;
},
/**
* Removes passed node from DOM
* @param {DOMElement} node
* @return {DOMElement} old node reference
*/
remove(node) {
return node.parentNode.removeChild(node);
},
/**
* Returns a text node with given text
* @param {String} txt
* @return {Object}
*/
text(txt) {
return document.createTextNode(txt);
},
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(key) {
return document.getElementById(key);
},
tag(o, tagname) {
return o.getElementsByTagName(tagname);
/**
* Returns text + text of children of given node
* @param {NodeElement} node
* @return {String}
*/
export const getText = node => {
if (isUndef(node.textContent)) {
return trim(node.innerText);
}
};
return trim(node.textContent);
}
/**
* Returns the first text node contained in the supplied node
* @param {NodeElement} node node
* @return {String}
*/
export const getFirstTextNode = node => {
for (let i = 0; i < node.childNodes.length; i++) {
let n = node.childNodes[i];
if (n.nodeType === 3) {
return n.data;
}
}
}
/**
* Creates an html element with given collection of attributes
* @param {String} tag a string of the html tag to create
* @param {Array} an undetermined number of arrays containing the with 2
* items, the attribute name and its value ['id','myId']
* @return {Object} created element
*/
export const createElm = tag => {
if (isUndef(tag)) {
return;
}
let el = document.createElement(tag),
args = arguments;
if (args.length > 1) {
for (let i = 0; i < args.length; i++) {
let argtype = typeof args[i];
if (argtype === 'object' && args[i].length === 2) {
el.setAttribute(args[i][0], args[i][1]);
}
}
}
return el;
}
/**
* Removes passed node from DOM
* @param {DOMElement} node
* @return {DOMElement} old node reference
*/
export const removeElm = node => node.parentNode.removeChild(node);
/**
* Returns a text node with given text
* @param {String} txt
* @return {Object}
*/
export const createText = txt => document.createTextNode(txt);
export const hasClass = (ele, cls) => {
if (!ele) { return false; }
if (supportsClassList()) {
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}
export const addClass = (ele, cls) => {
if (!ele) { return; }
if (supportsClassList()) {
ele.classList.add(cls);
return;
}
if (ele.className === '') {
ele.className = cls;
}
else if (!hasClass(ele, cls)) {
ele.className += ' ' + cls;
}
}
export const 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
*/
export const createOpt = (text, value, isSel) => {
let isSelected = isSel ? true : false,
opt = isSelected ?
createElm('option', ['value', value], ['selected', 'true']) :
createElm('option', ['value', value]);
opt.appendChild(createText(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
*/
export const createCheckItem = (chkIndex, chkValue, labelText) => {
let li = createElm('li');
let label = createElm('label', ['for', chkIndex]);
let check = createElm('input',
['id', chkIndex],
['name', chkIndex],
['type', 'checkbox'],
['value', chkValue]
);
label.appendChild(check);
label.appendChild(createText(labelText));
li.appendChild(label);
li.label = label;
li.check = check;
return li;
}
export const byId = key => document.getElementById(key);
export const tag = (o, tagname) => o.getElementsByTagName(tagname);
// };
// HTML5 classList API
function supportsClassList() {

View file

@ -1,5 +1,5 @@
import {Feature} from '../../feature';
import Dom from '../../dom';
import {tag} from '../../dom';
import {INPUT} from '../../const';
import {root} from '../../root';
@ -71,7 +71,7 @@ export default class AdapterEzEditTable extends Feature {
//start row for EditTable constructor needs to be calculated
var startRow,
cfg = this.cfg,
thead = Dom.tag(tf.tbl, 'thead');
thead = tag(tf.tbl, 'thead');
//if thead exists and startRow not specified, startRow is calculated
//automatically by EditTable

View file

@ -1,5 +1,5 @@
import {Feature} from '../../feature';
import Dom from '../../dom';
import {createText, byId} from '../../dom';
import {isArray, isFn, isUndef} from '../../types';
export default class ColOps extends Feature {
@ -268,25 +268,24 @@ export default class ColOps extends Feature {
if (oTypeThisCol && result) {
result = result.toFixed(precision);
if (Dom.id(labThisCol[i])) {
if (byId(labThisCol[i])) {
switch (oTypeThisCol.toLowerCase()) {
case 'innerhtml':
if (isNaN(result) || !isFinite(result) ||
nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = '.';
byId(labThisCol[i]).innerHTML = '.';
} else {
Dom.id(labThisCol[i]).innerHTML =
result;
byId(labThisCol[i]).innerHTML = result;
}
break;
case 'setvalue':
Dom.id(labThisCol[i]).value = result;
byId(labThisCol[i]).value = result;
break;
case 'createtextnode':
var oldnode = Dom.id(labThisCol[i])
.firstChild;
var txtnode = Dom.text(result);
Dom.id(labThisCol[i])
var oldnode =
byId(labThisCol[i]).firstChild;
var txtnode = createText(result);
byId(labThisCol[i])
.replaceChild(txtnode, oldnode);
break;
}//switch
@ -295,9 +294,9 @@ export default class ColOps extends Feature {
try {
if (isNaN(result) || !isFinite(result) ||
nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = '.';
byId(labThisCol[i]).innerHTML = '.';
} else {
Dom.id(labThisCol[i]).innerHTML =
byId(labThisCol[i]).innerHTML =
result.toFixed(precision);
}
} catch (e) { }//catch

View file

@ -1,5 +1,6 @@
import {Feature} from '../../feature';
import Dom from '../../dom';
import {addClass, removeClass, createElm, byId, removeElm, getText, tag}
from '../../dom';
import {isFn} from '../../types';
import Event from '../../event';
@ -80,7 +81,7 @@ export default class ColsVisibility extends Feature {
//array containing hidden columns indexes
this.hiddenCols = [];
this.tblHasColTag = (Dom.tag(tf.tbl, 'col').length > 0);
this.tblHasColTag = tag(tf.tbl, 'col').length > 0;
//callback invoked just after cols manager is loaded
this.onLoaded = isFn(f.on_loaded) ? f.on_loaded : null;
@ -155,9 +156,9 @@ export default class ColsVisibility extends Feature {
let colIndex = lbl.firstChild.getAttribute('id').split('_')[1];
colIndex = parseInt(colIndex, 10);
if (isChecked) {
Dom.addClass(li, this.listSlcItemCssClass);
addClass(li, this.listSlcItemCssClass);
} else {
Dom.removeClass(li, this.listSlcItemCssClass);
removeClass(li, this.listSlcItemCssClass);
}
let hide = false;
@ -194,14 +195,14 @@ export default class ColsVisibility extends Feature {
return;
}
let tf = this.tf;
let span = Dom.create('span', ['id', this.prfx + tf.id]);
let span = createElm('span', ['id', this.prfx + tf.id]);
span.className = this.spanCssClass;
//Container element (rdiv or custom element)
if (!this.btnTgtId) {
tf.setToolbar();
}
let targetEl = !this.btnTgtId ? tf.rDiv : Dom.id(this.btnTgtId);
let targetEl = !this.btnTgtId ? tf.rDiv : byId(this.btnTgtId);
if (!this.btnTgtId) {
let firstChild = targetEl.firstChild;
@ -211,7 +212,7 @@ export default class ColsVisibility extends Feature {
}
if (!this.btnHtml) {
let btn = Dom.create('a', ['href', 'javascript:;']);
let btn = createElm('a', ['href', 'javascript:;']);
btn.className = this.btnCssClass;
btn.title = this.desc;
@ -247,17 +248,17 @@ export default class ColsVisibility extends Feature {
let tf = this.tf;
let container = !this.contElTgtId ?
Dom.create('div', ['id', this.prfxCont + tf.id]) :
Dom.id(this.contElTgtId);
createElm('div', ['id', this.prfxCont + tf.id]) :
byId(this.contElTgtId);
container.className = this.contCssClass;
//Extension description
let extNameLabel = Dom.create('p');
let extNameLabel = createElm('p');
extNameLabel.innerHTML = this.text;
container.appendChild(extNameLabel);
//Headers list
let ul = Dom.create('ul', ['id', 'ul' + this.name + '_' + tf.id]);
let ul = createElm('ul', ['id', 'ul' + this.name + '_' + tf.id]);
ul.className = this.listCssClass;
let tbl = this.headersTbl ? this.headersTbl : tf.tbl;
@ -267,15 +268,15 @@ export default class ColsVisibility extends Feature {
//Tick all option
if (this.enableTickAll) {
let li = Dom.createCheckItem(
'col__' + tf.id, this.tickAllText, this.tickAllText);
Dom.addClass(li, this.listItemCssClass);
let li = createCheckItem('col__' + tf.id, this.tickAllText,
this.tickAllText);
addClass(li, this.listItemCssClass);
ul.appendChild(li);
li.check.checked = !this.tickToHide;
Event.add(li.check, 'click', () => {
for (let h = 0; h < headerRow.cells.length; h++) {
let itm = Dom.id('col_' + h + '_' + tf.id);
let itm = byId('col_' + h + '_' + tf.id);
if (itm && li.check.checked !== itm.checked) {
itm.click();
itm.checked = li.check.checked;
@ -288,11 +289,11 @@ export default class ColsVisibility extends Feature {
let cell = headerRow.cells[i];
let cellText = this.headersText && this.headersText[i] ?
this.headersText[i] : this._getHeaderText(cell);
let liElm = Dom.createCheckItem(
'col_' + i + '_' + tf.id, cellText, cellText);
Dom.addClass(liElm, this.listItemCssClass);
let liElm = createCheckItem('col_' + i + '_' + tf.id, cellText,
cellText);
addClass(liElm, this.listItemCssClass);
if (!this.tickToHide) {
Dom.addClass(liElm, this.listSlcItemCssClass);
addClass(liElm, this.listSlcItemCssClass);
}
ul.appendChild(liElm);
if (!this.tickToHide) {
@ -307,11 +308,11 @@ export default class ColsVisibility extends Feature {
}
//separator
let p = Dom.create('p', ['align', 'center']);
let p = createElm('p', ['align', 'center']);
let btn;
//Close link
if (!this.btnCloseHtml) {
btn = Dom.create('a', ['href', 'javascript:;']);
btn = createElm('a', ['href', 'javascript:;']);
btn.className = this.btnCloseCssClass;
btn.innerHTML = this.btnCloseText;
Event.add(btn, 'click', (evt) => this.toggle(evt));
@ -419,7 +420,7 @@ export default class ColsVisibility extends Feature {
return;
}
if (this.manager && this.contEl) {
let itm = Dom.id('col_' + colIndex + '_' + this.tf.id);
let itm = byId('col_' + colIndex + '_' + this.tf.id);
if (itm) {
itm.click();
}
@ -437,7 +438,7 @@ export default class ColsVisibility extends Feature {
return;
}
if (this.manager && this.contEl) {
let itm = Dom.id('col_' + colIndex + '_' + this.tf.id);
let itm = byId('col_' + colIndex + '_' + this.tf.id);
if (itm) {
itm.click();
}
@ -484,15 +485,15 @@ export default class ColsVisibility extends Feature {
if (!this.initialized) {
return;
}
if (Dom.id(this.contElTgtId)) {
Dom.id(this.contElTgtId).innerHTML = '';
if (byId(this.contElTgtId)) {
byId(this.contElTgtId).innerHTML = '';
} else {
this.contEl.innerHTML = '';
Dom.remove(this.contEl);
removeElm(this.contEl);
this.contEl = null;
}
this.btnEl.innerHTML = '';
Dom.remove(this.btnEl);
removeElm(this.btnEl);
this.btnEl = null;
this.emitter.off(['hide-column'],
@ -514,7 +515,7 @@ export default class ColsVisibility extends Feature {
if (n.id && n.id.indexOf('popUp') !== -1) {
continue;
} else {
return Dom.getText(n);
return getText(n);
}
}
continue;

View file

@ -1,5 +1,5 @@
import {Feature} from '../../feature';
import Dom from '../../dom';
import {createElm, removeElm, byId} from '../../dom';
import {isFn, isUndef} from '../../types';
import Event from '../../event';
@ -96,14 +96,14 @@ export default class FiltersVisibility extends Feature {
*/
buildUI() {
let tf = this.tf;
let span = Dom.create('span', ['id', this.prfx + tf.id]);
let span = createElm('span', ['id', this.prfx + tf.id]);
span.className = this.contCssClass;
//Container element (rdiv or custom element)
if (!this.targetId) {
tf.setToolbar();
}
let targetEl = !this.targetId ? tf.rDiv : Dom.id(this.targetId);
let targetEl = !this.targetId ? tf.rDiv : byId(this.targetId);
if (!this.targetId) {
let firstChild = targetEl.firstChild;
@ -114,7 +114,7 @@ export default class FiltersVisibility extends Feature {
let btn;
if (!this.btnHtml) {
btn = Dom.create('a', ['href', 'javascript:void(0);']);
btn = createElm('a', ['href', 'javascript:void(0);']);
btn.className = this.btnCssClass;
btn.title = this.btnText || this.defaultText;
btn.innerHTML = this.collapseBtnHtml;
@ -190,11 +190,11 @@ export default class FiltersVisibility extends Feature {
this.emitter.off(['show-filters'], (tf, visible) => this.show(visible));
this.btnEl.innerHTML = '';
Dom.remove(this.btnEl);
removeElm(this.btnEl);
this.btnEl = null;
this.contEl.innerHTML = '';
Dom.remove(this.contEl);
removeElm(this.contEl);
this.contEl = null;
this.initialized = false;
}

View file

@ -1,6 +1,6 @@
import {Feature} from '../../feature';
import {isArray, isFn, isUndef} from '../../types';
import Dom from '../../dom';
import {createElm, byId, getText, tag} from '../../dom';
import Event from '../../event';
import {formatDate} from '../../date';
import {removeNbFormat} from '../../helpers';
@ -186,7 +186,7 @@ export default class AdapterSortableTable extends Feature {
c = cells[i];
if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None') {
c.style.cursor = 'pointer';
img = Dom.create('img',
img = createElm('img',
['src', adpt.imgPath + adpt.imgBlank]);
c.appendChild(img);
if (stt.sortTypes[i] !== null) {
@ -214,7 +214,7 @@ export default class AdapterSortableTable extends Feature {
cells = [];
l = triggers.length;
for (let j = 0; j < triggers.length; j++) {
cells.push(Dom.id(triggers[j]));
cells.push(byId(triggers[j]));
}
} else {
if (!this.tHead) {
@ -228,7 +228,7 @@ export default class AdapterSortableTable extends Feature {
if (cellAttr !== null && cellAttr !== 'None') {
img = cells[i].lastChild || cells[i];
if (img.nodeName.toLowerCase() !== 'img') {
img = Dom.create('img',
img = createElm('img',
['src', adpt.imgPath + adpt.imgBlank]);
cells[i].appendChild(img);
}
@ -276,7 +276,7 @@ export default class AdapterSortableTable extends Feature {
if (oNode.getAttribute(adpt.customKey)) {
return oNode.getAttribute(adpt.customKey);
} else {
return Dom.getText(oNode);
return getText(oNode);
}
};
}
@ -335,7 +335,7 @@ export default class AdapterSortableTable extends Feature {
if (triggers[j] === null) {
continue;
}
let trigger = Dom.id(triggers[j]);
let trigger = byId(triggers[j]);
if (trigger) {
trigger.style.cursor = 'pointer';
@ -369,7 +369,7 @@ export default class AdapterSortableTable extends Feature {
let ids = tf.getFiltersId();
for (let idx = 0; idx < ids.length; idx++) {
let header = tf.getHeaderElement(idx);
let img = Dom.tag(header, 'img');
let img = tag(header, 'img');
if (img.length === 1) {
header.removeChild(img[0]);

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {addClass, removeClass} from '../dom';
export class AlternateRows extends Feature {
@ -21,7 +21,7 @@ export class AlternateRows extends Feature {
* Sets alternating rows color
*/
init() {
if(this.initialized){
if (this.initialized) {
return;
}
@ -29,15 +29,15 @@ export class AlternateRows extends Feature {
// Subscribe to events
this.emitter.on(['row-processed', 'row-paged'],
(tf, rowIndex, arrIndex, isValid)=>
(tf, rowIndex, arrIndex, isValid) =>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.on(['column-sorted'], ()=> this.processAll());
this.emitter.on(['column-sorted'], () => this.processAll());
this.initialized = true;
}
processAll() {
if(!this.isEnabled()){
if (!this.isEnabled()) {
return;
}
var tf = this.tf;
@ -47,12 +47,12 @@ export class AlternateRows extends Feature {
var beginIndex = noValidRowsIndex ? tf.refRow : 0;
// nb indexes
var indexLen = noValidRowsIndex ?
tf.nbFilterableRows+beginIndex :
validRowsIndex.length;
tf.nbFilterableRows + beginIndex :
validRowsIndex.length;
var idx = 0;
//alternates bg color
for(var j=beginIndex; j<indexLen; j++){
for (var j = beginIndex; j < indexLen; j++) {
var rowIdx = noValidRowsIndex ? j : validRowsIndex[j];
this.setRowBg(rowIdx, idx);
idx++;
@ -66,7 +66,7 @@ export class AlternateRows extends Feature {
* @param {Boolean} isValid Valid row flag
*/
processRow(rowIdx, arrIdx, isValid) {
if(isValid){
if (isValid) {
this.setRowBg(rowIdx, arrIdx);
} else {
this.removeRowBg(rowIdx);
@ -80,17 +80,14 @@ export class AlternateRows extends Feature {
* color
*/
setRowBg(rowIdx, idx) {
if(!this.isEnabled() || isNaN(rowIdx)){
if (!this.isEnabled() || isNaN(rowIdx)) {
return;
}
var rows = this.tf.tbl.rows;
var i = isNaN(idx) ? rowIdx : idx;
this.removeRowBg(rowIdx);
Dom.addClass(
rows[rowIdx],
(i%2) ? this.evenCss : this.oddCss
);
addClass(rows[rowIdx], (i % 2) ? this.evenCss : this.oddCss);
}
/**
@ -98,31 +95,31 @@ export class AlternateRows extends Feature {
* @param {Number} idx Row index
*/
removeRowBg(idx) {
if(isNaN(idx)){
if (isNaN(idx)) {
return;
}
var rows = this.tf.tbl.rows;
Dom.removeClass(rows[idx], this.oddCss);
Dom.removeClass(rows[idx], this.evenCss);
removeClass(rows[idx], this.oddCss);
removeClass(rows[idx], this.evenCss);
}
/**
* Removes all alternating backgrounds
*/
destroy() {
if(!this.initialized){
if (!this.initialized) {
return;
}
let nbRows = this.tf.getRowsNb(true);
for(var i=0; i<nbRows; i++){
for (var i = 0; i < nbRows; i++) {
this.removeRowBg(i);
}
// Unsubscribe to events
this.emitter.off(['row-processed', 'row-paged'],
(tf, rowIndex, arrIndex, isValid)=>
(tf, rowIndex, arrIndex, isValid) =>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.off(['column-sorted'], ()=> this.processAll());
this.emitter.off(['column-sorted'], () => this.processAll());
this.initialized = false;
}

View file

@ -1,5 +1,7 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {
addClass, createCheckItem, createText, createElm, byId, removeClass, tag
} from '../dom';
import {has} from '../array';
import {matchCase, trim, rgxEsc} from '../string';
import {ignoreCase, numSortAsc, numSortDesc} from '../sort';
@ -85,14 +87,14 @@ export class CheckList extends Feature {
let externalFltTgtId = isExternal ?
tf.externalFltTgtIds[colIndex] : null;
let divCont = Dom.create('div',
let divCont = createElm('div',
['id', this.prfxCheckListDiv + colIndex + '_' + tf.id],
['ct', colIndex], ['filled', '0']);
divCont.className = this.checkListDivCssClass;
//filter is appended in desired element
if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(divCont);
byId(externalFltTgtId).appendChild(divCont);
tf.externalFltEls.push(divCont);
} else {
container.appendChild(divCont);
@ -105,7 +107,7 @@ export class CheckList extends Feature {
this.build(colIndex);
} else {
Event.add(divCont, 'click', (evt) => this.onCheckListClick(evt));
divCont.appendChild(Dom.text(this.activateCheckListTxt));
divCont.appendChild(createText(this.activateCheckListTxt));
}
this.emitter.on(
@ -135,8 +137,8 @@ export class CheckList extends Feature {
this.optsTxt = [];
let flt = this.checkListDiv[colIndex];
let ul = Dom.create(
'ul', ['id', tf.fltIds[colIndex]], ['colIndex', colIndex]);
let ul = createElm('ul', ['id', tf.fltIds[colIndex]],
['colIndex', colIndex]);
ul.className = this.checkListCssClass;
Event.add(ul, 'change', (evt) => this.onChange(evt));
@ -279,14 +281,14 @@ export class CheckList extends Feature {
for (let y = 0; y < this.opts.length; y++) {
let val = this.opts[y]; //item value
let lbl = this.isCustom ? this.optsTxt[y] : val; //item text
let li = Dom.createCheckItem(
tf.fltIds[colIndex] + '_' + (y + chkCt), val, lbl);
let li = createCheckItem(tf.fltIds[colIndex] + '_' + (y + chkCt),
val, lbl);
li.className = this.checkListItemCssClass;
if (tf.linkedFilters && tf.disableExcludedOptions &&
has(this.excludedOpts, matchCase(val, tf.matchCase),
tf.matchCase)) {
Dom.addClass(li, this.checkListItemDisabledCssClass);
addClass(li, this.checkListItemDisabledCssClass);
li.check.disabled = true;
li.disabled = true;
} else {
@ -309,8 +311,8 @@ export class CheckList extends Feature {
addTChecks(colIndex, ul) {
let tf = this.tf;
let chkCt = 1;
let li0 = Dom.createCheckItem(
tf.fltIds[colIndex] + '_0', '', tf.displayAllText);
let li0 = createCheckItem(tf.fltIds[colIndex] + '_0', '',
tf.displayAllText);
li0.className = this.checkListItemCssClass;
ul.appendChild(li0);
@ -321,8 +323,8 @@ export class CheckList extends Feature {
}
if (tf.enableEmptyOption) {
let li1 = Dom.createCheckItem(
tf.fltIds[colIndex] + '_1', tf.emOperator, tf.emptyText);
let li1 = createCheckItem(tf.fltIds[colIndex] + '_1',
tf.emOperator, tf.emptyText);
li1.className = this.checkListItemCssClass;
ul.appendChild(li1);
Event.add(li1.check, 'click', (evt) => this.optionClick(evt));
@ -330,11 +332,8 @@ export class CheckList extends Feature {
}
if (tf.enableNonEmptyOption) {
let li2 = Dom.createCheckItem(
tf.fltIds[colIndex] + '_2',
tf.nmOperator,
tf.nonEmptyText
);
let li2 = createCheckItem(tf.fltIds[colIndex] + '_2', tf.nmOperator,
tf.nonEmptyText);
li2.className = this.checkListItemCssClass;
ul.appendChild(li2);
Event.add(li2.check, 'click', (evt) => this.optionClick(evt));
@ -374,14 +373,12 @@ export class CheckList extends Feature {
//checked items loop
for (let u = 0; u < indSplit.length; u++) {
//checked item
let cChk = Dom.id(tf.fltIds[colIndex] + '_' +
let cChk = byId(tf.fltIds[colIndex] + '_' +
indSplit[u]);
if (cChk) {
cChk.checked = false;
Dom.removeClass(
n.childNodes[indSplit[u]],
this.checkListSlcItemCssClass
);
removeClass(n.childNodes[indSplit[u]],
this.checkListSlcItemCssClass);
}
}
}
@ -396,15 +393,14 @@ export class CheckList extends Feature {
n.setAttribute('value', chkValue);
n.setAttribute('indexes', chkIndex);
//1st option unchecked
if (Dom.id(tf.fltIds[colIndex] + '_0')) {
Dom.id(tf.fltIds[colIndex] + '_0').checked = false;
if (byId(tf.fltIds[colIndex] + '_0')) {
byId(tf.fltIds[colIndex] + '_0').checked = false;
}
}
if (li.nodeName === itemTag) {
Dom.removeClass(
n.childNodes[0], this.checkListSlcItemCssClass);
Dom.addClass(li, this.checkListSlcItemCssClass);
removeClass(n.childNodes[0], this.checkListSlcItemCssClass);
addClass(li, this.checkListSlcItemCssClass);
}
} else { //removes values and indexes
if (chkValue !== '') {
@ -419,7 +415,7 @@ export class CheckList extends Feature {
n.setAttribute('indexes', fltIndexes);
}
if (li.nodeName === itemTag) {
Dom.removeClass(li, this.checkListSlcItemCssClass);
removeClass(li, this.checkListSlcItemCssClass);
}
}
}
@ -436,16 +432,16 @@ export class CheckList extends Feature {
return;
}
let lisNb = Dom.tag(flt, 'li').length;
let lisNb = tag(flt, 'li').length;
flt.setAttribute('value', '');
flt.setAttribute('indexes', '');
for (let k = 0; k < lisNb; k++) {
let li = Dom.tag(flt, 'li')[k],
lbl = Dom.tag(li, 'label')[0],
chk = Dom.tag(li, 'input')[0],
lblTxt = matchCase(Dom.getText(lbl), tf.caseSensitive);
let li = tag(flt, 'li')[k],
lbl = tag(li, 'label')[0],
chk = tag(li, 'input')[0],
lblTxt = matchCase(getText(lbl), tf.caseSensitive);
if (lblTxt !== '' && has(values, lblTxt, tf.caseSensitive)) {
chk.checked = true;
this.setCheckListValues(chk);

View file

@ -1,18 +1,18 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, createText, id, removeElm} from '../dom';
import Event from '../event';
export class ClearButton extends Feature{
export class ClearButton extends Feature {
/**
* Clear button component
* @param {Object} tf TableFilter instance
*/
constructor(tf){
constructor(tf) {
super(tf, 'btnReset');
// Configuration object
var f = this.config;
let f = this.config;
//id of container element
this.btnResetTgtId = f.btn_reset_target_id || null;
@ -25,14 +25,14 @@ export class ClearButton extends Feature{
//defines reset button innerHtml
this.btnResetHtml = f.btn_reset_html ||
(!tf.enableIcons ? null :
'<input type="button" value="" class="'+tf.btnResetCssClass+'" ' +
'title="'+this.btnResetTooltip+'" />');
'<input type="button" value="" class="' + tf.btnResetCssClass +
'" ' + 'title="' + this.btnResetTooltip + '" />');
//span containing reset button
this.prfxResetSpan = 'resetspan_';
}
onClick(){
if(!this.isEnabled()){
onClick() {
if (!this.isEnabled()) {
return;
}
this.tf.clearFilters();
@ -41,33 +41,32 @@ export class ClearButton extends Feature{
/**
* Build DOM elements
*/
init(){
var tf = this.tf;
init() {
let tf = this.tf;
if(this.initialized){
if (this.initialized) {
return;
}
var resetspan = Dom.create('span', ['id', this.prfxResetSpan+tf.id]);
let resetspan = createElm('span', ['id', this.prfxResetSpan + tf.id]);
// reset button is added to defined element
if(!this.btnResetTgtId){
if (!this.btnResetTgtId) {
tf.setToolbar();
}
var targetEl = !this.btnResetTgtId ?
tf.rDiv : Dom.id(this.btnResetTgtId);
let targetEl = !this.btnResetTgtId ? tf.rDiv : id(this.btnResetTgtId);
targetEl.appendChild(resetspan);
if(!this.btnResetHtml){
var fltreset = Dom.create('a', ['href', 'javascript:void(0);']);
if (!this.btnResetHtml) {
let fltreset = createElm('a', ['href', 'javascript:void(0);']);
fltreset.className = tf.btnResetCssClass;
fltreset.appendChild(Dom.text(this.btnResetText));
fltreset.appendChild(createText(this.btnResetText));
resetspan.appendChild(fltreset);
Event.add(fltreset, 'click', ()=> { this.onClick(); });
Event.add(fltreset, 'click', () => { this.onClick(); });
} else {
resetspan.innerHTML = this.btnResetHtml;
var resetEl = resetspan.firstChild;
Event.add(resetEl, 'click', ()=> { this.onClick(); });
let resetEl = resetspan.firstChild;
Event.add(resetEl, 'click', () => { this.onClick(); });
}
this.btnResetEl = resetspan.firstChild;
@ -77,16 +76,16 @@ export class ClearButton extends Feature{
/**
* Remove clear button UI
*/
destroy(){
var tf = this.tf;
destroy() {
let tf = this.tf;
if(!this.initialized){
if (!this.initialized) {
return;
}
var resetspan = Dom.id(this.prfxResetSpan+tf.id);
if(resetspan){
Dom.remove(resetspan);
let resetspan = id(this.prfxResetSpan + tf.id);
if (resetspan) {
removeElm(resetspan);
}
this.btnResetEl = null;
this.initialized = false;

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, createOpt, id} from '../dom';
import {has} from '../array';
import {matchCase} from '../string';
import {ignoreCase, numSortAsc, numSortDesc} from '../sort';
@ -67,7 +67,7 @@ export class Dropdown extends Feature {
let externalFltTgtId = isExternal ?
tf.externalFltTgtIds[colIndex] : null;
let slc = Dom.create(SELECT,
let slc = createElm(SELECT,
['id', tf.prfxFlt + colIndex + '_' + tf.id],
['ct', colIndex], ['filled', '0']
);
@ -81,7 +81,7 @@ export class Dropdown extends Feature {
//filter is appended in container element
if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(slc);
id(externalFltTgtId).appendChild(slc);
tf.externalFltEls.push(slc);
} else {
container.appendChild(slc);
@ -93,7 +93,7 @@ export class Dropdown extends Feature {
this.build(colIndex);
} else {
//1st option is created here since build isn't invoked
let opt0 = Dom.createOpt(tf.displayAllText, '');
let opt0 = createOpt(tf.displayAllText, '');
slc.appendChild(opt0);
}
@ -129,9 +129,9 @@ export class Dropdown extends Feature {
this.slcInnerHtml = '';
let slcId = tf.fltIds[colIndex];
let slc = Dom.id(slcId),
rows = tf.tbl.rows,
nbRows = tf.getRowsNb(true);
let slc = id(slcId);
let rows = tf.tbl.rows;
let nbRows = tf.getRowsNb(true);
//custom select test
this.isCustom = tf.isCustomOptions(colIndex);
@ -290,9 +290,9 @@ export class Dropdown extends Feature {
//fill select on demand
if (tf.loadFltOnDemand && slcValue === this.opts[y] &&
tf.getFilterType(colIndex) === SELECT) {
opt = Dom.createOpt(lbl, val, true);
opt = createOpt(lbl, val, true);
} else {
opt = Dom.createOpt(lbl, val, false);
opt = createOpt(lbl, val, false);
}
if (isDisabled) {
opt.disabled = true;
@ -310,18 +310,18 @@ export class Dropdown extends Feature {
addFirstOption(slc) {
let tf = this.tf;
let opt0 = Dom.createOpt(
let opt0 = createOpt(
(!this.enableSlcResetFilter ? '' : tf.displayAllText), '');
if (!this.enableSlcResetFilter) {
opt0.style.display = NONE;
}
slc.appendChild(opt0);
if (tf.enableEmptyOption) {
let opt1 = Dom.createOpt(tf.emptyText, tf.emOperator);
let opt1 = createOpt(tf.emptyText, tf.emOperator);
slc.appendChild(opt1);
}
if (tf.enableNonEmptyOption) {
let opt2 = Dom.createOpt(tf.nonEmptyText, tf.nmOperator);
let opt2 = createOpt(tf.nonEmptyText, tf.nmOperator);
slc.appendChild(opt2);
}
return slc;

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, removeElm, id, tag} from '../dom';
import {isFn, isNull, isUndef} from '../types';
import Event from '../event';
import {contains} from '../string';
@ -110,7 +110,7 @@ export class GridLayout extends Feature {
}
//Main container: it will contain all the elements
this.tblMainCont = Dom.create('div',
this.tblMainCont = createElm('div',
['id', this.prfxMainTblCont + tf.id]);
this.tblMainCont.className = this.gridMainContCssClass;
if (this.gridWidth) {
@ -119,7 +119,7 @@ export class GridLayout extends Feature {
tbl.parentNode.insertBefore(this.tblMainCont, tbl);
//Table container: div wrapping content table
this.tblCont = Dom.create('div', ['id', this.prfxTblCont + tf.id]);
this.tblCont = createElm('div', ['id', this.prfxTblCont + tf.id]);
this.tblCont.className = this.gridContCssClass;
if (this.gridWidth) {
if (this.gridWidth.indexOf('%') !== -1) {
@ -132,7 +132,7 @@ export class GridLayout extends Feature {
this.tblCont.style.height = this.gridHeight;
}
tbl.parentNode.insertBefore(this.tblCont, tbl);
let t = Dom.remove(tbl);
let t = removeElm(tbl);
this.tblCont.appendChild(t);
//In case table width is expressed in %
@ -141,11 +141,11 @@ export class GridLayout extends Feature {
tbl.clientWidth : tblW) + 'px';
}
let d = Dom.remove(this.tblCont);
let d = removeElm(this.tblCont);
this.tblMainCont.appendChild(d);
//Headers table container: div wrapping headers table
this.headTblCont = Dom.create(
this.headTblCont = createElm(
'div', ['id', this.prfxHeadTblCont + tf.id]);
this.headTblCont.className = this.gridHeadContCssClass;
if (this.gridWidth) {
@ -157,8 +157,8 @@ export class GridLayout extends Feature {
}
//Headers table
this.headTbl = Dom.create('table', ['id', this.prfxHeadTbl + tf.id]);
let tH = Dom.create('tHead');
this.headTbl = createElm('table', ['id', this.prfxHeadTbl + tf.id]);
let tH = createElm('tHead');
//1st row should be headers row, ids are added if not set
//Those ids are used by the sort feature
@ -175,12 +175,12 @@ export class GridLayout extends Feature {
}
//Filters row is created
let filtersRow = Dom.create('tr');
let filtersRow = createElm('tr');
if (this.gridEnableFilters && tf.fltGrid) {
tf.externalFltTgtIds = [];
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]);
let cl = createElm(tf.fltCellTag, ['id', fltTdId]);
filtersRow.appendChild(cl);
tf.externalFltTgtIds[j] = fltTdId;
}
@ -195,7 +195,7 @@ export class GridLayout extends Feature {
} else {
// Handle table with no headers, assuming here headers do not
// exist
tH.appendChild(Dom.create('tr'));
tH.appendChild(createElm('tr'));
}
this.headTbl.appendChild(tH);
@ -209,7 +209,7 @@ export class GridLayout extends Feature {
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
//THead needs to be removed in content table for sort feature
let thead = Dom.tag(tbl, 'thead');
let thead = tag(tbl, 'thead');
if (thead.length > 0) {
tbl.removeChild(thead[0]);
}
@ -264,13 +264,13 @@ export class GridLayout extends Feature {
}
//Cols generation for all browsers excepted IE<=7
this.tblHasColTag = Dom.tag(tbl, 'col').length > 0 ? true : false;
this.tblHasColTag = tag(tbl, 'col').length > 0 ? true : false;
//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 col = createElm('col', ['id', tf.id + '_col_' + k]);
tbl.insertBefore(col, tbl.firstChild);
col.style.width = tf.colWidths[k];
this.gridColElms[k] = col;
@ -281,7 +281,7 @@ export class GridLayout extends Feature {
if (!this.tblHasColTag) {
createColTags.call(this);
} else {
let cols = Dom.tag(tbl, 'col');
let cols = tag(tbl, 'col');
for (let ii = 0; ii < tf.nbCells; ii++) {
cols[ii].setAttribute('id', tf.id + '_col_' + ii);
cols[ii].style.width = tf.colWidths[ii];
@ -332,9 +332,9 @@ export class GridLayout extends Feature {
if (!this.initialized) {
return;
}
let t = Dom.remove(tbl);
let t = removeElm(tbl);
this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont);
Dom.remove(this.tblMainCont);
removeElm(this.tblMainCont);
this.tblMainCont = null;
this.headTblCont = null;
@ -343,7 +343,7 @@ export class GridLayout extends Feature {
tbl.outerHTML = this.sourceTblHtml;
//needed to keep reference of table element for future usage
this.tf.tbl = Dom.id(tf.id);
this.tf.tbl = id(tf.id);
this.initialized = false;
}

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, createText, id, removeElm} from '../dom';
import Event from '../event';
import {NONE} from '../const';
@ -70,36 +70,36 @@ export class Help extends Feature{
var tf = this.tf;
var helpspan = Dom.create('span', ['id', this.prfxHelpSpan+tf.id]);
var helpdiv = Dom.create('div', ['id', this.prfxHelpDiv+tf.id]);
var helpspan = createElm('span', ['id', this.prfxHelpSpan+tf.id]);
var helpdiv = createElm('div', ['id', this.prfxHelpDiv+tf.id]);
//help button is added to defined element
if(!this.tgtId){
tf.setToolbar();
}
var targetEl = !this.tgtId ? tf.rDiv : Dom.id(this.tgtId);
var targetEl = !this.tgtId ? tf.rDiv : id(this.tgtId);
targetEl.appendChild(helpspan);
var divContainer = !this.contTgtId ? helpspan : Dom.id(this.contTgtId);
var divContainer = !this.contTgtId ? helpspan : id(this.contTgtId);
if(!this.btnHtml){
divContainer.appendChild(helpdiv);
var helplink = Dom.create('a', ['href', 'javascript:void(0);']);
var helplink = createElm('a', ['href', 'javascript:void(0);']);
helplink.className = this.btnCssClass;
helplink.appendChild(Dom.text(this.btnText));
helplink.appendChild(createText(this.btnText));
helpspan.appendChild(helplink);
Event.add(helplink, 'click', () => { this.toggle(); });
Event.add(helplink, 'click', () => this.toggle());
} else {
helpspan.innerHTML = this.btnHtml;
var helpEl = helpspan.firstChild;
Event.add(helpEl, 'click', () => { this.toggle(); });
Event.add(helpEl, 'click', () => this.toggle());
divContainer.appendChild(helpdiv);
}
if(!this.instrHtml){
helpdiv.innerHTML = this.instrText;
helpdiv.className = this.contCssClass;
Event.add(helpdiv, 'dblclick', () => { this.toggle(); });
Event.add(helpdiv, 'dblclick', () => this.toggle());
} else {
if(this.contTgtId){
divContainer.appendChild(helpdiv);
@ -107,11 +107,11 @@ export class Help extends Feature{
helpdiv.innerHTML = this.instrHtml;
if(!this.contTgtId){
helpdiv.className = this.contCssClass;
Event.add(helpdiv, 'dblclick', () => { this.toggle(); });
Event.add(helpdiv, 'dblclick', () => this.toggle());
}
}
helpdiv.innerHTML += this.defaultHtml;
Event.add(helpdiv, 'click', () => { this.toggle(); });
Event.add(helpdiv, 'click', () => this.toggle());
this.cont = helpdiv;
this.btn = helpspan;
@ -142,12 +142,12 @@ export class Help extends Feature{
if(!this.initialized){
return;
}
Dom.remove(this.btn);
removeElm(this.btn);
this.btn = null;
if(!this.cont){
return;
}
Dom.remove(this.cont);
removeElm(this.cont);
this.cont = null;
this.initialized = false;
}

View file

@ -1,4 +1,4 @@
import Dom from '../dom';
import {createText, createElm, getText} from '../dom';
import {isArray} from '../types';
export class HighlightKeyword {
@ -55,11 +55,11 @@ export class HighlightKeyword {
let nv = node.nodeValue,
ni = tempNodeVal.indexOf(tempWordVal),
// Create a load of replacement nodes
before = Dom.text(nv.substr(0, ni)),
before = createText(nv.substr(0, ni)),
docWordVal = nv.substr(ni, word.length),
after = Dom.text(nv.substr(ni + word.length)),
hiwordtext = Dom.text(docWordVal),
hiword = Dom.create('span');
after = createText(nv.substr(ni + word.length)),
hiwordtext = createText(docWordVal),
hiword = createElm('span');
hiword.className = cssClass;
hiword.appendChild(hiwordtext);
pn.insertBefore(before, node);
@ -80,12 +80,12 @@ export class HighlightKeyword {
let highlightedNodes = this.tf.tbl.querySelectorAll(`.${cssClass}`);
for (let i = 0; i < highlightedNodes.length; i++) {
let n = highlightedNodes[i];
let nodeVal = Dom.getText(n),
let nodeVal = getText(n),
tempNodeVal = nodeVal.toLowerCase(),
tempWordVal = word.toLowerCase();
if (tempNodeVal.indexOf(tempWordVal) !== -1) {
n.parentNode.replaceChild(Dom.text(nodeVal), n);
n.parentNode.replaceChild(createText(nodeVal), n);
}
}
}

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, createText, id, removeElm} from '../dom';
import {isFn} from '../types';
import {root} from '../root';
import {NONE} from '../const';
@ -44,11 +44,11 @@ export class Loader extends Feature {
let tf = this.tf;
let emitter = this.emitter;
let containerDiv = Dom.create('div', ['id', this.prfxLoader + tf.id]);
let containerDiv = createElm('div', ['id', this.prfxLoader + tf.id]);
containerDiv.className = this.loaderCssClass;
let targetEl = !this.loaderTgtId ?
tf.tbl.parentNode : Dom.id(this.loaderTgtId);
tf.tbl.parentNode : id(this.loaderTgtId);
if (!this.loaderTgtId) {
targetEl.insertBefore(containerDiv, tf.tbl);
} else {
@ -56,7 +56,7 @@ export class Loader extends Feature {
}
this.loaderDiv = containerDiv;
if (!this.loaderHtml) {
this.loaderDiv.appendChild(Dom.text(this.loaderText));
this.loaderDiv.appendChild(createText(this.loaderText));
} else {
this.loaderDiv.innerHTML = this.loaderHtml;
}
@ -121,7 +121,7 @@ export class Loader extends Feature {
let emitter = this.emitter;
Dom.remove(this.loaderDiv);
removeElm(this.loaderDiv);
this.loaderDiv = null;
// Unsubscribe to events

View file

@ -1,15 +1,15 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, id, removeElm} from '../dom';
import {isEmpty, isFn} from '../types';
import {NONE} from '../const';
export class NoResults extends Feature{
export class NoResults extends Feature {
/**
* No results message UI component
* @param {Object} tf TableFilter instance
*/
constructor(tf){
constructor(tf) {
super(tf, 'noResults');
//configuration object
@ -40,20 +40,20 @@ export class NoResults extends Feature{
this.prfxNoResults = 'nores_';
}
init(){
if(this.initialized){
init() {
if (this.initialized) {
return;
}
let tf = this.tf;
let target = this.customContainer || Dom.id(this.customContainerId) ||
let target = this.customContainer || id(this.customContainerId) ||
tf.tbl;
//container
let cont = Dom.create('div', ['id', this.prfxNoResults+tf.id]);
let cont = createElm('div', ['id', this.prfxNoResults + tf.id]);
cont.className = this.cssClass;
cont.innerHTML = this.content;
if(this.isExternal){
if (this.isExternal) {
target.appendChild(cont);
} else {
target.parentNode.insertBefore(cont, target.nextSibling);
@ -62,58 +62,58 @@ export class NoResults extends Feature{
this.cont = cont;
// subscribe to after-filtering event
this.emitter.on(['after-filtering'], ()=> this.toggle());
this.emitter.on(['after-filtering'], () => this.toggle());
this.initialized = true;
this.hide();
}
toggle(){
if(this.tf.nbVisibleRows > 0){
toggle() {
if (this.tf.nbVisibleRows > 0) {
this.hide();
} else {
this.show();
}
}
show(){
if(!this.initialized || !this.isEnabled()){
show() {
if (!this.initialized || !this.isEnabled()) {
return;
}
if(this.onBeforeShowMsg){
if (this.onBeforeShowMsg) {
this.onBeforeShowMsg.call(null, this.tf, this);
}
this.setWidth();
this.cont.style.display = 'block';
if(this.onAfterShowMsg){
if (this.onAfterShowMsg) {
this.onAfterShowMsg.call(null, this.tf, this);
}
}
hide(){
if(!this.initialized || !this.isEnabled()){
hide() {
if (!this.initialized || !this.isEnabled()) {
return;
}
if(this.onBeforeHideMsg){
if (this.onBeforeHideMsg) {
this.onBeforeHideMsg.call(null, this.tf, this);
}
this.cont.style.display = NONE;
if(this.onBeforeHideMsg){
if (this.onBeforeHideMsg) {
this.onBeforeHideMsg.call(null, this.tf, this);
}
}
setWidth(){
if(!this.initialized || this.isExternal || !this.isEnabled()){
setWidth() {
if (!this.initialized || this.isExternal || !this.isEnabled()) {
return;
}
if(this.tf.gridLayout){
if (this.tf.gridLayout) {
let gridLayout = this.tf.feature('gridLayout');
this.cont.style.width = gridLayout.tblCont.clientWidth + 'px';
} else {
@ -122,14 +122,14 @@ export class NoResults extends Feature{
}
destroy(){
if(!this.initialized){
destroy() {
if (!this.initialized) {
return;
}
Dom.remove(this.cont);
removeElm(this.cont);
this.cont = null;
// unsubscribe to after-filtering event
this.emitter.off(['after-filtering'], ()=> this.toggle());
this.emitter.off(['after-filtering'], () => this.toggle());
this.initialized = false;
}

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, createOpt, createText, id, removeElm} from '../dom';
import {isArray, isFn, isNull} from '../types';
import Event from '../event';
import {INPUT, SELECT, NONE, ENTER_KEY} from '../const';
@ -205,14 +205,14 @@ export class Paging extends Feature {
// Paging drop-down list selector
if (this.pageSelectorType === SELECT) {
slcPages = Dom.create(SELECT, ['id', this.prfxSlcPages + tf.id]);
slcPages = createElm(SELECT, ['id', this.prfxSlcPages + tf.id]);
slcPages.className = this.pgSlcCssClass;
Event.add(slcPages, 'change', evt.slcPagesChange);
}
// Paging input selector
if (this.pageSelectorType === INPUT) {
slcPages = Dom.create(INPUT,
slcPages = createElm(INPUT,
['id', this.prfxSlcPages + tf.id],
['value', this.currentPageNb]
);
@ -221,19 +221,19 @@ export class Paging extends Feature {
}
// btns containers
var btnNextSpan = Dom.create(
var btnNextSpan = createElm(
'span', ['id', this.prfxBtnNextSpan + tf.id]);
var btnPrevSpan = Dom.create(
var btnPrevSpan = createElm(
'span', ['id', this.prfxBtnPrevSpan + tf.id]);
var btnLastSpan = Dom.create(
var btnLastSpan = createElm(
'span', ['id', this.prfxBtnLastSpan + tf.id]);
var btnFirstSpan = Dom.create(
var btnFirstSpan = createElm(
'span', ['id', this.prfxBtnFirstSpan + tf.id]);
if (this.hasPagingBtns) {
// Next button
if (!this.btnNextPageHtml) {
var btn_next = Dom.create(INPUT,
var btn_next = createElm(INPUT,
['id', this.prfxBtnNext + tf.id],
['type', 'button'],
['value', this.btnNextPageText],
@ -248,7 +248,7 @@ export class Paging extends Feature {
}
// Previous button
if (!this.btnPrevPageHtml) {
var btn_prev = Dom.create(INPUT,
var btn_prev = createElm(INPUT,
['id', this.prfxBtnPrev + tf.id],
['type', 'button'],
['value', this.btnPrevPageText],
@ -263,7 +263,7 @@ export class Paging extends Feature {
}
// Last button
if (!this.btnLastPageHtml) {
var btn_last = Dom.create(INPUT,
var btn_last = createElm(INPUT,
['id', this.prfxBtnLast + tf.id],
['type', 'button'],
['value', this.btnLastPageText],
@ -278,7 +278,7 @@ export class Paging extends Feature {
}
// First button
if (!this.btnFirstPageHtml) {
var btn_first = Dom.create(INPUT,
var btn_first = createElm(INPUT,
['id', this.prfxBtnFirst + tf.id],
['type', 'button'],
['value', this.btnFirstPageText],
@ -297,28 +297,28 @@ export class Paging extends Feature {
if (!this.pagingTgtId) {
tf.setToolbar();
}
var targetEl = !this.pagingTgtId ? tf.mDiv : Dom.id(this.pagingTgtId);
var targetEl = !this.pagingTgtId ? tf.mDiv : id(this.pagingTgtId);
targetEl.appendChild(btnFirstSpan);
targetEl.appendChild(btnPrevSpan);
var pgBeforeSpan = Dom.create(
var pgBeforeSpan = createElm(
'span', ['id', this.prfxPgBeforeSpan + tf.id]);
pgBeforeSpan.appendChild(Dom.text(this.pageText));
pgBeforeSpan.appendChild(createText(this.pageText));
pgBeforeSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgBeforeSpan);
targetEl.appendChild(slcPages);
var pgAfterSpan = Dom.create(
var pgAfterSpan = createElm(
'span', ['id', this.prfxPgAfterSpan + tf.id]);
pgAfterSpan.appendChild(Dom.text(this.ofText));
pgAfterSpan.appendChild(createText(this.ofText));
pgAfterSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgAfterSpan);
var pgspan = Dom.create('span', ['id', this.prfxPgSpan + tf.id]);
var pgspan = createElm('span', ['id', this.prfxPgSpan + tf.id]);
pgspan.className = this.nbPgSpanCssClass;
pgspan.appendChild(Dom.text(' ' + this.nbPages + ' '));
pgspan.appendChild(createText(' ' + this.nbPages + ' '));
targetEl.appendChild(pgspan);
targetEl.appendChild(btnNextSpan);
targetEl.appendChild(btnLastSpan);
this.pagingSlc = Dom.id(this.prfxSlcPages + tf.id);
this.pagingSlc = id(this.prfxSlcPages + tf.id);
this.setPagingInfo();
@ -369,8 +369,8 @@ export class Paging extends Feature {
*/
setPagingInfo(validRows) {
var tf = this.tf;
var mdiv = !this.pagingTgtId ? tf.mDiv : Dom.id(this.pagingTgtId);
var pgspan = Dom.id(this.prfxPgSpan + tf.id);
var mdiv = !this.pagingTgtId ? tf.mDiv : id(this.pagingTgtId);
var pgspan = id(this.prfxPgSpan + tf.id);
//store valid rows indexes
tf.validRowsIndex = validRows || tf.getValidRows(true);
@ -388,8 +388,7 @@ export class Paging extends Feature {
mdiv.style.visibility = 'visible';
if (this.pageSelectorType === SELECT) {
for (var z = 0; z < this.nbPages; z++) {
var opt = Dom.createOpt(z + 1, z * this.pagingLength,
false);
var opt = createOpt(z + 1, z * this.pagingLength, false);
this.pagingSlc.options[z] = opt;
}
} else {
@ -503,11 +502,11 @@ export class Paging extends Feature {
ev.target.blur();
};
var slcR = Dom.create(SELECT, ['id', this.prfxSlcResults + tf.id]);
var slcR = createElm(SELECT, ['id', this.prfxSlcResults + tf.id]);
slcR.className = this.resultsSlcCssClass;
var slcRText = this.resultsPerPage[0],
slcROpts = this.resultsPerPage[1];
var slcRSpan = Dom.create(
var slcRSpan = createElm(
'span', ['id', this.prfxSlcResultsTxt + tf.id]);
slcRSpan.className = this.resultsSpanCssClass;
@ -516,8 +515,8 @@ export class Paging extends Feature {
tf.setToolbar();
}
var targetEl = !this.resultsPerPageTgtId ?
tf.rDiv : Dom.id(this.resultsPerPageTgtId);
slcRSpan.appendChild(Dom.text(slcRText));
tf.rDiv : id(this.resultsPerPageTgtId);
slcRSpan.appendChild(createText(slcRText));
var help = tf.feature('help');
if (help && help.btn) {
@ -545,12 +544,12 @@ export class Paging extends Feature {
return;
}
var slcR = this.resultsPerPageSlc,
slcRSpan = Dom.id(this.prfxSlcResultsTxt + tf.id);
slcRSpan = id(this.prfxSlcResultsTxt + tf.id);
if (slcR) {
Dom.remove(slcR);
removeElm(slcR);
}
if (slcRSpan) {
Dom.remove(slcRSpan);
removeElm(slcRSpan);
}
this.resultsPerPageSlc = null;
}
@ -686,16 +685,16 @@ export class Paging extends Feature {
return;
}
// btns containers
var btnNextSpan = Dom.id(this.prfxBtnNextSpan + tf.id);
var btnPrevSpan = Dom.id(this.prfxBtnPrevSpan + tf.id);
var btnLastSpan = Dom.id(this.prfxBtnLastSpan + tf.id);
var btnFirstSpan = Dom.id(this.prfxBtnFirstSpan + tf.id);
var btnNextSpan = id(this.prfxBtnNextSpan + tf.id);
var btnPrevSpan = id(this.prfxBtnPrevSpan + tf.id);
var btnLastSpan = id(this.prfxBtnLastSpan + tf.id);
var btnFirstSpan = id(this.prfxBtnFirstSpan + tf.id);
//span containing 'Page' text
var pgBeforeSpan = Dom.id(this.prfxPgBeforeSpan + tf.id);
var pgBeforeSpan = id(this.prfxPgBeforeSpan + tf.id);
//span containing 'of' text
var pgAfterSpan = Dom.id(this.prfxPgAfterSpan + tf.id);
var pgAfterSpan = id(this.prfxPgAfterSpan + tf.id);
//span containing nb of pages
var pgspan = Dom.id(this.prfxPgSpan + tf.id);
var pgspan = id(this.prfxPgSpan + tf.id);
var evt = this.evt;
@ -706,39 +705,39 @@ export class Paging extends Feature {
else if (this.pageSelectorType === INPUT) {
Event.remove(this.pagingSlc, 'keypress', evt._detectKey);
}
Dom.remove(this.pagingSlc);
removeElm(this.pagingSlc);
}
if (btnNextSpan) {
Event.remove(btnNextSpan, 'click', evt.next);
Dom.remove(btnNextSpan);
removeElm(btnNextSpan);
}
if (btnPrevSpan) {
Event.remove(btnPrevSpan, 'click', evt.prev);
Dom.remove(btnPrevSpan);
removeElm(btnPrevSpan);
}
if (btnLastSpan) {
Event.remove(btnLastSpan, 'click', evt.last);
Dom.remove(btnLastSpan);
removeElm(btnLastSpan);
}
if (btnFirstSpan) {
Event.remove(btnFirstSpan, 'click', evt.first);
Dom.remove(btnFirstSpan);
removeElm(btnFirstSpan);
}
if (pgBeforeSpan) {
Dom.remove(pgBeforeSpan);
removeElm(pgBeforeSpan);
}
if (pgAfterSpan) {
Dom.remove(pgAfterSpan);
removeElm(pgAfterSpan);
}
if (pgspan) {
Dom.remove(pgspan);
removeElm(pgspan);
}
if (this.hasResultsPerPage) {

View file

@ -1,20 +1,20 @@
import {Feature} from '../feature';
import {isFn} from '../types';
import Dom from '../dom';
import {createElm, removeElm} from '../dom';
import Event from '../event';
import {INPUT, NONE} from '../const';
export class PopupFilter extends Feature{
export class PopupFilter extends Feature {
/**
* Pop-up filter component
* @param {Object} tf TableFilter instance
*/
constructor(tf){
constructor(tf) {
super(tf, 'popupFilters');
// Configuration object
var f = this.config;
let f = this.config;
// Enable external filters
tf.isExternalFlt = true;
@ -22,12 +22,12 @@ export class PopupFilter extends Feature{
//filter icon path
this.popUpImgFlt = f.popup_filters_image ||
tf.themesPath+'icn_filter.gif';
tf.themesPath + 'icn_filter.gif';
//active filter icon path
this.popUpImgFltActive = f.popup_filters_image_active ||
tf.themesPath+'icn_filterActive.gif';
tf.themesPath + 'icn_filterActive.gif';
this.popUpImgFltHtml = f.popup_filters_image_html ||
'<img src="'+ this.popUpImgFlt +'" alt="Column filter" />';
'<img src="' + this.popUpImgFlt + '" alt="Column filter" />';
//defines css class for popup div containing filter
this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter';
//callback function before popup filtes is opened
@ -57,15 +57,15 @@ export class PopupFilter extends Feature{
this.prfxPopUpDiv = 'popUpDiv_';
}
onClick(evt){
var elm = Event.target(evt).parentNode,
onClick(evt) {
let elm = Event.target(evt).parentNode,
colIndex = parseInt(elm.getAttribute('ci'), 10);
this.closeAll(colIndex);
this.toggle(colIndex);
if(this.popUpFltAdjustToContainer){
var popUpDiv = this.popUpFltElms[colIndex],
if (this.popUpFltAdjustToContainer) {
let popUpDiv = this.popUpFltElms[colIndex],
header = this.tf.getHeaderElement(colIndex),
headerWidth = header.clientWidth * 0.95;
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
@ -77,29 +77,29 @@ export class PopupFilter extends Feature{
/**
* Initialize DOM elements
*/
init(){
if(this.initialized){
init() {
if (this.initialized) {
return;
}
var tf = this.tf;
let tf = this.tf;
// Override headers row index if no grouped headers
if(tf.headersRow <= 1){
if (tf.headersRow <= 1) {
tf.headersRow = 0;
}
for(var i=0; i<tf.nbCells; i++){
if(tf.getFilterType(i) === NONE){
for (let i = 0; i < tf.nbCells; i++) {
if (tf.getFilterType(i) === NONE) {
continue;
}
var popUpSpan = Dom.create(
let popUpSpan = createElm(
'span',
['id', this.prfxPopUpSpan+tf.id+'_'+i],
['id', this.prfxPopUpSpan + tf.id + '_' + i],
['ci', i]
);
popUpSpan.innerHTML = this.popUpImgFltHtml;
var header = tf.getHeaderElement(i);
let header = tf.getHeaderElement(i);
header.appendChild(popUpSpan);
Event.add(popUpSpan, 'click', (evt) => { this.onClick(evt); });
this.popUpFltSpans[i] = popUpSpan;
@ -107,13 +107,13 @@ export class PopupFilter extends Feature{
}
// subscribe to events
this.emitter.on(['before-filtering'], ()=> this.buildIcons());
this.emitter.on(['after-filtering'], ()=> this.closeAll());
this.emitter.on(['before-filtering'], () => this.buildIcons());
this.emitter.on(['after-filtering'], () => this.closeAll());
this.emitter.on(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true));
this.emitter.on(['filters-row-inserted'], ()=> this.tf.headersRow++);
(tf, cellIndex) => this.buildIcon(cellIndex, true));
this.emitter.on(['filters-row-inserted'], () => this.tf.headersRow++);
this.emitter.on(['before-filter-init'],
(tf, colIndex)=> this.build(colIndex));
(tf, colIndex) => this.build(colIndex));
this.initialized = true;
}
@ -121,7 +121,7 @@ export class PopupFilter extends Feature{
/**
* Reset previously destroyed feature
*/
reset(){
reset() {
this.enable();
this.init();
this.buildAll();
@ -130,8 +130,8 @@ export class PopupFilter extends Feature{
/**
* Build all pop-up filters elements
*/
buildAll(){
for(var i=0; i<this.popUpFltElmCache.length; i++){
buildAll() {
for (let i = 0; i < this.popUpFltElmCache.length; i++) {
this.build(i, this.popUpFltElmCache[i]);
}
}
@ -141,14 +141,15 @@ export class PopupFilter extends Feature{
* @param {Number} colIndex Column index
* @param {Object} div Optional container DOM element
*/
build(colIndex, div){
var tf = this.tf;
var popUpDiv = !div ?
Dom.create('div', ['id', this.prfxPopUpDiv+tf.id+'_'+colIndex]) :
build(colIndex, div) {
let tf = this.tf;
let popUpDiv = !div ?
createElm('div',
['id', this.prfxPopUpDiv + tf.id + '_' + colIndex]) :
div;
popUpDiv.className = this.popUpDivCssClass;
tf.externalFltTgtIds.push(popUpDiv.id);
var header = tf.getHeaderElement(colIndex);
let header = tf.getHeaderElement(colIndex);
header.insertBefore(popUpDiv, header.firstChild);
Event.add(popUpDiv, 'click', (evt) => Event.stop(evt));
this.popUpFltElms[colIndex] = popUpDiv;
@ -158,34 +159,34 @@ export class PopupFilter extends Feature{
* Toogle visibility of specified filter
* @param {Number} colIndex Column index
*/
toggle(colIndex){
var tf = this.tf,
toggle(colIndex) {
let tf = this.tf,
popUpFltElm = this.popUpFltElms[colIndex];
if(popUpFltElm.style.display === NONE ||
popUpFltElm.style.display === ''){
if(this.onBeforePopUpOpen){
if (popUpFltElm.style.display === NONE ||
popUpFltElm.style.display === '') {
if (this.onBeforePopUpOpen) {
this.onBeforePopUpOpen.call(
null, this, this.popUpFltElms[colIndex], colIndex);
}
popUpFltElm.style.display = 'block';
if(tf.getFilterType(colIndex) === INPUT){
var flt = tf.getFilterElement(colIndex);
if(flt){
if (tf.getFilterType(colIndex) === INPUT) {
let flt = tf.getFilterElement(colIndex);
if (flt) {
flt.focus();
}
}
if(this.onAfterPopUpOpen){
if (this.onAfterPopUpOpen) {
this.onAfterPopUpOpen.call(
null, this, this.popUpFltElms[colIndex], colIndex);
}
} else {
if(this.onBeforePopUpClose){
if (this.onBeforePopUpClose) {
this.onBeforePopUpClose.call(
null, this, this.popUpFltElms[colIndex], colIndex);
}
popUpFltElm.style.display = NONE;
if(this.onAfterPopUpClose){
if (this.onAfterPopUpClose) {
this.onAfterPopUpClose.call(
null, this, this.popUpFltElms[colIndex], colIndex);
}
@ -196,13 +197,13 @@ export class PopupFilter extends Feature{
* Close all filters excepted for the specified one if any
* @param {Number} exceptIdx Column index of the filter to not close
*/
closeAll(exceptIdx){
for(var i=0; i<this.popUpFltElms.length; i++){
if(i === exceptIdx){
closeAll(exceptIdx) {
for (let i = 0; i < this.popUpFltElms.length; i++) {
if (i === exceptIdx) {
continue;
}
var popUpFltElm = this.popUpFltElms[i];
if(popUpFltElm){
let popUpFltElm = this.popUpFltElms[i];
if (popUpFltElm) {
popUpFltElm.style.display = NONE;
}
}
@ -211,8 +212,8 @@ export class PopupFilter extends Feature{
/**
* Build all the icons representing the pop-up filters
*/
buildIcons(){
for(var i=0; i<this.popUpFltImgs.length; i++){
buildIcons() {
for (let i = 0; i < this.popUpFltImgs.length; i++) {
this.buildIcon(i, false);
}
}
@ -222,8 +223,8 @@ export class PopupFilter extends Feature{
* @param {Number} colIndex Column index
* @param {Boolean} active Apply active state
*/
buildIcon(colIndex, active){
if(this.popUpFltImgs[colIndex]){
buildIcon(colIndex, active) {
if (this.popUpFltImgs[colIndex]) {
this.popUpFltImgs[colIndex].src = active ?
this.popUpImgFltActive : this.popUpImgFlt;
}
@ -232,27 +233,27 @@ export class PopupFilter extends Feature{
/**
* Remove pop-up filters
*/
destroy(){
if(!this.initialized){
destroy() {
if (!this.initialized) {
return;
}
this.popUpFltElmCache = [];
for(var i=0; i<this.popUpFltElms.length; i++){
var popUpFltElm = this.popUpFltElms[i],
for (let i = 0; i < this.popUpFltElms.length; i++) {
let popUpFltElm = this.popUpFltElms[i],
popUpFltSpan = this.popUpFltSpans[i],
popUpFltImg = this.popUpFltImgs[i];
if(popUpFltElm){
Dom.remove(popUpFltElm);
if (popUpFltElm) {
removeElm(popUpFltElm);
this.popUpFltElmCache[i] = popUpFltElm;
}
popUpFltElm = null;
if(popUpFltSpan){
Dom.remove(popUpFltSpan);
if (popUpFltSpan) {
removeElm(popUpFltSpan);
}
popUpFltSpan = null;
if(popUpFltImg){
Dom.remove(popUpFltImg);
if (popUpFltImg) {
removeElm(popUpFltImg);
}
popUpFltImg = null;
}
@ -261,13 +262,13 @@ export class PopupFilter extends Feature{
this.popUpFltImgs = [];
// unsubscribe to events
this.emitter.off(['before-filtering'], ()=> this.buildIcons());
this.emitter.off(['after-filtering'], ()=> this.closeAll());
this.emitter.off(['before-filtering'], () => this.buildIcons());
this.emitter.off(['after-filtering'], () => this.closeAll());
this.emitter.off(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true));
this.emitter.off(['filters-row-inserted'], ()=> this.tf.headersRow++);
(tf, cellIndex) => this.buildIcon(cellIndex, true));
this.emitter.off(['filters-row-inserted'], () => this.tf.headersRow++);
this.emitter.off(['before-filter-init'],
(tf, colIndex)=> this.build(colIndex));
(tf, colIndex) => this.build(colIndex));
this.initialized = false;
}

View file

@ -1,14 +1,14 @@
import {Feature} from '../feature';
import Dom from '../dom';
import {createElm, createText, id, removeElm} from '../dom';
import {isFn} from '../types';
export class RowsCounter extends Feature{
export class RowsCounter extends Feature {
/**
* Rows counter
* @param {Object} tf TableFilter instance
*/
constructor(tf){
constructor(tf) {
super(tf, 'rowsCounter');
// TableFilter configuration
@ -40,35 +40,35 @@ export class RowsCounter extends Feature{
f.on_after_refresh_counter : null;
}
init(){
if(this.initialized){
init() {
if (this.initialized) {
return;
}
var tf = this.tf;
//rows counter container
var countDiv = Dom.create('div', ['id', this.prfxCounter+tf.id]);
var countDiv = createElm('div', ['id', this.prfxCounter + tf.id]);
countDiv.className = this.totRowsCssClass;
//rows counter label
var countSpan = Dom.create('span', ['id', this.prfxTotRows+tf.id]);
var countText = Dom.create('span', ['id', this.prfxTotRowsTxt+tf.id]);
countText.appendChild(Dom.text(this.rowsCounterText));
var countSpan = createElm('span', ['id', this.prfxTotRows + tf.id]);
var countText = createElm('span', ['id', this.prfxTotRowsTxt + tf.id]);
countText.appendChild(createText(this.rowsCounterText));
// counter is added to defined element
if(!this.rowsCounterTgtId){
if (!this.rowsCounterTgtId) {
tf.setToolbar();
}
var targetEl = !this.rowsCounterTgtId ?
tf.lDiv : Dom.id( this.rowsCounterTgtId );
tf.lDiv : id(this.rowsCounterTgtId);
//default container: 'lDiv'
if(!this.rowsCounterTgtId){
if (!this.rowsCounterTgtId) {
countDiv.appendChild(countText);
countDiv.appendChild(countSpan);
targetEl.appendChild(countDiv);
}
else{
else {
//custom container, no need to append statusDiv
targetEl.appendChild(countText);
targetEl.appendChild(countSpan);
@ -78,40 +78,41 @@ export class RowsCounter extends Feature{
// subscribe to events
this.emitter.on(['after-filtering', 'grouped-by-page'],
()=> this.refresh(tf.nbVisibleRows));
this.emitter.on(['rows-changed'], ()=> this.refresh());
() => this.refresh(tf.nbVisibleRows));
this.emitter.on(['rows-changed'], () => this.refresh());
this.initialized = true;
this.refresh();
}
refresh(p){
if(!this.initialized || !this.isEnabled()){
refresh(p) {
if (!this.initialized || !this.isEnabled()) {
return;
}
var tf = this.tf;
if(this.onBeforeRefreshCounter){
if (this.onBeforeRefreshCounter) {
this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan);
}
var totTxt;
if(!tf.paging){
if(p && p !== ''){
if (!tf.paging) {
if (p && p !== '') {
totTxt = p;
} else{
} else {
totTxt = tf.nbFilterableRows - tf.nbHiddenRows;
}
} else {
var paging = tf.feature('paging');
if(paging){
if (paging) {
//paging start row
var paging_start_row = parseInt(paging.startPagingRow, 10) +
((tf.nbVisibleRows>0) ? 1 : 0);
var paging_end_row = (paging_start_row+paging.pagingLength)-1 <=
tf.nbVisibleRows ?
paging_start_row+paging.pagingLength-1 :
((tf.nbVisibleRows > 0) ? 1 : 0);
var paging_end_row =
(paging_start_row + paging.pagingLength) - 1 <=
tf.nbVisibleRows ?
paging_start_row + paging.pagingLength - 1 :
tf.nbVisibleRows;
totTxt = paging_start_row + this.fromToTextSeparator +
paging_end_row + this.overText + tf.nbVisibleRows;
@ -119,29 +120,29 @@ export class RowsCounter extends Feature{
}
this.rowsCounterSpan.innerHTML = totTxt;
if(this.onAfterRefreshCounter){
if (this.onAfterRefreshCounter) {
this.onAfterRefreshCounter.call(
null, tf, this.rowsCounterSpan, totTxt);
}
}
destroy(){
if(!this.initialized){
destroy() {
if (!this.initialized) {
return;
}
if(!this.rowsCounterTgtId && this.rowsCounterDiv){
Dom.remove(this.rowsCounterDiv);
if (!this.rowsCounterTgtId && this.rowsCounterDiv) {
removeElm(this.rowsCounterDiv);
} else {
Dom.id(this.rowsCounterTgtId).innerHTML = '';
id(this.rowsCounterTgtId).innerHTML = '';
}
this.rowsCounterSpan = null;
this.rowsCounterDiv = null;
// unsubscribe to events
this.emitter.off(['after-filtering', 'grouped-by-page'],
()=> this.refresh(tf.nbVisibleRows));
this.emitter.off(['rows-changed'], ()=> this.refresh());
() => this.refresh(tf.nbVisibleRows));
this.emitter.off(['rows-changed'], () => this.refresh());
this.initialized = false;
}

View file

@ -1,15 +1,15 @@
import {Feature} from '../feature';
import {root} from '../root';
import Dom from '../dom';
import {createElm, createText, id, removeElm} from '../dom';
import {isFn} from '../types';
export class StatusBar extends Feature{
export class StatusBar extends Feature {
/**
* Status bar UI component
* @param {Object} tf TableFilter instance
*/
constructor(tf){
constructor(tf) {
super(tf, 'statusBar');
// Configuration object
@ -72,8 +72,8 @@ export class StatusBar extends Feature{
this.prfxStatusTxt = 'statusText_';
}
init(){
if(this.initialized){
init() {
if (this.initialized) {
return;
}
@ -81,25 +81,25 @@ export class StatusBar extends Feature{
let emitter = this.emitter;
//status bar container
let statusDiv = Dom.create('div', ['id', this.prfxStatus+tf.id]);
let statusDiv = createElm('div', ['id', this.prfxStatus + tf.id]);
statusDiv.className = this.statusBarCssClass;
//status bar label
let statusSpan = Dom.create('span', ['id', this.prfxStatusSpan+tf.id]);
let statusSpan = createElm('span', ['id', this.prfxStatusSpan + tf.id]);
//preceding text
let statusSpanText = Dom.create('span',
['id', this.prfxStatusTxt+tf.id]);
statusSpanText.appendChild(Dom.text(this.statusBarText));
let statusSpanText = createElm('span',
['id', this.prfxStatusTxt + tf.id]);
statusSpanText.appendChild(createText(this.statusBarText));
// target element container
if(!this.statusBarTgtId){
if (!this.statusBarTgtId) {
tf.setToolbar();
}
let targetEl = (!this.statusBarTgtId) ?
tf.lDiv : Dom.id(this.statusBarTgtId);
tf.lDiv : id(this.statusBarTgtId);
//default container: 'lDiv'
if(!this.statusBarTgtId){
if (!this.statusBarTgtId) {
statusDiv.appendChild(statusSpanText);
statusDiv.appendChild(statusSpan);
targetEl.appendChild(statusDiv);
@ -114,22 +114,23 @@ export class StatusBar extends Feature{
this.statusBarSpanText = statusSpanText;
// Subscribe to events
emitter.on(['before-filtering'], ()=> this.message(this.msgFilter));
emitter.on(['before-filtering'], () => this.message(this.msgFilter));
emitter.on(['before-populating-filter'],
()=> this.message(this.msgPopulate));
() => this.message(this.msgPopulate));
emitter.on(['before-page-change'],
()=> this.message(this.msgChangePage));
emitter.on(['before-clearing-filters'], ()=>
() => this.message(this.msgChangePage));
emitter.on(['before-clearing-filters'], () =>
this.message(this.msgClear));
emitter.on(['before-page-length-change'],
()=> this.message(this.msgChangeResults));
emitter.on(['before-reset-page'], ()=> this.message(this.msgResetPage));
() => this.message(this.msgChangeResults));
emitter.on(['before-reset-page'],
() => this.message(this.msgResetPage));
emitter.on(['before-reset-page-length'],
()=> this.message(this.msgResetPageLength));
() => this.message(this.msgResetPageLength));
emitter.on(['before-loading-extensions'],
()=> this.message(this.msgLoadExtensions));
() => this.message(this.msgLoadExtensions));
emitter.on(['before-loading-themes'],
()=> this.message(this.msgLoadThemes));
() => this.message(this.msgLoadThemes));
emitter.on([
'after-filtering',
@ -141,66 +142,66 @@ export class StatusBar extends Feature{
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'],
()=> this.message('')
() => this.message('')
);
this.initialized = true;
}
message(t=''){
if(!this.isEnabled()){
message(t = '') {
if (!this.isEnabled()) {
return;
}
if(this.onBeforeShowMsg){
if (this.onBeforeShowMsg) {
this.onBeforeShowMsg.call(null, this.tf, t);
}
let d = t==='' ? this.statusBarCloseDelay : 1;
let d = t === '' ? this.statusBarCloseDelay : 1;
root.setTimeout(() => {
if(!this.initialized){
if (!this.initialized) {
return;
}
this.statusBarSpan.innerHTML = t;
if(this.onAfterShowMsg){
if (this.onAfterShowMsg) {
this.onAfterShowMsg.call(null, this.tf, t);
}
}, d);
}
destroy(){
if(!this.initialized){
destroy() {
if (!this.initialized) {
return;
}
let emitter = this.emitter;
this.statusBarDiv.innerHTML = '';
if(!this.statusBarTgtId){
Dom.remove(this.statusBarDiv);
if (!this.statusBarTgtId) {
removeElm(this.statusBarDiv);
}
this.statusBarSpan = null;
this.statusBarSpanText = null;
this.statusBarDiv = null;
// Unsubscribe to events
emitter.off(['before-filtering'], ()=> this.message(this.msgFilter));
emitter.off(['before-filtering'], () => this.message(this.msgFilter));
emitter.off(['before-populating-filter'],
()=> this.message(this.msgPopulate));
() => this.message(this.msgPopulate));
emitter.off(['before-page-change'],
()=> this.message(this.msgChangePage));
() => this.message(this.msgChangePage));
emitter.off(['before-clearing-filters'],
()=> this.message(this.msgClear));
() => this.message(this.msgClear));
emitter.off(['before-page-length-change'],
()=> this.message(this.msgChangeResults));
emitter.off(['before-reset-page'], ()=>
() => this.message(this.msgChangeResults));
emitter.off(['before-reset-page'], () =>
this.message(this.msgResetPage));
emitter.off(['before-reset-page-length'],
()=> this.message(this.msgResetPageLength));
() => this.message(this.msgResetPageLength));
emitter.off(['before-loading-extensions'],
()=> this.message(this.msgLoadExtensions));
() => this.message(this.msgLoadExtensions));
emitter.off(['before-loading-themes'],
()=> this.message(this.msgLoadThemes));
() => this.message(this.msgLoadThemes));
emitter.off([
'after-filtering',
@ -212,7 +213,7 @@ export class StatusBar extends Feature{
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'],
()=> this.message('')
() => this.message('')
);
this.initialized = false;

View file

@ -1,5 +1,8 @@
import Event from './event';
import Dom from './dom';
import {
addClass, createElm, createOpt, getText, getFirstTextNode, byId, tag,
removeClass, removeElm
} from './dom';
import {contains, matchCase, rgxEsc, trim} from './string';
import {isEmpty as isEmptyString} from './string';
import {isArray, isEmpty, isFn, isNumber, isObj, isString, isUndef}
@ -62,7 +65,7 @@ export class TableFilter {
this.id = arg.id || `tf_${new Date().getTime()}_`;
} else if (isString(arg)) {
this.id = arg;
this.tbl = Dom.id(arg);
this.tbl = byId(arg);
} else if (isNumber(arg)) {
this.startRow = arg;
} else if (isObj(arg)) {
@ -457,7 +460,7 @@ export class TableFilter {
for (let i = 0; i < n; i++) {
this.emitter.emit('before-filter-init', this, i);
let fltcell = Dom.create(this.fltCellTag),
let fltcell = createElm(this.fltCellTag),
col = this.getFilterType(i);
if (this.singleSearchFlt) {
@ -550,9 +553,9 @@ export class TableFilter {
//TF css class is added to table
if (!this.gridLayout) {
Dom.addClass(this.tbl, this.prfxTf);
addClass(this.tbl, this.prfxTf);
if (this.responsive) {
Dom.addClass(this.tbl, this.prfxResponsive);
addClass(this.tbl, this.prfxResponsive);
}
}
@ -673,7 +676,7 @@ export class TableFilter {
}
let fltrow;
let thead = Dom.tag(this.tbl, 'thead');
let thead = tag(this.tbl, 'thead');
if (thead.length > 0) {
fltrow = thead[0].insertRow(this.filtersRowIndex);
} else {
@ -713,7 +716,7 @@ export class TableFilter {
let externalFltTgtId = this.isExternalFlt ?
this.externalFltTgtIds[colIndex] : null;
let inptype = col === INPUT ? 'text' : 'hidden';
let inp = Dom.create(INPUT,
let inp = createElm(INPUT,
['id', this.prfxFlt + colIndex + '_' + this.id],
['type', inptype], ['ct', colIndex]);
@ -728,7 +731,7 @@ export class TableFilter {
//filter is appended in custom element
if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(inp);
byId(externalFltTgtId).appendChild(inp);
this.externalFltEls.push(inp);
} else {
container.appendChild(inp);
@ -750,14 +753,14 @@ export class TableFilter {
_buildSubmitButton(colIndex, container) {
let externalFltTgtId = this.isExternalFlt ?
this.externalFltTgtIds[colIndex] : null;
let btn = Dom.create(INPUT,
let btn = createElm(INPUT,
['id', this.prfxValButton + colIndex + '_' + this.id],
['type', 'button'], ['value', this.btnText]);
btn.className = this.btnCssClass;
//filter is appended in custom element
if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(btn);
byId(externalFltTgtId).appendChild(btn);
} else {
container.appendChild(btn);
}
@ -916,7 +919,7 @@ export class TableFilter {
* @return {DOMElement} stylesheet element
*/
getStylesheet(name = 'default') {
return Dom.id(this.prfxTf + name);
return byId(this.prfxTf + name);
}
/**
@ -975,8 +978,8 @@ export class TableFilter {
this.emitter.off(['filter-focus'],
(tf, filter) => this.setActiveFilterId(filter.id));
Dom.removeClass(this.tbl, this.prfxTf);
Dom.removeClass(this.tbl, this.prfxResponsive);
removeClass(this.tbl, this.prfxTf);
removeClass(this.tbl, this.prfxResponsive);
this.nbHiddenRows = 0;
this.validRowsIndex = [];
@ -994,12 +997,12 @@ export class TableFilter {
}
/*** container div ***/
let infdiv = Dom.create('div', ['id', this.prfxInfDiv + this.id]);
let infdiv = createElm('div', ['id', this.prfxInfDiv + this.id]);
infdiv.className = this.infDivCssClass;
//custom container
if (this.toolBarTgtId) {
Dom.id(this.toolBarTgtId).appendChild(infdiv);
byId(this.toolBarTgtId).appendChild(infdiv);
}
//grid-layout
else if (this.gridLayout) {
@ -1009,30 +1012,30 @@ export class TableFilter {
}
//default location: just above the table
else {
let cont = Dom.create('caption');
let cont = createElm('caption');
cont.appendChild(infdiv);
this.tbl.insertBefore(cont, this.tbl.firstChild);
}
this.infDiv = Dom.id(this.prfxInfDiv + this.id);
this.infDiv = byId(this.prfxInfDiv + this.id);
/*** left div containing rows # displayer ***/
let ldiv = Dom.create('div', ['id', this.prfxLDiv + this.id]);
let ldiv = createElm('div', ['id', this.prfxLDiv + this.id]);
ldiv.className = this.lDivCssClass;
infdiv.appendChild(ldiv);
this.lDiv = Dom.id(this.prfxLDiv + this.id);
this.lDiv = byId(this.prfxLDiv + this.id);
/*** right div containing reset button
+ nb results per page select ***/
let rdiv = Dom.create('div', ['id', this.prfxRDiv + this.id]);
let rdiv = createElm('div', ['id', this.prfxRDiv + this.id]);
rdiv.className = this.rDivCssClass;
infdiv.appendChild(rdiv);
this.rDiv = Dom.id(this.prfxRDiv + this.id);
this.rDiv = byId(this.prfxRDiv + this.id);
/*** mid div containing paging elements ***/
let mdiv = Dom.create('div', ['id', this.prfxMDiv + this.id]);
let mdiv = createElm('div', ['id', this.prfxMDiv + this.id]);
mdiv.className = this.mDivCssClass;
infdiv.appendChild(mdiv);
this.mDiv = Dom.id(this.prfxMDiv + this.id);
this.mDiv = byId(this.prfxMDiv + this.id);
// emit help initialisation only if undefined
if (isUndef(this.help)) {
@ -1050,11 +1053,11 @@ export class TableFilter {
if (!this.infDiv) {
return;
}
Dom.remove(this.infDiv);
removeElm(this.infDiv);
this.infDiv = null;
let tbl = this.tbl;
let captions = Dom.tag(tbl, 'caption');
let captions = tag(tbl, 'caption');
if (captions.length > 0) {
[].forEach.call(captions, (elm) => tbl.removeChild(elm));
}
@ -1071,7 +1074,7 @@ export class TableFilter {
len = ids.length;
for (let ct = 0; ct < len; ct++) {
let externalFltTgtId = ids[ct],
externalFlt = Dom.id(externalFltTgtId);
externalFlt = byId(externalFltTgtId);
if (externalFlt) {
externalFlt.innerHTML = '';
}
@ -1173,7 +1176,7 @@ export class TableFilter {
let w = str;
if (re_le.test(str) || re_ge.test(str) || re_l.test(str) ||
re_g.test(str) || re_d.test(str)) {
w = Dom.getText(cell);
w = getText(cell);
}
if (w !== '') {
this.emitter.emit('highlight-keyword', this, cell, w);
@ -1628,7 +1631,7 @@ export class TableFilter {
*/
getFilterElement(index) {
let fltId = this.fltIds[index];
return Dom.id(fltId);
return byId(fltId);
}
/**
@ -1668,7 +1671,7 @@ export class TableFilter {
this.customCellDataCols.indexOf(idx) !== -1) {
return this.customCellData.call(null, this, cell, idx);
} else {
return Dom.getText(cell);
return getText(cell);
}
}
@ -1901,7 +1904,7 @@ export class TableFilter {
function setWidths() {
let nbCols = this.nbCells;
let colWidths = this.colWidths;
let colTags = Dom.tag(tbl, 'col');
let colTags = tag(tbl, 'col');
let tblHasColTag = colTags.length > 0;
let frag = !tblHasColTag ? doc.createDocumentFragment() : null;
for (let k = 0; k < nbCols; k++) {
@ -1909,7 +1912,7 @@ export class TableFilter {
if (tblHasColTag) {
col = colTags[k];
} else {
col = Dom.create('col', ['id', this.id + '_col_' + k]);
col = createElm('col', ['id', this.id + '_col_' + k]);
frag.appendChild(col);
}
col.style.width = colWidths[k];
@ -1967,8 +1970,7 @@ export class TableFilter {
*/
clearActiveColumns() {
for (let i = 0, len = this.getCellsNb(this.headersRow); i < len; i++) {
Dom.removeClass(
this.getHeaderElement(i), this.activeColumnsCssClass);
removeClass(this.getHeaderElement(i), this.activeColumnsCssClass);
}
}
@ -1978,13 +1980,13 @@ export class TableFilter {
*/
markActiveColumn(colIndex) {
let header = this.getHeaderElement(colIndex);
if (Dom.hasClass(header, this.activeColumnsCssClass)) {
if (hasClass(header, this.activeColumnsCssClass)) {
return;
}
if (this.onBeforeActiveColumn) {
this.onBeforeActiveColumn.call(null, this, colIndex);
}
Dom.addClass(header, this.activeColumnsCssClass);
addClass(header, this.activeColumnsCssClass);
if (this.onAfterActiveColumn) {
this.onAfterActiveColumn.call(null, this, colIndex);
}
@ -2045,7 +2047,7 @@ export class TableFilter {
let activeIdx = this.getColumnIndexFromFilterId(this.activeFilterId);
for (let i = 0, len = slcIndex.length; i < len; i++) {
let curSlc = Dom.id(this.fltIds[slcIndex[i]]);
let curSlc = byId(this.fltIds[slcIndex[i]]);
let slcSelectedValue = this.getFilterValue(slcIndex[i]);
// Welcome to cyclomatic complexity hell :)
@ -2059,7 +2061,7 @@ export class TableFilter {
//1st option needs to be inserted
if (this.loadFltOnDemand) {
let opt0 = Dom.createOpt(this.displayAllText, '');
let opt0 = createOpt(this.displayAllText, '');
curSlc.innerHTML = '';
curSlc.appendChild(opt0);
}
@ -2098,7 +2100,7 @@ export class TableFilter {
let imported = false,
importType = !type ? 'script' : type,
attr = importType === 'script' ? 'src' : 'href',
files = Dom.tag(doc, importType);
files = tag(doc, importType);
for (let i = 0, len = files.length; i < len; i++) {
if (files[i][attr] === undefined) {
continue;
@ -2127,15 +2129,15 @@ export class TableFilter {
let o = this,
isLoaded = false,
file,
head = Dom.tag(doc, 'head')[0];
head = tag(doc, 'head')[0];
if (ftype.toLowerCase() === 'link') {
file = Dom.create('link',
file = createElm('link',
['id', fileId], ['type', 'text/css'],
['rel', 'stylesheet'], ['href', filePath]
);
} else {
file = Dom.create('script',
file = createElm('script',
['id', fileId],
['type', 'text/javascript'], ['src', filePath]
);
@ -2243,7 +2245,7 @@ export class TableFilter {
*/
getHeaderElement(colIndex) {
let table = this.gridLayout ? this.Mod.gridLayout.headTbl : this.tbl;
let tHead = Dom.tag(table, 'thead');
let tHead = tag(table, 'thead');
let headersRow = this.headersRow;
let header;
for (let i = 0; i < this.nbCells; i++) {
@ -2275,7 +2277,7 @@ export class TableFilter {
}
}
let header = this.getHeaderElement(j);
let headerText = Dom.getFirstTextNode(header);
let headerText = getFirstTextNode(header);
headers.push(headerText);
}
return headers;