1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-10 18:36:43 +02:00

Switched to Babel

This commit is contained in:
Max Guglielmi 2015-02-28 20:27:28 +11:00
parent 8252b1e859
commit dc4df9e14c
32 changed files with 4107 additions and 6458 deletions

View file

@ -6,6 +6,8 @@
// Eval can be harmful
"-W061": true,
"-W041": true,
// Wrap the /regexp/ literal in parens to disambiguate the slash operator
"-W092": true,
"curly": true,
//"indent": 4,
//"eqeqeq": true,

View file

@ -39,9 +39,9 @@ module.exports = function (grunt) {
compile: {
options: {
baseUrl: '<%= source_folder %>',
'paths': {
'tf': '.'
},
// 'paths': {
// 'tf': '.'
// },
include: ['../libs/almond/almond', 'core'],
out: '<%= dist_folder %>tablefilter.js',
wrap: {
@ -118,7 +118,7 @@ module.exports = function (grunt) {
}
},
'6to5': {
'babel': {
options: {
sourceMap: true,
modules: 'amd'
@ -143,12 +143,12 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-6to5');
grunt.loadNpmTasks('grunt-babel');
// This is the default task being executed if Grunt
// is called without any further parameter.
grunt.registerTask('default', ['jshint', '6to5', 'requirejs', 'concat', 'uglify', 'cssmin', 'copy', 'qunit']);
grunt.registerTask('dev', ['jshint', '6to5', 'concat', 'cssmin', 'copy']);
grunt.registerTask('toes5', ['6to5']);
grunt.registerTask('default', ['jshint', 'babel', 'requirejs', 'concat', 'uglify', 'cssmin', 'copy', 'qunit']);
grunt.registerTask('dev', ['jshint', 'babel', 'concat', 'cssmin', 'copy']);
grunt.registerTask('toes5', ['babel']);
grunt.registerTask('test', ['qunit']);
};

2
dist/filtergrid.css vendored
View file

@ -1,6 +1,6 @@
/*------------------------------------------------------------------------
- TableFilter stylesheet by Max Guglielmi
- (build date: Sun Feb 22 2015 22:45:26)
- (build date: Sat Feb 28 2015 20:15:53)
- Edit below for your projects' needs
------------------------------------------------------------------------*/

10
dist/tablefilter.js vendored

File diff suppressed because one or more lines are too long

View file

@ -3,7 +3,7 @@
"version": "3.0.0",
"devDependencies": {
"grunt": "~0.4.0",
"grunt-6to5": "^1.0.1",
"grunt-babel": "^4.0.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.1",

View file

@ -20,13 +20,28 @@ import {Helpers as hlp} from 'helpers';
import {DateHelper as dateHelper} from 'date';
import {Sort} from 'sort';
import {Store} from 'modules/store';
import {GridLayout} from 'modules/gridLayout';
import {Loader} from 'modules/loader';
import {HighlightKeyword} from 'modules/highlightKeywords';
import {PopupFilter} from 'modules/popupFilter';
import {Dropdown} from 'modules/dropdown';
import {CheckList} from 'modules/checkList';
import {RowsCounter} from 'modules/rowsCounter';
import {StatusBar} from 'modules/statusBar';
import {Paging} from 'modules/paging';
import {ClearButton} from 'modules/clearButton';
import {Help} from 'modules/help';
import {AlternateRows} from 'modules/alternateRows';
import {ColOps} from 'modules/colOps';
var global = window,
isValidDate = dateHelper.isValid,
formatDate = dateHelper.format,
doc = global.document;
export class TableFilter{
export default class TableFilter{
/**
* TF object constructor
@ -856,33 +871,36 @@ export class TableFilter{
if(this.rememberGridValues || this.rememberPageNb ||
this.rememberPageLen){
//var Store = require('modules/store').Store;
import {Store} from 'modules/store';
// import {Store} from 'modules/store';
this.Cpt.store = new Store(this);
}
if(this.gridLayout){
// var GridLayout = require('modules/gridLayout').GridLayout;
import {GridLayout} from 'modules/gridLayoutf';
// import {GridLayout} from 'modules/gridLayout';
this.Cpt.gridLayout = new GridLayout(this);
this.Cpt.gridLayout.init();
}
if(this.loader){
if(!this.Cpt.loader){
var Loader = require('modules/loader').Loader;
// var Loader = require('modules/loader').Loader;
// import {Loader} from 'modules/loader';
this.Cpt.loader = new Loader(this);
}
}
if(this.highlightKeywords){
var Highlight =
require('modules/highlightKeywords').HighlightKeyword;
this.Cpt.highlightKeyword = new Highlight(this);
// var Highlight =
// require('modules/highlightKeywords').HighlightKeyword;
// import {HighlightKeyword} from 'modules/highlightKeywords';
this.Cpt.highlightKeyword = new HighlightKeyword(this);
}
if(this.popUpFilters){
if(!this.Cpt.popupFilter){
var PopupFilter = require('modules/popupFilter').PopupFilter;
// var PopupFilter = require('modules/popupFilter').PopupFilter;
// import {PopupFilter} from 'modules/popupFilter';
this.Cpt.popupFilter = new PopupFilter(this);
}
this.Cpt.popupFilter.init();
@ -964,7 +982,8 @@ export class TableFilter{
//drop-down filters
if(col===this.fltTypeSlc || col===this.fltTypeMulti){
if(!this.Cpt.dropdown){
var Dropdown = require('modules/dropdown').Dropdown;
// var Dropdown = require('modules/dropdown').Dropdown;
// import {Dropdown} from 'modules/dropdown';
this.Cpt.dropdown = new Dropdown(this);
}
var dropdown = this.Cpt.dropdown;
@ -1010,8 +1029,9 @@ export class TableFilter{
// checklist
else if(col===this.fltTypeCheckList){
if(!this.Cpt.checkList){
var CheckList =
require('modules/checkList').CheckList;
// var CheckList =
// require('modules/checkList').CheckList;
// import {CheckList} from 'modules/checkList';
this.Cpt.checkList = new CheckList(this);
}
@ -1112,28 +1132,32 @@ export class TableFilter{
/* Filter behaviours */
if(this.rowsCounter){
var RowsCounter = require('modules/rowsCounter').RowsCounter;
// var RowsCounter = require('modules/rowsCounter').RowsCounter;
// import {RowsCounter} from 'modules/rowsCounter';
this.Cpt.rowsCounter = new RowsCounter(this);
this.Cpt.rowsCounter.init();
}
if(this.statusBar){
// this.SetStatusBar();
var StatusBar = require('modules/statusBar').StatusBar;
// var StatusBar = require('modules/statusBar').StatusBar;
// import {StatusBar} from 'modules/statusBar';
this.Cpt.statusBar = new StatusBar(this);
this.Cpt.statusBar.init();
}
if(this.paging){
var Paging = require('modules/paging').Paging;
// var Paging = require('modules/paging').Paging;
// import {Paging} from 'modules/paging';
this.Cpt.paging = new Paging(this);
this.Cpt.paging.init();
}
if(this.btnReset){
var ClearButton = require('modules/clearButton').ClearButton;
// var ClearButton = require('modules/clearButton').ClearButton;
// import {ClearButton} from 'modules/clearButton';
this.Cpt.clearButton = new ClearButton(this);
this.Cpt.clearButton.init();
}
if(this.helpInstructions){
var Help = require('modules/help').Help;
// var Help = require('modules/help').Help;
// import {Help} from 'modules/help';
this.Cpt.help = new Help(this);
this.Cpt.help.init();
}
@ -1142,16 +1166,18 @@ export class TableFilter{
}
if(this.alternateBgs){
//1st time only if no paging and rememberGridValues
var AlternateRows = require('modules/alternateRows').AlternateRows;
// var AlternateRows = require('modules/alternateRows').AlternateRows;
// import {AlternateRows} from 'modules/alternateRows';
this.Cpt.alternateRows = new AlternateRows(this);
this.Cpt.alternateRows.init();
}
if(this.hasColOperation){
var ColOps = require('modules/colOps').ColOps;
// var ColOps = require('modules/colOps').ColOps;
// import {ColOps} from 'modules/colOps';
this.Cpt.colOps = new ColOps(this);
this.Cpt.colOps.calc();
}
if(this.sort || this.gridLayout){
if(this.sort /*|| this.gridLayout*/){
this.SetSort();
}
if(this.selectable || this.editable){
@ -1555,7 +1581,8 @@ export class TableFilter{
// Enable help instructions by default is topbar is generated
if(!this.helpInstructions){
if(!this.Cpt.help){
var Help = require('modules/help').Help;
// var Help = require('modules/help').Help;
// import {Help} from 'modules/help';
this.Cpt.help = new Help(this);
}
this.Cpt.help.init();
@ -2425,7 +2452,7 @@ export class TableFilter{
else{
var fCol = f['col_'+j];
occurence = o._containsStr(
sA, cell_data, !fCol ? this.fltTypeInp : fCol);
sA, cell_data, !fCol ? o.fltTypeInp : fCol);
}
}//else
@ -3276,6 +3303,23 @@ export class TableFilter{
return regexp.test(data);
}
isImported(filePath, type){
var imported = false,
importType = !type ? 'script' : type,
attr = importType == 'script' ? 'src' : 'href',
files = dom.tag(doc, importType);
for (var i=0; i<files.length; i++){
if(files[i][attr] === undefined){
continue;
}
if(files[i][attr].match(filePath)){
imported = true;
break;
}
}
return imported;
}
includeFile(fileId, filePath, callback, type){
var ftype = !type ? 'script' : type,
imported = this.isImported(filePath, ftype);
@ -3444,15 +3488,15 @@ export class TableFilter{
return this.getRowsNb(false);
}
// };
}
numSortAsc(a, b){ return (a-b); }
function numSortAsc(a, b){ return (a-b); }
numSortDesc(a, b){ return (b-a); }
function numSortDesc(a, b){ return (b-a); }
removeNbFormat(data, format){
function removeNbFormat(data, format){
if(!data){
return;
}
@ -3468,23 +3512,6 @@ removeNbFormat(data, format){
return n;
}
isImported(filePath, type){
var imported = false,
importType = !type ? 'script' : type,
attr = importType == 'script' ? 'src' : 'href',
files = dom.tag(doc, importType);
for (var i=0; i<files.length; i++){
if(files[i][attr] === undefined){
continue;
}
if(files[i][attr].match(filePath)){
imported = true;
break;
}
}
return imported;
}
// function isStylesheetImported(stylesheet){
// var isImported = false;
// if(!doc.styleSheets){
@ -3515,7 +3542,7 @@ isImported(filePath, type){
// }
//Firefox does not support outerHTML property
setOuterHtml(){
function setOuterHtml(){
if(doc.body.__defineGetter__){
if(HTMLElement) {
var element = HTMLElement.prototype;
@ -3549,7 +3576,7 @@ setOuterHtml(){
// });
}
// }
/*====================================================
- Sets filters grid bar

View file

@ -1,29 +1,33 @@
define(["exports", "string"], function (exports, _string) {
"use strict";
"use strict";
var Str = _string.Str;
/**
* Array utilities
*/
var Str = _string.Str;
var Arr = {
has: function (arr, val, caseSensitive) {
var sCase = caseSensitive === undefined ? false : caseSensitive;
for (var i = 0; i < arr.length; i++) {
if (Str.matchCase(arr[i].toString(), sCase) == val) {
return true;
var Arr = {
has: function has(arr, val, caseSensitive) {
var sCase = caseSensitive === undefined ? false : caseSensitive;
for (var i = 0; i < arr.length; i++) {
if (Str.matchCase(arr[i].toString(), sCase) == val) {
return true;
}
}
return false;
},
indexByValue: function indexByValue(arr, val, caseSensitive) {
var sCase = caseSensitive === undefined ? false : caseSensitive;
for (var i = 0; i < arr.length; i++) {
if (Str.matchCase(arr[i].toString(), sCase) == val) {
return i;
}
}
return -1;
}
}
return false;
},
indexByValue: function (arr, val, caseSensitive) {
var sCase = caseSensitive === undefined ? false : caseSensitive;
for (var i = 0; i < arr.length; i++) {
if (Str.matchCase(arr[i].toString(), sCase) == val) {
return i;
}
}
return -1;
}
};
};
exports.Arr = Arr;
});
exports.Arr = Arr;
});
//# sourceMappingURL=array.js.map

View file

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

File diff suppressed because one or more lines are too long

View file

@ -1,160 +1,172 @@
define(["exports"], function (exports) {
"use strict";
"use strict";
/**
* Date utilities
*/
/**
* Date utilities
*/
var DateHelper = {
isValid: function (dateStr, format) {
if (!format) {
format = "DMY";
}
format = format.toUpperCase();
if (format.length != 3) {
if (format === "DDMMMYYYY") {
var d = this.format(dateStr, format);
dateStr = d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear();
format = "DMY";
}
}
if ((format.indexOf("M") === -1) || (format.indexOf("D") === -1) || (format.indexOf("Y") === -1)) {
format = "DMY";
}
var reg1, reg2;
// If the year is first
if (format.substring(0, 1) == "Y") {
reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;
reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;
} else if (format.substring(1, 2) == "Y") {
// If the year is second
reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/;
reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/;
} else {
// The year must be third
reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/;
reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
}
// If it doesn't conform to the right format (with either a 2 digit year or
// 4 digit year), fail
if (reg1.test(dateStr) === false && reg2.test(dateStr) === false) {
return false;
}
// Split into 3 parts based on what the divider was
var parts = dateStr.split(RegExp.$1);
var mm, dd, yy;
// Check to see if the 3 parts end up making a valid date
if (format.substring(0, 1) === "M") {
mm = parts[0];
} else if (format.substring(1, 2) === "M") {
mm = parts[1];
} else {
mm = parts[2];
}
if (format.substring(0, 1) === "D") {
dd = parts[0];
} else if (format.substring(1, 2) === "D") {
dd = parts[1];
} else {
dd = parts[2];
}
if (format.substring(0, 1) === "Y") {
yy = parts[0];
} else if (format.substring(1, 2) === "Y") {
yy = parts[1];
} else {
yy = parts[2];
}
if (parseInt(yy, 10) <= 50) {
yy = (parseInt(yy, 10) + 2000).toString();
}
if (parseInt(yy, 10) <= 99) {
yy = (parseInt(yy, 10) + 1900).toString();
}
var dt = new Date(parseInt(yy, 10), parseInt(mm, 10) - 1, parseInt(dd, 10), 0, 0, 0, 0);
if (parseInt(dd, 10) != dt.getDate()) {
return false;
}
if (parseInt(mm, 10) - 1 != dt.getMonth()) {
return false;
}
return true;
},
format: function (dateStr, format) {
if (!format) {
format = "DMY";
}
if (!dateStr || dateStr === "") {
return new Date(1001, 0, 1);
}
var oDate, parts;
var DateHelper = {
isValid: function isValid(dateStr, format) {
if (!format) {
format = "DMY";
}
format = format.toUpperCase();
if (format.length != 3) {
if (format === "DDMMMYYYY") {
var d = this.format(dateStr, format);
dateStr = d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear();
format = "DMY";
}
}
if (format.indexOf("M") === -1 || format.indexOf("D") === -1 || format.indexOf("Y") === -1) {
format = "DMY";
}
var reg1, reg2;
// If the year is first
if (format.substring(0, 1) == "Y") {
reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;
reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/;
} else if (format.substring(1, 2) == "Y") {
// If the year is second
reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/;
reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/;
} else {
// The year must be third
reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/;
reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
}
// If it doesn't conform to the right format (with either a 2 digit year or
// 4 digit year), fail
if (reg1.test(dateStr) === false && reg2.test(dateStr) === false) {
return false;
}
// Split into 3 parts based on what the divider was
var parts = dateStr.split(RegExp.$1);
var mm, dd, yy;
// Check to see if the 3 parts end up making a valid date
if (format.substring(0, 1) === "M") {
mm = parts[0];
} else if (format.substring(1, 2) === "M") {
mm = parts[1];
} else {
mm = parts[2];
}
if (format.substring(0, 1) === "D") {
dd = parts[0];
} else if (format.substring(1, 2) === "D") {
dd = parts[1];
} else {
dd = parts[2];
}
if (format.substring(0, 1) === "Y") {
yy = parts[0];
} else if (format.substring(1, 2) === "Y") {
yy = parts[1];
} else {
yy = parts[2];
}
if (parseInt(yy, 10) <= 50) {
yy = (parseInt(yy, 10) + 2000).toString();
}
if (parseInt(yy, 10) <= 99) {
yy = (parseInt(yy, 10) + 1900).toString();
}
var dt = new Date(parseInt(yy, 10), parseInt(mm, 10) - 1, parseInt(dd, 10), 0, 0, 0, 0);
if (parseInt(dd, 10) != dt.getDate()) {
return false;
}
if (parseInt(mm, 10) - 1 != dt.getMonth()) {
return false;
}
return true;
},
format: (function (_format) {
var _formatWrapper = function format(_x, _x2) {
return _format.apply(this, arguments);
};
function y2kDate(yr) {
if (yr === undefined) {
return 0;
}
if (yr.length > 2) {
return yr;
}
var y;
//>50 belong to 1900
if (yr <= 99 && yr > 50) {
y = "19" + yr;
}
//<50 belong to 2000
if (yr < 50 || yr === "00") {
y = "20" + yr;
}
return y;
}
_formatWrapper.toString = function () {
return _format.toString();
};
function mmm2mm(mmm) {
if (mmm === undefined) {
return 0;
}
var mondigit;
var MONTH_NAMES = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
for (var m_i = 0; m_i < MONTH_NAMES.length; m_i++) {
var month_name = MONTH_NAMES[m_i];
if (mmm.toLowerCase() === month_name) {
mondigit = m_i + 1;
break;
}
}
if (mondigit > 11 || mondigit < 23) {
mondigit = mondigit - 12;
}
if (mondigit < 1 || mondigit > 12) {
return 0;
}
return mondigit;
}
return _formatWrapper;
})(function (dateStr, format) {
if (!format) {
format = "DMY";
}
if (!dateStr || dateStr === "") {
return new Date(1001, 0, 1);
}
var oDate, parts;
switch (format.toUpperCase()) {
case "DDMMMYYYY":
parts = dateStr.replace(/[- \/.]/g, " ").split(" ");
oDate = new Date(y2kDate(parts[2]), mmm2mm(parts[1]) - 1, parts[0]);
break;
case "DMY":
parts = dateStr.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" ");
oDate = new Date(y2kDate(parts[2]), parts[1] - 1, parts[0]);
break;
case "MDY":
parts = dateStr.replace(/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" ");
oDate = new Date(y2kDate(parts[2]), parts[0] - 1, parts[1]);
break;
case "YMD":
parts = dateStr.replace(/^((\d\d)?\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/, "$1 $4 $6").split(" ");
oDate = new Date(y2kDate(parts[0]), parts[1] - 1, parts[2]);
break;
default: //in case format is not correct
parts = dateStr.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" ");
oDate = new Date(y2kDate(parts[2]), parts[1] - 1, parts[0]);
break;
}
return oDate;
}
};
function y2kDate(yr) {
if (yr === undefined) {
return 0;
}
if (yr.length > 2) {
return yr;
}
var y;
//>50 belong to 1900
if (yr <= 99 && yr > 50) {
y = "19" + yr;
}
//<50 belong to 2000
if (yr < 50 || yr === "00") {
y = "20" + yr;
}
return y;
}
exports.DateHelper = DateHelper;
});
function mmm2mm(mmm) {
if (mmm === undefined) {
return 0;
}
var mondigit;
var MONTH_NAMES = ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
for (var m_i = 0; m_i < MONTH_NAMES.length; m_i++) {
var month_name = MONTH_NAMES[m_i];
if (mmm.toLowerCase() === month_name) {
mondigit = m_i + 1;
break;
}
}
if (mondigit > 11 || mondigit < 23) {
mondigit = mondigit - 12;
}
if (mondigit < 1 || mondigit > 12) {
return 0;
}
return mondigit;
}
switch (format.toUpperCase()) {
case "DDMMMYYYY":
parts = dateStr.replace(/[- \/.]/g, " ").split(" ");
oDate = new Date(y2kDate(parts[2]), mmm2mm(parts[1]) - 1, parts[0]);
break;
case "DMY":
parts = dateStr.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" ");
oDate = new Date(y2kDate(parts[2]), parts[1] - 1, parts[0]);
break;
case "MDY":
parts = dateStr.replace(/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" ");
oDate = new Date(y2kDate(parts[2]), parts[0] - 1, parts[1]);
break;
case "YMD":
parts = dateStr.replace(/^((\d\d)?\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/, "$1 $4 $6").split(" ");
oDate = new Date(y2kDate(parts[0]), parts[1] - 1, parts[2]);
break;
default:
//in case format is not correct
parts = dateStr.replace(/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, "$1 $3 $5").split(" ");
oDate = new Date(y2kDate(parts[2]), parts[1] - 1, parts[0]);
break;
}
return oDate;
})
};
exports.DateHelper = DateHelper;
});
//# sourceMappingURL=date.js.map

View file

@ -1,156 +1,162 @@
define(["exports"], function (exports) {
"use strict";
"use strict";
/**
* DOM utilities
*/
/**
* DOM utilities
*/
var Dom = {};
var Dom = {};
/**
* Returns text + text of children of given node
* @param {NodeElement} node
* @return {String}
*/
Dom.getText = function (node) {
var s = node.textContent || node.innerText || node.innerHTML.replace(/<[^<>]+>/g, "");
s = s.replace(/^\s+/, "").replace(/\s+$/, "");
return s;
};
/**
* Returns text + text of children of given node
* @param {NodeElement} node
* @return {String}
*/
Dom.getText = function (node) {
var s = node.textContent || node.innerText || node.innerHTML.replace(/<[^<>]+>/g, "");
s = s.replace(/^\s+/, "").replace(/\s+$/, "");
return s;
};
/**
* 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
*/
Dom.create = function (tag) {
if (!tag || tag === "") {
return;
}
var el = document.createElement(tag), args = arguments;
if (args.length > 1) {
for (var i = 0; i < args.length; i++) {
var argtype = typeof args[i];
if (argtype.toLowerCase() === "object" && args[i].length === 2) {
el.setAttribute(args[i][0], args[i][1]);
/**
* 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
*/
Dom.create = function (tag) {
if (!tag || tag === "") {
return;
}
}
}
return el;
};
/**
* Returns a text node with given text
* @param {String} text
* @return {Object}
*/
Dom.text = function (text) {
return document.createTextNode(text);
};
var el = document.createElement(tag),
args = arguments;
/**
* Returns offset position of passed element
* @param {object} obj [description]
* @return {object} literal object with left and top values
*/
Dom.position = function (obj) {
var l = 0, t = 0;
if (obj && obj.offsetParent) {
do {
l += obj.offsetLeft;
t += obj.offsetTop;
} while (obj == obj.offsetParent);
}
return { left: l, top: t };
};
if (args.length > 1) {
for (var i = 0; i < args.length; i++) {
var argtype = typeof args[i];
if (argtype.toLowerCase() === "object" && args[i].length === 2) {
el.setAttribute(args[i][0], args[i][1]);
}
}
}
return el;
};
Dom.hasClass = function (ele, cls) {
if (!ele) {
return false;
/**
* Returns a text node with given text
* @param {String} text
* @return {Object}
*/
Dom.text = function (text) {
return document.createTextNode(text);
};
/**
* Returns offset position of passed element
* @param {object} obj [description]
* @return {object} literal object with left and top values
*/
Dom.position = function (obj) {
var l = 0,
t = 0;
if (obj && obj.offsetParent) {
do {
l += obj.offsetLeft;
t += obj.offsetTop;
} while (obj == obj.offsetParent);
}
return { left: l, top: t };
};
Dom.hasClass = function (ele, cls) {
if (!ele) {
return false;
}
if (supportsClassList()) {
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
};
Dom.addClass = function (ele, cls) {
if (!ele) {
return;
}
if (supportsClassList()) {
ele.classList.add(cls);
return;
}
if (ele.className === "") {
ele.className = cls;
} else if (!this.hasClass(ele, cls)) {
ele.className += " " + cls;
}
};
Dom.removeClass = function (ele, cls) {
if (!ele) {
return;
}
if (supportsClassList()) {
ele.classList.remove(cls);
return;
}
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)", "g");
ele.className = ele.className.replace(reg, "");
};
/**
* Creates and returns an option element
* @param {String} text option text
* @param {String} value option value
* @param {Boolean} isSel whether option is selected
* @return {Object} option element
*/
Dom.createOpt = function (text, value, isSel) {
var isSelected = isSel ? true : false,
opt = isSelected ? this.create("option", ["value", value], ["selected", "true"]) : this.create("option", ["value", value]);
opt.appendChild(this.text(text));
return opt;
};
/**
* Creates and returns a checklist item
* @param {Number} chkIndex index of check item
* @param {String} chkValue check item value
* @param {String} labelText check item label text
* @return {Object} li DOM element
*/
Dom.createCheckItem = function (chkIndex, chkValue, labelText) {
var li = this.create("li"),
label = this.create("label", ["for", chkIndex]),
check = this.create("input", ["id", chkIndex], ["name", chkIndex], ["type", "checkbox"], ["value", chkValue]);
label.appendChild(check);
label.appendChild(this.text(labelText));
li.appendChild(label);
li.label = label;
li.check = check;
return li;
};
Dom.id = function (id) {
return document.getElementById(id);
};
Dom.tag = function (o, tagname) {
return o.getElementsByTagName(tagname);
};
// HTML5 classList API
function supportsClassList() {
return document.documentElement.classList;
}
if (supportsClassList()) {
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
};
Dom.addClass = function (ele, cls) {
if (!ele) {
return;
}
if (supportsClassList()) {
ele.classList.add(cls);
return;
}
if (ele.className === "") {
ele.className = cls;
} else if (!this.hasClass(ele, cls)) {
ele.className += " " + cls;
}
};
Dom.removeClass = function (ele, cls) {
if (!ele) {
return;
}
if (supportsClassList()) {
ele.classList.remove(cls);
return;
}
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)", "g");
ele.className = ele.className.replace(reg, "");
};
/**
* Creates and returns an option element
* @param {String} text option text
* @param {String} value option value
* @param {Boolean} isSel whether option is selected
* @return {Object} option element
*/
Dom.createOpt = function (text, value, isSel) {
var isSelected = isSel ? true : false, opt = isSelected ? this.create("option", ["value", value], ["selected", "true"]) : this.create("option", ["value", value]);
opt.appendChild(this.text(text));
return opt;
};
/**
* Creates and returns a checklist item
* @param {Number} chkIndex index of check item
* @param {String} chkValue check item value
* @param {String} labelText check item label text
* @return {Object} li DOM element
*/
Dom.createCheckItem = function (chkIndex, chkValue, labelText) {
var li = this.create("li"), label = this.create("label", ["for", chkIndex]), check = this.create("input", ["id", chkIndex], ["name", chkIndex], ["type", "checkbox"], ["value", chkValue]);
label.appendChild(check);
label.appendChild(this.text(labelText));
li.appendChild(label);
li.label = label;
li.check = check;
return li;
};
Dom.id = function (id) {
return document.getElementById(id);
};
Dom.tag = function (o, tagname) {
return o.getElementsByTagName(tagname);
};
// HTML5 classList API
function supportsClassList() {
return document.documentElement.classList;
}
exports.Dom = Dom;
});
exports.Dom = Dom;
});
//# sourceMappingURL=dom.js.map

View file

@ -1,50 +1,51 @@
define(["exports"], function (exports) {
"use strict";
"use strict";
/**
* DOM event utilities
*/
/**
* DOM event utilities
*/
var Event = {
add: function (obj, type, func, capture) {
if (obj.addEventListener) {
obj.addEventListener(type, func, capture);
} else if (obj.attachEvent) {
obj.attachEvent("on" + type, func);
} else {
obj["on" + type] = func;
}
},
remove: function (obj, type, func, capture) {
if (obj.detachEvent) {
obj.detachEvent("on" + type, func);
} else if (obj.removeEventListener) {
obj.removeEventListener(type, func, capture);
} else {
obj["on" + type] = null;
}
},
stop: function (evt) {
if (!evt) {
evt = window.event;
}
if (evt.stopPropagation) {
evt.stopPropagation();
} else {
evt.cancelBubble = true;
}
},
cancel: function (evt) {
if (!evt) {
evt = window.event;
}
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.returnValue = false;
}
}
};
var Event = {
add: function add(obj, type, func, capture) {
if (obj.addEventListener) {
obj.addEventListener(type, func, capture);
} else if (obj.attachEvent) {
obj.attachEvent("on" + type, func);
} else {
obj["on" + type] = func;
}
},
remove: function remove(obj, type, func, capture) {
if (obj.detachEvent) {
obj.detachEvent("on" + type, func);
} else if (obj.removeEventListener) {
obj.removeEventListener(type, func, capture);
} else {
obj["on" + type] = null;
}
},
stop: function stop(evt) {
if (!evt) {
evt = window.event;
}
if (evt.stopPropagation) {
evt.stopPropagation();
} else {
evt.cancelBubble = true;
}
},
cancel: function cancel(evt) {
if (!evt) {
evt = window.event;
}
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.returnValue = false;
}
}
};
exports.Event = Event;
});
exports.Event = Event;
});
//# sourceMappingURL=event.js.map

View file

@ -1,15 +1,16 @@
define(["exports"], function (exports) {
"use strict";
"use strict";
/**
* Misc helpers
*/
/**
* Misc helpers
*/
var Helpers = {
isIE: function () {
return (/msie|MSIE/).test(navigator.userAgent);
}
};
var Helpers = {
isIE: function isIE() {
return /msie|MSIE/.test(navigator.userAgent);
}
};
exports.Helpers = Helpers;
});
exports.Helpers = Helpers;
});
//# sourceMappingURL=helpers.js.map

View file

@ -87,7 +87,7 @@
<script>
requirejs(['core'], function(TableFilter){
// Your logic here
tf = new TableFilter.TableFilter("demo", {
tf = new TableFilter("demo", {
col_0: 'select',
col_2: 'multiple',
col_3: 'checklist',

View file

@ -1,98 +1,139 @@
define(["exports", "../dom"], function (exports, _dom) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var AlternateRows = (function () {
var AlternateRows = function AlternateRows(tf) {
var f = tf.config();
//defines css class for even rows
this.evenCss = f.even_row_css_class || "even";
//defines css class for odd rows
this.oddCss = f.odd_row_css_class || "odd";
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
this.tf = tf;
};
var Dom = _dom.Dom;
_classProps(AlternateRows, null, {
init: {
writable: true,
value: function () {
if (!this.tf.hasGrid() && !this.tf.isFirstLoad) {
return;
}
var rows = this.tf.tbl.rows;
var noValidRowsIndex = this.tf.validRowsIndex === null;
//1st index
var beginIndex = noValidRowsIndex ? this.tf.refRow : 0;
// nb indexes
var indexLen = noValidRowsIndex ? this.tf.nbFilterableRows + beginIndex : this.tf.validRowsIndex.length;
var idx = 0;
var AlternateRows = exports.AlternateRows = (function () {
//alternates bg color
for (var j = beginIndex; j < indexLen; j++) {
var rowIdx = noValidRowsIndex ? j : this.tf.validRowsIndex[j];
this.setRowBg(rowIdx, idx);
idx++;
}
/**
* Alternating rows color
* @param {Object} tf TableFilter instance
*/
function AlternateRows(tf) {
_classCallCheck(this, AlternateRows);
var f = tf.config();
//defines css class for even rows
this.evenCss = f.even_row_css_class || "even";
//defines css class for odd rows
this.oddCss = f.odd_row_css_class || "odd";
this.tf = tf;
}
},
setRowBg: {
writable: true,
value: function (rowIdx, idx) {
if (!this.tf.alternateBgs || isNaN(rowIdx)) {
return;
}
var rows = this.tf.tbl.rows;
var i = !idx ? rowIdx : idx;
this.removeRowBg(rowIdx);
Dom.addClass(rows[rowIdx], (i % 2) ? this.evenCss : this.oddCss);
}
},
removeRowBg: {
writable: true,
value: function (idx) {
if (isNaN(idx)) {
return;
}
var rows = this.tf.tbl.rows;
Dom.removeClass(rows[idx], this.oddCss);
Dom.removeClass(rows[idx], this.evenCss);
}
},
remove: {
writable: true,
value: function () {
if (!this.tf.hasGrid()) {
return;
}
var row = this.tf.tbl.rows;
for (var i = this.tf.refRow; i < this.tf.nbRows; i++) {
this.removeRowBg(i);
}
this.tf.isStartBgAlternate = true;
}
},
enable: {
writable: true,
value: function () {
this.tf.alternateBgs = true;
}
},
disable: {
writable: true,
value: function () {
this.tf.alternateBgs = false;
}
}
_prototypeProperties(AlternateRows, null, {
init: {
/**
* Sets alternating rows color
*/
value: function init() {
if (!this.tf.hasGrid() && !this.tf.isFirstLoad) {
return;
}
var rows = this.tf.tbl.rows;
var noValidRowsIndex = this.tf.validRowsIndex === null;
//1st index
var beginIndex = noValidRowsIndex ? this.tf.refRow : 0;
// nb indexes
var indexLen = noValidRowsIndex ? this.tf.nbFilterableRows + beginIndex : this.tf.validRowsIndex.length;
var idx = 0;
//alternates bg color
for (var j = beginIndex; j < indexLen; j++) {
var rowIdx = noValidRowsIndex ? j : this.tf.validRowsIndex[j];
this.setRowBg(rowIdx, idx);
idx++;
}
},
writable: true,
configurable: true
},
setRowBg: {
/**
* Sets row background color
* @param {Number} rowIdx Row index
* @param {Number} idx Valid rows collection index needed to calculate bg
* color
*/
value: function setRowBg(rowIdx, idx) {
if (!this.tf.alternateBgs || isNaN(rowIdx)) {
return;
}
var rows = this.tf.tbl.rows;
var i = !idx ? rowIdx : idx;
this.removeRowBg(rowIdx);
Dom.addClass(rows[rowIdx], i % 2 ? this.evenCss : this.oddCss);
},
writable: true,
configurable: true
},
removeRowBg: {
/**
* Removes row background color
* @param {Number} idx Row index
*/
value: function removeRowBg(idx) {
if (isNaN(idx)) {
return;
}
var rows = this.tf.tbl.rows;
Dom.removeClass(rows[idx], this.oddCss);
Dom.removeClass(rows[idx], this.evenCss);
},
writable: true,
configurable: true
},
remove: {
/**
* Removes all row background color
*/
value: function remove() {
if (!this.tf.hasGrid()) {
return;
}
var row = this.tf.tbl.rows;
for (var i = this.tf.refRow; i < this.tf.nbRows; i++) {
this.removeRowBg(i);
}
this.tf.isStartBgAlternate = true;
},
writable: true,
configurable: true
},
enable: {
value: function enable() {
this.tf.alternateBgs = true;
},
writable: true,
configurable: true
},
disable: {
value: function disable() {
this.tf.alternateBgs = false;
},
writable: true,
configurable: true
}
});
return AlternateRows;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return AlternateRows;
})();
exports.AlternateRows = AlternateRows;
});
});
//# sourceMappingURL=alternateRows.js.map

View file

@ -1,375 +1,440 @@
define(["exports", "../dom", "../array", "../string", "../sort", "../event"], function (exports, _dom, _array, _string, _sort, _event) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var array = _array.Arr;
var Str = _string.Str;
var Sort = _sort.Sort;
var Event = _event.Event;
var CheckList = (function () {
var CheckList = function CheckList(tf) {
// Configuration object
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
this.checkListDiv = []; //checklist container div
//defines css class for div containing checklist filter
this.checkListDivCssClass = f.div_checklist_css_class || "div_checklist";
//defines css class for checklist filters
this.checkListCssClass = f.checklist_css_class || "flt_checklist";
//defines css class for checklist item (li)
this.checkListItemCssClass = f.checklist_item_css_class || "flt_checklist_item";
//defines css class for selected checklist item (li)
this.checkListSlcItemCssClass = f.checklist_selected_item_css_class || "flt_checklist_slc_item";
//Load on demand text
this.activateCheckListTxt = f.activate_checklist_text || "Click to load filter data";
//defines css class for checklist filters
this.checkListItemDisabledCssClass = f.checklist_item_disabled_css_class || "flt_checklist_item_disabled";
this.enableCheckListResetFilter = f.enable_checklist_reset_filter === false ? false : true;
var Dom = _dom.Dom;
var array = _array.Arr;
var Str = _string.Str;
var Sort = _sort.Sort;
var Event = _event.Event;
this.isCustom = null;
this.opts = null;
this.optsTxt = null;
var CheckList = exports.CheckList = (function () {
this.tf = tf;
};
/**
* Checklist UI component
* @param {Object} tf TableFilter instance
*/
_classProps(CheckList, null, {
onChange: {
writable: true,
value: function (evt) {
this.tf.Evt._OnSlcChange(evt);
function CheckList(tf) {
_classCallCheck(this, CheckList);
// Configuration object
var f = tf.config();
this.checkListDiv = []; //checklist container div
//defines css class for div containing checklist filter
this.checkListDivCssClass = f.div_checklist_css_class || "div_checklist";
//defines css class for checklist filters
this.checkListCssClass = f.checklist_css_class || "flt_checklist";
//defines css class for checklist item (li)
this.checkListItemCssClass = f.checklist_item_css_class || "flt_checklist_item";
//defines css class for selected checklist item (li)
this.checkListSlcItemCssClass = f.checklist_selected_item_css_class || "flt_checklist_slc_item";
//Load on demand text
this.activateCheckListTxt = f.activate_checklist_text || "Click to load filter data";
//defines css class for checklist filters
this.checkListItemDisabledCssClass = f.checklist_item_disabled_css_class || "flt_checklist_item_disabled";
this.enableCheckListResetFilter = f.enable_checklist_reset_filter === false ? false : true;
this.isCustom = null;
this.opts = null;
this.optsTxt = null;
this.tf = tf;
}
},
optionClick: {
writable: true,
value: function (evt) {
this.setCheckListValues(evt.target);
this.onChange(evt);
}
},
build: {
writable: true,
value: function (colIndex, isExternal, extFltId) {
var tf = this.tf;
tf.EvtManager(tf.Evt.name.checklist, { slcIndex: colIndex, slcExternal: isExternal, slcId: extFltId });
}
},
_build: {
writable: true,
value: function (colIndex, isExternal, extFltId) {
var _this = this;
if (extFltId === undefined) extFltId = null;
if (isExternal === undefined) isExternal = false;
var tf = this.tf;
colIndex = parseInt(colIndex, 10);
this.opts = [];
this.optsTxt = [];
_prototypeProperties(CheckList, null, {
onChange: {
var divFltId = tf.prfxCheckListDiv + colIndex + "_" + tf.id;
if ((!Dom.id(divFltId) && !isExternal) || (!Dom.id(extFltId) && isExternal)) {
return;
}
// TODO: add _OnSlcChange event here
var flt = !isExternal ? this.checkListDiv[colIndex] : Dom.id(extFltId);
var ul = Dom.create("ul", ["id", tf.fltIds[colIndex]], ["colIndex", colIndex]);
ul.className = this.checkListCssClass;
Event.add(ul, "change", function (evt) {
_this.onChange(evt);
});
value: function onChange(evt) {
this.tf.Evt._OnSlcChange(evt);
},
writable: true,
configurable: true
},
optionClick: {
value: function optionClick(evt) {
this.setCheckListValues(evt.target);
this.onChange(evt);
},
writable: true,
configurable: true
},
build: {
var rows = tf.tbl.rows;
this.isCustom = (tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex));
/**
* Build checklist UI asynchronously
* @param {Number} colIndex Column index
* @param {Boolean} isExternal Render in external container
* @param {String} extFltId External container id
*/
var activeFlt;
if (tf.refreshFilters && tf.activeFilterId) {
activeFlt = tf.activeFilterId.split("_")[0];
activeFlt = activeFlt.split(tf.prfxFlt)[1];
}
value: function build(colIndex, isExternal, extFltId) {
var tf = this.tf;
tf.EvtManager(tf.Evt.name.checklist, { slcIndex: colIndex, slcExternal: isExternal, slcId: extFltId });
},
writable: true,
configurable: true
},
_build: {
var excludedOpts, filteredDataCol = [];
if (tf.refreshFilters && tf.disableExcludedOptions) {
excludedOpts = [];
}
/**
* Build checklist UI
* @param {Number} colIndex Column index
* @param {Boolean} isExternal Render in external container
* @param {String} extFltId External container id
*/
for (var k = tf.refRow; k < tf.nbRows; k++) {
// always visible rows don't need to appear on selects as always
// valid
if (tf.hasVisibleRows && array.has(tf.visibleRows, k) && !tf.paging) {
continue;
value: function _build(colIndex) {
var _this = this;
var isExternal = arguments[1] === undefined ? false : arguments[1];
var extFltId = arguments[2] === undefined ? null : arguments[2];
var tf = this.tf;
colIndex = parseInt(colIndex, 10);
this.opts = [];
this.optsTxt = [];
var divFltId = tf.prfxCheckListDiv + colIndex + "_" + tf.id;
if (!Dom.id(divFltId) && !isExternal || !Dom.id(extFltId) && isExternal) {
return;
}
var flt = !isExternal ? this.checkListDiv[colIndex] : Dom.id(extFltId);
var ul = Dom.create("ul", ["id", tf.fltIds[colIndex]], ["colIndex", colIndex]);
ul.className = this.checkListCssClass;
Event.add(ul, "change", function (evt) {
_this.onChange(evt);
});
var rows = tf.tbl.rows;
this.isCustom = tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex);
var activeFlt;
if (tf.refreshFilters && tf.activeFilterId) {
activeFlt = tf.activeFilterId.split("_")[0];
activeFlt = activeFlt.split(tf.prfxFlt)[1];
}
var excludedOpts,
filteredDataCol = [];
if (tf.refreshFilters && tf.disableExcludedOptions) {
excludedOpts = [];
}
for (var k = tf.refRow; k < tf.nbRows; k++) {
// always visible rows don't need to appear on selects as always
// valid
if (tf.hasVisibleRows && array.has(tf.visibleRows, k) && !tf.paging) {
continue;
}
var cells = rows[k].cells;
var ncells = cells.length;
// checks if row has exact cell #
if (ncells !== tf.nbCells || this.isCustom) {
continue;
}
// this loop retrieves cell data
for (var j = 0; j < ncells; j++) {
if (colIndex === j && (!tf.refreshFilters || tf.refreshFilters && tf.disableExcludedOptions) || colIndex === j && tf.refreshFilters && (rows[k].style.display === "" && !tf.paging || tf.paging && (!activeFlt || activeFlt === colIndex || activeFlt != colIndex && array.has(tf.validRowsIndex, k)))) {
var cell_data = tf.getCellData(j, cells[j]);
//Vary Peter's patch
var cell_string = Str.matchCase(cell_data, tf.matchCase);
// checks if celldata is already in array
if (!array.has(this.opts, cell_string, tf.matchCase)) {
this.opts.push(cell_data);
}
var filteredCol = filteredDataCol[j];
if (tf.refreshFilters && tf.disableExcludedOptions) {
if (!filteredCol) {
filteredDataCol[j] = tf.GetFilteredDataCol(j);
}
if (!array.has(filteredCol, cell_string, tf.matchCase) && !array.has(excludedOpts, cell_string, tf.matchCase) && !tf.isFirstLoad) {
excludedOpts.push(cell_data);
}
}
}
}
}
//Retrieves custom values
if (this.isCustom) {
var customValues = tf.__getCustomValues(colIndex);
this.opts = customValues[0];
this.optsTxt = customValues[1];
}
if (tf.sortSlc && !this.isCustom) {
if (!tf.matchCase) {
this.opts.sort(Sort.ignoreCase);
if (excludedOpts) {
excludedOpts.sort(Sort.ignoreCase);
}
} else {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
}
}
//asc sort
if (tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)) {
try {
this.opts.sort(numSortAsc);
if (excludedOpts) {
excludedOpts.sort(numSortAsc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortAsc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
//desc sort
if (tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)) {
try {
this.opts.sort(numSortDesc);
if (excludedOpts) {
excludedOpts.sort(numSortDesc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortDesc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
this.addChecks(colIndex, ul, tf.separator);
if (tf.fillSlcOnDemand) {
flt.innerHTML = "";
}
flt.appendChild(ul);
flt.setAttribute("filled", "1");
},
writable: true,
configurable: true
},
addChecks: {
/**
* Add checklist options
* @param {Number} colIndex Column index
* @param {Object} ul Ul element
* @param {String} separator Data separator
*/
value: function addChecks(colIndex, ul, separator) {
var _this = this;
var tf = this.tf;
var chkCt = this.addTChecks(colIndex, ul);
var flts_values = [],
fltArr = []; //remember grid values
var store = tf.Cpt.store;
var tmpVal = store ? store.getFilterValues(tf.fltsValuesCookie)[colIndex] : null;
if (tmpVal && Str.trim(tmpVal).length > 0) {
if (tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex)) {
fltArr.push(tmpVal);
} else {
fltArr = tmpVal.split(" " + tf.orOperator + " ");
}
}
for (var y = 0; y < this.opts.length; y++) {
var val = this.opts[y]; //item value
var lbl = this.isCustom ? this.optsTxt[y] : val; //item text
var li = Dom.createCheckItem(tf.fltIds[colIndex] + "_" + (y + chkCt), val, lbl);
li.className = this.checkListItemCssClass;
if (tf.refreshFilters && tf.disableExcludedOptions && array.has(excludedOpts, Str.matchCase(val, tf.matchCase), tf.matchCase)) {
Dom.addClass(li, this.checkListItemDisabledCssClass);
li.check.disabled = true;
li.disabled = true;
} else {
Event.add(li.check, "click", function (evt) {
_this.optionClick(evt);
});
}
ul.appendChild(li);
if (val === "") {
//item is hidden
li.style.display = "none";
}
/*** remember grid values ***/
if (tf.rememberGridValues) {
if (tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex) && fltArr.toString().indexOf(val) != -1 || array.has(fltArr, Str.matchCase(val, tf.matchCase), tf.matchCase)) {
li.check.checked = true;
this.setCheckListValues(li.check);
}
}
}
},
writable: true,
configurable: true
},
addTChecks: {
/**
* Add checklist header option
* @param {Number} colIndex Column index
* @param {Object} ul Ul element
*/
value: function addTChecks(colIndex, ul) {
var _this = this;
var tf = this.tf;
var chkCt = 1;
var li0 = Dom.createCheckItem(tf.fltIds[colIndex] + "_0", "", tf.displayAllText);
li0.className = this.checkListItemCssClass;
ul.appendChild(li0);
Event.add(li0.check, "click", function (evt) {
_this.optionClick(evt);
});
if (!this.enableCheckListResetFilter) {
li0.style.display = "none";
}
if (tf.enableEmptyOption) {
var li1 = Dom.createCheckItem(tf.fltIds[colIndex] + "_1", tf.emOperator, tf.emptyText);
li1.className = this.checkListItemCssClass;
ul.appendChild(li1);
Event.add(li1.check, "click", function (evt) {
_this.optionClick(evt);
});
chkCt++;
}
if (tf.enableNonEmptyOption) {
var li2 = Dom.createCheckItem(tf.fltIds[colIndex] + "_2", tf.nmOperator, tf.nonEmptyText);
li2.className = this.checkListItemCssClass;
ul.appendChild(li2);
Event.add(li2.check, "click", function (evt) {
_this.optionClick(evt);
});
chkCt++;
}
return chkCt;
},
writable: true,
configurable: true
},
setCheckListValues: {
/**
* Store checked options in DOM element attribute
* @param {Object} o checklist option DOM element
*/
value: function setCheckListValues(o) {
if (!o) {
return;
}
var tf = this.tf;
var chkValue = o.value; //checked item value
var chkIndex = parseInt(o.id.split("_")[2], 10);
var filterTag = "ul",
itemTag = "li";
var n = o;
//ul tag search
while (Str.lower(n.nodeName) !== filterTag) {
n = n.parentNode;
}
var li = n.childNodes[chkIndex];
var colIndex = n.getAttribute("colIndex");
var fltValue = n.getAttribute("value"); //filter value (ul tag)
var fltIndexes = n.getAttribute("indexes"); //selected items (ul tag)
if (o.checked) {
//show all item
if (chkValue === "") {
if (fltIndexes && fltIndexes !== "") {
//items indexes
var indSplit = fltIndexes.split(tf.separator);
//checked items loop
for (var u = 0; u < indSplit.length; u++) {
//checked item
var cChk = Dom.id(tf.fltIds[colIndex] + "_" + indSplit[u]);
if (cChk) {
cChk.checked = false;
Dom.removeClass(n.childNodes[indSplit[u]], this.checkListSlcItemCssClass);
}
}
}
n.setAttribute("value", "");
n.setAttribute("indexes", "");
} else {
fltValue = fltValue ? fltValue : "";
chkValue = Str.trim(fltValue + " " + chkValue + " " + tf.orOperator);
chkIndex = fltIndexes + chkIndex + tf.separator;
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 (Str.lower(li.nodeName) === itemTag) {
Dom.removeClass(n.childNodes[0], this.checkListSlcItemCssClass);
Dom.addClass(li, this.checkListSlcItemCssClass);
}
} else {
//removes values and indexes
if (chkValue !== "") {
var replaceValue = new RegExp(Str.rgxEsc(chkValue + " " + tf.orOperator));
fltValue = fltValue.replace(replaceValue, "");
n.setAttribute("value", Str.trim(fltValue));
var replaceIndex = new RegExp(Str.rgxEsc(chkIndex + tf.separator));
fltIndexes = fltIndexes.replace(replaceIndex, "");
n.setAttribute("indexes", fltIndexes);
}
if (Str.lower(li.nodeName) === itemTag) {
Dom.removeClass(li, this.checkListSlcItemCssClass);
}
}
},
writable: true,
configurable: true
}
});
var cells = rows[k].cells;
var ncells = cells.length;
return CheckList;
})();
// checks if row has exact cell #
if (ncells !== tf.nbCells || this.isCustom) {
continue;
}
// this loop retrieves cell data
for (var j = 0; j < ncells; j++) {
if ((colIndex === j && (!tf.refreshFilters || (tf.refreshFilters && tf.disableExcludedOptions))) || (colIndex === j && tf.refreshFilters && ((rows[k].style.display === "" && !tf.paging) || (tf.paging && ((!activeFlt || activeFlt === colIndex) || (activeFlt != colIndex && array.has(tf.validRowsIndex, k))))))) {
var cell_data = tf.getCellData(j, cells[j]);
//Vary Peter's patch
var cell_string = Str.matchCase(cell_data, tf.matchCase);
// checks if celldata is already in array
if (!array.has(this.opts, cell_string, tf.matchCase)) {
this.opts.push(cell_data);
}
var filteredCol = filteredDataCol[j];
if (tf.refreshFilters && tf.disableExcludedOptions) {
if (!filteredCol) {
filteredDataCol[j] = tf.GetFilteredDataCol(j);
}
if (!array.has(filteredCol, cell_string, tf.matchCase) && !array.has(excludedOpts, cell_string, tf.matchCase) && !tf.isFirstLoad) {
excludedOpts.push(cell_data);
}
}
}
}
}
//Retrieves custom values
if (this.isCustom) {
var customValues = tf.__getCustomValues(colIndex);
this.opts = customValues[0];
this.optsTxt = customValues[1];
}
if (tf.sortSlc && !this.isCustom) {
if (!tf.matchCase) {
this.opts.sort(Sort.ignoreCase);
if (excludedOpts) {
excludedOpts.sort(Sort.ignoreCase);
}
} else {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
}
}
//asc sort
if (tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)) {
try {
this.opts.sort(numSortAsc);
if (excludedOpts) {
excludedOpts.sort(numSortAsc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortAsc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
//desc sort
if (tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)) {
try {
this.opts.sort(numSortDesc);
if (excludedOpts) {
excludedOpts.sort(numSortDesc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortDesc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
this.addChecks(colIndex, ul, tf.separator);
if (tf.fillSlcOnDemand) {
flt.innerHTML = "";
}
flt.appendChild(ul);
flt.setAttribute("filled", "1");
}
},
addChecks: {
writable: true,
value: function (colIndex, ul, separator) {
var _this2 = this;
var tf = this.tf;
var chkCt = this.addTChecks(colIndex, ul);
var flts_values = [], fltArr = []; //remember grid values
var store = tf.Cpt.store;
var tmpVal = store ? store.getFilterValues(tf.fltsValuesCookie)[colIndex] : null;
if (tmpVal && Str.trim(tmpVal).length > 0) {
if (tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex)) {
fltArr.push(tmpVal);
} else {
fltArr = tmpVal.split(" " + tf.orOperator + " ");
}
}
for (var y = 0; y < this.opts.length; y++) {
var val = this.opts[y]; //item value
var lbl = this.isCustom ? this.optsTxt[y] : val; //item text
var li = Dom.createCheckItem(tf.fltIds[colIndex] + "_" + (y + chkCt), val, lbl);
li.className = this.checkListItemCssClass;
if (tf.refreshFilters && tf.disableExcludedOptions && array.has(excludedOpts, Str.matchCase(val, tf.matchCase), tf.matchCase)) {
Dom.addClass(li, this.checkListItemDisabledCssClass);
li.check.disabled = true;
li.disabled = true;
} else {
Event.add(li.check, "click", function (evt) {
_this2.optionClick(evt);
});
}
ul.appendChild(li);
if (val === "") {
//item is hidden
li.style.display = "none";
}
/*** remember grid values ***/
if (tf.rememberGridValues) {
if ((tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex) && fltArr.toString().indexOf(val) != -1) || array.has(fltArr, Str.matchCase(val, tf.matchCase), tf.matchCase)) {
li.check.checked = true;
this.setCheckListValues(li.check);
}
}
}
}
},
addTChecks: {
writable: true,
value: function (colIndex, ul) {
var _this3 = this;
var tf = this.tf;
var chkCt = 1;
var li0 = Dom.createCheckItem(tf.fltIds[colIndex] + "_0", "", tf.displayAllText);
li0.className = this.checkListItemCssClass;
ul.appendChild(li0);
Event.add(li0.check, "click", function (evt) {
_this3.optionClick(evt);
});
if (!this.enableCheckListResetFilter) {
li0.style.display = "none";
}
if (tf.enableEmptyOption) {
var li1 = Dom.createCheckItem(tf.fltIds[colIndex] + "_1", tf.emOperator, tf.emptyText);
li1.className = this.checkListItemCssClass;
ul.appendChild(li1);
Event.add(li1.check, "click", function (evt) {
_this3.optionClick(evt);
});
chkCt++;
}
if (tf.enableNonEmptyOption) {
var li2 = Dom.createCheckItem(tf.fltIds[colIndex] + "_2", tf.nmOperator, tf.nonEmptyText);
li2.className = this.checkListItemCssClass;
ul.appendChild(li2);
Event.add(li2.check, "click", function (evt) {
_this3.optionClick(evt);
});
chkCt++;
}
return chkCt;
}
},
setCheckListValues: {
writable: true,
value: function (o) {
if (!o) {
return;
}
var tf = this.tf;
var chkValue = o.value; //checked item value
var chkIndex = parseInt(o.id.split("_")[2], 10);
var filterTag = "ul", itemTag = "li";
var n = o;
//ul tag search
while (Str.lower(n.nodeName) !== filterTag) {
n = n.parentNode;
}
var li = n.childNodes[chkIndex];
var colIndex = n.getAttribute("colIndex");
var fltValue = n.getAttribute("value"); //filter value (ul tag)
var fltIndexes = n.getAttribute("indexes"); //selected items (ul tag)
if (o.checked) {
//show all item
if (chkValue === "") {
if ((fltIndexes && fltIndexes !== "")) {
//items indexes
var indSplit = fltIndexes.split(tf.separator);
//checked items loop
for (var u = 0; u < indSplit.length; u++) {
//checked item
var cChk = Dom.id(tf.fltIds[colIndex] + "_" + indSplit[u]);
if (cChk) {
cChk.checked = false;
Dom.removeClass(n.childNodes[indSplit[u]], this.checkListSlcItemCssClass);
}
}
}
n.setAttribute("value", "");
n.setAttribute("indexes", "");
} else {
fltValue = (fltValue) ? fltValue : "";
chkValue = Str.trim(fltValue + " " + chkValue + " " + tf.orOperator);
chkIndex = fltIndexes + chkIndex + tf.separator;
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 (Str.lower(li.nodeName) === itemTag) {
Dom.removeClass(n.childNodes[0], this.checkListSlcItemCssClass);
Dom.addClass(li, this.checkListSlcItemCssClass);
}
} else {
//removes values and indexes
if (chkValue !== "") {
var replaceValue = new RegExp(Str.rgxEsc(chkValue + " " + tf.orOperator));
fltValue = fltValue.replace(replaceValue, "");
n.setAttribute("value", Str.trim(fltValue));
var replaceIndex = new RegExp(Str.rgxEsc(chkIndex + tf.separator));
fltIndexes = fltIndexes.replace(replaceIndex, "");
n.setAttribute("indexes", fltIndexes);
}
if (Str.lower(li.nodeName) === itemTag) {
Dom.removeClass(li, this.checkListSlcItemCssClass);
}
}
}
}
Object.defineProperty(exports, "__esModule", {
value: true
});
return CheckList;
})();
exports.CheckList = CheckList;
});
});
//# sourceMappingURL=checkList.js.map

View file

@ -1,98 +1,123 @@
define(["exports", "../dom", "../event"], function (exports, _dom, _event) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Event = _event.Event;
var ClearButton = (function () {
var ClearButton = function ClearButton(tf) {
// Configuration object
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
//id of container element
this.btnResetTgtId = f.btn_reset_target_id || null;
//reset button element
this.btnResetEl = null;
//defines reset text
this.btnResetText = f.btn_reset_text || "Reset";
//defines reset button tooltip
this.btnResetTooltip = f.btn_reset_tooltip || "Clear filters";
//defines reset button innerHtml
this.btnResetHtml = f.btn_reset_html || (!tf.enableIcons ? null : "<input type=\"button\" value=\"\" class=\"" + tf.btnResetCssClass + "\" " + "title=\"" + this.btnResetTooltip + "\" />");
var Dom = _dom.Dom;
var Event = _event.Event;
this.tf = tf;
};
var ClearButton = exports.ClearButton = (function () {
_classProps(ClearButton, null, {
onClick: {
writable: true,
value: function () {
this.tf.clearFilters();
/**
* Clear button component
* @param {Object} tf TableFilter instance
*/
function ClearButton(tf) {
_classCallCheck(this, ClearButton);
// Configuration object
var f = tf.config();
//id of container element
this.btnResetTgtId = f.btn_reset_target_id || null;
//reset button element
this.btnResetEl = null;
//defines reset text
this.btnResetText = f.btn_reset_text || "Reset";
//defines reset button tooltip
this.btnResetTooltip = f.btn_reset_tooltip || "Clear filters";
//defines reset button innerHtml
this.btnResetHtml = f.btn_reset_html || (!tf.enableIcons ? null : "<input type=\"button\" value=\"\" class=\"" + tf.btnResetCssClass + "\" " + "title=\"" + this.btnResetTooltip + "\" />");
this.tf = tf;
}
},
init: {
writable: true,
value: function () {
var _this = this;
var tf = this.tf;
if (!tf.hasGrid() && !tf.isFirstLoad && tf.btnResetEl) {
return;
}
_prototypeProperties(ClearButton, null, {
onClick: {
value: function onClick() {
this.tf.clearFilters();
},
writable: true,
configurable: true
},
init: {
var resetspan = Dom.create("span", ["id", tf.prfxResetSpan + tf.id]);
/**
* Build DOM elements
*/
// reset button is added to defined element
if (!this.btnResetTgtId) {
tf.setToolbar();
}
var targetEl = !this.btnResetTgtId ? tf.rDiv : Dom.id(this.btnResetTgtId);
targetEl.appendChild(resetspan);
value: function init() {
var _this = this;
if (!this.btnResetHtml) {
var fltreset = Dom.create("a", ["href", "javascript:void(0);"]);
fltreset.className = tf.btnResetCssClass;
fltreset.appendChild(Dom.text(this.btnResetText));
resetspan.appendChild(fltreset);
// fltreset.onclick = this.Evt._Clear;
Event.add(fltreset, "click", function () {
_this.onClick();
});
} else {
resetspan.innerHTML = this.btnResetHtml;
var resetEl = resetspan.firstChild;
// resetEl.onclick = this.Evt._Clear;
Event.add(resetEl, "click", function () {
_this.onClick();
});
}
this.btnResetEl = resetspan.firstChild;
}
},
destroy: {
writable: true,
value: function () {
var tf = this.tf;
var tf = this.tf;
if (!tf.hasGrid() || !this.btnResetEl) {
return;
}
if (!tf.hasGrid() && !tf.isFirstLoad && tf.btnResetEl) {
return;
}
var resetspan = Dom.id(tf.prfxResetSpan + tf.id);
if (resetspan) {
resetspan.parentNode.removeChild(resetspan);
}
this.btnResetEl = null;
}
}
var resetspan = Dom.create("span", ["id", tf.prfxResetSpan + tf.id]);
// reset button is added to defined element
if (!this.btnResetTgtId) {
tf.setToolbar();
}
var targetEl = !this.btnResetTgtId ? tf.rDiv : Dom.id(this.btnResetTgtId);
targetEl.appendChild(resetspan);
if (!this.btnResetHtml) {
var fltreset = Dom.create("a", ["href", "javascript:void(0);"]);
fltreset.className = tf.btnResetCssClass;
fltreset.appendChild(Dom.text(this.btnResetText));
resetspan.appendChild(fltreset);
// fltreset.onclick = this.Evt._Clear;
Event.add(fltreset, "click", function () {
_this.onClick();
});
} else {
resetspan.innerHTML = this.btnResetHtml;
var resetEl = resetspan.firstChild;
// resetEl.onclick = this.Evt._Clear;
Event.add(resetEl, "click", function () {
_this.onClick();
});
}
this.btnResetEl = resetspan.firstChild;
},
writable: true,
configurable: true
},
destroy: {
/**
* Remove clear button UI
*/
value: function destroy() {
var tf = this.tf;
if (!tf.hasGrid() || !this.btnResetEl) {
return;
}
var resetspan = Dom.id(tf.prfxResetSpan + tf.id);
if (resetspan) {
resetspan.parentNode.removeChild(resetspan);
}
this.btnResetEl = null;
},
writable: true,
configurable: true
}
});
return ClearButton;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return ClearButton;
})();
exports.ClearButton = ClearButton;
});
});
//# sourceMappingURL=clearButton.js.map

View file

@ -1,255 +1,316 @@
define(["exports", "../dom", "../string", "../types"], function (exports, _dom, _string, _types) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Str = _string.Str;
var Types = _types.Types;
var ColOps = (function () {
var ColOps = function ColOps(tf) {
var f = tf.config();
this.colOperation = f.col_operation;
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
//calls function before col operation
this.onBeforeOperation = Types.isFn(f.on_before_operation) ? f.on_before_operation : null;
//calls function after col operation
this.onAfterOperation = Types.isFn(f.on_after_operation) ? f.on_after_operation : null;
var Dom = _dom.Dom;
var Str = _string.Str;
var Types = _types.Types;
this.tf = tf;
};
var ColOps = exports.ColOps = (function () {
_classProps(ColOps, null, {
calc: {
writable: true,
value: function () {
if (!this.tf.isFirstLoad && !this.tf.hasGrid()) {
return;
}
/**
* Column calculations
* @param {Object} tf TableFilter instance
*/
if (this.onBeforeOperation) {
this.onBeforeOperation.call(null, this.tf);
}
function ColOps(tf) {
_classCallCheck(this, ColOps);
var colOperation = this.colOperation, labelId = colOperation.id, colIndex = colOperation.col, operation = colOperation.operation, outputType = colOperation.write_method, totRowIndex = colOperation.tot_row_index, excludeRow = colOperation.exclude_row, decimalPrecision = colOperation.decimal_precision !== undefined ? colOperation.decimal_precision : 2;
var f = tf.config();
this.colOperation = f.col_operation;
//nuovella: determine unique list of columns to operate on
var ucolIndex = [], ucolMax = 0;
ucolIndex[ucolMax] = colIndex[0];
//calls function before col operation
this.onBeforeOperation = Types.isFn(f.on_before_operation) ? f.on_before_operation : null;
//calls function after col operation
this.onAfterOperation = Types.isFn(f.on_after_operation) ? f.on_after_operation : null;
for (var ii = 1; ii < colIndex.length; ii++) {
var saved = 0;
//see if colIndex[ii] is already in the list of unique indexes
for (var jj = 0; jj <= ucolMax; jj++) {
if (ucolIndex[jj] === colIndex[ii]) {
saved = 1;
}
}
//if not saved then, save the index;
if (saved === 0) {
ucolMax++;
ucolIndex[ucolMax] = colIndex[ii];
}
}
if (Str.lower(typeof labelId) == "object" && Str.lower(typeof colIndex) == "object" && Str.lower(typeof operation) == "object") {
var row = this.tf.tbl.rows, colvalues = [];
for (var ucol = 0; ucol <= ucolMax; ucol++) {
//this retrieves col values
//use ucolIndex because we only want to pass through this loop
//once for each column get the values in this unique column
colvalues.push(this.tf.getColValues(ucolIndex[ucol], true, excludeRow));
//next: calculate all operations for this column
var result, nbvalues = 0, temp, meanValue = 0, sumValue = 0, minValue = null, maxValue = null, q1Value = null, medValue = null, q3Value = null, meanFlag = 0, sumFlag = 0, minFlag = 0, maxFlag = 0, q1Flag = 0, medFlag = 0, q3Flag = 0, theList = [], opsThisCol = [], decThisCol = [], labThisCol = [], oTypeThisCol = [], mThisCol = -1;
for (var k = 0; k < colIndex.length; k++) {
if (colIndex[k] === ucolIndex[ucol]) {
mThisCol++;
opsThisCol[mThisCol] = Str.lower(operation[k]);
decThisCol[mThisCol] = decimalPrecision[k];
labThisCol[mThisCol] = labelId[k];
oTypeThisCol = outputType !== undefined && Str.lower(typeof outputType) === "object" ? outputType[k] : null;
switch (opsThisCol[mThisCol]) {
case "mean":
meanFlag = 1;
break;
case "sum":
sumFlag = 1;
break;
case "min":
minFlag = 1;
break;
case "max":
maxFlag = 1;
break;
case "median":
medFlag = 1;
break;
case "q1":
q1Flag = 1;
break;
case "q3":
q3Flag = 1;
break;
}
}
}
for (var j = 0; j < colvalues[ucol].length; j++) {
//sort the list for calculation of median and quartiles
if ((q1Flag == 1) || (q3Flag == 1) || (medFlag == 1)) {
if (j < colvalues[ucol].length - 1) {
for (k = j + 1; k < colvalues[ucol].length; k++) {
if (eval(colvalues[ucol][k]) < eval(colvalues[ucol][j])) {
temp = colvalues[ucol][j];
colvalues[ucol][j] = colvalues[ucol][k];
colvalues[ucol][k] = temp;
}
}
}
}
var cvalue = parseFloat(colvalues[ucol][j]);
theList[j] = parseFloat(cvalue);
if (!isNaN(cvalue)) {
nbvalues++;
if (sumFlag === 1 || meanFlag === 1) {
sumValue += parseFloat(cvalue);
}
if (minFlag === 1) {
if (minValue === null) {
minValue = parseFloat(cvalue);
} else {
minValue = parseFloat(cvalue) < minValue ? parseFloat(cvalue) : minValue;
}
}
if (maxFlag === 1) {
if (maxValue === null) {
maxValue = parseFloat(cvalue);
} else {
maxValue = parseFloat(cvalue) > maxValue ? parseFloat(cvalue) : maxValue;
}
}
}
} //for j
if (meanFlag === 1) {
meanValue = sumValue / nbvalues;
}
if (medFlag === 1) {
var aux = 0;
if (nbvalues % 2 === 1) {
aux = Math.floor(nbvalues / 2);
medValue = theList[aux];
} else {
medValue = (theList[nbvalues / 2] + theList[((nbvalues / 2) - 1)]) / 2;
}
}
var posa;
if (q1Flag === 1) {
posa = 0;
posa = Math.floor(nbvalues / 4);
if (4 * posa == nbvalues) {
q1Value = (theList[posa - 1] + theList[posa]) / 2;
} else {
q1Value = theList[posa];
}
}
if (q3Flag === 1) {
posa = 0;
var posb = 0;
posa = Math.floor(nbvalues / 4);
if (4 * posa === nbvalues) {
posb = 3 * posa;
q3Value = (theList[posb] + theList[posb - 1]) / 2;
} else {
q3Value = theList[nbvalues - posa - 1];
}
}
for (var i = 0; i <= mThisCol; i++) {
switch (opsThisCol[i]) {
case "mean":
result = meanValue;
break;
case "sum":
result = sumValue;
break;
case "min":
result = minValue;
break;
case "max":
result = maxValue;
break;
case "median":
result = medValue;
break;
case "q1":
result = q1Value;
break;
case "q3":
result = q3Value;
break;
}
var precision = !isNaN(decThisCol[i]) ? decThisCol[i] : 2;
//if outputType is defined
if (oTypeThisCol && result) {
result = result.toFixed(precision);
if (Dom.id(labThisCol[i])) {
switch (Str.lower(oTypeThisCol)) {
case "innerhtml":
if (isNaN(result) || !isFinite(result) || nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = ".";
} else {
Dom.id(labThisCol[i]).innerHTML = result;
}
break;
case "setvalue":
Dom.id(labThisCol[i]).value = result;
break;
case "createtextnode":
var oldnode = Dom.id(labThisCol[i]).firstChild;
var txtnode = Dom.text(result);
Dom.id(labThisCol[i]).replaceChild(txtnode, oldnode);
break;
} //switch
}
} else {
try {
if (isNaN(result) || !isFinite(result) || nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = ".";
} else {
Dom.id(labThisCol[i]).innerHTML = result.toFixed(precision);
}
} catch (e) {} //catch
} //else
} //for i
// row(s) with result are always visible
var totRow = totRowIndex && totRowIndex[ucol] ? row[totRowIndex[ucol]] : null;
if (totRow) {
totRow.style.display = "";
}
} //for ucol
} //if typeof
if (this.onAfterOperation) {
this.onAfterOperation.call(null, this.tf);
}
this.tf = tf;
}
}
_prototypeProperties(ColOps, null, {
calc: {
/**
* Calculates columns' values
* Configuration options are stored in 'colOperation' property
* - 'id' contains ids of elements showing result (array)
* - 'col' contains the columns' indexes (array)
* - 'operation' contains operation type (array, values: 'sum', 'mean',
* 'min', 'max', 'median', 'q1', 'q3')
* - 'write_method' array defines which method to use for displaying the
* result (innerHTML, setValue, createTextNode) - default: 'innerHTML'
* - 'tot_row_index' defines in which row results are displayed
* (integers array)
*
* - changes made by Nuovella:
* (1) optimized the routine (now it will only process each column once),
* (2) added calculations for the median, lower and upper quartile.
*/
value: function calc() {
if (!this.tf.isFirstLoad && !this.tf.hasGrid()) {
return;
}
if (this.onBeforeOperation) {
this.onBeforeOperation.call(null, this.tf);
}
var colOperation = this.colOperation,
labelId = colOperation.id,
colIndex = colOperation.col,
operation = colOperation.operation,
outputType = colOperation.write_method,
totRowIndex = colOperation.tot_row_index,
excludeRow = colOperation.exclude_row,
decimalPrecision = colOperation.decimal_precision !== undefined ? colOperation.decimal_precision : 2;
//nuovella: determine unique list of columns to operate on
var ucolIndex = [],
ucolMax = 0;
ucolIndex[ucolMax] = colIndex[0];
for (var ii = 1; ii < colIndex.length; ii++) {
var saved = 0;
//see if colIndex[ii] is already in the list of unique indexes
for (var jj = 0; jj <= ucolMax; jj++) {
if (ucolIndex[jj] === colIndex[ii]) {
saved = 1;
}
}
//if not saved then, save the index;
if (saved === 0) {
ucolMax++;
ucolIndex[ucolMax] = colIndex[ii];
}
}
if (Str.lower(typeof labelId) == "object" && Str.lower(typeof colIndex) == "object" && Str.lower(typeof operation) == "object") {
var row = this.tf.tbl.rows,
colvalues = [];
for (var ucol = 0; ucol <= ucolMax; ucol++) {
//this retrieves col values
//use ucolIndex because we only want to pass through this loop
//once for each column get the values in this unique column
colvalues.push(this.tf.getColValues(ucolIndex[ucol], true, excludeRow));
//next: calculate all operations for this column
var result,
nbvalues = 0,
temp,
meanValue = 0,
sumValue = 0,
minValue = null,
maxValue = null,
q1Value = null,
medValue = null,
q3Value = null,
meanFlag = 0,
sumFlag = 0,
minFlag = 0,
maxFlag = 0,
q1Flag = 0,
medFlag = 0,
q3Flag = 0,
theList = [],
opsThisCol = [],
decThisCol = [],
labThisCol = [],
oTypeThisCol = [],
mThisCol = -1;
for (var k = 0; k < colIndex.length; k++) {
if (colIndex[k] === ucolIndex[ucol]) {
mThisCol++;
opsThisCol[mThisCol] = Str.lower(operation[k]);
decThisCol[mThisCol] = decimalPrecision[k];
labThisCol[mThisCol] = labelId[k];
oTypeThisCol = outputType !== undefined && Str.lower(typeof outputType) === "object" ? outputType[k] : null;
switch (opsThisCol[mThisCol]) {
case "mean":
meanFlag = 1;
break;
case "sum":
sumFlag = 1;
break;
case "min":
minFlag = 1;
break;
case "max":
maxFlag = 1;
break;
case "median":
medFlag = 1;
break;
case "q1":
q1Flag = 1;
break;
case "q3":
q3Flag = 1;
break;
}
}
}
for (var j = 0; j < colvalues[ucol].length; j++) {
//sort the list for calculation of median and quartiles
if (q1Flag == 1 || q3Flag == 1 || medFlag == 1) {
if (j < colvalues[ucol].length - 1) {
for (k = j + 1; k < colvalues[ucol].length; k++) {
if (eval(colvalues[ucol][k]) < eval(colvalues[ucol][j])) {
temp = colvalues[ucol][j];
colvalues[ucol][j] = colvalues[ucol][k];
colvalues[ucol][k] = temp;
}
}
}
}
var cvalue = parseFloat(colvalues[ucol][j]);
theList[j] = parseFloat(cvalue);
if (!isNaN(cvalue)) {
nbvalues++;
if (sumFlag === 1 || meanFlag === 1) {
sumValue += parseFloat(cvalue);
}
if (minFlag === 1) {
if (minValue === null) {
minValue = parseFloat(cvalue);
} else {
minValue = parseFloat(cvalue) < minValue ? parseFloat(cvalue) : minValue;
}
}
if (maxFlag === 1) {
if (maxValue === null) {
maxValue = parseFloat(cvalue);
} else {
maxValue = parseFloat(cvalue) > maxValue ? parseFloat(cvalue) : maxValue;
}
}
}
} //for j
if (meanFlag === 1) {
meanValue = sumValue / nbvalues;
}
if (medFlag === 1) {
var aux = 0;
if (nbvalues % 2 === 1) {
aux = Math.floor(nbvalues / 2);
medValue = theList[aux];
} else {
medValue = (theList[nbvalues / 2] + theList[nbvalues / 2 - 1]) / 2;
}
}
var posa;
if (q1Flag === 1) {
posa = 0;
posa = Math.floor(nbvalues / 4);
if (4 * posa == nbvalues) {
q1Value = (theList[posa - 1] + theList[posa]) / 2;
} else {
q1Value = theList[posa];
}
}
if (q3Flag === 1) {
posa = 0;
var posb = 0;
posa = Math.floor(nbvalues / 4);
if (4 * posa === nbvalues) {
posb = 3 * posa;
q3Value = (theList[posb] + theList[posb - 1]) / 2;
} else {
q3Value = theList[nbvalues - posa - 1];
}
}
for (var i = 0; i <= mThisCol; i++) {
switch (opsThisCol[i]) {
case "mean":
result = meanValue;
break;
case "sum":
result = sumValue;
break;
case "min":
result = minValue;
break;
case "max":
result = maxValue;
break;
case "median":
result = medValue;
break;
case "q1":
result = q1Value;
break;
case "q3":
result = q3Value;
break;
}
var precision = !isNaN(decThisCol[i]) ? decThisCol[i] : 2;
//if outputType is defined
if (oTypeThisCol && result) {
result = result.toFixed(precision);
if (Dom.id(labThisCol[i])) {
switch (Str.lower(oTypeThisCol)) {
case "innerhtml":
if (isNaN(result) || !isFinite(result) || nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = ".";
} else {
Dom.id(labThisCol[i]).innerHTML = result;
}
break;
case "setvalue":
Dom.id(labThisCol[i]).value = result;
break;
case "createtextnode":
var oldnode = Dom.id(labThisCol[i]).firstChild;
var txtnode = Dom.text(result);
Dom.id(labThisCol[i]).replaceChild(txtnode, oldnode);
break;
} //switch
}
} else {
try {
if (isNaN(result) || !isFinite(result) || nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = ".";
} else {
Dom.id(labThisCol[i]).innerHTML = result.toFixed(precision);
}
} catch (e) {} //catch
} //else
} //for i
// row(s) with result are always visible
var totRow = totRowIndex && totRowIndex[ucol] ? row[totRowIndex[ucol]] : null;
if (totRow) {
totRow.style.display = "";
}
} //for ucol
} //if typeof
if (this.onAfterOperation) {
this.onAfterOperation.call(null, this.tf);
}
},
writable: true,
configurable: true
}
});
return ColOps;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return ColOps;
})();
exports.ColOps = ColOps;
});
});
//# sourceMappingURL=colOps.js.map

View file

@ -1,283 +1,344 @@
define(["exports", "../dom", "../array", "../string", "../sort"], function (exports, _dom, _array, _string, _sort) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var array = _array.Arr;
var Str = _string.Str;
var Sort = _sort.Sort;
var Dropdown = (function () {
var Dropdown = function Dropdown(tf) {
// Configuration object
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
this.enableSlcResetFilter = f.enable_slc_reset_filter ? false : true;
//defines empty option text
this.nonEmptyText = f.non_empty_text || "(Non empty)";
//sets select filling method: 'innerHTML' or 'createElement'
this.slcFillingMethod = f.slc_filling_method || "createElement";
//IE only, tooltip text appearing on select before it is populated
this.activateSlcTooltip = f.activate_slc_tooltip || "Click to activate";
//tooltip text appearing on multiple select
this.multipleSlcTooltip = f.multiple_slc_tooltip || "Use Ctrl key for multiple selections";
var Dom = _dom.Dom;
var array = _array.Arr;
var Str = _string.Str;
var Sort = _sort.Sort;
this.isCustom = null;
this.opts = null;
this.optsTxt = null;
this.slcInnerHtml = null;
var Dropdown = exports.Dropdown = (function () {
this.tf = tf;
};
/**
* Dropdown UI component
* @param {Object} tf TableFilter instance
*/
_classProps(Dropdown, null, {
build: {
writable: true,
value: function (colIndex, isRefreshed, isExternal, extSlcId) {
var tf = this.tf;
tf.EvtManager(tf.Evt.name.dropdown, {
slcIndex: colIndex,
slcRefreshed: isRefreshed,
slcExternal: isExternal,
slcId: extSlcId
});
function Dropdown(tf) {
_classCallCheck(this, Dropdown);
// Configuration object
var f = tf.config();
this.enableSlcResetFilter = f.enable_slc_reset_filter ? false : true;
//defines empty option text
this.nonEmptyText = f.non_empty_text || "(Non empty)";
//sets select filling method: 'innerHTML' or 'createElement'
this.slcFillingMethod = f.slc_filling_method || "createElement";
//IE only, tooltip text appearing on select before it is populated
this.activateSlcTooltip = f.activate_slc_tooltip || "Click to activate";
//tooltip text appearing on multiple select
this.multipleSlcTooltip = f.multiple_slc_tooltip || "Use Ctrl key for multiple selections";
this.isCustom = null;
this.opts = null;
this.optsTxt = null;
this.slcInnerHtml = null;
this.tf = tf;
}
},
_build: {
writable: true,
value: function (colIndex, isRefreshed, isExternal, extSlcId) {
if (extSlcId === undefined) extSlcId = null;
if (isExternal === undefined) isExternal = false;
if (isRefreshed === undefined) isRefreshed = false;
var tf = this.tf;
colIndex = parseInt(colIndex, 10);
this.opts = [];
this.optsTxt = [];
this.slcInnerHtml = "";
_prototypeProperties(Dropdown, null, {
build: {
var slcId = tf.fltIds[colIndex];
if ((!Dom.id(slcId) && !isExternal) || (!Dom.id(extSlcId) && isExternal)) {
return;
}
var slc = !isExternal ? Dom.id(slcId) : Dom.id(extSlcId), rows = tf.tbl.rows, matchCase = tf.matchCase, fillMethod = Str.lower(this.slcFillingMethod);
/**
* Build drop-down filter UI asynchronously
* @param {Number} colIndex Column index
* @param {Boolean} isRefreshed Enable linked refresh behaviour
* @param {Boolean} isExternal Render in external container
* @param {String} extSlcId External container id
*/
//custom select test
this.isCustom = (tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex));
value: function build(colIndex, isRefreshed, isExternal, extSlcId) {
var tf = this.tf;
tf.EvtManager(tf.Evt.name.dropdown, {
slcIndex: colIndex,
slcRefreshed: isRefreshed,
slcExternal: isExternal,
slcId: extSlcId
});
},
writable: true,
configurable: true
},
_build: {
//custom selects text
var activeFlt;
if (isRefreshed && tf.activeFilterId) {
activeFlt = tf.activeFilterId.split("_")[0];
activeFlt = activeFlt.split(tf.prfxFlt)[1];
}
/**
* Build drop-down filter UI
* @param {Number} colIndex Column index
* @param {Boolean} isRefreshed Enable linked refresh behaviour
* @param {Boolean} isExternal Render in external container
* @param {String} extSlcId External container id
*/
/*** remember grid values ***/
var fltsValues = [], fltArr = [];
if (tf.rememberGridValues) {
fltsValues = tf.Cpt.store.getFilterValues(tf.fltsValuesCookie);
if (fltsValues && !Str.isEmpty(fltsValues.toString())) {
if (this.isCustom) {
fltArr.push(fltsValues[colIndex]);
} else {
fltArr = fltsValues[colIndex].split(" " + tf.orOperator + " ");
}
value: function _build(colIndex) {
var isRefreshed = arguments[1] === undefined ? false : arguments[1];
var isExternal = arguments[2] === undefined ? false : arguments[2];
var extSlcId = arguments[3] === undefined ? null : arguments[3];
var tf = this.tf;
colIndex = parseInt(colIndex, 10);
this.opts = [];
this.optsTxt = [];
this.slcInnerHtml = "";
var slcId = tf.fltIds[colIndex];
if (!Dom.id(slcId) && !isExternal || !Dom.id(extSlcId) && isExternal) {
return;
}
var slc = !isExternal ? Dom.id(slcId) : Dom.id(extSlcId),
rows = tf.tbl.rows,
matchCase = tf.matchCase,
fillMethod = Str.lower(this.slcFillingMethod);
//custom select test
this.isCustom = tf.hasCustomSlcOptions && array.has(tf.customSlcOptions.cols, colIndex);
//custom selects text
var activeFlt;
if (isRefreshed && tf.activeFilterId) {
activeFlt = tf.activeFilterId.split("_")[0];
activeFlt = activeFlt.split(tf.prfxFlt)[1];
}
/*** remember grid values ***/
var fltsValues = [],
fltArr = [];
if (tf.rememberGridValues) {
fltsValues = tf.Cpt.store.getFilterValues(tf.fltsValuesCookie);
if (fltsValues && !Str.isEmpty(fltsValues.toString())) {
if (this.isCustom) {
fltArr.push(fltsValues[colIndex]);
} else {
fltArr = fltsValues[colIndex].split(" " + tf.orOperator + " ");
}
}
}
var excludedOpts = null,
filteredDataCol = null;
if (isRefreshed && tf.disableExcludedOptions) {
excludedOpts = [];
filteredDataCol = [];
}
for (var k = tf.refRow; k < tf.nbRows; k++) {
// always visible rows don't need to appear on selects as always
// valid
if (tf.hasVisibleRows && array.has(tf.visibleRows, k) && !tf.paging) {
continue;
}
var cell = rows[k].cells,
nchilds = cell.length;
// checks if row has exact cell #
if (nchilds !== tf.nbCells || this.isCustom) {
continue;
}
// this loop retrieves cell data
for (var j = 0; j < nchilds; j++) {
if (colIndex === j && (!isRefreshed || isRefreshed && tf.disableExcludedOptions) || colIndex == j && isRefreshed && (rows[k].style.display === "" && !tf.paging || tf.paging && (!tf.validRowsIndex || tf.validRowsIndex && array.has(tf.validRowsIndex, k)) && (activeFlt === undefined || activeFlt == colIndex || activeFlt != colIndex && array.has(tf.validRowsIndex, k)))) {
var cell_data = tf.getCellData(j, cell[j]),
//Vary Peter's patch
cell_string = Str.matchCase(cell_data, matchCase);
// checks if celldata is already in array
if (!array.has(this.opts, cell_string, matchCase)) {
this.opts.push(cell_data);
}
if (isRefreshed && tf.disableExcludedOptions) {
var filteredCol = filteredDataCol[j];
if (!filteredCol) {
filteredCol = this.GetFilteredDataCol(j);
}
if (!array.has(filteredCol, cell_string, matchCase) && !array.has(excludedOpts, cell_string, matchCase) && !this.isFirstLoad) {
excludedOpts.push(cell_data);
}
}
} //if colIndex==j
} //for j
} //for k
//Retrieves custom values
if (this.isCustom) {
var customValues = tf.__getCustomValues(colIndex);
this.opts = customValues[0];
this.optsTxt = customValues[1];
}
if (tf.sortSlc && !this.isCustom) {
if (!matchCase) {
this.opts.sort(Sort.ignoreCase);
if (excludedOpts) {
excludedOpts.sort(Sort.ignoreCase);
}
} else {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
}
}
//asc sort
if (tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)) {
try {
this.opts.sort(numSortAsc);
if (excludedOpts) {
excludedOpts.sort(numSortAsc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortAsc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
//desc sort
if (tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)) {
try {
this.opts.sort(numSortDesc);
if (excludedOpts) {
excludedOpts.sort(numSortDesc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortDesc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
//populates drop-down
this.addOptions(colIndex, slc, isRefreshed, excludedOpts, fltsValues, fltArr);
},
writable: true,
configurable: true
},
addOptions: {
/**
* Add drop-down options
* @param {Number} colIndex Column index
* @param {Object} slc Select Dom element
* @param {Boolean} isRefreshed Enable linked refresh behaviour
* @param {Array} excludedOpts Array of excluded options
* @param {Array} fltsValues Collection of persisted filter values
* @param {Array} fltArr Collection of persisted filter values
*/
value: function addOptions(colIndex, slc, isRefreshed, excludedOpts, fltsValues, fltArr) {
var tf = this.tf,
fillMethod = Str.lower(this.slcFillingMethod),
slcValue = slc.value;
slc.innerHTML = "";
slc = this.addFirstOption(slc);
for (var y = 0; y < this.opts.length; y++) {
if (this.opts[y] === "") {
continue;
}
var val = this.opts[y]; //option value
var lbl = this.isCustom ? this.optsTxt[y] : val; //option text
var isDisabled = false;
if (isRefreshed && this.disableExcludedOptions && array.has(excludedOpts, Str.matchCase(val, tf.matchCase), tf.matchCase)) {
isDisabled = true;
}
if (fillMethod === "innerhtml") {
var slcAttr = "";
if (tf.fillSlcOnDemand && slcValue === this.opts[y]) {
slcAttr = "selected=\"selected\"";
}
this.slcInnerHtml += "<option value=\"" + val + "\" " + slcAttr + (isDisabled ? "disabled=\"disabled\"" : "") + ">" + lbl + "</option>";
} else {
var opt;
//fill select on demand
if (tf.fillSlcOnDemand && slcValue === this.opts[y] && tf["col" + colIndex] === tf.fltTypeSlc) {
opt = Dom.createOpt(lbl, val, true);
} else {
if (tf["col" + colIndex] !== tf.fltTypeMulti) {
opt = Dom.createOpt(lbl, val, fltsValues[colIndex] !== " " && val === fltsValues[colIndex] ? true : false);
} else {
opt = Dom.createOpt(lbl, val, array.has(fltArr, Str.matchCase(this.opts[y], tf.matchCase), tf.matchCase) || fltArr.toString().indexOf(val) !== -1 ? true : false);
}
}
if (isDisabled) {
opt.disabled = true;
}
slc.appendChild(opt);
}
} // for y
if (fillMethod === "innerhtml") {
slc.innerHTML += this.slcInnerHtml;
}
slc.setAttribute("filled", "1");
},
writable: true,
configurable: true
},
addFirstOption: {
/**
* Add drop-down header option
* @param {Object} slc Select DOM element
*/
value: function addFirstOption(slc) {
var tf = this.tf,
fillMethod = Str.lower(this.slcFillingMethod);
if (fillMethod === "innerhtml") {
this.slcInnerHtml += "<option value=\"\">" + tf.displayAllText + "</option>";
} else {
var opt0 = Dom.createOpt(!this.enableSlcResetFilter ? "" : tf.displayAllText, "");
if (!this.enableSlcResetFilter) {
opt0.style.display = "none";
}
slc.appendChild(opt0);
if (tf.enableEmptyOption) {
var opt1 = Dom.createOpt(tf.emptyText, tf.emOperator);
slc.appendChild(opt1);
}
if (tf.enableNonEmptyOption) {
var opt2 = Dom.createOpt(tf.nonEmptyText, tf.nmOperator);
slc.appendChild(opt2);
}
}
return slc;
},
writable: true,
configurable: true
}
}
});
var excludedOpts = null, filteredDataCol = null;
if (isRefreshed && tf.disableExcludedOptions) {
excludedOpts = [];
filteredDataCol = [];
}
return Dropdown;
})();
for (var k = tf.refRow; k < tf.nbRows; k++) {
// always visible rows don't need to appear on selects as always
// valid
if (tf.hasVisibleRows && array.has(tf.visibleRows, k) && !tf.paging) {
continue;
}
var cell = rows[k].cells, nchilds = cell.length;
// checks if row has exact cell #
if (nchilds !== tf.nbCells || this.isCustom) {
continue;
}
// this loop retrieves cell data
for (var j = 0; j < nchilds; j++) {
if ((colIndex === j && (!isRefreshed || (isRefreshed && tf.disableExcludedOptions))) || (colIndex == j && isRefreshed && ((rows[k].style.display === "" && !tf.paging) || (tf.paging && (!tf.validRowsIndex || (tf.validRowsIndex && array.has(tf.validRowsIndex, k))) && ((activeFlt === undefined || activeFlt == colIndex) || (activeFlt != colIndex && array.has(tf.validRowsIndex, k))))))) {
var cell_data = tf.getCellData(j, cell[j]),
//Vary Peter's patch
cell_string = Str.matchCase(cell_data, matchCase);
// checks if celldata is already in array
if (!array.has(this.opts, cell_string, matchCase)) {
this.opts.push(cell_data);
}
if (isRefreshed && tf.disableExcludedOptions) {
var filteredCol = filteredDataCol[j];
if (!filteredCol) {
filteredCol = this.GetFilteredDataCol(j);
}
if (!array.has(filteredCol, cell_string, matchCase) && !array.has(excludedOpts, cell_string, matchCase) && !this.isFirstLoad) {
excludedOpts.push(cell_data);
}
}
} //if colIndex==j
} //for j
} //for k
//Retrieves custom values
if (this.isCustom) {
var customValues = tf.__getCustomValues(colIndex);
this.opts = customValues[0];
this.optsTxt = customValues[1];
}
if (tf.sortSlc && !this.isCustom) {
if (!matchCase) {
this.opts.sort(Sort.ignoreCase);
if (excludedOpts) {
excludedOpts.sort(Sort.ignoreCase);
}
} else {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
}
}
//asc sort
if (tf.sortNumAsc && array.has(tf.sortNumAsc, colIndex)) {
try {
this.opts.sort(numSortAsc);
if (excludedOpts) {
excludedOpts.sort(numSortAsc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortAsc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
//desc sort
if (tf.sortNumDesc && array.has(tf.sortNumDesc, colIndex)) {
try {
this.opts.sort(numSortDesc);
if (excludedOpts) {
excludedOpts.sort(numSortDesc);
}
if (this.isCustom) {
this.optsTxt.sort(numSortDesc);
}
} catch (e) {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
if (this.isCustom) {
this.optsTxt.sort();
}
} //in case there are alphanumeric values
}
//populates drop-down
this.addOptions(colIndex, slc, isRefreshed, excludedOpts, fltsValues, fltArr);
}
},
addOptions: {
writable: true,
value: function (colIndex, slc, isRefreshed, excludedOpts, fltsValues, fltArr) {
var tf = this.tf, fillMethod = Str.lower(this.slcFillingMethod), slcValue = slc.value;
slc.innerHTML = "";
slc = this.addFirstOption(slc);
for (var y = 0; y < this.opts.length; y++) {
if (this.opts[y] === "") {
continue;
}
var val = this.opts[y]; //option value
var lbl = this.isCustom ? this.optsTxt[y] : val; //option text
var isDisabled = false;
if (isRefreshed && this.disableExcludedOptions && array.has(excludedOpts, Str.matchCase(val, tf.matchCase), tf.matchCase)) {
isDisabled = true;
}
if (fillMethod === "innerhtml") {
var slcAttr = "";
if (tf.fillSlcOnDemand && slcValue === this.opts[y]) {
slcAttr = "selected=\"selected\"";
}
this.slcInnerHtml += "<option value=\"" + val + "\" " + slcAttr + (isDisabled ? "disabled=\"disabled\"" : "") + ">" + lbl + "</option>";
} else {
var opt;
//fill select on demand
if (tf.fillSlcOnDemand && slcValue === this.opts[y] && tf["col" + colIndex] === tf.fltTypeSlc) {
opt = Dom.createOpt(lbl, val, true);
} else {
if (tf["col" + colIndex] !== tf.fltTypeMulti) {
opt = Dom.createOpt(lbl, val, (fltsValues[colIndex] !== " " && val === fltsValues[colIndex]) ? true : false);
} else {
opt = Dom.createOpt(lbl, val, (array.has(fltArr, Str.matchCase(this.opts[y], tf.matchCase), tf.matchCase) || fltArr.toString().indexOf(val) !== -1) ? true : false);
}
}
if (isDisabled) {
opt.disabled = true;
}
slc.appendChild(opt);
}
} // for y
if (fillMethod === "innerhtml") {
slc.innerHTML += this.slcInnerHtml;
}
slc.setAttribute("filled", "1");
}
},
addFirstOption: {
writable: true,
value: function (slc) {
var tf = this.tf, fillMethod = Str.lower(this.slcFillingMethod);
if (fillMethod === "innerhtml") {
this.slcInnerHtml += "<option value=\"\">" + tf.displayAllText + "</option>";
} else {
var opt0 = Dom.createOpt((!this.enableSlcResetFilter ? "" : tf.displayAllText), "");
if (!this.enableSlcResetFilter) {
opt0.style.display = "none";
}
slc.appendChild(opt0);
if (tf.enableEmptyOption) {
var opt1 = Dom.createOpt(tf.emptyText, tf.emOperator);
slc.appendChild(opt1);
}
if (tf.enableNonEmptyOption) {
var opt2 = Dom.createOpt(tf.nonEmptyText, tf.nmOperator);
slc.appendChild(opt2);
}
}
return slc;
}
}
Object.defineProperty(exports, "__esModule", {
value: true
});
return Dropdown;
})();
exports.Dropdown = Dropdown;
});
});
//# sourceMappingURL=dropdown.js.map

View file

@ -1,333 +1,357 @@
define(["exports", "../dom", "../types", "../helpers", "../event"], function (exports, _dom, _types, _helpers, _event) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Types = _types.Types;
var Helpers = _helpers.Helpers;
var Event = _event.Event;
var GridLayout = (function () {
var GridLayout = function GridLayout(tf) {
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
//defines grid width
this.gridWidth = f.grid_width || null;
//defines grid height
this.gridHeight = f.grid_height || null;
//defines css class for main container
this.gridMainContCssClass = f.grid_cont_css_class || "grd_Cont";
//defines css class for div containing table
this.gridContCssClass = f.grid_tbl_cont_css_class || "grd_tblCont";
//defines css class for div containing headers' table
this.gridHeadContCssClass = f.grid_tblHead_cont_css_class || "grd_headTblCont";
//defines css class for div containing rows counter, paging etc.
this.gridInfDivCssClass = f.grid_inf_grid_css_class || "grd_inf";
//defines which row contains column headers
this.gridHeadRowIndex = f.grid_headers_row_index || 0;
//array of headers row indexes to be placed in header table
this.gridHeadRows = f.grid_headers_rows || [0];
//generate filters in table headers
this.gridEnableFilters = f.grid_enable_default_filters !== undefined ? f.grid_enable_default_filters : true;
//default col width
this.gridDefaultColWidth = f.grid_default_col_width || "100px";
//enables/disables columns resizer
this.gridEnableColResizer = f.grid_enable_cols_resizer !== undefined ? f.grid_enable_cols_resizer : false;
//defines col resizer script path
this.gridColResizerPath = f.grid_cont_col_resizer_path || this.basePath + "TFExt_ColsResizer/TFExt_ColsResizer.js";
var Dom = _dom.Dom;
var Types = _types.Types;
var Helpers = _helpers.Helpers;
var Event = _event.Event;
this.gridColElms = [];
var GridLayout = exports.GridLayout = (function () {
this.tf = tf;
};
/**
* Grid layout, table with fixed headers
* @param {Object} tf TableFilter instance
*/
_classProps(GridLayout, null, {
init: {
writable: true,
value: function () {
var tf = this.tf;
var f = tf.config();
var tbl = tf.tbl;
function GridLayout(tf) {
_classCallCheck(this, GridLayout);
if (!tf.gridLayout) {
return;
}
var f = tf.config();
tf.isExternalFlt = true;
//defines grid width
this.gridWidth = f.grid_width || null;
//defines grid height
this.gridHeight = f.grid_height || null;
//defines css class for main container
this.gridMainContCssClass = f.grid_cont_css_class || "grd_Cont";
//defines css class for div containing table
this.gridContCssClass = f.grid_tbl_cont_css_class || "grd_tblCont";
//defines css class for div containing headers' table
this.gridHeadContCssClass = f.grid_tblHead_cont_css_class || "grd_headTblCont";
//defines css class for div containing rows counter, paging etc.
this.gridInfDivCssClass = f.grid_inf_grid_css_class || "grd_inf";
//defines which row contains column headers
this.gridHeadRowIndex = f.grid_headers_row_index || 0;
//array of headers row indexes to be placed in header table
this.gridHeadRows = f.grid_headers_rows || [0];
//generate filters in table headers
this.gridEnableFilters = f.grid_enable_default_filters !== undefined ? f.grid_enable_default_filters : true;
//default col width
this.gridDefaultColWidth = f.grid_default_col_width || "100px";
//enables/disables columns resizer
this.gridEnableColResizer = f.grid_enable_cols_resizer !== undefined ? f.grid_enable_cols_resizer : false;
//defines col resizer script path
this.gridColResizerPath = f.grid_cont_col_resizer_path || this.basePath + "TFExt_ColsResizer/TFExt_ColsResizer.js";
// default width of 100px if column widths not set
if (!tf.hasColWidth) {
tf.colWidth = [];
for (var k = 0; k < tf.nbCells; k++) {
var colW, cell = tbl.rows[this.gridHeadRowIndex].cells[k];
if (cell.width !== "") {
colW = cell.width;
} else if (cell.style.width !== "") {
colW = parseInt(cell.style.width, 10);
} else {
colW = this.gridDefaultColWidth;
}
tf.colWidth[k] = colW;
}
tf.hasColWidth = true;
}
tf.setColWidths(this.gridHeadRowIndex);
this.gridColElms = [];
var tblW; //initial table width
if (tbl.width !== "") {
tblW = tbl.width;
} else if (tbl.style.width !== "") {
tblW = parseInt(tbl.style.width, 10);
} else {
tblW = tbl.clientWidth;
}
//Main container: it will contain all the elements
this.tblMainCont = Dom.create("div", ["id", tf.prfxMainTblCont + tf.id]);
this.tblMainCont.className = this.gridMainContCssClass;
if (this.gridWidth) {
this.tblMainCont.style.width = this.gridWidth;
}
tbl.parentNode.insertBefore(this.tblMainCont, tbl);
//Table container: div wrapping content table
this.tblCont = Dom.create("div", ["id", tf.prfxTblCont + tf.id]);
this.tblCont.className = this.gridContCssClass;
if (this.gridWidth) {
this.tblCont.style.width = this.gridWidth;
}
if (this.gridHeight) {
this.tblCont.style.height = this.gridHeight;
}
tbl.parentNode.insertBefore(this.tblCont, tbl);
var t = tbl.parentNode.removeChild(tbl);
this.tblCont.appendChild(t);
//In case table width is expressed in %
if (tbl.style.width === "") {
tbl.style.width = (tf._containsStr("%", tblW) ? tbl.clientWidth : tblW) + "px";
}
var d = this.tblCont.parentNode.removeChild(this.tblCont);
this.tblMainCont.appendChild(d);
//Headers table container: div wrapping headers table
this.headTblCont = Dom.create("div", ["id", tf.prfxHeadTblCont + tf.id]);
this.headTblCont.className = this.gridHeadContCssClass;
if (this.gridWidth) {
this.headTblCont.style.width = this.gridWidth;
}
//Headers table
this.headTbl = Dom.create("table", ["id", tf.prfxHeadTbl + tf.id]);
var tH = Dom.create("tHead"); //IE<7 needs it
//1st row should be headers row, ids are added if not set
//Those ids are used by the sort feature
var hRow = tbl.rows[this.gridHeadRowIndex];
var sortTriggers = [];
for (var n = 0; n < tf.nbCells; n++) {
var c = hRow.cells[n];
var thId = c.getAttribute("id");
if (!thId || thId === "") {
thId = tf.prfxGridTh + n + "_" + tf.id;
c.setAttribute("id", thId);
}
sortTriggers.push(thId);
}
//Filters row is created
var filtersRow = Dom.create("tr");
if (this.gridEnableFilters && tf.fltGrid) {
tf.externalFltTgtIds = [];
for (var j = 0; j < tf.nbCells; j++) {
var fltTdId = tf.prfxFlt + j + tf.prfxGridFltTd + tf.id;
var cl = Dom.create(tf.fltCellTag, ["id", fltTdId]);
filtersRow.appendChild(cl);
tf.externalFltTgtIds[j] = fltTdId;
}
}
//Headers row are moved from content table to headers table
for (var i = 0; i < this.gridHeadRows.length; i++) {
var headRow = tbl.rows[this.gridHeadRows[0]];
tH.appendChild(headRow);
}
this.headTbl.appendChild(tH);
if (tf.filtersRowIndex === 0) {
tH.insertBefore(filtersRow, hRow);
} else {
tH.appendChild(filtersRow);
}
this.headTblCont.appendChild(this.headTbl);
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
//THead needs to be removed in content table for sort feature
var thead = Dom.tag(tbl, "thead");
if (thead.length > 0) {
tbl.removeChild(thead[0]);
}
//Headers table style
this.headTbl.style.width = tbl.style.width;
this.headTbl.style.tableLayout = "fixed";
tbl.style.tableLayout = "fixed";
this.headTbl.cellPadding = tbl.cellPadding;
this.headTbl.cellSpacing = tbl.cellSpacing;
//content table without headers needs col widths to be reset
tf.setColWidths();
//Headers container width
this.headTblCont.style.width = this.tblCont.clientWidth + "px";
tbl.style.width = "";
//scroll synchronisation
var o = this;
Event.add(this.tblCont, "scroll", function (evt) {
//this = scroll element
var scrollLeft = this.scrollLeft;
o.headTblCont.scrollLeft = scrollLeft;
//New pointerX calc taking into account scrollLeft
if (!o.isPointerXOverwritten) {
try {
o.Evt.pointerX = function (evt) {
var e = evt || global.event;
var bdScrollLeft = tf_StandardBody().scrollLeft + scrollLeft;
return (e.pageX + scrollLeft) || (e.clientX + bdScrollLeft);
};
o.isPointerXOverwritten = true;
} catch (err) {
o.isPointerXOverwritten = false;
}
}
});
//Sort is enabled if not specified in config object
if (f.sort !== false) {
tf.sort = true;
tf.sortConfig.asyncSort = true;
tf.sortConfig.triggerIds = sortTriggers;
}
if (this.gridEnableColResizer) {
if (!tf.hasExtensions) {
tf.extensions = {
name: ["ColumnsResizer_" + tf.id],
src: [this.gridColResizerPath],
description: ["Columns Resizing"],
initialize: [function (o) {
o.SetColsResizer("ColumnsResizer_" + o.id);
}]
};
tf.hasExtensions = true;
} else {
if (!tf._containsStr("colsresizer", Str.lower(tf.extensions.src.toString()))) {
tf.extensions.name.push("ColumnsResizer_" + tf.id);
tf.extensions.src.push(tf.gridColResizerPath);
tf.extensions.description.push("Columns Resizing");
tf.extensions.initialize.push(function (o) {
o.SetColsResizer("ColumnsResizer_" + o.id);
});
}
}
}
//Default columns resizer properties for grid layout
f.col_resizer_cols_headers_table = this.headTbl.getAttribute("id");
f.col_resizer_cols_headers_index = this.gridHeadRowIndex;
f.col_resizer_width_adjustment = 0;
f.col_enable_text_ellipsis = false;
//Cols generation for all browsers excepted IE<=7
o.tblHasColTag = Dom.tag(tbl, "col").length > 0 ? true : false;
//Col elements are enough to keep column widths after sorting and
//filtering
var createColTags = function (o) {
if (!o) {
return;
}
for (var k = (tf.nbCells - 1); k >= 0; k--) {
var col = Dom.create("col", ["id", tf.id + "_col_" + k]);
tbl.firstChild.parentNode.insertBefore(col, tbl.firstChild);
col.style.width = tf.colWidth[k];
o.gridColElms[k] = col;
}
o.tblHasColTag = true;
};
if (!o.tblHasColTag) {
createColTags(o);
} else {
var cols = Dom.tag(tbl, "col");
for (var ii = 0; ii < tf.nbCells; ii++) {
cols[ii].setAttribute("id", tf.id + "_col_" + ii);
cols[ii].style.width = tf.colWidth[ii];
o.gridColElms.push(cols[ii]);
}
}
var afterColResizedFn = Types.isFn(f.on_after_col_resized) ? f.on_after_col_resized : null;
f.on_after_col_resized = function (o, colIndex) {
if (!colIndex) {
return;
}
var w = o.crWColsRow.cells[colIndex].style.width;
var col = o.gridColElms[colIndex];
col.style.width = w;
var thCW = o.crWColsRow.cells[colIndex].clientWidth;
var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth;
if (thCW != tdCW /*&& !Helpers.isIE()*/) {
o.headTbl.style.width = tbl.clientWidth + "px";
}
if (afterColResizedFn) {
afterColResizedFn.call(null, o, colIndex);
}
};
if (tbl.clientWidth !== this.headTbl.clientWidth) {
tbl.style.width = this.headTbl.clientWidth + "px";
}
// Re-adjust reference row
//tf.refRow = Helpers.isIE() ? (tf.refRow+1) : 0;
this.tf = tf;
}
},
destroy: {
writable: true,
value: function () {
var tf = this.tf;
var tbl = tf.tbl;
if (!tf.gridLayout) {
return;
}
var t = tbl.parentNode.removeChild(tbl);
this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont);
this.tblMainCont.parentNode.removeChild(this.tblMainCont);
_prototypeProperties(GridLayout, null, {
init: {
this.tblMainCont = null;
this.headTblCont = null;
this.headTbl = null;
this.tblCont = null;
/**
* Generates a grid with fixed headers
*/
tbl.outerHTML = tf.sourceTblHtml;
//needed to keep reference of table element
tbl = Dom.id(tf.id);
}
}
value: function init() {
var tf = this.tf;
var f = tf.config();
var tbl = tf.tbl;
if (!tf.gridLayout) {
return;
}
tf.isExternalFlt = true;
// default width of 100px if column widths not set
if (!tf.hasColWidth) {
tf.colWidth = [];
for (var k = 0; k < tf.nbCells; k++) {
var colW,
cell = tbl.rows[this.gridHeadRowIndex].cells[k];
if (cell.width !== "") {
colW = cell.width;
} else if (cell.style.width !== "") {
colW = parseInt(cell.style.width, 10);
} else {
colW = this.gridDefaultColWidth;
}
tf.colWidth[k] = colW;
}
tf.hasColWidth = true;
}
tf.setColWidths(this.gridHeadRowIndex);
var tblW; //initial table width
if (tbl.width !== "") {
tblW = tbl.width;
} else if (tbl.style.width !== "") {
tblW = parseInt(tbl.style.width, 10);
} else {
tblW = tbl.clientWidth;
}
//Main container: it will contain all the elements
this.tblMainCont = Dom.create("div", ["id", tf.prfxMainTblCont + tf.id]);
this.tblMainCont.className = this.gridMainContCssClass;
if (this.gridWidth) {
this.tblMainCont.style.width = this.gridWidth;
}
tbl.parentNode.insertBefore(this.tblMainCont, tbl);
//Table container: div wrapping content table
this.tblCont = Dom.create("div", ["id", tf.prfxTblCont + tf.id]);
this.tblCont.className = this.gridContCssClass;
if (this.gridWidth) {
this.tblCont.style.width = this.gridWidth;
}
if (this.gridHeight) {
this.tblCont.style.height = this.gridHeight;
}
tbl.parentNode.insertBefore(this.tblCont, tbl);
var t = tbl.parentNode.removeChild(tbl);
this.tblCont.appendChild(t);
//In case table width is expressed in %
if (tbl.style.width === "") {
tbl.style.width = (tf._containsStr("%", tblW) ? tbl.clientWidth : tblW) + "px";
}
var d = this.tblCont.parentNode.removeChild(this.tblCont);
this.tblMainCont.appendChild(d);
//Headers table container: div wrapping headers table
this.headTblCont = Dom.create("div", ["id", tf.prfxHeadTblCont + tf.id]);
this.headTblCont.className = this.gridHeadContCssClass;
if (this.gridWidth) {
this.headTblCont.style.width = this.gridWidth;
}
//Headers table
this.headTbl = Dom.create("table", ["id", tf.prfxHeadTbl + tf.id]);
var tH = Dom.create("tHead"); //IE<7 needs it
//1st row should be headers row, ids are added if not set
//Those ids are used by the sort feature
var hRow = tbl.rows[this.gridHeadRowIndex];
var sortTriggers = [];
for (var n = 0; n < tf.nbCells; n++) {
var c = hRow.cells[n];
var thId = c.getAttribute("id");
if (!thId || thId === "") {
thId = tf.prfxGridTh + n + "_" + tf.id;
c.setAttribute("id", thId);
}
sortTriggers.push(thId);
}
//Filters row is created
var filtersRow = Dom.create("tr");
if (this.gridEnableFilters && tf.fltGrid) {
tf.externalFltTgtIds = [];
for (var j = 0; j < tf.nbCells; j++) {
var fltTdId = tf.prfxFlt + j + tf.prfxGridFltTd + tf.id;
var cl = Dom.create(tf.fltCellTag, ["id", fltTdId]);
filtersRow.appendChild(cl);
tf.externalFltTgtIds[j] = fltTdId;
}
}
//Headers row are moved from content table to headers table
for (var i = 0; i < this.gridHeadRows.length; i++) {
var headRow = tbl.rows[this.gridHeadRows[0]];
tH.appendChild(headRow);
}
this.headTbl.appendChild(tH);
if (tf.filtersRowIndex === 0) {
tH.insertBefore(filtersRow, hRow);
} else {
tH.appendChild(filtersRow);
}
this.headTblCont.appendChild(this.headTbl);
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
//THead needs to be removed in content table for sort feature
var thead = Dom.tag(tbl, "thead");
if (thead.length > 0) {
tbl.removeChild(thead[0]);
}
//Headers table style
this.headTbl.style.width = tbl.style.width;
this.headTbl.style.tableLayout = "fixed";
tbl.style.tableLayout = "fixed";
this.headTbl.cellPadding = tbl.cellPadding;
this.headTbl.cellSpacing = tbl.cellSpacing;
//content table without headers needs col widths to be reset
tf.setColWidths();
//Headers container width
this.headTblCont.style.width = this.tblCont.clientWidth + "px";
tbl.style.width = "";
//scroll synchronisation
var o = this;
Event.add(this.tblCont, "scroll", function (evt) {
//this = scroll element
var scrollLeft = this.scrollLeft;
o.headTblCont.scrollLeft = scrollLeft;
//New pointerX calc taking into account scrollLeft
if (!o.isPointerXOverwritten) {
try {
o.Evt.pointerX = function (evt) {
var e = evt || global.event;
var bdScrollLeft = tf_StandardBody().scrollLeft + scrollLeft;
return e.pageX + scrollLeft || e.clientX + bdScrollLeft;
};
o.isPointerXOverwritten = true;
} catch (err) {
o.isPointerXOverwritten = false;
}
}
});
//Sort is enabled if not specified in config object
if (f.sort !== false) {
tf.sort = true;
tf.sortConfig.asyncSort = true;
tf.sortConfig.triggerIds = sortTriggers;
}
if (this.gridEnableColResizer) {
if (!tf.hasExtensions) {
tf.extensions = {
name: ["ColumnsResizer_" + tf.id],
src: [this.gridColResizerPath],
description: ["Columns Resizing"],
initialize: [function (o) {
o.SetColsResizer("ColumnsResizer_" + o.id);
}]
};
tf.hasExtensions = true;
} else {
if (!tf._containsStr("colsresizer", Str.lower(tf.extensions.src.toString()))) {
tf.extensions.name.push("ColumnsResizer_" + tf.id);
tf.extensions.src.push(tf.gridColResizerPath);
tf.extensions.description.push("Columns Resizing");
tf.extensions.initialize.push(function (o) {
o.SetColsResizer("ColumnsResizer_" + o.id);
});
}
}
}
//Default columns resizer properties for grid layout
f.col_resizer_cols_headers_table = this.headTbl.getAttribute("id");
f.col_resizer_cols_headers_index = this.gridHeadRowIndex;
f.col_resizer_width_adjustment = 0;
f.col_enable_text_ellipsis = false;
//Cols generation for all browsers excepted IE<=7
o.tblHasColTag = Dom.tag(tbl, "col").length > 0 ? true : false;
//Col elements are enough to keep column widths after sorting and
//filtering
var createColTags = function createColTags(o) {
if (!o) {
return;
}
for (var k = tf.nbCells - 1; k >= 0; k--) {
var col = Dom.create("col", ["id", tf.id + "_col_" + k]);
tbl.firstChild.parentNode.insertBefore(col, tbl.firstChild);
col.style.width = tf.colWidth[k];
o.gridColElms[k] = col;
}
o.tblHasColTag = true;
};
if (!o.tblHasColTag) {
createColTags(o);
} else {
var cols = Dom.tag(tbl, "col");
for (var ii = 0; ii < tf.nbCells; ii++) {
cols[ii].setAttribute("id", tf.id + "_col_" + ii);
cols[ii].style.width = tf.colWidth[ii];
o.gridColElms.push(cols[ii]);
}
}
var afterColResizedFn = Types.isFn(f.on_after_col_resized) ? f.on_after_col_resized : null;
f.on_after_col_resized = function (o, colIndex) {
if (!colIndex) {
return;
}
var w = o.crWColsRow.cells[colIndex].style.width;
var col = o.gridColElms[colIndex];
col.style.width = w;
var thCW = o.crWColsRow.cells[colIndex].clientWidth;
var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth;
if (thCW != tdCW /*&& !Helpers.isIE()*/) {
o.headTbl.style.width = tbl.clientWidth + "px";
}
if (afterColResizedFn) {
afterColResizedFn.call(null, o, colIndex);
}
};
if (tbl.clientWidth !== this.headTbl.clientWidth) {
tbl.style.width = this.headTbl.clientWidth + "px";
}
// Re-adjust reference row
//tf.refRow = Helpers.isIE() ? (tf.refRow+1) : 0;
},
writable: true,
configurable: true
},
destroy: {
/**
* Removes the grid layout
*/
value: function destroy() {
var tf = this.tf;
var tbl = tf.tbl;
if (!tf.gridLayout) {
return;
}
var t = tbl.parentNode.removeChild(tbl);
this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont);
this.tblMainCont.parentNode.removeChild(this.tblMainCont);
this.tblMainCont = null;
this.headTblCont = null;
this.headTbl = null;
this.tblCont = null;
tbl.outerHTML = tf.sourceTblHtml;
//needed to keep reference of table element
tbl = Dom.id(tf.id);
},
writable: true,
configurable: true
}
});
return GridLayout;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return GridLayout;
})();
exports.GridLayout = GridLayout;
});
});
//# sourceMappingURL=gridLayout.js.map

View file

@ -1,149 +1,174 @@
define(["exports", "../dom", "../event"], function (exports, _dom, _event) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Event = _event.Event;
var Help = (function () {
var Help = function Help(tf) {
// Configuration object
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
//id of custom container element for instructions
this.helpInstrTgtId = f.help_instructions_target_id || null;
//id of custom container element for instructions
this.helpInstrContTgtId = f.help_instructions_container_target_id || null;
//defines help text
this.helpInstrText = f.help_instructions_text ? f.help_instructions_text : "Use the filters above each column to filter and limit table " + "data. Avanced searches can be performed by using the following " + "operators: <br /><b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, " + "<b>&gt;=</b>, <b>=</b>, <b>*</b>, <b>!</b>, <b>{</b>, <b>}</b>, " + "<b>||</b>,<b>&amp;&amp;</b>, <b>[empty]</b>, <b>[nonempty]</b>, " + "<b>rgx:</b><br/> These operators are described here:<br/>" + "<a href=\"http://tablefilter.free.fr/#operators\" " + "target=\"_blank\">http://tablefilter.free.fr/#operators</a><hr/>";
//defines help innerHtml
this.helpInstrHtml = f.help_instructions_html || null;
//defines reset button text
this.helpInstrBtnText = f.help_instructions_btn_text || "?";
//defines reset button innerHtml
this.helpInstrBtnHtml = f.help_instructions_btn_html || null;
//defines css class for help button
this.helpInstrBtnCssClass = f.help_instructions_btn_css_class || "helpBtn";
//defines css class for help container
this.helpInstrContCssClass = f.help_instructions_container_css_class || "helpCont";
//help button element
this.helpInstrBtnEl = null;
//help content div
this.helpInstrContEl = null;
this.helpInstrDefaultHtml = "<div class=\"helpFooter\"><h4>HTML Table " + "Filter Generator v. " + tf.version + "</h4>" + "<a href=\"http://tablefilter.free.fr\" target=\"_blank\">" + "http://tablefilter.free.fr</a><br/>" + "<span>&copy;2009-" + tf.year + " Max Guglielmi.</span>" + "<div align=\"center\" style=\"margin-top:8px;\">" + "<a href=\"javascript:void(0);\">Close</a></div></div>";
var Dom = _dom.Dom;
var Event = _event.Event;
this.tf = tf;
};
var Help = exports.Help = (function () {
_classProps(Help, null, {
init: {
writable: true,
value: function () {
var _this = this;
if (this.helpInstrBtnEl) {
return;
}
/**
* Help UI component
* @param {Object} tf TableFilter instance
*/
var tf = this.tf;
function Help(tf) {
_classCallCheck(this, Help);
var helpspan = Dom.create("span", ["id", tf.prfxHelpSpan + tf.id]);
var helpdiv = Dom.create("div", ["id", tf.prfxHelpDiv + tf.id]);
// Configuration object
var f = tf.config();
//help button is added to defined element
if (!this.helpInstrTgtId) {
tf.setToolbar();
}
var targetEl = !this.helpInstrTgtId ? tf.rDiv : Dom.id(this.helpInstrTgtId);
targetEl.appendChild(helpspan);
//id of custom container element for instructions
this.helpInstrTgtId = f.help_instructions_target_id || null;
//id of custom container element for instructions
this.helpInstrContTgtId = f.help_instructions_container_target_id || null;
//defines help text
this.helpInstrText = f.help_instructions_text ? f.help_instructions_text : "Use the filters above each column to filter and limit table " + "data. Avanced searches can be performed by using the following " + "operators: <br /><b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, " + "<b>&gt;=</b>, <b>=</b>, <b>*</b>, <b>!</b>, <b>{</b>, <b>}</b>, " + "<b>||</b>,<b>&amp;&amp;</b>, <b>[empty]</b>, <b>[nonempty]</b>, " + "<b>rgx:</b><br/> These operators are described here:<br/>" + "<a href=\"http://tablefilter.free.fr/#operators\" " + "target=\"_blank\">http://tablefilter.free.fr/#operators</a><hr/>";
//defines help innerHtml
this.helpInstrHtml = f.help_instructions_html || null;
//defines reset button text
this.helpInstrBtnText = f.help_instructions_btn_text || "?";
//defines reset button innerHtml
this.helpInstrBtnHtml = f.help_instructions_btn_html || null;
//defines css class for help button
this.helpInstrBtnCssClass = f.help_instructions_btn_css_class || "helpBtn";
//defines css class for help container
this.helpInstrContCssClass = f.help_instructions_container_css_class || "helpCont";
//help button element
this.helpInstrBtnEl = null;
//help content div
this.helpInstrContEl = null;
this.helpInstrDefaultHtml = "<div class=\"helpFooter\"><h4>HTML Table " + "Filter Generator v. " + tf.version + "</h4>" + "<a href=\"http://tablefilter.free.fr\" target=\"_blank\">" + "http://tablefilter.free.fr</a><br/>" + "<span>&copy;2009-" + tf.year + " Max Guglielmi.</span>" + "<div align=\"center\" style=\"margin-top:8px;\">" + "<a href=\"javascript:void(0);\">Close</a></div></div>";
var divContainer = !this.helpInstrContTgtId ? helpspan : Dom.id(this.helpInstrContTgtId);
if (!this.helpInstrBtnHtml) {
divContainer.appendChild(helpdiv);
var helplink = Dom.create("a", ["href", "javascript:void(0);"]);
helplink.className = this.helpInstrBtnCssClass;
helplink.appendChild(Dom.text(this.helpInstrBtnText));
helpspan.appendChild(helplink);
Event.add(helplink, "click", function () {
_this.toggle();
});
} else {
helpspan.innerHTML = this.helpInstrBtnHtml;
var helpEl = helpspan.firstChild;
Event.add(helpEl, "click", function () {
_this.toggle();
});
divContainer.appendChild(helpdiv);
}
if (!this.helpInstrHtml) {
helpdiv.innerHTML = this.helpInstrText;
helpdiv.className = this.helpInstrContCssClass;
Event.add(helpdiv, "dblclick", function () {
_this.toggle();
});
} else {
if (this.helpInstrContTgtId) {
divContainer.appendChild(helpdiv);
}
helpdiv.innerHTML = this.helpInstrHtml;
if (!this.helpInstrContTgtId) {
helpdiv.className = this.helpInstrContCssClass;
Event.add(helpdiv, "dblclick", function () {
_this.toggle();
});
}
}
helpdiv.innerHTML += this.helpInstrDefaultHtml;
Event.add(helpdiv, "click", function () {
_this.toggle();
});
this.helpInstrContEl = helpdiv;
this.helpInstrBtnEl = helpspan;
this.tf = tf;
}
},
toggle: {
writable: true,
value: function () {
if (!this.helpInstrContEl) {
return;
}
var divDisplay = this.helpInstrContEl.style.display;
if (divDisplay === "" || divDisplay === "none") {
this.helpInstrContEl.style.display = "block";
// TODO: use CSS instead for element positioning
var btnLeft = Dom.position(this.helpInstrBtnEl).left;
if (!this.helpInstrContTgtId) {
this.helpInstrContEl.style.left = (btnLeft - this.helpInstrContEl.clientWidth + 25) + "px";
_prototypeProperties(Help, null, {
init: {
value: function init() {
var _this = this;
if (this.helpInstrBtnEl) {
return;
}
var tf = this.tf;
var helpspan = Dom.create("span", ["id", tf.prfxHelpSpan + tf.id]);
var helpdiv = Dom.create("div", ["id", tf.prfxHelpDiv + tf.id]);
//help button is added to defined element
if (!this.helpInstrTgtId) {
tf.setToolbar();
}
var targetEl = !this.helpInstrTgtId ? tf.rDiv : Dom.id(this.helpInstrTgtId);
targetEl.appendChild(helpspan);
var divContainer = !this.helpInstrContTgtId ? helpspan : Dom.id(this.helpInstrContTgtId);
if (!this.helpInstrBtnHtml) {
divContainer.appendChild(helpdiv);
var helplink = Dom.create("a", ["href", "javascript:void(0);"]);
helplink.className = this.helpInstrBtnCssClass;
helplink.appendChild(Dom.text(this.helpInstrBtnText));
helpspan.appendChild(helplink);
Event.add(helplink, "click", function () {
_this.toggle();
});
} else {
helpspan.innerHTML = this.helpInstrBtnHtml;
var helpEl = helpspan.firstChild;
Event.add(helpEl, "click", function () {
_this.toggle();
});
divContainer.appendChild(helpdiv);
}
if (!this.helpInstrHtml) {
helpdiv.innerHTML = this.helpInstrText;
helpdiv.className = this.helpInstrContCssClass;
Event.add(helpdiv, "dblclick", function () {
_this.toggle();
});
} else {
if (this.helpInstrContTgtId) {
divContainer.appendChild(helpdiv);
}
helpdiv.innerHTML = this.helpInstrHtml;
if (!this.helpInstrContTgtId) {
helpdiv.className = this.helpInstrContCssClass;
Event.add(helpdiv, "dblclick", function () {
_this.toggle();
});
}
}
helpdiv.innerHTML += this.helpInstrDefaultHtml;
Event.add(helpdiv, "click", function () {
_this.toggle();
});
this.helpInstrContEl = helpdiv;
this.helpInstrBtnEl = helpspan;
},
writable: true,
configurable: true
},
toggle: {
/**
* Toggle help pop-up
*/
value: function toggle() {
if (!this.helpInstrContEl) {
return;
}
var divDisplay = this.helpInstrContEl.style.display;
if (divDisplay === "" || divDisplay === "none") {
this.helpInstrContEl.style.display = "block";
// TODO: use CSS instead for element positioning
var btnLeft = Dom.position(this.helpInstrBtnEl).left;
if (!this.helpInstrContTgtId) {
this.helpInstrContEl.style.left = btnLeft - this.helpInstrContEl.clientWidth + 25 + "px";
}
} else {
this.helpInstrContEl.style.display = "none";
}
},
writable: true,
configurable: true
},
destroy: {
/**
* Remove help UI
*/
value: function destroy() {
if (!this.helpInstrBtnEl) {
return;
}
this.helpInstrBtnEl.parentNode.removeChild(this.helpInstrBtnEl);
this.helpInstrBtnEl = null;
if (!this.helpInstrContEl) {
return;
}
this.helpInstrContEl.parentNode.removeChild(this.helpInstrContEl);
this.helpInstrContEl = null;
},
writable: true,
configurable: true
}
} else {
this.helpInstrContEl.style.display = "none";
}
}
},
destroy: {
writable: true,
value: function () {
if (!this.helpInstrBtnEl) {
return;
}
this.helpInstrBtnEl.parentNode.removeChild(this.helpInstrBtnEl);
this.helpInstrBtnEl = null;
if (!this.helpInstrContEl) {
return;
}
this.helpInstrContEl.parentNode.removeChild(this.helpInstrContEl);
this.helpInstrContEl = null;
}
}
});
return Help;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return Help;
})();
exports.Help = Help;
});
});
//# sourceMappingURL=help.js.map

View file

@ -1,103 +1,145 @@
define(["exports", "../dom", "../string"], function (exports, _dom, _string) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Str = _string.Str;
var HighlightKeyword = (function () {
var HighlightKeyword = function HighlightKeyword(tf) {
var f = tf.config();
//defines css class for highlighting
this.highlightCssClass = f.highlight_css_class || "keyword";
this.highlightedNodes = [];
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
this.tf = tf;
};
var Dom = _dom.Dom;
var Str = _string.Str;
_classProps(HighlightKeyword, null, {
highlight: {
writable: true,
value: function (node, word, cssClass) {
// Iterate into this nodes childNodes
if (node.hasChildNodes) {
var children = node.childNodes;
for (var i = 0; i < children.length; i++) {
this.highlight(children[i], word, cssClass);
}
}
var HighlightKeyword = exports.HighlightKeyword = (function () {
if (node.nodeType === 3) {
var tempNodeVal = Str.lower(node.nodeValue);
var tempWordVal = Str.lower(word);
if (tempNodeVal.indexOf(tempWordVal) != -1) {
var pn = node.parentNode;
if (pn && pn.className != cssClass) {
// word not highlighted yet
var nv = node.nodeValue, ni = tempNodeVal.indexOf(tempWordVal),
// Create a load of replacement nodes
before = Dom.text(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");
hiword.className = cssClass;
hiword.appendChild(hiwordtext);
pn.insertBefore(before, node);
pn.insertBefore(hiword, node);
pn.insertBefore(after, node);
pn.removeChild(node);
this.highlightedNodes.push(hiword.firstChild);
}
}
}
/**
* HighlightKeyword, highlight matched keyword
* @param {Object} tf TableFilter instance
*/
function HighlightKeyword(tf) {
_classCallCheck(this, HighlightKeyword);
var f = tf.config();
//defines css class for highlighting
this.highlightCssClass = f.highlight_css_class || "keyword";
this.highlightedNodes = [];
this.tf = tf;
}
},
unhighlight: {
writable: true,
value: function (word, cssClass) {
var arrRemove = [];
var highlightedNodes = this.highlightedNodes;
for (var i = 0; i < highlightedNodes.length; i++) {
var n = highlightedNodes[i];
if (!n) {
continue;
_prototypeProperties(HighlightKeyword, null, {
highlight: {
/**
* highlight occurences of searched term in passed node
* @param {Node} node
* @param {String} word Searched term
* @param {String} cssClass Css class name
*/
value: function highlight(node, word, cssClass) {
// Iterate into this nodes childNodes
if (node.hasChildNodes) {
var children = node.childNodes;
for (var i = 0; i < children.length; i++) {
this.highlight(children[i], word, cssClass);
}
}
if (node.nodeType === 3) {
var tempNodeVal = Str.lower(node.nodeValue);
var tempWordVal = Str.lower(word);
if (tempNodeVal.indexOf(tempWordVal) != -1) {
var pn = node.parentNode;
if (pn && pn.className != cssClass) {
// word not highlighted yet
var nv = node.nodeValue,
ni = tempNodeVal.indexOf(tempWordVal),
// Create a load of replacement nodes
before = Dom.text(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");
hiword.className = cssClass;
hiword.appendChild(hiwordtext);
pn.insertBefore(before, node);
pn.insertBefore(hiword, node);
pn.insertBefore(after, node);
pn.removeChild(node);
this.highlightedNodes.push(hiword.firstChild);
}
}
}
},
writable: true,
configurable: true
},
unhighlight: {
/**
* Removes highlight to nodes matching passed string
* @param {String} word
* @param {String} cssClass Css class to remove
*/
value: function unhighlight(word, cssClass) {
var arrRemove = [];
var highlightedNodes = this.highlightedNodes;
for (var i = 0; i < highlightedNodes.length; i++) {
var n = highlightedNodes[i];
if (!n) {
continue;
}
var tempNodeVal = Str.lower(n.nodeValue),
tempWordVal = Str.lower(word);
if (tempNodeVal.indexOf(tempWordVal) !== -1) {
var pn = n.parentNode;
if (pn && pn.className === cssClass) {
var prevSib = pn.previousSibling,
nextSib = pn.nextSibling;
if (!prevSib || !nextSib) {
continue;
}
nextSib.nodeValue = prevSib.nodeValue + n.nodeValue + nextSib.nodeValue;
prevSib.nodeValue = "";
n.nodeValue = "";
arrRemove.push(i);
}
}
}
for (var k = 0; k < arrRemove.length; k++) {
highlightedNodes.splice(arrRemove[k], 1);
}
},
writable: true,
configurable: true
},
unhighlightAll: {
/**
* Clear all occurrences of highlighted nodes
*/
value: function unhighlightAll() {
if (!this.tf.highlightKeywords || !this.tf.searchArgs) {
return;
}
for (var y = 0; y < this.tf.searchArgs.length; y++) {
this.unhighlight(this.tf.searchArgs[y], this.highlightCssClass);
}
this.highlightedNodes = [];
},
writable: true,
configurable: true
}
var tempNodeVal = Str.lower(n.nodeValue), tempWordVal = Str.lower(word);
if (tempNodeVal.indexOf(tempWordVal) !== -1) {
var pn = n.parentNode;
if (pn && pn.className === cssClass) {
var prevSib = pn.previousSibling, nextSib = pn.nextSibling;
if (!prevSib || !nextSib) {
continue;
}
nextSib.nodeValue = prevSib.nodeValue + n.nodeValue + nextSib.nodeValue;
prevSib.nodeValue = "";
n.nodeValue = "";
arrRemove.push(i);
}
}
}
for (var k = 0; k < arrRemove.length; k++) {
highlightedNodes.splice(arrRemove[k], 1);
}
}
},
unhighlightAll: {
writable: true,
value: function () {
if (!this.tf.highlightKeywords || !this.tf.searchArgs) {
return;
}
for (var y = 0; y < this.tf.searchArgs.length; y++) {
this.unhighlight(this.tf.searchArgs[y], this.highlightCssClass);
}
this.highlightedNodes = [];
}
}
});
return HighlightKeyword;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return HighlightKeyword;
})();
exports.HighlightKeyword = HighlightKeyword;
});
});
//# sourceMappingURL=highlightKeywords.js.map

View file

@ -1,98 +1,110 @@
define(["exports", "../dom", "../types"], function (exports, _dom, _types) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Types = _types.Types;
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Dom = _dom.Dom;
var Types = _types.Types;
var global = window;
var global = window;
var Loader = (function () {
var Loader = function Loader(tf) {
// TableFilter configuration
var f = tf.config();
//id of container element
this.loaderTgtId = f.loader_target_id || null;
//div containing loader
this.loaderDiv = null;
//defines loader text
this.loaderText = f.loader_text || "Loading...";
//defines loader innerHtml
this.loaderHtml = f.loader_html || null;
//defines css class for loader div
this.loaderCssClass = f.loader_css_class || "loader";
//delay for hiding loader
this.loaderCloseDelay = 200;
//callback function before loader is displayed
this.onShowLoader = Types.isFn(f.on_show_loader) ? f.on_show_loader : null;
//callback function after loader is closed
this.onHideLoader = Types.isFn(f.on_hide_loader) ? f.on_hide_loader : null;
/**
* Loading message/spinner
* @param {Object} tf TableFilter instance
*/
this.tf = tf;
var Loader = exports.Loader = (function () {
function Loader(tf) {
_classCallCheck(this, Loader);
var containerDiv = Dom.create("div", ["id", tf.prfxLoader + tf.id]);
containerDiv.className = this.loaderCssClass;
// TableFilter configuration
var f = tf.config();
//id of container element
this.loaderTgtId = f.loader_target_id || null;
//div containing loader
this.loaderDiv = null;
//defines loader text
this.loaderText = f.loader_text || "Loading...";
//defines loader innerHtml
this.loaderHtml = f.loader_html || null;
//defines css class for loader div
this.loaderCssClass = f.loader_css_class || "loader";
//delay for hiding loader
this.loaderCloseDelay = 200;
//callback function before loader is displayed
this.onShowLoader = Types.isFn(f.on_show_loader) ? f.on_show_loader : null;
//callback function after loader is closed
this.onHideLoader = Types.isFn(f.on_hide_loader) ? f.on_hide_loader : null;
var targetEl = !this.loaderTgtId ? tf.tbl.parentNode : Dom.id(this.loaderTgtId);
if (!this.loaderTgtId) {
targetEl.insertBefore(containerDiv, tf.tbl);
} else {
targetEl.appendChild(containerDiv);
}
this.loaderDiv = Dom.id(tf.prfxLoader + tf.id);
if (!this.loaderHtml) {
this.loaderDiv.appendChild(Dom.text(this.loaderText));
} else {
this.loaderDiv.innerHTML = this.loaderHtml;
}
};
this.tf = tf;
_classProps(Loader, null, {
show: {
writable: true,
value: function (p) {
var _this = this;
if (!this.tf.loader || !this.loaderDiv || this.loaderDiv.style.display === p) {
return;
}
var containerDiv = Dom.create("div", ["id", tf.prfxLoader + tf.id]);
containerDiv.className = this.loaderCssClass;
var displayLoader = function () {
if (!_this.loaderDiv) {
return;
var targetEl = !this.loaderTgtId ? tf.tbl.parentNode : Dom.id(this.loaderTgtId);
if (!this.loaderTgtId) {
targetEl.insertBefore(containerDiv, tf.tbl);
} else {
targetEl.appendChild(containerDiv);
}
if (_this.onShowLoader && p !== "none") {
_this.onShowLoader.call(null, _this);
this.loaderDiv = Dom.id(tf.prfxLoader + tf.id);
if (!this.loaderHtml) {
this.loaderDiv.appendChild(Dom.text(this.loaderText));
} else {
this.loaderDiv.innerHTML = this.loaderHtml;
}
_this.loaderDiv.style.display = p;
if (_this.onHideLoader && p === "none") {
_this.onHideLoader.call(null, _this);
}
};
var t = p === "none" ? this.loaderCloseDelay : 1;
global.setTimeout(displayLoader, t);
}
},
remove: {
writable: true,
value: function () {
if (!this.loaderDiv) {
return;
}
var tf = this.tf, targetEl = !this.loaderTgtId ? (tf.gridLayout ? tf.Cpt.gridLayout.tblCont : tf.tbl.parentNode) : Dom.id(this.loaderTgtId);
targetEl.removeChild(this.loaderDiv);
this.loaderDiv = null;
}
}
_prototypeProperties(Loader, null, {
show: {
value: function show(p) {
var _this = this;
if (!this.tf.loader || !this.loaderDiv || this.loaderDiv.style.display === p) {
return;
}
var displayLoader = function () {
if (!_this.loaderDiv) {
return;
}
if (_this.onShowLoader && p !== "none") {
_this.onShowLoader.call(null, _this);
}
_this.loaderDiv.style.display = p;
if (_this.onHideLoader && p === "none") {
_this.onHideLoader.call(null, _this);
}
};
var t = p === "none" ? this.loaderCloseDelay : 1;
global.setTimeout(displayLoader, t);
},
writable: true,
configurable: true
},
remove: {
value: function remove() {
if (!this.loaderDiv) {
return;
}
var tf = this.tf,
targetEl = !this.loaderTgtId ? tf.gridLayout ? tf.Cpt.gridLayout.tblCont : tf.tbl.parentNode : Dom.id(this.loaderTgtId);
targetEl.removeChild(this.loaderDiv);
this.loaderDiv = null;
},
writable: true,
configurable: true
}
});
return Loader;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return Loader;
})();
exports.Loader = Loader;
});
});
//# sourceMappingURL=loader.js.map

File diff suppressed because it is too large Load diff

View file

@ -1,203 +1,277 @@
define(["exports", "../types", "../dom", "../event", "../helpers"], function (exports, _types, _dom, _event, _helpers) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Types = _types.Types;
var Dom = _dom.Dom;
var Event = _event.Event;
var Helpers = _helpers.Helpers;
var PopupFilter = (function () {
var PopupFilter = function PopupFilter(tf) {
// Configuration object
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
// Enable external filters behaviour
tf.isExternalFlt = true;
tf.externalFltTgtIds = [];
var Types = _types.Types;
var Dom = _dom.Dom;
var Event = _event.Event;
var Helpers = _helpers.Helpers;
//filter icon path
this.popUpImgFlt = f.popup_filters_image || tf.themesPath + "icn_filter.gif";
//active filter icon path
this.popUpImgFltActive = f.popup_filters_image_active || tf.themesPath + "icn_filterActive.gif";
this.popUpImgFltHtml = f.popup_filters_image_html || "<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
this.onBeforePopUpOpen = Types.isFn(f.on_before_popup_filter_open) ? f.on_before_popup_filter_open : null;
//callback function after popup filtes is opened
this.onAfterPopUpOpen = Types.isFn(f.on_after_popup_filter_open) ? f.on_after_popup_filter_open : null;
//callback function before popup filtes is closed
this.onBeforePopUpClose = Types.isFn(f.on_before_popup_filter_close) ? f.on_before_popup_filter_close : null;
//callback function after popup filtes is closed
this.onAfterPopUpClose = Types.isFn(f.on_after_popup_filter_close) ? f.on_after_popup_filter_close : null;
var PopupFilter = exports.PopupFilter = (function () {
//stores filters spans
this.popUpFltSpans = [];
//stores filters icons
this.popUpFltImgs = [];
//stores filters containers
this.popUpFltElms = this.popUpFltElmCache || [];
this.popUpFltAdjustToContainer = true;
/**
* Pop-up filter component
* @param {Object} tf TableFilter instance
*/
this.tf = tf;
};
function PopupFilter(tf) {
_classCallCheck(this, PopupFilter);
_classProps(PopupFilter, null, {
onClick: {
writable: true,
value: function (e) {
var evt = e || global.event, elm = evt.target.parentNode, colIndex = parseInt(elm.getAttribute("ci"), 10);
// Configuration object
var f = tf.config();
this.closeAll(colIndex);
this.toggle(colIndex);
// Enable external filters behaviour
tf.isExternalFlt = true;
tf.externalFltTgtIds = [];
if (this.popUpFltAdjustToContainer) {
var popUpDiv = this.popUpFltElms[colIndex], header = this.tf.getHeaderElement(colIndex), headerWidth = header.clientWidth * 0.95;
if (Helpers.isIE()) {
var headerLeft = Dom.position(header).left;
popUpDiv.style.left = (headerLeft) + "px";
}
popUpDiv.style.width = parseInt(headerWidth, 10) + "px";
}
Event.cancel(evt);
Event.stop(evt);
//filter icon path
this.popUpImgFlt = f.popup_filters_image || tf.themesPath + "icn_filter.gif";
//active filter icon path
this.popUpImgFltActive = f.popup_filters_image_active || tf.themesPath + "icn_filterActive.gif";
this.popUpImgFltHtml = f.popup_filters_image_html || "<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
this.onBeforePopUpOpen = Types.isFn(f.on_before_popup_filter_open) ? f.on_before_popup_filter_open : null;
//callback function after popup filtes is opened
this.onAfterPopUpOpen = Types.isFn(f.on_after_popup_filter_open) ? f.on_after_popup_filter_open : null;
//callback function before popup filtes is closed
this.onBeforePopUpClose = Types.isFn(f.on_before_popup_filter_close) ? f.on_before_popup_filter_close : null;
//callback function after popup filtes is closed
this.onAfterPopUpClose = Types.isFn(f.on_after_popup_filter_close) ? f.on_after_popup_filter_close : null;
//stores filters spans
this.popUpFltSpans = [];
//stores filters icons
this.popUpFltImgs = [];
//stores filters containers
this.popUpFltElms = this.popUpFltElmCache || [];
this.popUpFltAdjustToContainer = true;
this.tf = tf;
}
},
init: {
writable: true,
value: function () {
var _this = this;
var tf = this.tf;
for (var i = 0; i < tf.nbCells; i++) {
if (tf["col" + i] === tf.fltTypeNone) {
continue;
}
var popUpSpan = Dom.create("span", ["id", tf.prfxPopUpSpan + tf.id + "_" + i], ["ci", i]);
popUpSpan.innerHTML = this.popUpImgFltHtml;
var header = tf.getHeaderElement(i);
header.appendChild(popUpSpan);
Event.add(popUpSpan, "click", function (evt) {
_this.onClick(evt);
});
this.popUpFltSpans[i] = popUpSpan;
this.popUpFltImgs[i] = popUpSpan.firstChild;
}
}
},
buildAll: {
writable: true,
value: function () {
for (var i = 0; i < this.popUpFltElmCache.length; i++) {
this.build(i, this.popUpFltElmCache[i]);
}
}
},
build: {
writable: true,
value: function (colIndex, div) {
var tf = this.tf;
var popUpDiv = !div ? Dom.create("div", ["id", tf.prfxPopUpDiv + tf.id + "_" + colIndex]) : div;
popUpDiv.className = this.popUpDivCssClass;
tf.externalFltTgtIds.push(popUpDiv.id);
var header = tf.getHeaderElement(colIndex);
header.insertBefore(popUpDiv, header.firstChild);
Event.add(popUpDiv, "click", function (evt) {
Event.stop(evt);
});
this.popUpFltElms[colIndex] = popUpDiv;
}
},
toggle: {
writable: true,
value: function (colIndex) {
var tf = this.tf, popUpFltElm = this.popUpFltElms[colIndex];
if (popUpFltElm.style.display === "none" || popUpFltElm.style.display === "") {
if (this.onBeforePopUpOpen) {
this.onBeforePopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex);
_prototypeProperties(PopupFilter, null, {
onClick: {
value: function onClick(e) {
var evt = e || global.event,
elm = evt.target.parentNode,
colIndex = parseInt(elm.getAttribute("ci"), 10);
this.closeAll(colIndex);
this.toggle(colIndex);
if (this.popUpFltAdjustToContainer) {
var popUpDiv = this.popUpFltElms[colIndex],
header = this.tf.getHeaderElement(colIndex),
headerWidth = header.clientWidth * 0.95;
if (Helpers.isIE()) {
var headerLeft = Dom.position(header).left;
popUpDiv.style.left = headerLeft + "px";
}
popUpDiv.style.width = parseInt(headerWidth, 10) + "px";
}
Event.cancel(evt);
Event.stop(evt);
},
writable: true,
configurable: true
},
init: {
/**
* Initialize DOM elements
*/
value: function init() {
var _this = this;
var tf = this.tf;
for (var i = 0; i < tf.nbCells; i++) {
if (tf["col" + i] === tf.fltTypeNone) {
continue;
}
var popUpSpan = Dom.create("span", ["id", tf.prfxPopUpSpan + tf.id + "_" + i], ["ci", i]);
popUpSpan.innerHTML = this.popUpImgFltHtml;
var header = tf.getHeaderElement(i);
header.appendChild(popUpSpan);
Event.add(popUpSpan, "click", function (evt) {
_this.onClick(evt);
});
this.popUpFltSpans[i] = popUpSpan;
this.popUpFltImgs[i] = popUpSpan.firstChild;
}
},
writable: true,
configurable: true
},
buildAll: {
/**
* Build all pop-up filters elements
*/
value: function buildAll() {
for (var i = 0; i < this.popUpFltElmCache.length; i++) {
this.build(i, this.popUpFltElmCache[i]);
}
},
writable: true,
configurable: true
},
build: {
/**
* Build a specified pop-up filter elements
* @param {Number} colIndex Column index
* @param {Object} div Optional container DOM element
*/
value: function build(colIndex, div) {
var tf = this.tf;
var popUpDiv = !div ? Dom.create("div", ["id", tf.prfxPopUpDiv + tf.id + "_" + colIndex]) : div;
popUpDiv.className = this.popUpDivCssClass;
tf.externalFltTgtIds.push(popUpDiv.id);
var header = tf.getHeaderElement(colIndex);
header.insertBefore(popUpDiv, header.firstChild);
Event.add(popUpDiv, "click", function (evt) {
Event.stop(evt);
});
this.popUpFltElms[colIndex] = popUpDiv;
},
writable: true,
configurable: true
},
toggle: {
/**
* Toogle visibility of specified filter
* @param {Number} colIndex Column index
*/
value: function toggle(colIndex) {
var tf = this.tf,
popUpFltElm = this.popUpFltElms[colIndex];
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["col" + colIndex] === tf.fltTypeInp) {
tf.GetFilterElement(colIndex).focus();
}
if (this.onAfterPopUpOpen) {
this.onAfterPopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex);
}
} else {
if (this.onBeforePopUpClose) {
this.onBeforePopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex);
}
popUpFltElm.style.display = "none";
if (this.onAfterPopUpClose) {
this.onAfterPopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex);
}
}
},
writable: true,
configurable: true
},
closeAll: {
/**
* Close all filters excepted for the specified one if any
* @param {Number} exceptIdx Column index of the filter to not close
*/
value: function closeAll(exceptIdx) {
for (var i = 0; i < this.popUpFltElms.length; i++) {
if (i === exceptIdx) {
continue;
}
var popUpFltElm = this.popUpFltElms[i];
if (popUpFltElm) {
popUpFltElm.style.display = "none";
}
}
},
writable: true,
configurable: true
},
buildIcons: {
/**
* Build all the icons representing the pop-up filters
*/
value: function buildIcons() {
for (var i = 0; i < this.popUpFltImgs.length; i++) {
this.buildIcon(i, false);
}
},
writable: true,
configurable: true
},
buildIcon: {
/**
* Build specified icon
* @param {Number} colIndex Column index
* @param {Boolean} active Apply active state
*/
value: function buildIcon(colIndex, active) {
var activeImg = Types.isUndef(active) ? true : active;
if (this.popUpFltImgs[colIndex]) {
this.popUpFltImgs[colIndex].src = active ? this.popUpImgFltActive : this.popUpImgFlt;
}
},
writable: true,
configurable: true
},
destroy: {
/**
* Remove pop-up filters
*/
value: function destroy() {
this.popUpFltElmCache = [];
for (var i = 0; i < this.popUpFltElms.length; i++) {
var popUpFltElm = this.popUpFltElms[i],
popUpFltSpan = this.popUpFltSpans[i],
popUpFltImg = this.popUpFltImgs[i];
if (popUpFltElm) {
popUpFltElm.parentNode.removeChild(popUpFltElm);
this.popUpFltElmCache[i] = popUpFltElm;
}
popUpFltElm = null;
if (popUpFltSpan) {
popUpFltSpan.parentNode.removeChild(popUpFltSpan);
}
popUpFltSpan = null;
if (popUpFltImg) {
popUpFltImg.parentNode.removeChild(popUpFltImg);
}
popUpFltImg = null;
}
this.popUpFltElms = [];
this.popUpFltSpans = [];
this.popUpFltImgs = [];
},
writable: true,
configurable: true
}
popUpFltElm.style.display = "block";
if (tf["col" + colIndex] === tf.fltTypeInp) {
tf.GetFilterElement(colIndex).focus();
}
if (this.onAfterPopUpOpen) {
this.onAfterPopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex);
}
} else {
if (this.onBeforePopUpClose) {
this.onBeforePopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex);
}
popUpFltElm.style.display = "none";
if (this.onAfterPopUpClose) {
this.onAfterPopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex);
}
}
}
},
closeAll: {
writable: true,
value: function (exceptIdx) {
for (var i = 0; i < this.popUpFltElms.length; i++) {
if (i === exceptIdx) {
continue;
}
var popUpFltElm = this.popUpFltElms[i];
if (popUpFltElm) {
popUpFltElm.style.display = "none";
}
}
}
},
buildIcons: {
writable: true,
value: function () {
for (var i = 0; i < this.popUpFltImgs.length; i++) {
this.buildIcon(i, false);
}
}
},
buildIcon: {
writable: true,
value: function (colIndex, active) {
var activeImg = Types.isUndef(active) ? true : active;
if (this.popUpFltImgs[colIndex]) {
this.popUpFltImgs[colIndex].src = active ? this.popUpImgFltActive : this.popUpImgFlt;
}
}
},
destroy: {
writable: true,
value: function () {
this.popUpFltElmCache = [];
for (var i = 0; i < this.popUpFltElms.length; i++) {
var popUpFltElm = this.popUpFltElms[i], popUpFltSpan = this.popUpFltSpans[i], popUpFltImg = this.popUpFltImgs[i];
if (popUpFltElm) {
popUpFltElm.parentNode.removeChild(popUpFltElm);
this.popUpFltElmCache[i] = popUpFltElm;
}
popUpFltElm = null;
if (popUpFltSpan) {
popUpFltSpan.parentNode.removeChild(popUpFltSpan);
}
popUpFltSpan = null;
if (popUpFltImg) {
popUpFltImg.parentNode.removeChild(popUpFltImg);
}
popUpFltImg = null;
}
this.popUpFltElms = [];
this.popUpFltSpans = [];
this.popUpFltImgs = [];
}
}
});
return PopupFilter;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return PopupFilter;
})();
exports.PopupFilter = PopupFilter;
});
});
//# sourceMappingURL=popupFilter.js.map

View file

@ -1,147 +1,161 @@
define(["exports", "../dom", "../types", "../helpers"], function (exports, _dom, _types, _helpers) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Types = _types.Types;
var Helpers = _helpers.Helpers;
var RowsCounter = (function () {
var RowsCounter = function RowsCounter(tf) {
// TableFilter configuration
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
//id of custom container element
this.rowsCounterTgtId = f.rows_counter_target_id || null;
//element containing tot nb rows
this.rowsCounterDiv = null;
//element containing tot nb rows label
this.rowsCounterSpan = null;
//defines rows counter text
this.rowsCounterText = f.rows_counter_text || "Rows: ";
this.fromToTextSeparator = f.from_to_text_separator || "-";
this.overText = f.over_text || " / ";
//defines css class rows counter
this.totRowsCssClass = f.tot_rows_css_class || "tot";
//callback raised before counter is refreshed
this.onBeforeRefreshCounter = Types.isFn(f.on_before_refresh_counter) ? f.on_before_refresh_counter : null;
//callback raised after counter is refreshed
this.onAfterRefreshCounter = Types.isFn(f.on_after_refresh_counter) ? f.on_after_refresh_counter : null;
var Dom = _dom.Dom;
var Types = _types.Types;
var Helpers = _helpers.Helpers;
this.tf = tf;
};
var RowsCounter = exports.RowsCounter = (function () {
_classProps(RowsCounter, null, {
init: {
writable: true,
value: function () {
var tf = this.tf;
/**
* Rows counter
* @param {Object} tf TableFilter instance
*/
if ((!tf.hasGrid() && !tf.isFirstLoad) || this.rowsCounterSpan) {
return;
}
function RowsCounter(tf) {
_classCallCheck(this, RowsCounter);
//rows counter container
var countDiv = Dom.create("div", ["id", tf.prfxCounter + tf.id]);
countDiv.className = this.totRowsCssClass;
//rows counter label
var countSpan = Dom.create("span", ["id", tf.prfxTotRows + tf.id]);
var countText = Dom.create("span", ["id", tf.prfxTotRowsTxt + tf.id]);
countText.appendChild(Dom.text(this.rowsCounterText));
// TableFilter configuration
var f = tf.config();
// counter is added to defined element
if (!this.rowsCounterTgtId) {
tf.setToolbar();
}
var targetEl = !this.rowsCounterTgtId ? tf.lDiv : Dom.id(this.rowsCounterTgtId);
//id of custom container element
this.rowsCounterTgtId = f.rows_counter_target_id || null;
//element containing tot nb rows
this.rowsCounterDiv = null;
//element containing tot nb rows label
this.rowsCounterSpan = null;
//defines rows counter text
this.rowsCounterText = f.rows_counter_text || "Rows: ";
this.fromToTextSeparator = f.from_to_text_separator || "-";
this.overText = f.over_text || " / ";
//defines css class rows counter
this.totRowsCssClass = f.tot_rows_css_class || "tot";
//callback raised before counter is refreshed
this.onBeforeRefreshCounter = Types.isFn(f.on_before_refresh_counter) ? f.on_before_refresh_counter : null;
//callback raised after counter is refreshed
this.onAfterRefreshCounter = Types.isFn(f.on_after_refresh_counter) ? f.on_after_refresh_counter : null;
//IE only: clears all for sure
if (this.rowsCounterDiv && Helpers.isIE()) {
this.rowsCounterDiv.outerHTML = "";
}
//default container: 'lDiv'
if (!this.rowsCounterTgtId) {
countDiv.appendChild(countText);
countDiv.appendChild(countSpan);
targetEl.appendChild(countDiv);
} else {
//custom container, no need to append statusDiv
targetEl.appendChild(countText);
targetEl.appendChild(countSpan);
}
this.rowsCounterDiv = countDiv;
this.rowsCounterSpan = countSpan;
this.refresh();
this.tf = tf;
}
},
refresh: {
writable: true,
value: function (p) {
if (!this.rowsCounterSpan) {
return;
}
var tf = this.tf;
_prototypeProperties(RowsCounter, null, {
init: {
value: function init() {
var tf = this.tf;
if (this.onBeforeRefreshCounter) {
this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan);
}
if (!tf.hasGrid() && !tf.isFirstLoad || this.rowsCounterSpan) {
return;
}
var totTxt;
if (!tf.paging) {
if (p && p !== "") {
totTxt = p;
} else {
totTxt = tf.nbFilterableRows - tf.nbHiddenRows - (tf.hasVisibleRows ? tf.visibleRows.length : 0);
//rows counter container
var countDiv = Dom.create("div", ["id", tf.prfxCounter + tf.id]);
countDiv.className = this.totRowsCssClass;
//rows counter label
var countSpan = Dom.create("span", ["id", tf.prfxTotRows + tf.id]);
var countText = Dom.create("span", ["id", tf.prfxTotRowsTxt + tf.id]);
countText.appendChild(Dom.text(this.rowsCounterText));
// counter is added to defined element
if (!this.rowsCounterTgtId) {
tf.setToolbar();
}
var targetEl = !this.rowsCounterTgtId ? tf.lDiv : Dom.id(this.rowsCounterTgtId);
//IE only: clears all for sure
if (this.rowsCounterDiv && Helpers.isIE()) {
this.rowsCounterDiv.outerHTML = "";
}
//default container: 'lDiv'
if (!this.rowsCounterTgtId) {
countDiv.appendChild(countText);
countDiv.appendChild(countSpan);
targetEl.appendChild(countDiv);
} else {
//custom container, no need to append statusDiv
targetEl.appendChild(countText);
targetEl.appendChild(countSpan);
}
this.rowsCounterDiv = countDiv;
this.rowsCounterSpan = countSpan;
this.refresh();
},
writable: true,
configurable: true
},
refresh: {
value: function refresh(p) {
if (!this.rowsCounterSpan) {
return;
}
var tf = this.tf;
if (this.onBeforeRefreshCounter) {
this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan);
}
var totTxt;
if (!tf.paging) {
if (p && p !== "") {
totTxt = p;
} else {
totTxt = tf.nbFilterableRows - tf.nbHiddenRows - (tf.hasVisibleRows ? tf.visibleRows.length : 0);
}
} else {
var paging = tf.Cpt.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;
totTxt = paging_start_row + this.fromToTextSeparator + paging_end_row + this.overText + tf.nbVisibleRows;
}
}
this.rowsCounterSpan.innerHTML = totTxt;
if (this.onAfterRefreshCounter) {
this.onAfterRefreshCounter.call(null, tf, this.rowsCounterSpan, totTxt);
}
},
writable: true,
configurable: true
},
destroy: {
value: function destroy() {
var tf = this.tf;
if (!tf.hasGrid()) {
return;
}
if (!this.rowsCounterSpan) {
return;
}
if (!this.rowsCounterTgtId && this.rowsCounterDiv) {
//IE only: clears all for sure
if (Helpers.isIE()) {
this.rowsCounterDiv.outerHTML = "";
} else {
this.rowsCounterDiv.parentNode.removeChild(this.rowsCounterDiv);
}
} else {
Dom.id(this.rowsCounterTgtId).innerHTML = "";
}
this.rowsCounterSpan = null;
this.rowsCounterDiv = null;
},
writable: true,
configurable: true
}
} else {
var paging = tf.Cpt.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;
totTxt = paging_start_row + this.fromToTextSeparator + paging_end_row + this.overText + tf.nbVisibleRows;
}
}
this.rowsCounterSpan.innerHTML = totTxt;
if (this.onAfterRefreshCounter) {
this.onAfterRefreshCounter.call(null, tf, this.rowsCounterSpan, totTxt);
}
}
},
destroy: {
writable: true,
value: function () {
var tf = this.tf;
if (!tf.hasGrid()) {
return;
}
if (!this.rowsCounterSpan) {
return;
}
});
if (!this.rowsCounterTgtId && this.rowsCounterDiv) {
//IE only: clears all for sure
if (Helpers.isIE()) {
this.rowsCounterDiv.outerHTML = "";
} else {
this.rowsCounterDiv.parentNode.removeChild(this.rowsCounterDiv);
}
} else {
Dom.id(this.rowsCounterTgtId).innerHTML = "";
}
this.rowsCounterSpan = null;
this.rowsCounterDiv = null;
}
}
return RowsCounter;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return RowsCounter;
})();
exports.RowsCounter = RowsCounter;
});
});
//# sourceMappingURL=rowsCounter.js.map

View file

@ -1,134 +1,148 @@
define(["exports", "../dom", "../event", "../types", "../helpers"], function (exports, _dom, _event, _types, _helpers) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Dom = _dom.Dom;
var Event = _event.Event;
var Types = _types.Types;
var Helpers = _helpers.Helpers;
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Dom = _dom.Dom;
var Event = _event.Event;
var Types = _types.Types;
var Helpers = _helpers.Helpers;
var global = window;
var global = window;
var StatusBar = (function () {
var StatusBar = function StatusBar(tf) {
// Configuration object
var f = tf.config();
var StatusBar = exports.StatusBar = (function () {
//id of custom container element
this.statusBarTgtId = f.status_bar_target_id || null;
//element containing status bar label
this.statusBarDiv = null;
//status bar
this.statusBarSpan = null;
//status bar label
this.statusBarSpanText = null;
//defines status bar text
this.statusBarText = f.status_bar_text || "";
//defines css class status bar
this.statusBarCssClass = f.status_bar_css_class || "status";
//delay for status bar clearing
this.statusBarCloseDelay = 250;
/**
* Status bar UI component
* @param {Object} tf TableFilter instance
*/
//calls function before message is displayed
this.onBeforeShowMsg = Types.isFn(f.on_before_show_msg) ? f.on_before_show_msg : null;
//calls function after message is displayed
this.onAfterShowMsg = Types.isFn(f.on_after_show_msg) ? f.on_after_show_msg : null;
function StatusBar(tf) {
_classCallCheck(this, StatusBar);
this.tf = tf;
};
// Configuration object
var f = tf.config();
_classProps(StatusBar, null, {
init: {
writable: true,
value: function () {
var tf = this.tf;
if (!tf.hasGrid() && !tf.isFirstLoad) {
return;
}
//id of custom container element
this.statusBarTgtId = f.status_bar_target_id || null;
//element containing status bar label
this.statusBarDiv = null;
//status bar
this.statusBarSpan = null;
//status bar label
this.statusBarSpanText = null;
//defines status bar text
this.statusBarText = f.status_bar_text || "";
//defines css class status bar
this.statusBarCssClass = f.status_bar_css_class || "status";
//delay for status bar clearing
this.statusBarCloseDelay = 250;
//status bar container
var statusDiv = Dom.create("div", ["id", tf.prfxStatus + tf.id]);
statusDiv.className = this.statusBarCssClass;
//calls function before message is displayed
this.onBeforeShowMsg = Types.isFn(f.on_before_show_msg) ? f.on_before_show_msg : null;
//calls function after message is displayed
this.onAfterShowMsg = Types.isFn(f.on_after_show_msg) ? f.on_after_show_msg : null;
//status bar label
var statusSpan = Dom.create("span", ["id", tf.prfxStatusSpan + tf.id]);
//preceding text
var statusSpanText = Dom.create("span", ["id", tf.prfxStatusTxt + tf.id]);
statusSpanText.appendChild(Dom.text(this.statusBarText));
// target element container
if (!this.statusBarTgtId) {
tf.setToolbar();
}
var targetEl = (!this.statusBarTgtId) ? tf.lDiv : Dom.id(this.statusBarTgtId);
// TODO: use alternative to outerHTML
if (this.statusBarDiv && Helpers.isIE()) {
this.statusBarDiv.outerHTML = "";
}
//default container: 'lDiv'
if (!this.statusBarTgtId) {
statusDiv.appendChild(statusSpanText);
statusDiv.appendChild(statusSpan);
targetEl.appendChild(statusDiv);
} else {
// custom container, no need to append statusDiv
targetEl.appendChild(statusSpanText);
targetEl.appendChild(statusSpan);
}
this.statusBarDiv = statusDiv;
this.statusBarSpan = statusSpan;
this.statusBarSpanText = statusSpanText;
this.tf = tf;
}
},
message: {
writable: true,
value: function (t) {
var _this = this;
if (t === undefined) t = "";
var tf = this.tf;
if (!tf.statusBar || !this.statusBarSpan) {
return;
}
if (this.onBeforeShowMsg) {
this.onBeforeShowMsg.call(null, this.tf, t);
}
var d = t === "" ? this.statusBarCloseDelay : 1;
global.setTimeout(function () {
_this.statusBarSpan.innerHTML = t;
if (_this.onAfterShowMsg) {
_this.onAfterShowMsg.call(null, _this.tf, t);
_prototypeProperties(StatusBar, null, {
init: {
value: function init() {
var tf = this.tf;
if (!tf.hasGrid() && !tf.isFirstLoad) {
return;
}
//status bar container
var statusDiv = Dom.create("div", ["id", tf.prfxStatus + tf.id]);
statusDiv.className = this.statusBarCssClass;
//status bar label
var statusSpan = Dom.create("span", ["id", tf.prfxStatusSpan + tf.id]);
//preceding text
var statusSpanText = Dom.create("span", ["id", tf.prfxStatusTxt + tf.id]);
statusSpanText.appendChild(Dom.text(this.statusBarText));
// target element container
if (!this.statusBarTgtId) {
tf.setToolbar();
}
var targetEl = !this.statusBarTgtId ? tf.lDiv : Dom.id(this.statusBarTgtId);
// TODO: use alternative to outerHTML
if (this.statusBarDiv && Helpers.isIE()) {
this.statusBarDiv.outerHTML = "";
}
//default container: 'lDiv'
if (!this.statusBarTgtId) {
statusDiv.appendChild(statusSpanText);
statusDiv.appendChild(statusSpan);
targetEl.appendChild(statusDiv);
} else {
// custom container, no need to append statusDiv
targetEl.appendChild(statusSpanText);
targetEl.appendChild(statusSpan);
}
this.statusBarDiv = statusDiv;
this.statusBarSpan = statusSpan;
this.statusBarSpanText = statusSpanText;
},
writable: true,
configurable: true
},
message: {
value: function message() {
var _this = this;
var t = arguments[0] === undefined ? "" : arguments[0];
var tf = this.tf;
if (!tf.statusBar || !this.statusBarSpan) {
return;
}
if (this.onBeforeShowMsg) {
this.onBeforeShowMsg.call(null, this.tf, t);
}
var d = t === "" ? this.statusBarCloseDelay : 1;
global.setTimeout(function () {
_this.statusBarSpan.innerHTML = t;
if (_this.onAfterShowMsg) {
_this.onAfterShowMsg.call(null, _this.tf, t);
}
}, d);
},
writable: true,
configurable: true
},
destroy: {
value: function destroy() {
var tf = this.tf;
if (!tf.hasGrid() || !this.statusBarDiv) {
return;
}
this.statusBarDiv.innerHTML = "";
this.statusBarDiv.parentNode.removeChild(this.statusBarDiv);
this.statusBarSpan = null;
this.statusBarSpanText = null;
this.statusBarDiv = null;
},
writable: true,
configurable: true
}
}, d);
}
},
destroy: {
writable: true,
value: function () {
var tf = this.tf;
if (!tf.hasGrid() || !this.statusBarDiv) {
return;
}
});
this.statusBarDiv.innerHTML = "";
this.statusBarDiv.parentNode.removeChild(this.statusBarDiv);
this.statusBarSpan = null;
this.statusBarSpanText = null;
this.statusBarDiv = null;
}
}
return StatusBar;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return StatusBar;
})();
exports.StatusBar = StatusBar;
});
});
//# sourceMappingURL=statusBar.js.map

View file

@ -1,79 +1,135 @@
define(["exports", "../cookie"], function (exports, _cookie) {
"use strict";
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var Cookie = _cookie.Cookie;
var Store = (function () {
var Store = function Store(tf) {
var f = tf.config();
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
this.duration = !isNaN(f.set_cookie_duration) ? parseInt(f.set_cookie_duration, 10) : 100000;
var Cookie = _cookie.Cookie;
this.tf = tf;
};
var Store = exports.Store = (function () {
_classProps(Store, null, {
saveFilterValues: {
writable: true,
value: function (name) {
var tf = this.tf;
var fltValues = [];
//store filters' values
for (var i = 0; i < tf.fltIds.length; i++) {
var value = tf.getFilterValue(i);
if (value === "") {
value = " ";
/**
* Store, persistence manager
* @param {Object} tf TableFilter instance
*/
function Store(tf) {
_classCallCheck(this, Store);
var f = tf.config();
this.duration = !isNaN(f.set_cookie_duration) ? parseInt(f.set_cookie_duration, 10) : 100000;
this.tf = tf;
}
_prototypeProperties(Store, null, {
saveFilterValues: {
/**
* Store filters' values in cookie
* @param {String} cookie name
*/
value: function saveFilterValues(name) {
var tf = this.tf;
var fltValues = [];
//store filters' values
for (var i = 0; i < tf.fltIds.length; i++) {
var value = tf.getFilterValue(i);
if (value === "") {
value = " ";
}
fltValues.push(value);
}
//adds array size
fltValues.push(tf.fltIds.length);
//writes cookie
Cookie.write(name, fltValues.join(tf.separator), this.duration);
},
writable: true,
configurable: true
},
getFilterValues: {
/**
* Retrieve filters' values from cookie
* @param {String} cookie name
* @return {Array}
*/
value: function getFilterValues(name) {
var flts = Cookie.read(name);
var rgx = new RegExp(this.tf.separator, "g");
// filters' values array
return flts.split(rgx);
},
writable: true,
configurable: true
},
savePageNb: {
/**
* Store page number in cookie
* @param {String} cookie name
*/
value: function savePageNb(name) {
Cookie.write(name, this.tf.Cpt.paging.currentPageNb, this.duration);
},
writable: true,
configurable: true
},
getPageNb: {
/**
* Retrieve page number from cookie
* @param {String} cookie name
* @return {String}
*/
value: function getPageNb(name) {
return Cookie.read(name);
},
writable: true,
configurable: true
},
savePageLength: {
/**
* Store page length in cookie
* @param {String} cookie name
*/
value: function savePageLength(name) {
Cookie.write(name, this.tf.Cpt.paging.resultsPerPageSlc.selectedIndex, this.duration);
},
writable: true,
configurable: true
},
getPageLength: {
/**
* Retrieve page length from cookie
* @param {String} cookie name
* @return {String}
*/
value: function getPageLength(name) {
return Cookie.read(name);
},
writable: true,
configurable: true
}
fltValues.push(value);
}
//adds array size
fltValues.push(tf.fltIds.length);
});
//writes cookie
Cookie.write(name, fltValues.join(tf.separator), this.duration);
}
},
getFilterValues: {
writable: true,
value: function (name) {
var flts = Cookie.read(name);
var rgx = new RegExp(this.tf.separator, "g");
// filters' values array
return flts.split(rgx);
}
},
savePageNb: {
writable: true,
value: function (name) {
Cookie.write(name, this.tf.Cpt.paging.currentPageNb, this.duration);
}
},
getPageNb: {
writable: true,
value: function (name) {
return Cookie.read(name);
}
},
savePageLength: {
writable: true,
value: function (name) {
Cookie.write(name, this.tf.Cpt.paging.resultsPerPageSlc.selectedIndex, this.duration);
}
},
getPageLength: {
writable: true,
value: function (name) {
return Cookie.read(name);
}
}
return Store;
})();
Object.defineProperty(exports, "__esModule", {
value: true
});
return Store;
})();
exports.Store = Store;
});
});
//# sourceMappingURL=store.js.map

View file

@ -1,16 +1,20 @@
define(["exports", "string"], function (exports, _string) {
"use strict";
/**
* Sort helpers
*/
var Str = _string.Str;
var Sort = {
ignoreCase: function (a, b) {
ignoreCase: function ignoreCase(a, b) {
var x = Str.lower(a);
var y = Str.lower(b);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
return x < y ? -1 : x > y ? 1 : 0;
}
};
exports.Sort = Sort;
});
});
//# sourceMappingURL=sort.js.map

View file

@ -1,50 +1,51 @@
define(["exports"], function (exports) {
"use strict";
"use strict";
/**
* String utilities
*/
/**
* String utilities
*/
var Str = {};
var Str = {};
Str.lower = function (text) {
return text.toLowerCase();
};
Str.lower = function (text) {
return text.toLowerCase();
};
Str.upper = function (text) {
return text.toUpperCase();
};
Str.upper = function (text) {
return text.toUpperCase();
};
Str.trim = function (text) {
if (text.trim) {
return text.trim();
}
return text.replace(/^\s*|\s*$/g, "");
};
Str.trim = function (text) {
if (text.trim) {
return text.trim();
}
return text.replace(/^\s*|\s*$/g, "");
};
Str.isEmpty = function (text) {
return this.trim(text) === "";
};
Str.isEmpty = function (text) {
return this.trim(text) === "";
};
Str.rgxEsc = function (text) {
function escape(e) {
var a = new RegExp("\\" + e, "g");
text = text.replace(a, "\\" + e);
}
Str.rgxEsc = function (text) {
function escape(e) {
var a = new RegExp("\\" + e, "g");
text = text.replace(a, "\\" + e);
}
var chars = ["\\", "[", "^", "$", ".", "|", "?", "*", "+", "(", ")"];
for (var e = 0; e < chars.length; e++) {
escape(chars[e]);
}
return text;
};
var chars = ["\\", "[", "^", "$", ".", "|", "?", "*", "+", "(", ")"];
for (var e = 0; e < chars.length; e++) {
escape(chars[e]);
}
return text;
};
Str.matchCase = function (text, mc) {
if (!mc) {
return this.lower(text);
}
return text;
};
Str.matchCase = function (text, mc) {
if (!mc) {
return this.lower(text);
}
return text;
};
exports.Str = Str;
});
exports.Str = Str;
});
//# sourceMappingURL=string.js.map

View file

@ -1,59 +1,60 @@
define(["exports"], function (exports) {
"use strict";
"use strict";
/**
* Types utilities
*/
/**
* Types utilities
*/
var Types = {};
var Types = {};
var UNDEFINED = void 0;
var UNDEFINED = void 0;
/**
* Checks if var exists and is an object
* @param {String or Object} v
* @return {Boolean}
*/
Types.isObj = function (v) {
var isO = false;
if (typeof v === "string") {
if (window[v] && typeof window[v] === "object") {
isO = true;
}
} else {
if (v && typeof v === "object") {
isO = true;
}
}
return isO;
};
/**
* Checks if var exists and is an object
* @param {String or Object} v
* @return {Boolean}
*/
Types.isObj = function (v) {
var isO = false;
if (typeof v === "string") {
if (window[v] && typeof window[v] === "object") {
isO = true;
}
} else {
if (v && typeof v === "object") {
isO = true;
}
}
return isO;
};
/**
* Checks if passed parameter is a function
* @param {Function} fn
* @return {Boolean}
*/
Types.isFn = function (fn) {
return (fn && fn.constructor == Function);
};
/**
* Checks if passed parameter is a function
* @param {Function} fn
* @return {Boolean}
*/
Types.isFn = function (fn) {
return fn && fn.constructor == Function;
};
/**
* Checks if passed param is an array
* @param {Array} obj
* @return {Boolean}
*/
Types.isArray = function (obj) {
return (obj && obj.constructor == Array);
};
/**
* Checks if passed param is an array
* @param {Array} obj
* @return {Boolean}
*/
Types.isArray = function (obj) {
return obj && obj.constructor == Array;
};
/**
* Determines if passed param is undefined
* @param {Any} o
* @return {Boolean}
*/
Types.isUndef = function (o) {
return o === UNDEFINED;
};
/**
* Determines if passed param is undefined
* @param {Any} o
* @return {Boolean}
*/
Types.isUndef = function (o) {
return o === UNDEFINED;
};
exports.Types = Types;
});
exports.Types = Types;
});
//# sourceMappingURL=types.js.map

View file

@ -5,7 +5,8 @@ requirejs(['test-config', '../src/core'], function(config, TableFilter){
var GridLayout = require('modules/gridLayout').GridLayout;
var tf = new TableFilter('demo', {
grid_layout: true
grid_layout: true,
sort: false
});
tf.init();