mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-20 15:26:40 +02:00
Added comments to TableFilter methods
This commit is contained in:
parent
86bc0d7b98
commit
c03197e78d
|
@ -2674,14 +2674,9 @@ export class TableFilter{
|
||||||
}// for i
|
}// for i
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- Private methods
|
* Re-generate the filters grid bar when previously removed
|
||||||
=====================================================*/
|
*/
|
||||||
|
|
||||||
/*====================================================
|
|
||||||
- Only used by AddGrid() method
|
|
||||||
- Resets filtering grid bar if previously removed
|
|
||||||
=====================================================*/
|
|
||||||
_resetGrid(){
|
_resetGrid(){
|
||||||
if(this.isFirstLoad){
|
if(this.isFirstLoad){
|
||||||
return;
|
return;
|
||||||
|
@ -2756,18 +2751,17 @@ export class TableFilter{
|
||||||
this._hasGrid = true;
|
this._hasGrid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==============================================
|
/**
|
||||||
- Checks if data contains searched arg,
|
* Checks if passed data contains the searched arg
|
||||||
returns a boolean
|
* @param {String} arg Search term
|
||||||
- Params:
|
* @param {String} data Data string
|
||||||
- arg: searched string
|
* @param {String} fltType Filter type ('input', 'select')
|
||||||
- data: data string
|
* @param {Boolean} forceMatch Exact match
|
||||||
- fltType: filter type (string,
|
* @return {Boolean]}
|
||||||
exact match by default for selects -
|
*
|
||||||
optional)
|
* TODO: move into string module, remove fltType in order to decouple it
|
||||||
- forceMatch: boolean forcing exact
|
* from TableFilter module
|
||||||
match (optional)
|
*/
|
||||||
===============================================*/
|
|
||||||
_containsStr(arg, data, fltType, forceMatch){
|
_containsStr(arg, data, fltType, forceMatch){
|
||||||
// Improved by Cedric Wartel (cwl)
|
// Improved by Cedric Wartel (cwl)
|
||||||
// automatic exact match for selects and special characters are now
|
// automatic exact match for selects and special characters are now
|
||||||
|
@ -2784,6 +2778,12 @@ export class TableFilter{
|
||||||
return regexp.test(data);
|
return regexp.test(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if passed script or stylesheet is already imported
|
||||||
|
* @param {String} filePath Ressource path
|
||||||
|
* @param {String} type Possible values: 'script' or 'link'
|
||||||
|
* @return {Boolean}
|
||||||
|
*/
|
||||||
isImported(filePath, type){
|
isImported(filePath, type){
|
||||||
var imported = false,
|
var imported = false,
|
||||||
importType = !type ? 'script' : type,
|
importType = !type ? 'script' : type,
|
||||||
|
@ -2801,6 +2801,13 @@ export class TableFilter{
|
||||||
return imported;
|
return imported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import script or stylesheet
|
||||||
|
* @param {String} fileId Ressource ID
|
||||||
|
* @param {String} filePath Ressource path
|
||||||
|
* @param {Function} callback Callback
|
||||||
|
* @param {String} type Possible values: 'script' or 'link'
|
||||||
|
*/
|
||||||
import(fileId, filePath, callback, type){
|
import(fileId, filePath, callback, type){
|
||||||
var ftype = !type ? 'script' : type,
|
var ftype = !type ? 'script' : type,
|
||||||
imported = this.isImported(filePath, ftype);
|
imported = this.isImported(filePath, ftype);
|
||||||
|
@ -2842,29 +2849,27 @@ export class TableFilter{
|
||||||
head.appendChild(file);
|
head.appendChild(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- checks if table has a filter grid
|
* Check if table has filters grid
|
||||||
- returns a boolean
|
* @return {Boolean}
|
||||||
=====================================================*/
|
*/
|
||||||
hasGrid(){
|
hasGrid(){
|
||||||
return this._hasGrid;
|
return this._hasGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- returns an array containing filters ids
|
* Get list of filter IDs
|
||||||
- Note that hidden filters are also returned
|
* @return {[type]} [description]
|
||||||
=====================================================*/
|
*/
|
||||||
getFiltersId(){
|
getFiltersId(){
|
||||||
if(!this._hasGrid){
|
return this.fltIds || [];
|
||||||
return;
|
|
||||||
}
|
|
||||||
return this.fltIds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- returns an array containing valid rows indexes
|
* Get filtered (valid) rows indexes
|
||||||
(valid rows upon filtering)
|
* @param {Boolean} reCalc Force calculation of filtered rows list
|
||||||
=====================================================*/
|
* @return {Array} List of row indexes
|
||||||
|
*/
|
||||||
getValidRows(reCalc){
|
getValidRows(reCalc){
|
||||||
if(!this._hasGrid){
|
if(!this._hasGrid){
|
||||||
return;
|
return;
|
||||||
|
@ -2890,10 +2895,10 @@ export class TableFilter{
|
||||||
return this.validRowsIndex;
|
return this.validRowsIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- Returns the index of the row containing the
|
* Get the index of the row containing the filters
|
||||||
filters
|
* @return {Number}
|
||||||
=====================================================*/
|
*/
|
||||||
getFiltersRowIndex(){
|
getFiltersRowIndex(){
|
||||||
if(!this._hasGrid){
|
if(!this._hasGrid){
|
||||||
return;
|
return;
|
||||||
|
@ -2901,9 +2906,10 @@ export class TableFilter{
|
||||||
return this.filtersRowIndex;
|
return this.filtersRowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- Returns the index of the headers row
|
* Get the index of the headers row
|
||||||
=====================================================*/
|
* @return {Number}
|
||||||
|
*/
|
||||||
getHeadersRowIndex(){
|
getHeadersRowIndex(){
|
||||||
if(!this._hasGrid){
|
if(!this._hasGrid){
|
||||||
return;
|
return;
|
||||||
|
@ -2911,10 +2917,11 @@ export class TableFilter{
|
||||||
return this.headersRow;
|
return this.headersRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- Returns the index of the row from which will
|
* Get the row index from where the filtering process start (1st filterable
|
||||||
start the filtering process (1st filterable row)
|
* row)
|
||||||
=====================================================*/
|
* @return {Number}
|
||||||
|
*/
|
||||||
getStartRowIndex(){
|
getStartRowIndex(){
|
||||||
if(!this._hasGrid){
|
if(!this._hasGrid){
|
||||||
return;
|
return;
|
||||||
|
@ -2922,9 +2929,10 @@ export class TableFilter{
|
||||||
return this.refRow;
|
return this.refRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- Returns the index of the last row
|
* Get the index of the last row
|
||||||
=====================================================*/
|
* @return {Number}
|
||||||
|
*/
|
||||||
getLastRowIndex(){
|
getLastRowIndex(){
|
||||||
if(!this._hasGrid){
|
if(!this._hasGrid){
|
||||||
return;
|
return;
|
||||||
|
@ -2932,10 +2940,11 @@ export class TableFilter{
|
||||||
return (this.nbRows-1);
|
return (this.nbRows-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- returns a header DOM element for a given column
|
* Get the header DOM element for a given column index
|
||||||
index
|
* @param {Number} colIndex Column index
|
||||||
=====================================================*/
|
* @return {Object}
|
||||||
|
*/
|
||||||
getHeaderElement(colIndex){
|
getHeaderElement(colIndex){
|
||||||
var table = this.gridLayout ? this.Cpt.gridLayout.headTbl : this.tbl;
|
var table = this.gridLayout ? this.Cpt.gridLayout.headTbl : this.tbl;
|
||||||
var tHead = dom.tag(table, 'thead');
|
var tHead = dom.tag(table, 'thead');
|
||||||
|
@ -2956,17 +2965,18 @@ export class TableFilter{
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- returns the original configuration object
|
* Get the configuration object (literal object)
|
||||||
=====================================================*/
|
* @return {Object}
|
||||||
|
*/
|
||||||
config(){
|
config(){
|
||||||
return this.cfg;
|
return this.cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*====================================================
|
/**
|
||||||
- returns the total number of rows that can be
|
* Get the total number of filterable rows
|
||||||
filtered
|
* @return {Number}
|
||||||
=====================================================*/
|
*/
|
||||||
getFilterableRowsNb(){
|
getFilterableRowsNb(){
|
||||||
return this.getRowsNb(false);
|
return this.getRowsNb(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue