mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-08 00:42:28 +02:00
Created constants file, added filter types constants
This commit is contained in:
parent
cf34009205
commit
8a2a7c7ba7
4
dist/starter.html
vendored
4
dist/starter.html
vendored
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>tablefilter v0.2.19 - Starter</title>
|
||||
<title>tablefilter v0.2.20 - Starter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>tablefilter v0.2.19</h1>
|
||||
<h1>tablefilter v0.2.20</h1>
|
||||
|
||||
|
||||
|
||||
|
|
4
dist/tablefilter/style/colsVisibility.css
vendored
4
dist/tablefilter/style/colsVisibility.css
vendored
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.19 by Max Guglielmi
|
||||
* build date: 2016-05-07T09:50:22.795Z
|
||||
* tablefilter v0.2.20 by Max Guglielmi
|
||||
* build date: 2016-05-07T10:31:02.804Z
|
||||
* 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.19 by Max Guglielmi
|
||||
* build date: 2016-05-07T09:50:22.795Z
|
||||
* tablefilter v0.2.20 by Max Guglielmi
|
||||
* build date: 2016-05-07T10:31:02.804Z
|
||||
* 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.19 by Max Guglielmi
|
||||
* build date: 2016-05-07T09:50:22.795Z
|
||||
* tablefilter v0.2.20 by Max Guglielmi
|
||||
* build date: 2016-05-07T10:31:02.804Z
|
||||
* MIT License
|
||||
*/
|
||||
.activeHeader{background-color:#66afe9 !important;color:#fff !important}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* tablefilter v0.2.19 by Max Guglielmi
|
||||
* build date: 2016-05-07T09:50:22.795Z
|
||||
* tablefilter v0.2.20 by Max Guglielmi
|
||||
* build date: 2016-05-07T10:31:02.804Z
|
||||
* 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.19 by Max Guglielmi
|
||||
* build date: 2016-05-07T09:50:22.795Z
|
||||
* tablefilter v0.2.20 by Max Guglielmi
|
||||
* build date: 2016-05-07T10:31:02.804Z
|
||||
* 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.19 by Max Guglielmi
|
||||
* build date: 2016-05-07T09:50:22.795Z
|
||||
* tablefilter v0.2.20 by Max Guglielmi
|
||||
* build date: 2016-05-07T10:31:02.804Z
|
||||
* 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}
|
8239
dist/tablefilter/tablefilter.js
vendored
8239
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
2304
dist/tablefilter/tf-1.js
vendored
2304
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.19",
|
||||
"version": "0.2.20",
|
||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Dom from '../../dom';
|
||||
import {INPUT} from '../../const';
|
||||
|
||||
export default class AdapterEzEditTable {
|
||||
/**
|
||||
|
@ -416,7 +417,7 @@ export default class AdapterEzEditTable {
|
|||
}
|
||||
var colIndex = tf.getColumnIndexFromFilterId(tf.getActiveFilterId());
|
||||
var filterType = tf.getFilterType(colIndex);
|
||||
if(filterType === tf.fltTypeInp){
|
||||
if(filterType === INPUT){
|
||||
this.toggle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,15 @@ import Dom from '../../dom';
|
|||
import Event from '../../event';
|
||||
import DateHelper from '../../date';
|
||||
import Helpers from '../../helpers';
|
||||
import {NONE} from '../../const';
|
||||
|
||||
export default class AdapterSortableTable{
|
||||
export default class AdapterSortableTable {
|
||||
|
||||
/**
|
||||
* SortableTable Adapter module
|
||||
* @param {Object} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf, opts){
|
||||
constructor(tf, opts) {
|
||||
this.initialized = false;
|
||||
this.name = opts.name;
|
||||
this.desc = opts.description || 'Sortable table';
|
||||
|
@ -31,7 +32,7 @@ export default class AdapterSortableTable{
|
|||
this.imgBlank = opts.image_blank || 'blank.png';
|
||||
this.imgClassName = opts.image_class_name || 'sort-arrow';
|
||||
this.imgAscClassName = opts.image_asc_class_name || 'ascending';
|
||||
this.imgDescClassName = opts.image_desc_class_name ||'descending';
|
||||
this.imgDescClassName = opts.image_desc_class_name || 'descending';
|
||||
//cell attribute storing custom key
|
||||
this.customKey = opts.custom_key || 'data-tf-sortKey';
|
||||
|
||||
|
@ -49,12 +50,12 @@ export default class AdapterSortableTable{
|
|||
this.emitter = tf.emitter;
|
||||
}
|
||||
|
||||
init(){
|
||||
init() {
|
||||
let tf = this.tf;
|
||||
let adpt = this;
|
||||
|
||||
// SortableTable class sanity check (sortabletable.js)
|
||||
if(Types.isUndef(SortableTable)){
|
||||
if (Types.isUndef(SortableTable)) {
|
||||
throw new Error('SortableTable class not found.');
|
||||
}
|
||||
|
||||
|
@ -63,31 +64,31 @@ export default class AdapterSortableTable{
|
|||
|
||||
//Column sort at start
|
||||
let sortColAtStart = adpt.sortColAtStart;
|
||||
if(sortColAtStart){
|
||||
if (sortColAtStart) {
|
||||
this.stt.sort(sortColAtStart[0], sortColAtStart[1]);
|
||||
}
|
||||
|
||||
if(this.onSortLoaded){
|
||||
if (this.onSortLoaded) {
|
||||
this.onSortLoaded.call(null, tf, this);
|
||||
}
|
||||
|
||||
/*** SortableTable callbacks ***/
|
||||
this.stt.onbeforesort = function(){
|
||||
if(adpt.onBeforeSort){
|
||||
this.stt.onbeforesort = function () {
|
||||
if (adpt.onBeforeSort) {
|
||||
adpt.onBeforeSort.call(null, tf, adpt.stt.sortColumn);
|
||||
}
|
||||
|
||||
/*** sort behaviour for paging ***/
|
||||
if(tf.paging){
|
||||
if (tf.paging) {
|
||||
tf.feature('paging').disable();
|
||||
}
|
||||
};
|
||||
|
||||
this.stt.onsort = function(){
|
||||
this.stt.onsort = function () {
|
||||
adpt.sorted = true;
|
||||
|
||||
//sort behaviour for paging
|
||||
if(tf.paging){
|
||||
if (tf.paging) {
|
||||
let paginator = tf.feature('paging');
|
||||
// recalculate valid rows index as sorting may have change it
|
||||
tf.getValidRows(true);
|
||||
|
@ -95,7 +96,7 @@ export default class AdapterSortableTable{
|
|||
paginator.setPage(paginator.getPage());
|
||||
}
|
||||
|
||||
if(adpt.onAfterSort){
|
||||
if (adpt.onAfterSort) {
|
||||
adpt.onAfterSort.call(null, tf, adpt.stt.sortColumn,
|
||||
adpt.stt.descending);
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ export default class AdapterSortableTable{
|
|||
};
|
||||
|
||||
this.emitter.on(['sort'],
|
||||
(tf, colIdx, desc)=> this.sortByColumnIndex(colIdx, desc));
|
||||
(tf, colIdx, desc) => this.sortByColumnIndex(colIdx, desc));
|
||||
|
||||
this.initialized = true;
|
||||
this.emitter.emit('sort-initialized', tf, this);
|
||||
|
@ -116,11 +117,11 @@ export default class AdapterSortableTable{
|
|||
* @param {Number} colIdx Column index
|
||||
* @param {Boolean} desc Optional: descending manner
|
||||
*/
|
||||
sortByColumnIndex(colIdx, desc){
|
||||
sortByColumnIndex(colIdx, desc) {
|
||||
this.stt.sort(colIdx, desc);
|
||||
}
|
||||
|
||||
overrideSortableTable(){
|
||||
overrideSortableTable() {
|
||||
let adpt = this,
|
||||
tf = this.tf;
|
||||
|
||||
|
@ -128,15 +129,15 @@ export default class AdapterSortableTable{
|
|||
* Overrides headerOnclick method in order to handle th event
|
||||
* @param {Object} e [description]
|
||||
*/
|
||||
SortableTable.prototype.headerOnclick = function(evt){
|
||||
if(!adpt.initialized){
|
||||
SortableTable.prototype.headerOnclick = function (evt) {
|
||||
if (!adpt.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// find Header element
|
||||
let el = evt.target || evt.srcElement;
|
||||
|
||||
while(el.tagName !== 'TD' && el.tagName !== 'TH'){
|
||||
while (el.tagName !== 'TD' && el.tagName !== 'TH') {
|
||||
el = el.parentNode;
|
||||
}
|
||||
|
||||
|
@ -152,10 +153,10 @@ export default class AdapterSortableTable{
|
|||
* @param {Object} oTd TD element
|
||||
* @return {Number} Cell index
|
||||
*/
|
||||
SortableTable.getCellIndex = function(oTd){
|
||||
SortableTable.getCellIndex = function (oTd) {
|
||||
let cells = oTd.parentNode.cells,
|
||||
l = cells.length, i;
|
||||
for (i = 0; cells[i] != oTd && i < l; i++){}
|
||||
for (i = 0; cells[i] != oTd && i < l; i++) { }
|
||||
return i;
|
||||
};
|
||||
|
||||
|
@ -163,10 +164,10 @@ export default class AdapterSortableTable{
|
|||
* Overrides initHeader in order to handle filters row position
|
||||
* @param {Array} oSortTypes
|
||||
*/
|
||||
SortableTable.prototype.initHeader = function(oSortTypes){
|
||||
SortableTable.prototype.initHeader = function (oSortTypes) {
|
||||
let stt = this;
|
||||
if (!stt.tHead){
|
||||
if(tf.gridLayout){
|
||||
if (!stt.tHead) {
|
||||
if (tf.gridLayout) {
|
||||
stt.tHead = tf.feature('gridLayout').headTbl.tHead;
|
||||
} else {
|
||||
return;
|
||||
|
@ -181,13 +182,13 @@ export default class AdapterSortableTable{
|
|||
|
||||
for (let i = 0; i < l; i++) {
|
||||
c = cells[i];
|
||||
if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None'){
|
||||
if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None') {
|
||||
c.style.cursor = 'pointer';
|
||||
img = Dom.create('img',
|
||||
['src', adpt.imgPath + adpt.imgBlank]);
|
||||
c.appendChild(img);
|
||||
if (stt.sortTypes[i] !== null){
|
||||
c.setAttribute( '_sortType', stt.sortTypes[i]);
|
||||
if (stt.sortTypes[i] !== null) {
|
||||
c.setAttribute('_sortType', stt.sortTypes[i]);
|
||||
}
|
||||
Event.add(c, 'click', stt._headerOnclick);
|
||||
} else {
|
||||
|
@ -201,40 +202,40 @@ export default class AdapterSortableTable{
|
|||
/**
|
||||
* Overrides updateHeaderArrows in order to handle arrows indicators
|
||||
*/
|
||||
SortableTable.prototype.updateHeaderArrows = function(){
|
||||
SortableTable.prototype.updateHeaderArrows = function () {
|
||||
let stt = this;
|
||||
let cells, l, img;
|
||||
|
||||
// external headers
|
||||
if(adpt.asyncSort && adpt.triggerIds.length > 0){
|
||||
if (adpt.asyncSort && adpt.triggerIds.length > 0) {
|
||||
let triggers = adpt.triggerIds;
|
||||
cells = [];
|
||||
l = triggers.length;
|
||||
for(let j=0; j<triggers.length; j++){
|
||||
for (let j = 0; j < triggers.length; j++) {
|
||||
cells.push(Dom.id(triggers[j]));
|
||||
}
|
||||
} else {
|
||||
if(!this.tHead){
|
||||
if (!this.tHead) {
|
||||
return;
|
||||
}
|
||||
cells = stt.tHead.rows[stt.headersRow].cells;
|
||||
l = cells.length;
|
||||
}
|
||||
for(let i = 0; i < l; i++){
|
||||
for (let i = 0; i < l; i++) {
|
||||
let cellAttr = cells[i].getAttribute('_sortType');
|
||||
if(cellAttr !== null && cellAttr !== 'None'){
|
||||
if (cellAttr !== null && cellAttr !== 'None') {
|
||||
img = cells[i].lastChild || cells[i];
|
||||
if(img.nodeName.toLowerCase() !== 'img'){
|
||||
if (img.nodeName.toLowerCase() !== 'img') {
|
||||
img = Dom.create('img',
|
||||
['src', adpt.imgPath + adpt.imgBlank]);
|
||||
cells[i].appendChild(img);
|
||||
}
|
||||
if (i === stt.sortColumn){
|
||||
img.className = adpt.imgClassName +' '+
|
||||
if (i === stt.sortColumn) {
|
||||
img.className = adpt.imgClassName + ' ' +
|
||||
(this.descending ?
|
||||
adpt.imgDescClassName :
|
||||
adpt.imgAscClassName);
|
||||
} else{
|
||||
} else {
|
||||
img.className = adpt.imgClassName;
|
||||
}
|
||||
}
|
||||
|
@ -248,11 +249,11 @@ export default class AdapterSortableTable{
|
|||
* @param {Number} nColumn
|
||||
* @return {String}
|
||||
*/
|
||||
SortableTable.prototype.getRowValue = function(oRow, sType, nColumn){
|
||||
SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
|
||||
let stt = this;
|
||||
// if we have defined a custom getRowValue use that
|
||||
let sortTypeInfo = stt._sortTypeInfo[sType];
|
||||
if (sortTypeInfo && sortTypeInfo.getRowValue){
|
||||
if (sortTypeInfo && sortTypeInfo.getRowValue) {
|
||||
return sortTypeInfo.getRowValue(oRow, nColumn);
|
||||
}
|
||||
let c = oRow.cells[nColumn];
|
||||
|
@ -266,11 +267,11 @@ export default class AdapterSortableTable{
|
|||
* @param {Object} oNode DOM element
|
||||
* @return {String} DOM element inner text
|
||||
*/
|
||||
SortableTable.getInnerText = function(oNode){
|
||||
if(!oNode){
|
||||
SortableTable.getInnerText = function (oNode) {
|
||||
if (!oNode) {
|
||||
return;
|
||||
}
|
||||
if(oNode.getAttribute(adpt.customKey)){
|
||||
if (oNode.getAttribute(adpt.customKey)) {
|
||||
return oNode.getAttribute(adpt.customKey);
|
||||
} else {
|
||||
return Dom.getText(oNode);
|
||||
|
@ -278,29 +279,29 @@ export default class AdapterSortableTable{
|
|||
};
|
||||
}
|
||||
|
||||
addSortType(){
|
||||
addSortType() {
|
||||
var args = arguments;
|
||||
SortableTable.prototype.addSortType(args[0], args[1], args[2], args[3]);
|
||||
}
|
||||
|
||||
setSortTypes(){
|
||||
setSortTypes() {
|
||||
let tf = this.tf,
|
||||
sortTypes = this.sortTypes,
|
||||
_sortTypes = [];
|
||||
|
||||
for(let i=0; i<tf.nbCells; i++){
|
||||
for (let i = 0; i < tf.nbCells; i++) {
|
||||
let colType;
|
||||
|
||||
if(sortTypes[i]){
|
||||
if (sortTypes[i]) {
|
||||
colType = sortTypes[i].toLowerCase();
|
||||
if(colType === 'none'){
|
||||
if (colType === NONE) {
|
||||
colType = 'None';
|
||||
}
|
||||
} else { // resolve column types
|
||||
if(tf.hasColNbFormat && tf.colNbFormat[i] !== null){
|
||||
if (tf.hasColNbFormat && tf.colNbFormat[i] !== null) {
|
||||
colType = tf.colNbFormat[i].toLowerCase();
|
||||
} else if(tf.hasColDateType && tf.colDateType[i] !== null){
|
||||
colType = tf.colDateType[i].toLowerCase()+'date';
|
||||
} else if (tf.hasColDateType && tf.colDateType[i] !== null) {
|
||||
colType = tf.colDateType[i].toLowerCase() + 'date';
|
||||
} else {
|
||||
colType = 'String';
|
||||
}
|
||||
|
@ -317,7 +318,7 @@ export default class AdapterSortableTable{
|
|||
this.addSortType('string');
|
||||
this.addSortType('us', usNumberConverter);
|
||||
this.addSortType('eu', euNumberConverter);
|
||||
this.addSortType('dmydate', dmyDateConverter );
|
||||
this.addSortType('dmydate', dmyDateConverter);
|
||||
this.addSortType('ymddate', ymdDateConverter);
|
||||
this.addSortType('mdydate', mdyDateConverter);
|
||||
this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter);
|
||||
|
@ -326,19 +327,19 @@ export default class AdapterSortableTable{
|
|||
this.stt = new SortableTable(tf.tbl, _sortTypes);
|
||||
|
||||
/*** external table headers adapter ***/
|
||||
if(this.asyncSort && this.triggerIds.length > 0){
|
||||
if (this.asyncSort && this.triggerIds.length > 0) {
|
||||
let triggers = this.triggerIds;
|
||||
for(let j=0; j<triggers.length; j++){
|
||||
if(triggers[j] === null){
|
||||
for (let j = 0; j < triggers.length; j++) {
|
||||
if (triggers[j] === null) {
|
||||
continue;
|
||||
}
|
||||
let trigger = Dom.id(triggers[j]);
|
||||
if(trigger){
|
||||
if (trigger) {
|
||||
trigger.style.cursor = 'pointer';
|
||||
|
||||
Event.add(trigger, 'click', (evt) => {
|
||||
let elm = evt.target;
|
||||
if(!this.tf.sort){
|
||||
if (!this.tf.sort) {
|
||||
return;
|
||||
}
|
||||
this.stt.asyncSort(triggers.indexOf(elm.id));
|
||||
|
@ -352,20 +353,20 @@ export default class AdapterSortableTable{
|
|||
/**
|
||||
* Destroy sort
|
||||
*/
|
||||
destroy(){
|
||||
destroy() {
|
||||
let tf = this.tf;
|
||||
this.emitter.off(['sort'],
|
||||
(tf, colIdx, desc)=> this.sortByColumnIndex(colIdx, desc));
|
||||
(tf, colIdx, desc) => this.sortByColumnIndex(colIdx, desc));
|
||||
this.sorted = false;
|
||||
this.initialized = false;
|
||||
this.stt.destroy();
|
||||
|
||||
let ids = tf.getFiltersId();
|
||||
for (let idx = 0; idx < ids.length; idx++){
|
||||
for (let idx = 0; idx < ids.length; idx++) {
|
||||
let header = tf.getHeaderElement(idx);
|
||||
let img = Dom.tag(header, 'img');
|
||||
|
||||
if(img.length === 1){
|
||||
if (img.length === 1) {
|
||||
header.removeChild(img[0]);
|
||||
}
|
||||
}
|
||||
|
@ -374,46 +375,46 @@ export default class AdapterSortableTable{
|
|||
}
|
||||
|
||||
//Converters
|
||||
function usNumberConverter(s){
|
||||
function usNumberConverter(s) {
|
||||
return Helpers.removeNbFormat(s, 'us');
|
||||
}
|
||||
function euNumberConverter(s){
|
||||
function euNumberConverter(s) {
|
||||
return Helpers.removeNbFormat(s, 'eu');
|
||||
}
|
||||
function dateConverter(s, format){
|
||||
function dateConverter(s, format) {
|
||||
return DateHelper.format(s, format);
|
||||
}
|
||||
function dmyDateConverter(s){
|
||||
function dmyDateConverter(s) {
|
||||
return dateConverter(s, 'DMY');
|
||||
}
|
||||
function mdyDateConverter(s){
|
||||
function mdyDateConverter(s) {
|
||||
return dateConverter(s, 'MDY');
|
||||
}
|
||||
function ymdDateConverter(s){
|
||||
function ymdDateConverter(s) {
|
||||
return dateConverter(s, 'YMD');
|
||||
}
|
||||
function ddmmmyyyyDateConverter(s){
|
||||
function ddmmmyyyyDateConverter(s) {
|
||||
return dateConverter(s, 'DDMMMYYYY');
|
||||
}
|
||||
|
||||
function ipAddress(value){
|
||||
function ipAddress(value) {
|
||||
let vals = value.split('.');
|
||||
for (let x in vals) {
|
||||
let val = vals[x];
|
||||
while (3 > val.length){
|
||||
val = '0'+val;
|
||||
while (3 > val.length) {
|
||||
val = '0' + val;
|
||||
}
|
||||
vals[x] = val;
|
||||
}
|
||||
return vals.join('.');
|
||||
}
|
||||
|
||||
function sortIP(a,b){
|
||||
function sortIP(a, b) {
|
||||
let aa = ipAddress(a.value.toLowerCase());
|
||||
let bb = ipAddress(b.value.toLowerCase());
|
||||
if (aa==bb){
|
||||
if (aa == bb) {
|
||||
return 0;
|
||||
} else if (aa<bb){
|
||||
} else if (aa < bb) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
|
|
|
@ -5,6 +5,7 @@ import Str from '../string';
|
|||
import Sort from '../sort';
|
||||
import Event from '../event';
|
||||
import Types from '../types';
|
||||
import {CHECKLIST, NONE} from '../const';
|
||||
|
||||
const SORT_ERROR = 'Filter options for column {0} cannot be sorted in ' +
|
||||
'{1} manner.';
|
||||
|
@ -294,7 +295,7 @@ export class CheckList extends Feature {
|
|||
|
||||
if (val === '') {
|
||||
//item is hidden
|
||||
li.style.display = 'none';
|
||||
li.style.display = NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +316,7 @@ export class CheckList extends Feature {
|
|||
Event.add(li0.check, 'click', (evt) => this.optionClick(evt));
|
||||
|
||||
if (!this.enableCheckListResetFilter) {
|
||||
li0.style.display = 'none';
|
||||
li0.style.display = NONE;
|
||||
}
|
||||
|
||||
if (tf.enableEmptyOption) {
|
||||
|
@ -429,8 +430,7 @@ export class CheckList extends Feature {
|
|||
*/
|
||||
selectOptions(colIndex, values = []) {
|
||||
let tf = this.tf;
|
||||
if (tf.getFilterType(colIndex) !== tf.fltTypeCheckList ||
|
||||
values.length === 0) {
|
||||
if (tf.getFilterType(colIndex) !== CHECKLIST || values.length === 0) {
|
||||
return;
|
||||
}
|
||||
let flt = tf.getFilterElement(colIndex);
|
||||
|
|
|
@ -4,6 +4,7 @@ import Arr from '../array';
|
|||
import Str from '../string';
|
||||
import Sort from '../sort';
|
||||
import Event from '../event';
|
||||
import {SELECT, MULTIPLE, NONE} from '../const';
|
||||
|
||||
const SORT_ERROR = 'Filter options for column {0} cannot be sorted in ' +
|
||||
'{1} manner.';
|
||||
|
@ -66,16 +67,16 @@ export class Dropdown extends Feature {
|
|||
let externalFltTgtId = isExternal ?
|
||||
tf.externalFltTgtIds[colIndex] : null;
|
||||
|
||||
let slc = Dom.create(tf.fltTypeSlc,
|
||||
let slc = Dom.create(SELECT,
|
||||
['id', tf.prfxFlt + colIndex + '_' + tf.id],
|
||||
['ct', colIndex], ['filled', '0']
|
||||
);
|
||||
|
||||
if (col === tf.fltTypeMulti) {
|
||||
slc.multiple = tf.fltTypeMulti;
|
||||
if (col === MULTIPLE) {
|
||||
slc.multiple = MULTIPLE;
|
||||
slc.title = this.multipleSlcTooltip;
|
||||
}
|
||||
slc.className = Str.lower(col) === tf.fltTypeSlc ?
|
||||
slc.className = Str.lower(col) === SELECT ?
|
||||
tf.fltCssClass : tf.fltMultiCssClass;
|
||||
|
||||
//filter is appended in container element
|
||||
|
@ -292,7 +293,7 @@ export class Dropdown extends Feature {
|
|||
let opt;
|
||||
//fill select on demand
|
||||
if (tf.loadFltOnDemand && slcValue === this.opts[y] &&
|
||||
tf.getFilterType(colIndex) === tf.fltTypeSlc) {
|
||||
tf.getFilterType(colIndex) === SELECT) {
|
||||
opt = Dom.createOpt(lbl, val, true);
|
||||
} else {
|
||||
opt = Dom.createOpt(lbl, val, false);
|
||||
|
@ -316,7 +317,7 @@ export class Dropdown extends Feature {
|
|||
let opt0 = Dom.createOpt(
|
||||
(!this.enableSlcResetFilter ? '' : tf.displayAllText), '');
|
||||
if (!this.enableSlcResetFilter) {
|
||||
opt0.style.display = 'none';
|
||||
opt0.style.display = NONE;
|
||||
}
|
||||
slc.appendChild(opt0);
|
||||
if (tf.enableEmptyOption) {
|
||||
|
@ -337,8 +338,7 @@ export class Dropdown extends Feature {
|
|||
*/
|
||||
selectOptions(colIndex, values = []) {
|
||||
let tf = this.tf;
|
||||
if (tf.getFilterType(colIndex) !== tf.fltTypeMulti ||
|
||||
values.length === 0) {
|
||||
if (tf.getFilterType(colIndex) !== MULTIPLE || values.length === 0) {
|
||||
return;
|
||||
}
|
||||
let slc = tf.getFilterElement(colIndex);
|
||||
|
|
|
@ -3,6 +3,7 @@ import Dom from '../dom';
|
|||
import Types from '../types';
|
||||
import Event from '../event';
|
||||
import Str from '../string';
|
||||
import {NONE} from '../const';
|
||||
|
||||
export class GridLayout extends Feature{
|
||||
|
||||
|
@ -311,7 +312,7 @@ export class GridLayout extends Feature{
|
|||
};
|
||||
|
||||
if(tf.popupFilters){
|
||||
filtersRow.style.display = 'none';
|
||||
filtersRow.style.display = NONE;
|
||||
}
|
||||
|
||||
if(tbl.clientWidth !== this.headTbl.clientWidth){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Feature} from './feature';
|
||||
import Dom from '../dom';
|
||||
import Event from '../event';
|
||||
|
||||
import {NONE} from '../const';
|
||||
|
||||
const WIKI_URL = 'https://github.com/koalyptus/TableFilter/wiki/' +
|
||||
'4.-Filter-operators';
|
||||
|
@ -128,10 +128,10 @@ export class Help extends Feature{
|
|||
return;
|
||||
}
|
||||
var divDisplay = this.cont.style.display;
|
||||
if(divDisplay === '' || divDisplay === 'none'){
|
||||
if(divDisplay === '' || divDisplay === NONE){
|
||||
this.cont.style.display = 'inline';
|
||||
} else {
|
||||
this.cont.style.display = 'none';
|
||||
this.cont.style.display = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import {Feature} from './feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {NONE} from '../const';
|
||||
|
||||
let global = window;
|
||||
|
||||
export class Loader extends Feature{
|
||||
export class Loader extends Feature {
|
||||
|
||||
/**
|
||||
* Loading message/spinner
|
||||
|
@ -39,31 +40,31 @@ export class Loader extends Feature{
|
|||
}
|
||||
|
||||
init() {
|
||||
if(this.initialized){
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
let tf = this.tf;
|
||||
let emitter = this.emitter;
|
||||
|
||||
let containerDiv = Dom.create('div', ['id', this.prfxLoader+tf.id]);
|
||||
let containerDiv = Dom.create('div', ['id', this.prfxLoader + tf.id]);
|
||||
containerDiv.className = this.loaderCssClass;
|
||||
|
||||
let targetEl = !this.loaderTgtId ?
|
||||
tf.tbl.parentNode : Dom.id(this.loaderTgtId);
|
||||
if(!this.loaderTgtId){
|
||||
if (!this.loaderTgtId) {
|
||||
targetEl.insertBefore(containerDiv, tf.tbl);
|
||||
} else {
|
||||
targetEl.appendChild(containerDiv);
|
||||
}
|
||||
this.loaderDiv = containerDiv;
|
||||
if(!this.loaderHtml){
|
||||
if (!this.loaderHtml) {
|
||||
this.loaderDiv.appendChild(Dom.text(this.loaderText));
|
||||
} else {
|
||||
this.loaderDiv.innerHTML = this.loaderHtml;
|
||||
}
|
||||
|
||||
this.show('none');
|
||||
this.show(NONE);
|
||||
|
||||
// Subscribe to events
|
||||
emitter.on([
|
||||
|
@ -76,7 +77,7 @@ export class Loader extends Feature{
|
|||
'before-reset-page-length',
|
||||
'before-loading-extensions',
|
||||
'before-loading-themes'],
|
||||
()=> this.show('')
|
||||
() => this.show('')
|
||||
);
|
||||
emitter.on([
|
||||
'after-filtering',
|
||||
|
@ -88,36 +89,36 @@ export class Loader extends Feature{
|
|||
'after-reset-page-length',
|
||||
'after-loading-extensions',
|
||||
'after-loading-themes'],
|
||||
()=> this.show('none')
|
||||
() => this.show(NONE)
|
||||
);
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
show(p) {
|
||||
if(!this.isEnabled() /*|| this.loaderDiv.style.display === p*/){
|
||||
if (!this.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let displayLoader = () => {
|
||||
if(!this.loaderDiv){
|
||||
if (!this.loaderDiv) {
|
||||
return;
|
||||
}
|
||||
if(this.onShowLoader && p !== 'none'){
|
||||
if (this.onShowLoader && p !== NONE) {
|
||||
this.onShowLoader.call(null, this);
|
||||
}
|
||||
this.loaderDiv.style.display = p;
|
||||
if(this.onHideLoader && p === 'none'){
|
||||
if (this.onHideLoader && p === NONE) {
|
||||
this.onHideLoader.call(null, this);
|
||||
}
|
||||
};
|
||||
|
||||
let t = p === 'none' ? this.loaderCloseDelay : 1;
|
||||
let t = p === NONE ? this.loaderCloseDelay : 1;
|
||||
global.setTimeout(displayLoader, t);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if(!this.initialized){
|
||||
if (!this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,7 +138,7 @@ export class Loader extends Feature{
|
|||
'before-reset-page-length',
|
||||
'before-loading-extensions',
|
||||
'before-loading-themes'],
|
||||
()=> this.show('')
|
||||
() => this.show('')
|
||||
);
|
||||
emitter.off([
|
||||
'after-filtering',
|
||||
|
@ -149,7 +150,7 @@ export class Loader extends Feature{
|
|||
'after-reset-page-length',
|
||||
'after-loading-extensions',
|
||||
'after-loading-themes'],
|
||||
()=> this.show('none')
|
||||
() => this.show(NONE)
|
||||
);
|
||||
|
||||
this.initialized = false;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {Feature} from './feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
import {NONE} from '../const';
|
||||
|
||||
export class NoResults extends Feature{
|
||||
|
||||
|
@ -101,7 +102,7 @@ export class NoResults extends Feature{
|
|||
this.onBeforeHideMsg.call(null, this.tf, this);
|
||||
}
|
||||
|
||||
this.cont.style.display = 'none';
|
||||
this.cont.style.display = NONE;
|
||||
|
||||
if(this.onBeforeHideMsg){
|
||||
this.onBeforeHideMsg.call(null, this.tf, this);
|
||||
|
|
|
@ -3,6 +3,7 @@ import Dom from '../dom';
|
|||
import Types from '../types';
|
||||
import Str from '../string';
|
||||
import Event from '../event';
|
||||
import {INPUT, SELECT, NONE} from '../const';
|
||||
|
||||
export class Paging extends Feature {
|
||||
|
||||
|
@ -83,7 +84,7 @@ export class Paging extends Feature {
|
|||
//enables/disables paging buttons
|
||||
this.hasPagingBtns = f.paging_btns === false ? false : true;
|
||||
//defines previous page button html
|
||||
this.pageSelectorType = f.page_selector_type || tf.fltTypeSlc;
|
||||
this.pageSelectorType = f.page_selector_type || SELECT;
|
||||
//calls function before page is changed
|
||||
this.onBeforeChangePage = Types.isFn(f.on_before_change_page) ?
|
||||
f.on_before_change_page : null;
|
||||
|
@ -130,12 +131,12 @@ export class Paging extends Feature {
|
|||
// Paging DOM events
|
||||
this.evt = {
|
||||
slcIndex() {
|
||||
return (o.pageSelectorType === tf.fltTypeSlc) ?
|
||||
return (o.pageSelectorType === SELECT) ?
|
||||
o.pagingSlc.options.selectedIndex :
|
||||
parseInt(o.pagingSlc.value, 10) - 1;
|
||||
},
|
||||
nbOpts() {
|
||||
return (o.pageSelectorType === tf.fltTypeSlc) ?
|
||||
return (o.pageSelectorType === SELECT) ?
|
||||
parseInt(o.pagingSlc.options.length, 10) - 1 :
|
||||
(o.nbPages - 1);
|
||||
},
|
||||
|
@ -204,17 +205,15 @@ export class Paging extends Feature {
|
|||
};
|
||||
|
||||
// Paging drop-down list selector
|
||||
if (this.pageSelectorType === tf.fltTypeSlc) {
|
||||
slcPages = Dom.create(
|
||||
tf.fltTypeSlc, ['id', this.prfxSlcPages + tf.id]);
|
||||
if (this.pageSelectorType === SELECT) {
|
||||
slcPages = Dom.create(SELECT, ['id', this.prfxSlcPages + tf.id]);
|
||||
slcPages.className = this.pgSlcCssClass;
|
||||
Event.add(slcPages, 'change', evt.slcPagesChange);
|
||||
}
|
||||
|
||||
// Paging input selector
|
||||
if (this.pageSelectorType === tf.fltTypeInp) {
|
||||
slcPages = Dom.create(
|
||||
tf.fltTypeInp,
|
||||
if (this.pageSelectorType === INPUT) {
|
||||
slcPages = Dom.create(INPUT,
|
||||
['id', this.prfxSlcPages + tf.id],
|
||||
['value', this.currentPageNb]
|
||||
);
|
||||
|
@ -235,8 +234,7 @@ export class Paging extends Feature {
|
|||
if (this.hasPagingBtns) {
|
||||
// Next button
|
||||
if (!this.btnNextPageHtml) {
|
||||
var btn_next = Dom.create(
|
||||
tf.fltTypeInp,
|
||||
var btn_next = Dom.create(INPUT,
|
||||
['id', this.prfxBtnNext + tf.id],
|
||||
['type', 'button'],
|
||||
['value', this.btnNextPageText],
|
||||
|
@ -251,8 +249,7 @@ export class Paging extends Feature {
|
|||
}
|
||||
// Previous button
|
||||
if (!this.btnPrevPageHtml) {
|
||||
var btn_prev = Dom.create(
|
||||
tf.fltTypeInp,
|
||||
var btn_prev = Dom.create(INPUT,
|
||||
['id', this.prfxBtnPrev + tf.id],
|
||||
['type', 'button'],
|
||||
['value', this.btnPrevPageText],
|
||||
|
@ -267,8 +264,7 @@ export class Paging extends Feature {
|
|||
}
|
||||
// Last button
|
||||
if (!this.btnLastPageHtml) {
|
||||
var btn_last = Dom.create(
|
||||
tf.fltTypeInp,
|
||||
var btn_last = Dom.create(INPUT,
|
||||
['id', this.prfxBtnLast + tf.id],
|
||||
['type', 'button'],
|
||||
['value', this.btnLastPageText],
|
||||
|
@ -283,8 +279,7 @@ export class Paging extends Feature {
|
|||
}
|
||||
// First button
|
||||
if (!this.btnFirstPageHtml) {
|
||||
var btn_first = Dom.create(
|
||||
tf.fltTypeInp,
|
||||
var btn_first = Dom.create(INPUT,
|
||||
['id', this.prfxBtnFirst + tf.id],
|
||||
['type', 'button'],
|
||||
['value', this.btnFirstPageText],
|
||||
|
@ -386,13 +381,13 @@ export class Paging extends Feature {
|
|||
//refresh page nb span
|
||||
pgspan.innerHTML = this.nbPages;
|
||||
//select clearing shortcut
|
||||
if (this.pageSelectorType === tf.fltTypeSlc) {
|
||||
if (this.pageSelectorType === SELECT) {
|
||||
this.pagingSlc.innerHTML = '';
|
||||
}
|
||||
|
||||
if (this.nbPages > 0) {
|
||||
mdiv.style.visibility = 'visible';
|
||||
if (this.pageSelectorType === tf.fltTypeSlc) {
|
||||
if (this.pageSelectorType === SELECT) {
|
||||
for (var z = 0; z < this.nbPages; z++) {
|
||||
var opt = Dom.createOpt(z + 1, z * this.pagingLength,
|
||||
false);
|
||||
|
@ -439,7 +434,7 @@ export class Paging extends Feature {
|
|||
rowDisplayed = true;
|
||||
}
|
||||
} else {
|
||||
r.style.display = 'none';
|
||||
r.style.display = NONE;
|
||||
}
|
||||
this.emitter.emit('row-paged', tf, validRowIdx, h, rowDisplayed);
|
||||
}
|
||||
|
@ -510,8 +505,7 @@ export class Paging extends Feature {
|
|||
ev.target.blur();
|
||||
};
|
||||
|
||||
var slcR = Dom.create(
|
||||
tf.fltTypeSlc, ['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];
|
||||
|
@ -577,7 +571,7 @@ export class Paging extends Feature {
|
|||
this.emitter.emit('before-page-change', tf, (index + 1));
|
||||
|
||||
if (index === null) {
|
||||
index = this.pageSelectorType === tf.fltTypeSlc ?
|
||||
index = this.pageSelectorType === SELECT ?
|
||||
this.pagingSlc.options.selectedIndex : this.pagingSlc.value - 1;
|
||||
}
|
||||
if (index >= 0 && index <= (this.nbPages - 1)) {
|
||||
|
@ -585,13 +579,13 @@ export class Paging extends Feature {
|
|||
this.onBeforeChangePage.call(null, this, (index + 1));
|
||||
}
|
||||
this.currentPageNb = parseInt(index, 10) + 1;
|
||||
if (this.pageSelectorType === tf.fltTypeSlc) {
|
||||
if (this.pageSelectorType === SELECT) {
|
||||
this.pagingSlc.options[index].selected = true;
|
||||
} else {
|
||||
this.pagingSlc.value = this.currentPageNb;
|
||||
}
|
||||
|
||||
this.startPagingRow = (this.pageSelectorType === tf.fltTypeSlc) ?
|
||||
this.startPagingRow = (this.pageSelectorType === SELECT) ?
|
||||
this.pagingSlc.value : (index * this.pagingLength);
|
||||
|
||||
this.groupByPage();
|
||||
|
@ -627,7 +621,7 @@ export class Paging extends Feature {
|
|||
|
||||
var slcR = this.resultsPerPageSlc;
|
||||
var slcIndex = slcR.selectedIndex;
|
||||
var slcPagesSelIndex = (this.pageSelectorType === tf.fltTypeSlc) ?
|
||||
var slcPagesSelIndex = (this.pageSelectorType === SELECT) ?
|
||||
this.pagingSlc.selectedIndex :
|
||||
parseInt(this.pagingSlc.value - 1, 10);
|
||||
this.pagingLength = parseInt(slcR.options[slcIndex].value, 10);
|
||||
|
@ -639,7 +633,7 @@ export class Paging extends Feature {
|
|||
}
|
||||
this.setPagingInfo();
|
||||
|
||||
if (this.pageSelectorType === tf.fltTypeSlc) {
|
||||
if (this.pageSelectorType === SELECT) {
|
||||
var slcIdx =
|
||||
(this.pagingSlc.options.length - 1 <= slcPagesSelIndex) ?
|
||||
(this.pagingSlc.options.length - 1) : slcPagesSelIndex;
|
||||
|
@ -708,10 +702,10 @@ export class Paging extends Feature {
|
|||
var evt = this.evt;
|
||||
|
||||
if (this.pagingSlc) {
|
||||
if (this.pageSelectorType === tf.fltTypeSlc) {
|
||||
if (this.pageSelectorType === SELECT) {
|
||||
Event.remove(this.pagingSlc, 'change', evt.slcPagesChange);
|
||||
}
|
||||
else if (this.pageSelectorType === tf.fltTypeInp) {
|
||||
else if (this.pageSelectorType === INPUT) {
|
||||
Event.remove(this.pagingSlc, 'keypress', evt._detectKey);
|
||||
}
|
||||
Dom.remove(this.pagingSlc);
|
||||
|
|
|
@ -2,6 +2,7 @@ import {Feature} from './feature';
|
|||
import Types from '../types';
|
||||
import Dom from '../dom';
|
||||
import Event from '../event';
|
||||
import {INPUT, NONE} from '../const';
|
||||
|
||||
export class PopupFilter extends Feature{
|
||||
|
||||
|
@ -91,7 +92,7 @@ export class PopupFilter extends Feature{
|
|||
}
|
||||
|
||||
for(var i=0; i<tf.nbCells; i++){
|
||||
if(tf.getFilterType(i) === tf.fltTypeNone){
|
||||
if(tf.getFilterType(i) === NONE){
|
||||
continue;
|
||||
}
|
||||
var popUpSpan = Dom.create(
|
||||
|
@ -163,14 +164,14 @@ export class PopupFilter extends Feature{
|
|||
var tf = this.tf,
|
||||
popUpFltElm = this.popUpFltElms[colIndex];
|
||||
|
||||
if(popUpFltElm.style.display === 'none' ||
|
||||
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) === tf.fltTypeInp){
|
||||
if(tf.getFilterType(colIndex) === INPUT){
|
||||
var flt = tf.getFilterElement(colIndex);
|
||||
if(flt){
|
||||
flt.focus();
|
||||
|
@ -185,7 +186,7 @@ export class PopupFilter extends Feature{
|
|||
this.onBeforePopUpClose.call(
|
||||
null, this, this.popUpFltElms[colIndex], colIndex);
|
||||
}
|
||||
popUpFltElm.style.display = 'none';
|
||||
popUpFltElm.style.display = NONE;
|
||||
if(this.onAfterPopUpClose){
|
||||
this.onAfterPopUpClose.call(
|
||||
null, this, this.popUpFltElms[colIndex], colIndex);
|
||||
|
@ -204,7 +205,7 @@ export class PopupFilter extends Feature{
|
|||
}
|
||||
var popUpFltElm = this.popUpFltElms[i];
|
||||
if(popUpFltElm){
|
||||
popUpFltElm.style.display = 'none';
|
||||
popUpFltElm.style.display = NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import {AlternateRows} from './modules/alternateRows';
|
|||
import {NoResults} from './modules/noResults';
|
||||
import {State} from './modules/state';
|
||||
|
||||
import {INPUT, SELECT, MULTIPLE, CHECKLIST, NONE} from './const';
|
||||
|
||||
let global = window,
|
||||
doc = global.document;
|
||||
|
||||
|
@ -35,8 +37,6 @@ export class TableFilter {
|
|||
* @param {Object} configuration object
|
||||
*/
|
||||
constructor(...args) {
|
||||
if (args.length === 0) { return; }
|
||||
|
||||
this.id = null;
|
||||
this.version = '{VERSION}';
|
||||
this.year = new Date().getFullYear();
|
||||
|
@ -68,10 +68,10 @@ export class TableFilter {
|
|||
// }
|
||||
});
|
||||
|
||||
if (!this.tbl || this.tbl.nodeName != 'TABLE' ||
|
||||
if (!this.tbl || this.tbl.nodeName !== 'TABLE' ||
|
||||
this.getRowsNb() === 0) {
|
||||
throw new Error(
|
||||
'Could not instantiate TableFilter: HTML table not found.');
|
||||
throw new Error('Could not instantiate TableFilter: HTML table ' +
|
||||
'DOMElement not found.');
|
||||
}
|
||||
|
||||
// configuration object
|
||||
|
@ -88,11 +88,8 @@ export class TableFilter {
|
|||
this.basePath = f.base_path || 'tablefilter/';
|
||||
|
||||
/*** filter types ***/
|
||||
this.fltTypeInp = 'input';
|
||||
this.fltTypeSlc = 'select';
|
||||
this.fltTypeMulti = 'multiple';
|
||||
this.fltTypeCheckList = 'checklist';
|
||||
this.fltTypeNone = 'none';
|
||||
// this.fltTypeCheckList = 'checklist';
|
||||
// this.fltTypeNone = 'none';
|
||||
|
||||
/*** filters' grid properties ***/
|
||||
|
||||
|
@ -488,19 +485,19 @@ export class TableFilter {
|
|||
|
||||
//only 1 input for single search
|
||||
if (this.singleSearchFlt) {
|
||||
col = this.fltTypeInp;
|
||||
col = INPUT;
|
||||
inpclass = this.singleFltCssClass;
|
||||
}
|
||||
|
||||
//drop-down filters
|
||||
if (col === this.fltTypeSlc || col === this.fltTypeMulti) {
|
||||
if (col === SELECT || col === MULTIPLE) {
|
||||
if (!Mod.dropdown) {
|
||||
Mod.dropdown = new Dropdown(this);
|
||||
}
|
||||
Mod.dropdown.init(i, this.isExternalFlt, fltcell);
|
||||
}
|
||||
// checklist
|
||||
else if (col === this.fltTypeCheckList) {
|
||||
else if (col === CHECKLIST) {
|
||||
if (!Mod.checkList) {
|
||||
Mod.checkList = new CheckList(this);
|
||||
}
|
||||
|
@ -699,7 +696,7 @@ export class TableFilter {
|
|||
fltrow.className = this.fltsRowCssClass;
|
||||
|
||||
if (this.isExternalFlt) {
|
||||
fltrow.style.display = 'none';
|
||||
fltrow.style.display = NONE;
|
||||
}
|
||||
|
||||
this.emitter.emit('filters-row-inserted', this, fltrow);
|
||||
|
@ -729,8 +726,8 @@ export class TableFilter {
|
|||
let col = this.getFilterType(colIndex);
|
||||
let externalFltTgtId = this.isExternalFlt ?
|
||||
this.externalFltTgtIds[colIndex] : null;
|
||||
let inptype = col === this.fltTypeInp ? 'text' : 'hidden';
|
||||
let inp = Dom.create(this.fltTypeInp,
|
||||
let inptype = col === INPUT ? 'text' : 'hidden';
|
||||
let inp = Dom.create(INPUT,
|
||||
['id', this.prfxFlt + colIndex + '_' + this.id],
|
||||
['type', inptype], ['ct', colIndex]);
|
||||
|
||||
|
@ -767,7 +764,7 @@ export class TableFilter {
|
|||
_buildSubmitButton(colIndex, container) {
|
||||
let externalFltTgtId = this.isExternalFlt ?
|
||||
this.externalFltTgtIds[colIndex] : null;
|
||||
let btn = Dom.create(this.fltTypeInp,
|
||||
let btn = Dom.create(INPUT,
|
||||
['id', this.prfxValButton + colIndex + '_' + this.id],
|
||||
['type', 'button'], ['value', this.btnText]);
|
||||
btn.className = this.btnCssClass;
|
||||
|
@ -1566,16 +1563,15 @@ export class TableFilter {
|
|||
}
|
||||
|
||||
let fltColType = this.getFilterType(index);
|
||||
if (fltColType !== this.fltTypeMulti &&
|
||||
fltColType !== this.fltTypeCheckList) {
|
||||
if (fltColType !== MULTIPLE && fltColType !== CHECKLIST) {
|
||||
fltValue = flt.value;
|
||||
}
|
||||
//mutiple select
|
||||
else if (fltColType === this.fltTypeMulti) {
|
||||
else if (fltColType === MULTIPLE) {
|
||||
fltValue = this.feature('dropdown').getValues(index);
|
||||
}
|
||||
//checklist
|
||||
else if (fltColType === this.fltTypeCheckList) {
|
||||
else if (fltColType === CHECKLIST) {
|
||||
fltValue = this.feature('checkList').getValues(index);
|
||||
}
|
||||
//return an empty string if collection is empty or contains a single
|
||||
|
@ -1825,7 +1821,7 @@ export class TableFilter {
|
|||
isValid = true;
|
||||
}
|
||||
|
||||
let displayFlag = isValid ? '' : 'none',
|
||||
let displayFlag = isValid ? '' : NONE,
|
||||
validFlag = isValid ? 'true' : 'false';
|
||||
row.style.display = displayFlag;
|
||||
|
||||
|
@ -1871,8 +1867,7 @@ export class TableFilter {
|
|||
let slc = this.getFilterElement(index),
|
||||
fltColType = this.getFilterType(index);
|
||||
|
||||
if (fltColType !== this.fltTypeMulti &&
|
||||
fltColType != this.fltTypeCheckList) {
|
||||
if (fltColType !== MULTIPLE && fltColType !== CHECKLIST) {
|
||||
if (this.loadFltOnDemand && !this.initialized) {
|
||||
this.emitter.emit('build-select-filter', this, index,
|
||||
this.linkedFilters, this.isExternalFlt);
|
||||
|
@ -1880,7 +1875,7 @@ export class TableFilter {
|
|||
slc.value = query;
|
||||
}
|
||||
//multiple selects
|
||||
else if (fltColType === this.fltTypeMulti) {
|
||||
else if (fltColType === MULTIPLE) {
|
||||
let values = Types.isArray(query) ? query :
|
||||
query.split(' ' + this.orOperator + ' ');
|
||||
|
||||
|
@ -1892,7 +1887,7 @@ export class TableFilter {
|
|||
this.emitter.emit('select-options', this, index, values);
|
||||
}
|
||||
//checklist
|
||||
else if (fltColType === this.fltTypeCheckList) {
|
||||
else if (fltColType === CHECKLIST) {
|
||||
let values = [];
|
||||
if (this.loadFltOnDemand && !this.initialized) {
|
||||
this.emitter.emit('build-checklist-filter', this, index,
|
||||
|
@ -2058,9 +2053,9 @@ export class TableFilter {
|
|||
if (!this.linkedFilters || !this.activeFilterId) {
|
||||
return;
|
||||
}
|
||||
let slcA1 = this.getFiltersByType(this.fltTypeSlc, true),
|
||||
slcA2 = this.getFiltersByType(this.fltTypeMulti, true),
|
||||
slcA3 = this.getFiltersByType(this.fltTypeCheckList, true),
|
||||
let slcA1 = this.getFiltersByType(SELECT, true),
|
||||
slcA2 = this.getFiltersByType(MULTIPLE, true),
|
||||
slcA3 = this.getFiltersByType(CHECKLIST, true),
|
||||
slcIndex = slcA1.concat(slcA2);
|
||||
slcIndex = slcIndex.concat(slcA3);
|
||||
|
||||
|
@ -2107,7 +2102,7 @@ export class TableFilter {
|
|||
isExactMatch(colIndex) {
|
||||
let fltType = this.getFilterType(colIndex);
|
||||
return this.exactMatchByCol[colIndex] || this.exactMatch ||
|
||||
(fltType !== this.fltTypeInp);
|
||||
fltType !== INPUT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2210,7 +2205,7 @@ export class TableFilter {
|
|||
for (let k = this.refRow; k < this.getRowsNb(true); k++) {
|
||||
let r = this.tbl.rows[k];
|
||||
if (!this.paging) {
|
||||
if (this.getRowDisplay(r) !== 'none') {
|
||||
if (this.getRowDisplay(r) !== NONE) {
|
||||
this.validRowsIndex.push(r.rowIndex);
|
||||
}
|
||||
} else {
|
||||
|
@ -2308,7 +2303,7 @@ export class TableFilter {
|
|||
*/
|
||||
getFilterType(colIndex) {
|
||||
let colType = this.cfg['col_' + colIndex];
|
||||
return !colType ? this.fltTypeInp : Str.lower(colType);
|
||||
return !colType ? INPUT : Str.lower(colType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
var filtersConfig = {
|
||||
base_path: '../dist/tablefilter/',
|
||||
auto_filter: true,
|
||||
auto_filter_delay: 1100, //milliseconds
|
||||
auto_filter_delay: 750, //milliseconds
|
||||
filters_row_index: 1,
|
||||
state: true,
|
||||
alternate_rows: true,
|
||||
|
|
Loading…
Reference in a new issue