1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-01 22:32:49 +02:00

Clean gruntfile and build steps

This commit is contained in:
Max Guglielmi 2015-05-14 20:08:19 +10:00
parent 75090d7053
commit eef326e6b0
154 changed files with 761 additions and 27308 deletions

3
.gitignore vendored
View file

@ -1,7 +1,6 @@
node_modules
npm-debug.log
src/extensions/ezEditTable
dist/extensions/ezEditTable
build
*.js.map
.codio
.settings

View file

@ -1,8 +1,9 @@
module.exports = function (grunt) {
var webpack = require("webpack");
// var webpackConfig = require("./webpack.config.js");
var path = require("path");
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');
var pkg = grunt.file.readJSON('package.json');
var version = pkg.version;
grunt.initConfig({
@ -20,22 +21,39 @@ module.exports = function (grunt) {
files: ['test/**/*.html']
},
"webpack-dev-server": {
copy: {
build: {
src: ['**'],
cwd: 'static/style',
dest: 'build/tablefilter',
expand: true
},
dist: {
src: ['**'],
cwd: 'static/style',
dest: 'dist/tablefilter',
expand: true
}
},
'webpack-dev-server': {
options: {
webpack: webpack.dev,
publicPath: "/src/"
publicPath: '/dev/'
},
start: {
keepAlive: true,
webpack: {
devtool: "eval",
devtool: 'eval',
debug: true
}
}
},
webpack: {
// "dev": {
dist: webpackConfig.dist,
build: webpackConfig.build
// 'dev': {
// entry: __dirname + '/src-es6/tablefilter.js',
// // entry: {
// // tablefilter: __dirname + '/src-es6/tablefilter.js',
@ -43,10 +61,10 @@ module.exports = function (grunt) {
// // '/src-es6/extensions/colsVisibility/colsVisibility.js'
// // },
// output: {
// publicPath: "/src/",
// path: __dirname + "/src",
// filename: "tablefilter.js",
// chunkFilename: "[name].js",
// publicPath: '/src/',
// path: __dirname + '/src',
// filename: 'tablefilter.js',
// chunkFilename: '[name].js',
// libraryTarget: 'umd'
// },
// resolve: {
@ -62,60 +80,9 @@ module.exports = function (grunt) {
// loader: 'babel-loader'
// }]
// },
// devtool: "sourcemap",
// devtool: 'sourcemap',
// debug: true
// },
"build": {
entry: __dirname + '/src-es6/tablefilter.js',
// entry: {
// tablefilter: __dirname + '/src-es6/tablefilter.js',
// sortabletable: __dirname + '/libs/sortabletable.js'
// },
output: {
publicPath: "/dist/",
path: __dirname + "/dist",
filename: "tablefilter.js",
// chunkFilename: "[name]-[chunkhash].js",
chunkFilename: "[name].js",
libraryTarget: 'umd'
},
resolve: {
extensions: ['', '.js'],
alias: {
sortabletable: "../../../libs/sortabletable.js"
// ,
// adapterSortabletable:
// './extensions/sortabletable/adapterSortabletable'
}
},
// externals: {
// 'sortabletable': "SortableTable"
// },
module: {
loaders: [{
test: path.join(__dirname, 'src-es6'),
exclude: /node_modules/,
query: {
compact: false
},
loader: 'babel-loader'
}]
},
plugins: [
// new webpack.DefinePlugin({
// "process.env": {
// // This has effect on the react lib size
// "NODE_ENV": JSON.stringify("production")
// }
// }),
// new webpack.IgnorePlugin(/adapterSortabletable$/),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.MinChunkSizePlugin(
{minChunkSize: 10000})
// ,
// new webpack.optimize.UglifyJsPlugin()
]
}
},
babel: {
@ -129,7 +96,7 @@ module.exports = function (grunt) {
expand: true,
cwd: 'src-es6',
src: ['**/*.js'],
dest: 'dev'
dest: 'dev/tablefilter'
}]
}
}
@ -138,20 +105,21 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-webpack');
grunt.loadNpmTasks('grunt-babel');
// The development server (the recommended option for development)
grunt.registerTask("default", ["webpack-dev-server:start"]);
grunt.registerTask('dev-server', ['webpack-dev-server:start']);
// Build and watch cycle (another option for development)
// Advantage: No server required, can run app from filesystem
// Disadvantage: Requests are not blocked until bundle is available,
// can serve an old app on too fast refresh
grunt.registerTask("dev", ["webpack:dev"/*, "watch:app"*/]);
grunt.registerTask('dev', ['jshint', 'webpack:build', 'copy:build'/*, 'watch:app'*/]);
// Production build
grunt.registerTask("build", ['jshint', "webpack:build"]);
grunt.registerTask('dist', ['jshint', 'webpack:dist', 'copy:dist']);
// Tests
grunt.registerTask('test', ['qunit']);

View file

@ -1,30 +0,0 @@
define(['exports', './string'], function (exports, _string) {
'use strict';
var Arr = {
has: function has(arr, val, caseSensitive) {
var sCase = caseSensitive === undefined ? false : caseSensitive;
for (var i = 0; i < arr.length; i++) {
if (_string.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 (_string.Str.matchCase(arr[i].toString(), sCase) == val) {
return i;
}
}
return -1;
}
};
exports.Arr = Arr;
});
/**
* Array utilities
*/
//# sourceMappingURL=array.js.map

View file

@ -1,63 +0,0 @@
define(['exports'], function (exports) {
/**
* Cookie utilities
*/
'use strict';
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;
}
cookieValue = unescape(cookie.substring(offset, end));
}
}
return cookieValue;
};
Cookie.remove = function (name) {
this.write(name, '', -1);
};
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.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

View file

@ -1,172 +0,0 @@
define(['exports'], function (exports) {
/**
* Date utilities
*/
'use strict';
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) {
function format(_x, _x2) {
return _format.apply(this, arguments);
}
format.toString = function () {
return _format.toString();
};
return format;
})(function (dateStr, format) {
if (!format) {
format = 'DMY';
}
if (!dateStr || dateStr === '') {
return new Date(1001, 0, 1);
}
var oDate, parts;
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;
}
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,162 +0,0 @@
define(['exports'], function (exports) {
/**
* DOM utilities
*/
'use strict';
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;
};
/**
* 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]);
}
}
}
return el;
};
/**
* 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;
}
exports.Dom = Dom;
});
//# sourceMappingURL=dom.js.map

View file

@ -1,57 +0,0 @@
define(['exports'], function (exports) {
/**
* DOM event utilities
*/
'use strict';
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;
}
},
target: function target(evt) {
return evt && evt.target || window.event && window.event.srcElement;
},
keyCode: function keyCode(evt) {
return evt.charCode ? evt.charCode : evt.keyCode ? evt.keyCode : evt.which ? evt.which : 0;
}
};
exports.Event = Event;
});
//# sourceMappingURL=event.js.map

View file

@ -1,579 +0,0 @@
define(['exports', 'module', '../../dom', '../../types', '../../event', '../../helpers', '../../array'], function (exports, module, _dom, _types, _event, _helpers, _array) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var ColsVisibility = (function () {
/**
* Columns Visibility extension
* @param {Object} tf TableFilter instance
*/
function ColsVisibility(tf) {
var ext = arguments[1] === undefined ? {
name: 'colsVisibility',
description: 'Columns visibility manager'
} : arguments[1];
_classCallCheck(this, ColsVisibility);
// Configuration object
var f = ext;
var cfg = tf.config();
this.initialized = false;
this.extName = f.name;
this.extDesc = f.description;
//show/hide cols span element
this.spanEl = null;
//show/hide cols button element
this.btnEl = null;
//show/hide cols container div element
this.contEl = null;
//tick to hide or show column
this.tickToHide = f.tick_to_hide === false ? false : true;
//enables/disables cols manager generation
this.manager = f.manager === false ? false : true;
//only if external headers
this.headersTbl = f.headers_table || false;
//only if external headers
this.headersIndex = f.headers_index || 1;
//id of container element
this.contElTgtId = f.container_target_id || null;
//alternative headers text
this.headersText = f.headers_text || null;
//id of button container element
this.btnTgtId = f.btn_target_id || null;
//defines show/hide cols text
this.btnText = f.btn_text || 'Columns&#9660;';
//defines show/hide cols button innerHtml
this.btnHtml = f.btn_html || null;
//defines css class for show/hide cols button
this.btnCssClass = f.btn_css_class || 'colVis';
//defines close link text
this.btnCloseText = f.btn_close_text || 'Close';
//defines close button innerHtml
this.btnCloseHtml = f.btn_close_html || null;
//defines css class for close button
this.btnCloseCssClass = f.btn_close_css_class || this.btnCssClass;
this.path = f.path || tf.extensionsPath + 'colsVisibility/';
this.stylesheet = f.stylesheet || 'colsVisibility.css';
//span containing show/hide cols button
this.prfx = 'colVis_';
//defines css class span containing show/hide cols
this.spanCssClass = f.span_css_class || 'colVisSpan';
this.prfxCont = this.prfx + 'Cont_';
//defines css class div containing show/hide cols
this.contCssClass = f.cont_css_class || 'colVisCont';
//defines css class for cols list (ul)
this.listCssClass = cfg.list_css_class || 'cols_checklist';
//defines css class for list item (li)
this.listItemCssClass = cfg.checklist_item_css_class || 'cols_checklist_item';
//defines css class for selected list item (li)
this.listSlcItemCssClass = cfg.checklist_selected_item_css_class || 'cols_checklist_slc_item';
//text preceding columns list
this.text = f.text || (this.tickToHide ? 'Hide: ' : 'Show: ');
this.atStart = f.at_start || null;
this.enableHover = Boolean(f.enable_hover);
//enables select all option
this.enableTickAll = Boolean(f.enable_tick_all);
//text preceding columns list
this.tickAllText = f.tick_all_text || 'Select all:';
//array containing hidden columns indexes
this.hiddenCols = [];
this.tblHasColTag = _dom.Dom.tag(tf.tbl, 'col').length > 0;
//callback invoked just after cols manager is loaded
this.onLoaded = _types.Types.isFn(f.on_loaded) ? f.on_loaded : null;
//calls function before cols manager is opened
this.onBeforeOpen = _types.Types.isFn(f.on_before_open) ? f.on_before_open : null;
//calls function after cols manager is opened
this.onAfterOpen = _types.Types.isFn(f.on_after_open) ? f.on_after_open : null;
//calls function before cols manager is closed
this.onBeforeClose = _types.Types.isFn(f.on_before_close) ? f.on_before_close : null;
//calls function after cols manager is closed
this.onAfterClose = _types.Types.isFn(f.on_after_close) ? f.on_after_close : null;
//calls function before col is hidden
this.onBeforeColHidden = _types.Types.isFn(f.on_before_col_hidden) ? f.on_before_col_hidden : null;
//calls function after col is hidden
this.onAfterColHidden = _types.Types.isFn(f.on_after_col_hidden) ? f.on_after_col_hidden : null;
//calls function before col is displayed
this.onBeforeColDisplayed = _types.Types.isFn(f.on_before_col_displayed) ? f.on_before_col_displayed : null;
//calls function after col is displayed
this.onAfterColDisplayed = _types.Types.isFn(f.on_after_col_displayed) ? f.on_after_col_displayed : null;
//Grid layout compatibility
if (tf.gridLayout) {
this.headersTbl = tf.Cpt.gridLayout.headTbl; //headers table
this.headersIndex = 0; //headers index
this.onAfterColDisplayed = function () {};
this.onAfterColHidden = function () {};
}
//Loads extension stylesheet
tf.includeFile(f.name + 'Style', this.path + '/' + this.stylesheet, null, 'link');
this.tf = tf;
}
_createClass(ColsVisibility, [{
key: 'toggle',
value: function toggle(evt) {
var tf = this.tf;
var contDisplay = this.contEl.style.display;
var onBeforeOpen = this.onBeforeOpen;
var onBeforeClose = this.onBeforeClose;
var onAfterOpen = this.onAfterOpen;
var onAfterClose = this.onAfterClose;
if (onBeforeOpen && contDisplay !== 'inline') {
onBeforeOpen.call(null, this);
}
if (onBeforeClose && contDisplay === 'inline') {
onBeforeClose.call(null, this);
}
this.contEl.style.display = contDisplay === 'inline' ? 'none' : 'inline';
if (onAfterOpen && contDisplay !== 'inline') {
onAfterOpen.call(null, this);
}
if (onAfterClose && contDisplay === 'inline') {
onAfterClose.call(null, this);
}
}
}, {
key: 'checkItem',
value: function checkItem(lbl) {
var li = lbl.parentNode;
if (!li || !lbl) {
return;
}
var isChecked = lbl.firstChild.checked;
var colIndex = lbl.firstChild.getAttribute('id').split('_')[1];
colIndex = parseInt(colIndex, 10);
if (isChecked) {
_dom.Dom.addClass(li, this.listSlcItemCssClass);
} else {
_dom.Dom.removeClass(li, this.listSlcItemCssClass);
}
var hide = false;
if (this.tickToHide && isChecked || !this.tickToHide && !isChecked) {
hide = true;
}
this.setHidden(colIndex, hide);
}
}, {
key: 'init',
value: function init() {
if (!this.manager) {
return;
}
this.buildBtn();
this.buildManager();
this.initialized = true;
}
}, {
key: 'buildBtn',
/**
* Build main button UI
*/
value: function buildBtn() {
var _this = this;
if (this.btnEl) {
return;
}
var tf = this.tf;
var span = _dom.Dom.create('span', ['id', this.prfx + tf.id]);
span.className = this.spanCssClass;
//Container element (rdiv or custom element)
if (!this.btnTgtId) {
tf.setToolbar();
}
var targetEl = !this.btnTgtId ? tf.rDiv : _dom.Dom.id(this.btnTgtId);
if (!this.btnTgtId) {
var firstChild = targetEl.firstChild;
firstChild.parentNode.insertBefore(span, firstChild);
} else {
targetEl.appendChild(span);
}
if (!this.btnHtml) {
var btn = _dom.Dom.create('a', ['href', 'javascript:;']);
btn.className = this.btnCssClass;
btn.title = this.extDesc;
btn.innerHTML = this.btnText;
span.appendChild(btn);
if (!this.enableHover) {
_event.Event.add(btn, 'click', function (evt) {
_this.toggle(evt);
});
} else {
_event.Event.add(btn, 'mouseover', function (evt) {
_this.toggle(evt);
});
}
} else {
//Custom html
span.innerHTML = this.btnHtml;
var colVisEl = span.firstChild;
if (!this.enableHover) {
_event.Event.add(colVisEl, 'click', function (evt) {
_this.toggle(evt);
});
} else {
_event.Event.add(colVisEl, 'mouseover', function (evt) {
_this.toggle(evt);
});
}
}
this.spanEl = span;
this.btnEl = this.spanEl.firstChild;
if (this.onLoaded) {
this.onLoaded.call(null, this);
}
}
}, {
key: 'buildManager',
/**
* Build columns manager UI
*/
value: function buildManager() {
var _this2 = this;
var tf = this.tf;
var container = !this.contElTgtId ? _dom.Dom.create('div', ['id', this.prfxCont + tf.id]) : _dom.Dom.id(this.contElTgtId);
container.className = this.contCssClass;
//Extension description
var extNameLabel = _dom.Dom.create('p');
extNameLabel.innerHTML = this.text;
container.appendChild(extNameLabel);
//Headers list
var ul = _dom.Dom.create('ul', ['id', 'ul' + this.extName + '_' + tf.id]);
ul.className = this.listCssClass;
var tbl = this.headersTbl ? this.headersTbl : tf.tbl;
var headerIndex = this.headersTbl ? this.headersIndex : tf.getHeadersRowIndex();
var headerRow = tbl.rows[headerIndex];
//Tick all option
if (this.enableTickAll) {
var li = _dom.Dom.createCheckItem('col__' + tf.id, this.tickAllText, this.tickAllText);
_dom.Dom.addClass(li, this.listItemCssClass);
ul.appendChild(li);
li.check.checked = !this.tickToHide;
_event.Event.add(li.check, 'click', function (evt) {
for (var h = 0; h < headerRow.cells.length; h++) {
var itm = _dom.Dom.id('col_' + h + '_' + tf.id);
if (itm && li.check.checked !== itm.checked) {
itm.click();
itm.checked = li.check.checked;
}
}
});
}
for (var i = 0; i < headerRow.cells.length; i++) {
var cell = headerRow.cells[i];
var cellText = this.headersText && this.headersText[i] ? this.headersText[i] : this._getHeaderText(cell);
var liElm = _dom.Dom.createCheckItem('col_' + i + '_' + tf.id, cellText, cellText);
_dom.Dom.addClass(liElm, this.listItemCssClass);
if (!this.tickToHide) {
_dom.Dom.addClass(liElm, this.listSlcItemCssClass);
}
ul.appendChild(liElm);
if (!this.tickToHide) {
liElm.check.checked = true;
}
_event.Event.add(liElm.check, 'click', function (evt) {
var elm = _event.Event.target(evt);
var lbl = elm.parentNode;
_this2.checkItem(lbl);
});
}
//separator
var p = _dom.Dom.create('p', ['align', 'center']);
var btn;
//Close link
if (!this.btnCloseHtml) {
btn = _dom.Dom.create('a', ['href', 'javascript:;']);
btn.className = this.btnCloseCssClass;
btn.innerHTML = this.btnCloseText;
_event.Event.add(btn, 'click', function (evt) {
_this2.toggle(evt);
});
p.appendChild(btn);
} else {
p.innerHTML = this.btnCloseHtml;
btn = p.firstChild;
_event.Event.add(btn, 'click', function (evt) {
_this2.toggle(evt);
});
}
container.appendChild(ul);
container.appendChild(p);
this.btnEl.parentNode.insertBefore(container, this.btnEl);
this.contEl = container;
if (this.atStart) {
var a = this.atStart;
for (var k = 0; k < a.length; k++) {
var itm = _dom.Dom.id('col_' + a[k] + '_' + tf.id);
if (itm) {
itm.click();
}
}
}
}
}, {
key: 'setHidden',
/**
* Hide or show specified columns
* @param {Numner} colIndex Column index
* @param {Boolean} hide hide column if true or show if false
*/
value: function setHidden(colIndex, hide) {
var tf = this.tf;
var tbl = tf.tbl;
var col = _dom.Dom.tag(tbl, 'col')[colIndex];
if (this.onBeforeColHidden && hide) {
this.onBeforeColHidden.call(null, this, colIndex);
}
if (this.onBeforeColDisplayed && !hide) {
this.onBeforeColDisplayed.call(null, this, colIndex);
}
this._hideCells(tbl, colIndex, hide);
if (this.headersTbl) {
this._hideCells(this.headersTbl, colIndex, hide);
}
var hiddenCols = this.hiddenCols;
if (hide) {
if (hiddenCols.indexOf(colIndex) === -1) {
this.hiddenCols.push(colIndex);
}
} else {
var itemIndex = _array.Arr.indexByValue(hiddenCols, colIndex, true);
if (hiddenCols.indexOf(colIndex) !== -1) {
this.hiddenCols.splice(itemIndex, 1);
}
}
var gridLayout;
var headTbl;
var gridColElms;
if (this.onAfterColHidden && hide) {
//This event is fired just after a column is displayed for
//grid_layout compatibility
if (tf.gridLayout) {
gridLayout = tf.Cpt.gridLayout;
headTbl = gridLayout.headTbl;
gridColElms = gridLayout.gridColElms;
if (_helpers.Helpers.isIE()) {
tbl.style.width = headTbl.clientWidth + 'px';
} else {
var ths = headTbl.rows[this.headersIndex].cells;
var hiddenWidth = 0;
for (var i = 0; i < tf.nbCells; i++) {
if (ths[i].style.display === 'none') {
var w = parseInt(ths[i].style.width, 10);
ths[i].style.width = 0;
hiddenWidth += w;
}
}
var headTblW = parseInt(headTbl.style.width, 10);
headTbl.style.width = headTblW - hiddenWidth + 'px';
tbl.style.width = headTbl.style.width;
gridColElms[colIndex].style.display = 'none';
}
}
this.onAfterColHidden.call(null, this, colIndex);
}
if (this.onAfterColDisplayed && !hide) {
//This event is fired just after a column is displayed for
//grid_layout compatibility
if (tf.gridLayout) {
gridLayout = tf.Cpt.gridLayout;
headTbl = gridLayout.headTbl;
gridColElms = gridLayout.gridColElms;
gridColElms[colIndex].style.display = '';
var width = parseInt(gridColElms[colIndex].style.width, 10);
var header = tf.getHeaderElement(colIndex);
header.style.width = width + 'px';
headTbl.style.width = parseInt(headTbl.style.width, 10) + width + 'px';
tf.tbl.style.width = headTbl.style.width;
}
this.onAfterColDisplayed.call(null, this, colIndex);
}
}
}, {
key: 'showCol',
/**
* Show specified column
* @param {Number} colIndex Column index
*/
value: function showCol(colIndex) {
if (colIndex === undefined || !this.isColHidden(colIndex)) {
return;
}
if (this.manager && this.contEl) {
var itm = _dom.Dom.id('col_' + colIndex + '_' + this.tf.id);
if (itm) {
itm.click();
}
} else {
this.setHidden(colIndex, false);
}
}
}, {
key: 'hideCol',
/**
* Hide specified column
* @param {Number} colIndex Column index
*/
value: function hideCol(colIndex) {
if (colIndex === undefined || this.isColHidden(colIndex)) {
return;
}
if (this.manager && this.contEl) {
var itm = _dom.Dom.id('col_' + colIndex + '_' + this.tf.id);
if (itm) {
itm.click();
}
} else {
this.setHidden(colIndex, true);
}
}
}, {
key: 'isColHidden',
/**
* Determine if specified column is hidden
* @param {Number} colIndex Column index
*/
value: function isColHidden(colIndex) {
if (this.hiddenCols.indexOf(colIndex) !== -1) {
return true;
}
return false;
}
}, {
key: 'toggleCol',
/**
* Toggle visibility of specified column
* @param {Number} colIndex Column index
*/
value: function toggleCol(colIndex) {
if (colIndex === undefined || this.isColHidden(colIndex)) {
this.showCol(colIndex);
} else {
this.hideCol(colIndex);
}
}
}, {
key: 'getHiddenCols',
/**
* Returns the indexes of the columns currently hidden
* @return {Array} column indexes
*/
value: function getHiddenCols() {
return this.hiddenCols;
}
}, {
key: 'destroy',
/**
* Remove the columns manager
*/
value: function destroy() {
if (!this.btnEl || !this.contEl) {
return;
}
if (_dom.Dom.id(this.contElTgtId)) {
_dom.Dom.id(this.contElTgtId).innerHTML = '';
} else {
this.contEl.innerHTML = '';
this.contEl.parentNode.removeChild(this.contEl);
this.contEl = null;
}
this.btnEl.innerHTML = '';
this.btnEl.parentNode.removeChild(this.btnEl);
this.btnEl = null;
this.initialized = false;
}
}, {
key: '_getHeaderText',
value: function _getHeaderText(cell) {
if (!cell.hasChildNodes) {
return '';
}
for (var i = 0; i < cell.childNodes.length; i++) {
var n = cell.childNodes[i];
if (n.nodeType === 3) {
return n.nodeValue;
} else if (n.nodeType === 1) {
if (n.id && n.id.indexOf('popUp') !== -1) {
continue;
} else {
return _dom.Dom.getText(n);
}
}
continue;
}
return '';
}
}, {
key: '_hideCells',
value: function _hideCells(tbl, colIndex, hide) {
for (var i = 0; i < tbl.rows.length; i++) {
var row = tbl.rows[i];
var cell = row.cells[colIndex];
if (cell) {
cell.style.display = hide ? 'none' : '';
}
}
}
}]);
return ColsVisibility;
})();
module.exports = ColsVisibility;
});
//# sourceMappingURL=colsVisibility.js.map

View file

@ -1,460 +0,0 @@
define(['exports', 'module', '../../types', '../../dom', '../../array', '../../event', '../../date', '../../helpers', 'script!sortabletable'], function (exports, module, _types, _dom, _array, _event, _date, _helpers, _scriptSortabletable) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var AdapterSortableTable = (function () {
/**
* SortableTable Adapter module
* @param {Object} tf TableFilter instance
*/
function AdapterSortableTable(tf) {
_classCallCheck(this, AdapterSortableTable);
// Configuration object
var f = tf.config();
this.isPaged = false;
//indicates if tables was sorted
this.sorted = false;
// edit .sort-arrow.descending / .sort-arrow.ascending in filtergrid.css
// to reflect any path change
this.sortImgPath = f.sort_images_path || tf.themesPath;
this.sortImgBlank = f.sort_image_blank || 'blank.png';
this.sortImgClassName = f.sort_image_class_name || 'sort-arrow';
this.sortImgAscClassName = f.sort_image_asc_class_name || 'ascending';
this.sortImgDescClassName = f.sort_image_desc_class_name || 'descending';
//cell attribute storing custom key
this.sortCustomKey = f.sort_custom_key || 'data-tf-sortKey';
/*** TF additional events ***/
//additional paging events for alternating background
// o.Evt._Paging.nextEvt = function(){ if(o.sorted && o.alternateBgs) o.Filter(); }
// o.Evt._Paging.prevEvt = o.Evt._Paging.nextEvt;
// o.Evt._Paging.firstEvt = o.Evt._Paging.nextEvt;
// o.Evt._Paging.lastEvt = o.Evt._Paging.nextEvt;
// o.Evt._OnSlcPagesChangeEvt = o.Evt._Paging.nextEvt;
// callback invoked after sort is loaded and instanciated
this.onSortLoaded = _types.Types.isFn(f.on_sort_loaded) ? f.on_sort_loaded : null;
// callback invoked before table is sorted
this.onBeforeSort = _types.Types.isFn(f.on_before_sort) ? f.on_before_sort : null;
// callback invoked after table is sorted
this.onAfterSort = _types.Types.isFn(f.on_after_sort) ? f.on_after_sort : null;
this.tf = tf;
}
_createClass(AdapterSortableTable, [{
key: 'init',
value: function init() {
var tf = this.tf;
var sortConfig = tf.sortConfig;
var adpt = this;
// SortableTable class sanity check (sortabletable.js)
if (_types.Types.isUndef(SortableTable)) {
throw new Error('SortableTable class not found.');
}
this.overrideSortableTable();
this.setSortTypes();
//Column sort at start
if (sortConfig.sortCol) {
this.stt.sort(sortConfig.sortCol[0], sortConfig.sortCol[1]);
}
tf.isSortEnabled = true;
if (this.onSortLoaded) {
this.onSortLoaded.call(null, tf, this);
}
/*** SortableTable callbacks ***/
this.stt.onbeforesort = function () {
if (this.onBeforeSort) {
this.onBeforeSort.call(null, tf, this.stt.sortColumn);
}
tf.performSort();
/*** sort behaviour for paging ***/
if (tf.paging) {
adpt.isPaged = true;
tf.paging = false;
tf.Cpt.paging.destroy();
}
};
this.stt.onsort = function () {
adpt.sorted = true;
//rows alternating bg issue
// TODO: move into AlternateRows component
if (tf.alternateBgs) {
var rows = tf.tbl.rows,
c = 0;
var setClass = function setClass(row, i, removeOnly) {
if (_types.Types.isUndef(removeOnly)) {
removeOnly = false;
}
var altRows = tf.Cpt.alternateRows,
oddCls = altRows.oddCss,
evenCls = altRows.evenCss;
_dom.Dom.removeClass(row, oddCls);
_dom.Dom.removeClass(row, evenCls);
if (!removeOnly) {
_dom.Dom.addClass(row, i % 2 ? oddCls : evenCls);
}
};
for (var i = tf.refRow; i < tf.nbRows; i++) {
var isRowValid = rows[i].getAttribute('validRow');
if (tf.paging && rows[i].style.display === '') {
setClass(rows[i], c);
c++;
} else {
if ((isRowValid === 'true' || isRowValid === null) && rows[i].style.display === '') {
setClass(rows[i], c);
c++;
} else {
setClass(rows[i], c, true);
}
}
}
}
//sort behaviour for paging
if (adpt.isPaged) {
var paginator = tf.Cpt.paging,
config = tf.config();
if (paginator.hasResultsPerPage) {
var slc = paginator.resultsPerPageSlc;
config.paging_length = slc.options[slc.selectedIndex].value;
}
paginator.addPaging(false);
paginator.setPage(paginator.currentPageNb);
adpt.isPaged = false;
}
if (adpt.onAfterSort) {
adpt.onAfterSort.call(null, tf, tf.stt.sortColumn);
}
};
}
}, {
key: 'sortByColumnIndex',
/**
* Sort specified column
* @param {Number} colIdx Column index
*/
value: function sortByColumnIndex(colIdx) {
this.stt.sort(colIdx);
}
}, {
key: 'overrideSortableTable',
value: function overrideSortableTable() {
var adpt = this,
tf = this.tf;
/**
* Overrides headerOnclick method in order to handle th event
* @param {Object} e [description]
*/
SortableTable.prototype.headerOnclick = function (evt) {
if (!tf.sort) {
return;
}
// find Header element
var el = evt.target || evt.srcElement;
while (el.tagName !== 'TD' && el.tagName !== 'TH') {
el = el.parentNode;
}
this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);
};
/**
* Overrides getCellIndex IE returns wrong cellIndex when columns are
* hidden
* @param {Object} oTd TD element
* @return {Number} Cell index
*/
SortableTable.getCellIndex = function (oTd) {
var cells = oTd.parentNode.cells,
l = cells.length,
i;
for (i = 0; cells[i] != oTd && i < l; i++) {}
return i;
};
/**
* Overrides initHeader in order to handle filters row position
* @param {Array} oSortTypes
*/
SortableTable.prototype.initHeader = function (oSortTypes) {
var stt = this;
if (!stt.tHead) {
// throw new Error('Sorting feature requires a THEAD element');
return;
}
stt.headersRow = tf.headersRow;
var cells = stt.tHead.rows[stt.headersRow].cells;
var doc = stt.tHead.ownerDocument || stt.tHead.document;
stt.sortTypes = oSortTypes || [];
var l = cells.length;
var img, c;
for (var i = 0; i < l; i++) {
c = cells[i];
if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None') {
c.style.cursor = 'pointer';
img = _dom.Dom.create('img', ['src', adpt.sortImgPath + adpt.sortImgBlank]);
c.appendChild(img);
if (stt.sortTypes[i] !== null) {
c.setAttribute('_sortType', stt.sortTypes[i]);
}
_event.Event.add(c, 'click', stt._headerOnclick);
} else {
c.setAttribute('_sortType', oSortTypes[i]);
c._sortType = 'None';
}
}
stt.updateHeaderArrows();
};
/**
* Overrides updateHeaderArrows in order to handle arrows indicators
*/
SortableTable.prototype.updateHeaderArrows = function () {
var stt = this;
var cells, l, img;
// external headers
if (tf.sortConfig.asyncSort && tf.sortConfig.triggerIds !== null) {
var triggers = tf.sortConfig.triggerIds;
cells = [];
l = triggers.length;
for (var j = 0; j < triggers.length; j++) {
cells.push(_dom.Dom.id(triggers[j]));
}
} else {
if (!this.tHead) {
return;
}
cells = stt.tHead.rows[stt.headersRow].cells;
l = cells.length;
}
for (var i = 0; i < l; i++) {
var cellAttr = cells[i].getAttribute('_sortType');
if (cellAttr !== null && cellAttr !== 'None') {
img = cells[i].lastChild || cells[i];
if (img.nodeName.toLowerCase() !== 'img') {
img = _dom.Dom.create('img', ['src', adpt.sortImgPath + adpt.sortImgBlank]);
cells[i].appendChild(img);
}
if (i === stt.sortColumn) {
img.className = adpt.sortImgClassName + ' ' + (this.descending ? adpt.sortImgDescClassName : adpt.sortImgAscClassName);
} else {
img.className = adpt.sortImgClassName;
}
}
}
};
/**
* Overrides getRowValue for custom key value feature
* @param {Object} oRow Row element
* @param {String} sType
* @param {Number} nColumn
* @return {String}
*/
SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
var stt = this;
// if we have defined a custom getRowValue use that
var sortTypeInfo = stt._sortTypeInfo[sType];
if (sortTypeInfo && sortTypeInfo.getRowValue) {
return sortTypeInfo.getRowValue(oRow, nColumn);
}
var c = oRow.cells[nColumn];
var s = SortableTable.getInnerText(c);
return stt.getValueFromString(s, sType);
};
/**
* Overrides getInnerText in order to avoid Firefox unexpected sorting
* behaviour with untrimmed text elements
* @param {Object} oNode DOM element
* @return {String} DOM element inner text
*/
SortableTable.getInnerText = function (oNode) {
if (!oNode) {
return;
}
if (oNode.getAttribute(adpt.sortCustomKey)) {
return oNode.getAttribute(adpt.sortCustomKey);
} else {
return _dom.Dom.getText(oNode);
}
};
}
}, {
key: 'addSortType',
value: function addSortType() {
SortableTable.prototype.addSortType(arguments[0], arguments[1], arguments[2], arguments[3]);
}
}, {
key: 'setSortTypes',
value: function setSortTypes() {
var _this = this;
var tf = this.tf,
configSort = tf.sortConfig,
configSortTypes = configSort.sortTypes,
sortTypes = [];
for (var i = 0; i < tf.nbCells; i++) {
var colType;
if (configSortTypes !== null && configSortTypes[i] != null) {
colType = configSortTypes[i].toLowerCase();
if (colType === 'none') {
colType = 'None';
}
} else {
// resolve column types
if (tf.hasColNbFormat && tf.colNbFormat[i] !== null) {
colType = tf.colNbFormat[i].toLowerCase();
} else if (tf.hasColDateType && tf.colDateType[i] !== null) {
colType = tf.colDateType[i].toLowerCase() + 'date';
} else {
colType = 'String';
}
}
sortTypes.push(colType);
}
//Public TF method to add sort type
//Custom sort types
this.addSortType('number', Number);
this.addSortType('caseinsensitivestring', SortableTable.toUpperCase);
this.addSortType('date', SortableTable.toDate);
this.addSortType('string');
this.addSortType('us', usNumberConverter);
this.addSortType('eu', euNumberConverter);
this.addSortType('dmydate', dmyDateConverter);
this.addSortType('ymddate', ymdDateConverter);
this.addSortType('mdydate', mdyDateConverter);
this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter);
this.addSortType('ipaddress', ipAddress, sortIP);
this.stt = new SortableTable(tf.tbl, sortTypes);
/*** external table headers adapter ***/
if (configSort.asyncSort && configSort.triggerIds !== null) {
var triggers = configSort.triggerIds;
for (var j = 0; j < triggers.length; j++) {
if (triggers[j] === null) {
continue;
}
var trigger = _dom.Dom.id(triggers[j]);
if (trigger) {
trigger.style.cursor = 'pointer';
_event.Event.add(trigger, 'click', function (evt) {
var elm = evt.target;
if (!_this.tf.sort) {
return;
}
_this.stt.asyncSort(_array.Arr.indexByValue(triggers, elm.id, true));
});
trigger.setAttribute('_sortType', sortTypes[j]);
}
}
}
}
}, {
key: 'destroy',
/**
* Destroy sort
*/
value: function destroy() {
var tf = this.tf;
tf.sort = false;
this.sorted = false;
this.stt.destroy();
var ids = tf.getFiltersId();
for (var idx = 0; idx < ids.length; idx++) {
var header = tf.getHeaderElement(idx);
var img = _dom.Dom.tag(header, 'img');
if (img.length === 1) {
header.removeChild(img[0]);
}
}
}
}]);
return AdapterSortableTable;
})();
module.exports = AdapterSortableTable;
//Converters
function usNumberConverter(s) {
return _helpers.Helpers.removeNbFormat(s, 'us');
}
function euNumberConverter(s) {
return _helpers.Helpers.removeNbFormat(s, 'eu');
}
function dateConverter(s, format) {
return _date.DateHelper.format(s, format);
}
function dmyDateConverter(s) {
return dateConverter(s, 'DMY');
}
function mdyDateConverter(s) {
return dateConverter(s, 'MDY');
}
function ymdDateConverter(s) {
return dateConverter(s, 'YMD');
}
function ddmmmyyyyDateConverter(s) {
return dateConverter(s, 'DDMMMYYYY');
}
function ipAddress(value) {
var vals = value.split('.');
for (var x in vals) {
var val = vals[x];
while (3 > val.length) {
val = '0' + val;
}
vals[x] = val;
}
return vals.join('.');
}
function sortIP(a, b) {
var aa = ipAddress(a.value.toLowerCase());
var bb = ipAddress(b.value.toLowerCase());
if (aa == bb) {
return 0;
} else if (aa < bb) {
return -1;
} else {
return 1;
}
}
});
//# sourceMappingURL=adapterSortabletable.js.map

View file

@ -1,31 +0,0 @@
define(['exports', './string'], function (exports, _string) {
'use strict';
var Helpers = {
isIE: function isIE() {
return /msie|MSIE/.test(navigator.userAgent);
},
removeNbFormat: function removeNbFormat(data, format) {
if (!data) {
return;
}
if (!format) {
format = 'us';
}
var n = data;
if (_string.Str.lower(format) === 'us') {
n = +n.replace(/[^\d\.-]/g, '');
} else {
n = +n.replace(/[^\d\,-]/g, '').replace(',', '.');
}
return n;
}
};
exports.Helpers = Helpers;
});
/**
* Misc helpers
*/
//# sourceMappingURL=helpers.js.map

View file

@ -1,122 +0,0 @@
define(['exports', '../dom'], function (exports, _dom) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var AlternateRows = (function () {
/**
* 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;
}
_createClass(AlternateRows, [{
key: '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++;
}
}
}, {
key: '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.Dom.addClass(rows[rowIdx], i % 2 ? this.evenCss : this.oddCss);
}
}, {
key: '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.Dom.removeClass(rows[idx], this.oddCss);
_dom.Dom.removeClass(rows[idx], this.evenCss);
}
}, {
key: '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;
}
}, {
key: 'enable',
value: function enable() {
this.tf.alternateBgs = true;
}
}, {
key: 'disable',
value: function disable() {
this.tf.alternateBgs = false;
}
}]);
return AlternateRows;
})();
exports.AlternateRows = AlternateRows;
});
//# sourceMappingURL=alternateRows.js.map

View file

@ -1,417 +0,0 @@
define(['exports', '../dom', '../array', '../string', '../sort', '../event'], function (exports, _dom, _array, _string, _sort, _event) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var CheckList = (function () {
/**
* Checklist UI component
* @param {Object} tf TableFilter instance
*/
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;
//checklist filter container div
this.prfxCheckListDiv = 'chkdiv_';
this.isCustom = null;
this.opts = null;
this.optsTxt = null;
this.tf = tf;
}
_createClass(CheckList, [{
key: 'onChange',
// TODO: move event here
value: function onChange(evt) {
this.tf.Evt.onSlcChange(evt);
}
}, {
key: 'optionClick',
value: function optionClick(evt) {
this.setCheckListValues(evt.target);
this.onChange(evt);
}
}, {
key: 'build',
/**
* Build checklist UI asynchronously
* @param {Number} colIndex Column index
* @param {Boolean} isExternal Render in external container
* @param {String} extFltId External container id
*/
value: function build(colIndex, isExternal, extFltId) {
var tf = this.tf;
tf.EvtManager(tf.Evt.name.checklist, { slcIndex: colIndex, slcExternal: isExternal, slcId: extFltId });
}
}, {
key: '_build',
/**
* Build checklist UI
* @param {Number} colIndex Column index
* @param {Boolean} isExternal Render in external container
* @param {String} extFltId External container id
*/
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 = this.prfxCheckListDiv + colIndex + '_' + tf.id;
if (!_dom.Dom.id(divFltId) && !isExternal || !_dom.Dom.id(extFltId) && isExternal) {
return;
}
var flt = !isExternal ? this.checkListDiv[colIndex] : _dom.Dom.id(extFltId);
var ul = _dom.Dom.create('ul', ['id', tf.fltIds[colIndex]], ['colIndex', colIndex]);
ul.className = this.checkListCssClass;
_event.Event.add(ul, 'change', function (evt) {
_this.onChange(evt);
});
var rows = tf.tbl.rows;
this.isCustom = tf.hasCustomSlcOptions && _array.Arr.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.Arr.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.Arr.has(tf.validRowsIndex, k)))) {
var cell_data = tf.getCellData(j, cells[j]);
//Vary Peter's patch
var cell_string = _string.Str.matchCase(cell_data, tf.matchCase);
// checks if celldata is already in array
if (!_array.Arr.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.Arr.has(filteredCol, cell_string, tf.matchCase) && !_array.Arr.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.Sort.ignoreCase);
if (excludedOpts) {
excludedOpts.sort(_sort.Sort.ignoreCase);
}
} else {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
}
}
//asc sort
if (tf.sortNumAsc && _array.Arr.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.Arr.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');
}
}, {
key: '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 _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 && _string.Str.trim(tmpVal).length > 0) {
if (tf.hasCustomSlcOptions && _array.Arr.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.Dom.createCheckItem(tf.fltIds[colIndex] + '_' + (y + chkCt), val, lbl);
li.className = this.checkListItemCssClass;
if (tf.refreshFilters && tf.disableExcludedOptions && _array.Arr.has(excludedOpts, _string.Str.matchCase(val, tf.matchCase), tf.matchCase)) {
_dom.Dom.addClass(li, this.checkListItemDisabledCssClass);
li.check.disabled = true;
li.disabled = true;
} else {
_event.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.Arr.has(tf.customSlcOptions.cols, colIndex) && fltArr.toString().indexOf(val) != -1 || _array.Arr.has(fltArr, _string.Str.matchCase(val, tf.matchCase), tf.matchCase)) {
li.check.checked = true;
this.setCheckListValues(li.check);
}
}
}
}
}, {
key: 'addTChecks',
/**
* Add checklist header option
* @param {Number} colIndex Column index
* @param {Object} ul Ul element
*/
value: function addTChecks(colIndex, ul) {
var _this3 = this;
var tf = this.tf;
var chkCt = 1;
var li0 = _dom.Dom.createCheckItem(tf.fltIds[colIndex] + '_0', '', tf.displayAllText);
li0.className = this.checkListItemCssClass;
ul.appendChild(li0);
_event.Event.add(li0.check, 'click', function (evt) {
_this3.optionClick(evt);
});
if (!this.enableCheckListResetFilter) {
li0.style.display = 'none';
}
if (tf.enableEmptyOption) {
var li1 = _dom.Dom.createCheckItem(tf.fltIds[colIndex] + '_1', tf.emOperator, tf.emptyText);
li1.className = this.checkListItemCssClass;
ul.appendChild(li1);
_event.Event.add(li1.check, 'click', function (evt) {
_this3.optionClick(evt);
});
chkCt++;
}
if (tf.enableNonEmptyOption) {
var li2 = _dom.Dom.createCheckItem(tf.fltIds[colIndex] + '_2', tf.nmOperator, tf.nonEmptyText);
li2.className = this.checkListItemCssClass;
ul.appendChild(li2);
_event.Event.add(li2.check, 'click', function (evt) {
_this3.optionClick(evt);
});
chkCt++;
}
return chkCt;
}
}, {
key: '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 (_string.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.Dom.id(tf.fltIds[colIndex] + '_' + indSplit[u]);
if (cChk) {
cChk.checked = false;
_dom.Dom.removeClass(n.childNodes[indSplit[u]], this.checkListSlcItemCssClass);
}
}
}
n.setAttribute('value', '');
n.setAttribute('indexes', '');
} else {
fltValue = fltValue ? fltValue : '';
chkValue = _string.Str.trim(fltValue + ' ' + chkValue + ' ' + tf.orOperator);
chkIndex = fltIndexes + chkIndex + tf.separator;
n.setAttribute('value', chkValue);
n.setAttribute('indexes', chkIndex);
//1st option unchecked
if (_dom.Dom.id(tf.fltIds[colIndex] + '_0')) {
_dom.Dom.id(tf.fltIds[colIndex] + '_0').checked = false;
}
}
if (_string.Str.lower(li.nodeName) === itemTag) {
_dom.Dom.removeClass(n.childNodes[0], this.checkListSlcItemCssClass);
_dom.Dom.addClass(li, this.checkListSlcItemCssClass);
}
} else {
//removes values and indexes
if (chkValue !== '') {
var replaceValue = new RegExp(_string.Str.rgxEsc(chkValue + ' ' + tf.orOperator));
fltValue = fltValue.replace(replaceValue, '');
n.setAttribute('value', _string.Str.trim(fltValue));
var replaceIndex = new RegExp(_string.Str.rgxEsc(chkIndex + tf.separator));
fltIndexes = fltIndexes.replace(replaceIndex, '');
n.setAttribute('indexes', fltIndexes);
}
if (_string.Str.lower(li.nodeName) === itemTag) {
_dom.Dom.removeClass(li, this.checkListSlcItemCssClass);
}
}
}
}]);
return CheckList;
})();
exports.CheckList = CheckList;
});
//# sourceMappingURL=checkList.js.map

View file

@ -1,115 +0,0 @@
define(['exports', '../dom', '../event'], function (exports, _dom, _event) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var ClearButton = (function () {
/**
* 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 + '" />');
//span containing reset button
this.prfxResetSpan = 'resetspan_';
this.tf = tf;
}
_createClass(ClearButton, [{
key: 'onClick',
value: function onClick() {
this.tf.clearFilters();
}
}, {
key: 'init',
/**
* Build DOM elements
*/
value: function init() {
var _this = this;
var tf = this.tf;
if (!tf.hasGrid() && !tf.isFirstLoad && tf.btnResetEl) {
return;
}
var resetspan = _dom.Dom.create('span', ['id', this.prfxResetSpan + tf.id]);
// reset button is added to defined element
if (!this.btnResetTgtId) {
tf.setToolbar();
}
var targetEl = !this.btnResetTgtId ? tf.rDiv : _dom.Dom.id(this.btnResetTgtId);
targetEl.appendChild(resetspan);
if (!this.btnResetHtml) {
var fltreset = _dom.Dom.create('a', ['href', 'javascript:void(0);']);
fltreset.className = tf.btnResetCssClass;
fltreset.appendChild(_dom.Dom.text(this.btnResetText));
resetspan.appendChild(fltreset);
// fltreset.onclick = this.Evt._Clear;
_event.Event.add(fltreset, 'click', function () {
_this.onClick();
});
} else {
resetspan.innerHTML = this.btnResetHtml;
var resetEl = resetspan.firstChild;
// resetEl.onclick = this.Evt._Clear;
_event.Event.add(resetEl, 'click', function () {
_this.onClick();
});
}
this.btnResetEl = resetspan.firstChild;
}
}, {
key: 'destroy',
/**
* Remove clear button UI
*/
value: function destroy() {
var tf = this.tf;
if (!tf.hasGrid() || !this.btnResetEl) {
return;
}
var resetspan = _dom.Dom.id(tf.prfxResetSpan + tf.id);
if (resetspan) {
resetspan.parentNode.removeChild(resetspan);
}
this.btnResetEl = null;
}
}]);
return ClearButton;
})();
exports.ClearButton = ClearButton;
});
//# sourceMappingURL=clearButton.js.map

View file

@ -1,310 +0,0 @@
define(['exports', '../dom', '../string', '../types'], function (exports, _dom, _string, _types) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var ColOps = (function () {
/**
* Column calculations
* @param {Object} tf TableFilter instance
*/
function ColOps(tf) {
_classCallCheck(this, ColOps);
var f = tf.config();
this.colOperation = f.col_operation;
//calls function before col operation
this.onBeforeOperation = _types.Types.isFn(f.on_before_operation) ? f.on_before_operation : null;
//calls function after col operation
this.onAfterOperation = _types.Types.isFn(f.on_after_operation) ? f.on_after_operation : null;
this.tf = tf;
}
_createClass(ColOps, [{
key: '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 (_string.Str.lower(typeof labelId) == 'object' && _string.Str.lower(typeof colIndex) == 'object' && _string.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] = _string.Str.lower(operation[k]);
decThisCol[mThisCol] = decimalPrecision[k];
labThisCol[mThisCol] = labelId[k];
oTypeThisCol = outputType !== undefined && _string.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.Dom.id(labThisCol[i])) {
switch (_string.Str.lower(oTypeThisCol)) {
case 'innerhtml':
if (isNaN(result) || !isFinite(result) || nbvalues === 0) {
_dom.Dom.id(labThisCol[i]).innerHTML = '.';
} else {
_dom.Dom.id(labThisCol[i]).innerHTML = result;
}
break;
case 'setvalue':
_dom.Dom.id(labThisCol[i]).value = result;
break;
case 'createtextnode':
var oldnode = _dom.Dom.id(labThisCol[i]).firstChild;
var txtnode = _dom.Dom.text(result);
_dom.Dom.id(labThisCol[i]).replaceChild(txtnode, oldnode);
break;
} //switch
}
} else {
try {
if (isNaN(result) || !isFinite(result) || nbvalues === 0) {
_dom.Dom.id(labThisCol[i]).innerHTML = '.';
} else {
_dom.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);
}
}
}]);
return ColOps;
})();
exports.ColOps = ColOps;
});
//# sourceMappingURL=colOps.js.map

View file

@ -1,328 +0,0 @@
define(['exports', '../dom', '../array', '../string', '../sort'], function (exports, _dom, _array, _string, _sort) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var Dropdown = (function () {
/**
* Dropdown UI component
* @param {Object} tf TableFilter instance
*/
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;
}
_createClass(Dropdown, [{
key: 'build',
/**
* 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
*/
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
});
}
}, {
key: '_build',
/**
* 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
*/
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.Dom.id(slcId) && !isExternal || !_dom.Dom.id(extSlcId) && isExternal) {
return;
}
var slc = !isExternal ? _dom.Dom.id(slcId) : _dom.Dom.id(extSlcId),
rows = tf.tbl.rows,
matchCase = tf.matchCase,
fillMethod = _string.Str.lower(this.slcFillingMethod);
//custom select test
this.isCustom = tf.hasCustomSlcOptions && _array.Arr.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 && !_string.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.Arr.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.Arr.has(tf.validRowsIndex, k)) && (activeFlt === undefined || activeFlt == colIndex || activeFlt != colIndex && _array.Arr.has(tf.validRowsIndex, k)))) {
var cell_data = tf.getCellData(j, cell[j]),
//Vary Peter's patch
cell_string = _string.Str.matchCase(cell_data, matchCase);
// checks if celldata is already in array
if (!_array.Arr.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.Arr.has(filteredCol, cell_string, matchCase) && !_array.Arr.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.Sort.ignoreCase);
if (excludedOpts) {
excludedOpts.sort(_sort.Sort.ignoreCase);
}
} else {
this.opts.sort();
if (excludedOpts) {
excludedOpts.sort();
}
}
}
//asc sort
if (tf.sortNumAsc && _array.Arr.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.Arr.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);
}
}, {
key: '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 = _string.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.Arr.has(excludedOpts, _string.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.Dom.createOpt(lbl, val, true);
} else {
if (tf['col' + colIndex] !== tf.fltTypeMulti) {
opt = _dom.Dom.createOpt(lbl, val, fltsValues[colIndex] !== ' ' && val === fltsValues[colIndex] ? true : false);
} else {
opt = _dom.Dom.createOpt(lbl, val, _array.Arr.has(fltArr, _string.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');
}
}, {
key: 'addFirstOption',
/**
* Add drop-down header option
* @param {Object} slc Select DOM element
*/
value: function addFirstOption(slc) {
var tf = this.tf,
fillMethod = _string.Str.lower(this.slcFillingMethod);
if (fillMethod === 'innerhtml') {
this.slcInnerHtml += '<option value="">' + tf.displayAllText + '</option>';
} else {
var opt0 = _dom.Dom.createOpt(!this.enableSlcResetFilter ? '' : tf.displayAllText, '');
if (!this.enableSlcResetFilter) {
opt0.style.display = 'none';
}
slc.appendChild(opt0);
if (tf.enableEmptyOption) {
var opt1 = _dom.Dom.createOpt(tf.emptyText, tf.emOperator);
slc.appendChild(opt1);
}
if (tf.enableNonEmptyOption) {
var opt2 = _dom.Dom.createOpt(tf.nonEmptyText, tf.nmOperator);
slc.appendChild(opt2);
}
}
return slc;
}
}]);
return Dropdown;
})();
exports.Dropdown = Dropdown;
});
//# sourceMappingURL=dropdown.js.map

View file

@ -1,365 +0,0 @@
define(['exports', '../dom', '../types', '../helpers', '../event'], function (exports, _dom, _types, _helpers, _event) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var GridLayout = (function () {
/**
* Grid layout, table with fixed headers
* @param {Object} tf TableFilter instance
*/
function GridLayout(tf) {
_classCallCheck(this, GridLayout);
var f = tf.config();
//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';
this.gridColElms = [];
//div containing grid elements if grid_layout true
this.prfxMainTblCont = 'gridCont_';
//div containing table if grid_layout true
this.prfxTblCont = 'tblCont_';
//div containing headers table if grid_layout true
this.prfxHeadTblCont = 'tblHeadCont_';
//headers' table if grid_layout true
this.prfxHeadTbl = 'tblHead_';
//id of td containing the filter if grid_layout true
this.prfxGridFltTd = '_td_';
//id of th containing column header if grid_layout true
this.prfxGridTh = 'tblHeadTh_';
this.tf = tf;
}
_createClass(GridLayout, [{
key: 'init',
/**
* Generates a grid with fixed headers
*/
value: function init() {
var _this = this;
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.Dom.create('div', ['id', this.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.Dom.create('div', ['id', this.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.Dom.create('div', ['id', this.prfxHeadTblCont + tf.id]);
this.headTblCont.className = this.gridHeadContCssClass;
if (this.gridWidth) {
this.headTblCont.style.width = this.gridWidth;
}
//Headers table
this.headTbl = _dom.Dom.create('table', ['id', this.prfxHeadTbl + tf.id]);
var tH = _dom.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 = this.prfxGridTh + n + '_' + tf.id;
c.setAttribute('id', thId);
}
sortTriggers.push(thId);
}
//Filters row is created
var filtersRow = _dom.Dom.create('tr');
if (this.gridEnableFilters && tf.fltGrid) {
tf.externalFltTgtIds = [];
for (var j = 0; j < tf.nbCells; j++) {
var fltTdId = tf.prfxFlt + j + this.prfxGridFltTd + tf.id;
var cl = _dom.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.Dom.tag(tbl, 'thead');
if (thead.length > 0) {
tbl.removeChild(thead[0]);
}
//Headers table style
this.headTbl.style.tableLayout = 'fixed';
tbl.style.tableLayout = 'fixed';
this.headTbl.cellPadding = tbl.cellPadding;
this.headTbl.cellSpacing = tbl.cellSpacing;
// this.headTbl.style.width = tbl.style.width;
//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 = '';
//
this.headTbl.style.width = tbl.clientWidth + 'px';
//
//scroll synchronisation
_event.Event.add(this.tblCont, 'scroll', function (evt) {
var elm = _event.Event.target(evt);
var scrollLeft = elm.scrollLeft;
_this.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
this.tblHasColTag = _dom.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.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 (!this.tblHasColTag) {
createColTags(this);
} else {
var cols = _dom.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.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;
}
}, {
key: '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.Dom.id(tf.id);
}
}]);
return GridLayout;
})();
exports.GridLayout = GridLayout;
});
//# sourceMappingURL=gridLayout.js.map

View file

@ -1,169 +0,0 @@
define(['exports', '../dom', '../event'], function (exports, _dom, _event) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var Help = (function () {
/**
* Help UI component
* @param {Object} tf TableFilter instance
*/
function Help(tf) {
_classCallCheck(this, Help);
// Configuration object
var f = tf.config();
//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>';
//id prefix for help elements
this.prfxHelpSpan = 'helpSpan_';
//id prefix for help elements
this.prfxHelpDiv = 'helpDiv_';
this.tf = tf;
}
_createClass(Help, [{
key: 'init',
value: function init() {
var _this = this;
if (this.helpInstrBtnEl) {
return;
}
var tf = this.tf;
var helpspan = _dom.Dom.create('span', ['id', this.prfxHelpSpan + tf.id]);
var helpdiv = _dom.Dom.create('div', ['id', this.prfxHelpDiv + tf.id]);
//help button is added to defined element
if (!this.helpInstrTgtId) {
tf.setToolbar();
}
var targetEl = !this.helpInstrTgtId ? tf.rDiv : _dom.Dom.id(this.helpInstrTgtId);
targetEl.appendChild(helpspan);
var divContainer = !this.helpInstrContTgtId ? helpspan : _dom.Dom.id(this.helpInstrContTgtId);
if (!this.helpInstrBtnHtml) {
divContainer.appendChild(helpdiv);
var helplink = _dom.Dom.create('a', ['href', 'javascript:void(0);']);
helplink.className = this.helpInstrBtnCssClass;
helplink.appendChild(_dom.Dom.text(this.helpInstrBtnText));
helpspan.appendChild(helplink);
_event.Event.add(helplink, 'click', function () {
_this.toggle();
});
} else {
helpspan.innerHTML = this.helpInstrBtnHtml;
var helpEl = helpspan.firstChild;
_event.Event.add(helpEl, 'click', function () {
_this.toggle();
});
divContainer.appendChild(helpdiv);
}
if (!this.helpInstrHtml) {
helpdiv.innerHTML = this.helpInstrText;
helpdiv.className = this.helpInstrContCssClass;
_event.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.Event.add(helpdiv, 'dblclick', function () {
_this.toggle();
});
}
}
helpdiv.innerHTML += this.helpInstrDefaultHtml;
_event.Event.add(helpdiv, 'click', function () {
_this.toggle();
});
this.helpInstrContEl = helpdiv;
this.helpInstrBtnEl = helpspan;
}
}, {
key: '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.Dom.position(this.helpInstrBtnEl).left;
if (!this.helpInstrContTgtId) {
this.helpInstrContEl.style.left = btnLeft - this.helpInstrContEl.clientWidth + 25 + 'px';
}
} else {
this.helpInstrContEl.style.display = 'none';
}
}
}, {
key: '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;
}
}]);
return Help;
})();
exports.Help = Help;
});
//# sourceMappingURL=help.js.map

View file

@ -1,134 +0,0 @@
define(['exports', '../dom', '../string'], function (exports, _dom, _string) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var HighlightKeyword = (function () {
/**
* 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;
}
_createClass(HighlightKeyword, [{
key: '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 = _string.Str.lower(node.nodeValue);
var tempWordVal = _string.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.Dom.text(nv.substr(0, ni)),
docWordVal = nv.substr(ni, word.length),
after = _dom.Dom.text(nv.substr(ni + word.length)),
hiwordtext = _dom.Dom.text(docWordVal),
hiword = _dom.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);
}
}
}
}
}, {
key: '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 = _string.Str.lower(n.nodeValue),
tempWordVal = _string.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);
}
}
}, {
key: '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 = [];
}
}]);
return HighlightKeyword;
})();
exports.HighlightKeyword = HighlightKeyword;
});
//# sourceMappingURL=highlightKeywords.js.map

View file

@ -1,106 +0,0 @@
define(['exports', '../dom', '../types'], function (exports, _dom, _types) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var global = window;
/**
* Loading message/spinner
* @param {Object} tf TableFilter instance
*/
var Loader = (function () {
function Loader(tf) {
_classCallCheck(this, Loader);
// 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.Types.isFn(f.on_show_loader) ? f.on_show_loader : null;
//callback function after loader is closed
this.onHideLoader = _types.Types.isFn(f.on_hide_loader) ? f.on_hide_loader : null;
//loader div
this.prfxLoader = 'load_';
this.tf = tf;
var containerDiv = _dom.Dom.create('div', ['id', this.prfxLoader + tf.id]);
containerDiv.className = this.loaderCssClass;
var targetEl = !this.loaderTgtId ? tf.tbl.parentNode : _dom.Dom.id(this.loaderTgtId);
if (!this.loaderTgtId) {
targetEl.insertBefore(containerDiv, tf.tbl);
} else {
targetEl.appendChild(containerDiv);
}
this.loaderDiv = _dom.Dom.id(this.prfxLoader + tf.id);
if (!this.loaderHtml) {
this.loaderDiv.appendChild(_dom.Dom.text(this.loaderText));
} else {
this.loaderDiv.innerHTML = this.loaderHtml;
}
}
_createClass(Loader, [{
key: 'show',
value: function show(p) {
var _this = this;
if (!this.tf.loader || !this.loaderDiv || this.loaderDiv.style.display === p) {
return;
}
var displayLoader = function displayLoader() {
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);
}
}, {
key: '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.Dom.id(this.loaderTgtId);
targetEl.removeChild(this.loaderDiv);
this.loaderDiv = null;
}
}]);
return Loader;
})();
exports.Loader = Loader;
});
//# sourceMappingURL=loader.js.map

View file

@ -1,760 +0,0 @@
define(['exports', '../dom', '../types', '../string', '../helpers', '../event'], function (exports, _dom, _types, _string, _helpers, _event) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var Paging = (function () {
/**
* Pagination component
* @param {Object} tf TableFilter instance
*/
function Paging(tf) {
_classCallCheck(this, Paging);
// Configuration object
var f = tf.config();
//css class for paging buttons (previous,next,etc.)
this.btnPageCssClass = f.paging_btn_css_class || 'pgInp';
//stores paging select element
this.pagingSlc = null;
//results per page select element
this.resultsPerPageSlc = null;
//id of container element
this.pagingTgtId = f.paging_target_id || null;
//defines table paging length
this.pagingLength = !isNaN(f.paging_length) ? f.paging_length : 10;
//id of container element
this.resultsPerPageTgtId = f.results_per_page_target_id || null;
//css class for paging select element
this.pgSlcCssClass = f.paging_slc_css_class || 'pgSlc';
//css class for paging input element
this.pgInpCssClass = f.paging_inp_css_class || 'pgNbInp';
//stores results per page text and values
this.resultsPerPage = f.results_per_page || null;
//enables/disables results per page drop-down
this.hasResultsPerPage = _types.Types.isArray(this.resultsPerPage);
//defines css class for results per page select
this.resultsSlcCssClass = f.results_slc_css_class || 'rspg';
//css class for label preceding results per page select
this.resultsSpanCssClass = f.results_span_css_class || 'rspgSpan';
//1st row index of current page
this.startPagingRow = 0;
//total nb of pages
this.nbPages = 0;
//current page nb
this.currentPageNb = 1;
//defines next page button text
this.btnNextPageText = f.btn_next_page_text || '>';
//defines previous page button text
this.btnPrevPageText = f.btn_prev_page_text || '<';
//defines last page button text
this.btnLastPageText = f.btn_last_page_text || '>|';
//defines first page button text
this.btnFirstPageText = f.btn_first_page_text || '|<';
//defines next page button html
this.btnNextPageHtml = f.btn_next_page_html || (!tf.enableIcons ? null : '<input type="button" value="" class="' + this.btnPageCssClass + ' nextPage" title="Next page" />');
//defines previous page button html
this.btnPrevPageHtml = f.btn_prev_page_html || (!tf.enableIcons ? null : '<input type="button" value="" class="' + this.btnPageCssClass + ' previousPage" title="Previous page" />');
//defines last page button html
this.btnFirstPageHtml = f.btn_first_page_html || (!tf.enableIcons ? null : '<input type="button" value="" class="' + this.btnPageCssClass + ' firstPage" title="First page" />');
//defines previous page button html
this.btnLastPageHtml = f.btn_last_page_html || (!tf.enableIcons ? null : '<input type="button" value="" class="' + this.btnPageCssClass + ' lastPage" title="Last page" />');
//defines text preceeding page selector drop-down
this.pageText = f.page_text || ' Page ';
//defines text after page selector drop-down
this.ofText = f.of_text || ' of ';
//css class for span containing tot nb of pages
this.nbPgSpanCssClass = f.nb_pages_css_class || 'nbpg';
//enables/disables paging buttons
this.hasPagingBtns = f.paging_btns === false ? false : true;
//defines previous page button html
this.pageSelectorType = f.page_selector_type || tf.fltTypeSlc;
//calls function before page is changed
this.onBeforeChangePage = _types.Types.isFn(f.on_before_change_page) ? f.on_before_change_page : null;
//calls function before page is changed
this.onAfterChangePage = _types.Types.isFn(f.on_after_change_page) ? f.on_after_change_page : null;
//pages select
this.prfxSlcPages = 'slcPages_';
//results per page select
this.prfxSlcResults = 'slcResults_';
//label preciding results per page select
this.prfxSlcResultsTxt = 'slcResultsTxt_';
//span containing next page button
this.prfxBtnNextSpan = 'btnNextSpan_';
//span containing previous page button
this.prfxBtnPrevSpan = 'btnPrevSpan_';
//span containing last page button
this.prfxBtnLastSpan = 'btnLastSpan_';
//span containing first page button
this.prfxBtnFirstSpan = 'btnFirstSpan_';
//next button
this.prfxBtnNext = 'btnNext_';
//previous button
this.prfxBtnPrev = 'btnPrev_';
//last button
this.prfxBtnLast = 'btnLast_';
//first button
this.prfxBtnFirst = 'btnFirst_';
//span for tot nb pages
this.prfxPgSpan = 'pgspan_';
//span preceding pages select (contains 'Page')
this.prfxPgBeforeSpan = 'pgbeforespan_';
//span following pages select (contains ' of ')
this.prfxPgAfterSpan = 'pgafterspan_';
var start_row = this.refRow;
var nrows = this.nbRows;
//calculates page nb
this.nbPages = Math.ceil((nrows - start_row) / this.pagingLength);
//Paging elements events
var o = this;
// Paging DOM events
this.evt = {
slcIndex: function slcIndex() {
return o.pageSelectorType === tf.fltTypeSlc ? o.pagingSlc.options.selectedIndex : parseInt(o.pagingSlc.value, 10) - 1;
},
nbOpts: function nbOpts() {
return o.pageSelectorType === tf.fltTypeSlc ? parseInt(o.pagingSlc.options.length, 10) - 1 : o.nbPages - 1;
},
next: function next() {
var nextIndex = o.evt.slcIndex() < o.evt.nbOpts() ? o.evt.slcIndex() + 1 : 0;
o.changePage(nextIndex);
},
prev: function prev() {
var prevIndex = o.evt.slcIndex() > 0 ? o.evt.slcIndex() - 1 : o.evt.nbOpts();
o.changePage(prevIndex);
},
last: function last() {
o.changePage(o.evt.nbOpts());
},
first: function first() {
o.changePage(0);
},
_detectKey: function _detectKey(e) {
var key = _event.Event.keyCode(e);
if (key === 13) {
if (tf.sorted) {
tf.filter();
o.changePage(o.evt.slcIndex());
} else {
o.changePage();
}
this.blur();
}
},
slcPagesChange: null,
nextEvt: null,
prevEvt: null,
lastEvt: null,
firstEvt: null
};
this.tf = tf;
}
_createClass(Paging, [{
key: 'init',
/**
* Initialize DOM elements
*/
value: function init() {
var _this = this;
var slcPages;
var tf = this.tf;
var evt = this.evt;
// Check resultsPerPage is in expected format and initialise the
// results per page component
if (this.hasResultsPerPage) {
if (this.resultsPerPage.length < 2) {
this.hasResultsPerPage = false;
} else {
this.pagingLength = this.resultsPerPage[1][0];
this.setResultsPerPage();
}
}
/*====================================================
- onchange event for paging select
=====================================================*/
evt.slcPagesChange = function (event) {
_this.changePage();
event.target.blur();
};
// Paging drop-down list selector
if (this.pageSelectorType === tf.fltTypeSlc) {
slcPages = _dom.Dom.create(tf.fltTypeSlc, ['id', this.prfxSlcPages + tf.id]);
slcPages.className = this.pgSlcCssClass;
_event.Event.add(slcPages, 'change', evt.slcPagesChange);
}
// Paging input selector
if (this.pageSelectorType === tf.fltTypeInp) {
slcPages = _dom.Dom.create(tf.fltTypeInp, ['id', this.prfxSlcPages + tf.id], ['value', this.currentPageNb]);
slcPages.className = this.pgInpCssClass;
_event.Event.add(slcPages, 'keypress', evt._detectKey);
}
// btns containers
var btnNextSpan = _dom.Dom.create('span', ['id', this.prfxBtnNextSpan + tf.id]);
var btnPrevSpan = _dom.Dom.create('span', ['id', this.prfxBtnPrevSpan + tf.id]);
var btnLastSpan = _dom.Dom.create('span', ['id', this.prfxBtnLastSpan + tf.id]);
var btnFirstSpan = _dom.Dom.create('span', ['id', this.prfxBtnFirstSpan + tf.id]);
if (this.hasPagingBtns) {
// Next button
if (!this.btnNextPageHtml) {
var btn_next = _dom.Dom.create(tf.fltTypeInp, ['id', this.prfxBtnNext + tf.id], ['type', 'button'], ['value', this.btnNextPageText], ['title', 'Next']);
btn_next.className = this.btnPageCssClass;
_event.Event.add(btn_next, 'click', evt.next);
btnNextSpan.appendChild(btn_next);
} else {
btnNextSpan.innerHTML = this.btnNextPageHtml;
_event.Event.add(btnNextSpan, 'click', evt.next);
}
// Previous button
if (!this.btnPrevPageHtml) {
var btn_prev = _dom.Dom.create(tf.fltTypeInp, ['id', this.prfxBtnPrev + tf.id], ['type', 'button'], ['value', this.btnPrevPageText], ['title', 'Previous']);
btn_prev.className = this.btnPageCssClass;
_event.Event.add(btn_prev, 'click', evt.prev);
btnPrevSpan.appendChild(btn_prev);
} else {
btnPrevSpan.innerHTML = this.btnPrevPageHtml;
_event.Event.add(btnPrevSpan, 'click', evt.prev);
}
// Last button
if (!this.btnLastPageHtml) {
var btn_last = _dom.Dom.create(tf.fltTypeInp, ['id', this.prfxBtnLast + tf.id], ['type', 'button'], ['value', this.btnLastPageText], ['title', 'Last']);
btn_last.className = this.btnPageCssClass;
_event.Event.add(btn_last, 'click', evt.last);
btnLastSpan.appendChild(btn_last);
} else {
btnLastSpan.innerHTML = this.btnLastPageHtml;
_event.Event.add(btnLastSpan, 'click', evt.last);
}
// First button
if (!this.btnFirstPageHtml) {
var btn_first = _dom.Dom.create(tf.fltTypeInp, ['id', this.prfxBtnFirst + tf.id], ['type', 'button'], ['value', this.btnFirstPageText], ['title', 'First']);
btn_first.className = this.btnPageCssClass;
_event.Event.add(btn_first, 'click', evt.first);
btnFirstSpan.appendChild(btn_first);
} else {
btnFirstSpan.innerHTML = this.btnFirstPageHtml;
_event.Event.add(btnFirstSpan, 'click', evt.first);
}
}
// paging elements (buttons+drop-down list) are added to defined element
if (!this.pagingTgtId) {
tf.setToolbar();
}
var targetEl = !this.pagingTgtId ? tf.mDiv : _dom.Dom.id(this.pagingTgtId);
targetEl.appendChild(btnFirstSpan);
targetEl.appendChild(btnPrevSpan);
var pgBeforeSpan = _dom.Dom.create('span', ['id', this.prfxPgBeforeSpan + tf.id]);
pgBeforeSpan.appendChild(_dom.Dom.text(this.pageText));
pgBeforeSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgBeforeSpan);
targetEl.appendChild(slcPages);
var pgAfterSpan = _dom.Dom.create('span', ['id', this.prfxPgAfterSpan + tf.id]);
pgAfterSpan.appendChild(_dom.Dom.text(this.ofText));
pgAfterSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgAfterSpan);
var pgspan = _dom.Dom.create('span', ['id', this.prfxPgSpan + tf.id]);
pgspan.className = this.nbPgSpanCssClass;
pgspan.appendChild(_dom.Dom.text(' ' + this.nbPages + ' '));
targetEl.appendChild(pgspan);
targetEl.appendChild(btnNextSpan);
targetEl.appendChild(btnLastSpan);
this.pagingSlc = _dom.Dom.id(this.prfxSlcPages + tf.id);
// if this.rememberGridValues==true this.setPagingInfo() is called
// in ResetGridValues() method
if (!tf.rememberGridValues || this.isPagingRemoved) {
this.setPagingInfo();
}
if (!tf.fltGrid) {
tf.ValidateAllRows();
this.setPagingInfo(tf.validRowsIndex);
}
this.isPagingRemoved = false;
}
}, {
key: 'addPaging',
/**
* Add paging when filters are already instanciated
* @param {Boolean} filterTable Execute filtering once paging instanciated
*/
value: function addPaging() {
var filterTable = arguments[0] === undefined ? false : arguments[0];
var tf = this.tf;
if (!tf.hasGrid() || tf.paging) {
return;
}
tf.paging = true;
this.isPagingRemoved = true;
this.init();
tf.resetValues();
if (filterTable) {
tf.filter();
}
}
}, {
key: 'setPagingInfo',
/**
* Calculate number of pages based on valid rows
* Refresh paging select according to number of pages
* @param {Array} validRows Collection of valid rows
*/
value: function setPagingInfo(validRows) {
var tf = this.tf;
var rows = tf.tbl.rows;
var mdiv = !this.pagingTgtId ? tf.mDiv : _dom.Dom.id(this.pagingTgtId);
var pgspan = _dom.Dom.id(this.prfxPgSpan + tf.id);
//stores valid rows indexes
if (validRows && validRows.length > 0) {
tf.validRowsIndex = validRows;
} else {
//re-sets valid rows indexes array
tf.validRowsIndex = [];
//counts rows to be grouped
for (var j = tf.refRow; j < tf.nbRows; j++) {
var row = rows[j];
if (!row) {
continue;
}
var isRowValid = row.getAttribute('validRow');
if (isRowValid === 'true' || !isRowValid) {
tf.validRowsIndex.push(j);
}
}
}
//calculate nb of pages
this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pagingLength);
//refresh page nb span
pgspan.innerHTML = this.nbPages;
//select clearing shortcut
if (this.pageSelectorType === tf.fltTypeSlc) {
this.pagingSlc.innerHTML = '';
}
if (this.nbPages > 0) {
mdiv.style.visibility = 'visible';
if (this.pageSelectorType === tf.fltTypeSlc) {
for (var z = 0; z < this.nbPages; z++) {
var currOpt = new Option(z + 1, z * this.pagingLength, false, false);
this.pagingSlc.options[z] = currOpt;
}
} else {
//input type
this.pagingSlc.value = this.currentPageNb;
}
} else {
/*** if no results paging select and buttons are hidden ***/
mdiv.style.visibility = 'hidden';
}
this.groupByPage(tf.validRowsIndex);
}
}, {
key: 'groupByPage',
/**
* Group table rows by page and display valid rows
* @param {Array} validRows Collection of valid rows
*/
value: function groupByPage(validRows) {
var tf = this.tf;
var rows = tf.tbl.rows;
var paging_end_row = parseInt(this.startPagingRow, 10) + parseInt(this.pagingLength, 10);
//store valid rows indexes
if (validRows) {
tf.validRowsIndex = validRows;
}
//this loop shows valid rows of current page
for (var h = 0; h < tf.validRowsIndex.length; h++) {
var r = rows[tf.validRowsIndex[h]];
if (h >= this.startPagingRow && h < paging_end_row) {
if (r.getAttribute('validRow') === 'true' || !r.getAttribute('validRow')) {
r.style.display = '';
}
if (tf.alternateBgs && tf.Cpt.alternateRows) {
tf.Cpt.alternateRows.setRowBg(tf.validRowsIndex[h], h);
}
} else {
r.style.display = 'none';
if (tf.alternateBgs && tf.Cpt.alternateRows) {
tf.Cpt.alternateRows.removeRowBg(tf.validRowsIndex[h]);
}
}
}
tf.nbVisibleRows = tf.validRowsIndex.length;
tf.isStartBgAlternate = false;
//re-applies filter behaviours after filtering process
tf.applyGridProps();
}
}, {
key: 'setPage',
/**
* Show page based on passed param value (string or number):
* @param {String} or {Number} cmd possible string values: 'next',
* 'previous', 'last', 'first' or page number as per param
*/
value: function setPage(cmd) {
var tf = this.tf;
if (!tf.hasGrid() || !tf.paging) {
return;
}
var btnEvt = this.evt,
cmdtype = typeof cmd;
if (cmdtype === 'string') {
switch (_string.Str.lower(cmd)) {
case 'next':
btnEvt.next();
break;
case 'previous':
btnEvt.prev();
break;
case 'last':
btnEvt.last();
break;
case 'first':
btnEvt.first();
break;
default:
btnEvt.next();
break;
}
} else if (cmdtype === 'number') {
this.changePage(cmd - 1);
}
}
}, {
key: 'setResultsPerPage',
/**
* Generates UI elements for the number of results per page drop-down
*/
value: function setResultsPerPage() {
var _this2 = this;
var tf = this.tf;
var evt = this.evt;
if (!tf.hasGrid() && !tf.isFirstLoad) {
return;
}
if (this.resultsPerPageSlc || !this.resultsPerPage) {
return;
}
/*====================================================
- onchange event for results per page select
=====================================================*/
evt.slcResultsChange = function (ev) {
_this2.changeResultsPerPage();
ev.target.blur();
};
var slcR = _dom.Dom.create(tf.fltTypeSlc, ['id', this.prfxSlcResults + tf.id]);
slcR.className = tf.resultsSlcCssClass;
var slcRText = this.resultsPerPage[0],
slcROpts = this.resultsPerPage[1];
var slcRSpan = _dom.Dom.create('span', ['id', this.prfxSlcResultsTxt + tf.id]);
slcRSpan.className = this.resultsSpanCssClass;
// results per page select is added to external element
if (!this.resultsPerPageTgtId) {
tf.setToolbar();
}
var targetEl = !this.resultsPerPageTgtId ? tf.rDiv : _dom.Dom.id(this.resultsPerPageTgtId);
slcRSpan.appendChild(_dom.Dom.text(slcRText));
targetEl.appendChild(slcRSpan);
targetEl.appendChild(slcR);
this.resultsPerPageSlc = _dom.Dom.id(this.prfxSlcResults + tf.id);
for (var r = 0; r < slcROpts.length; r++) {
var currOpt = new Option(slcROpts[r], slcROpts[r], false, false);
this.resultsPerPageSlc.options[r] = currOpt;
}
_event.Event.add(slcR, 'change', evt.slcResultsChange);
}
}, {
key: 'removeResultsPerPage',
/**
* Remove number of results per page UI elements
*/
value: function removeResultsPerPage() {
var tf = this.tf;
if (!tf.hasGrid() || !this.resultsPerPageSlc || !this.resultsPerPage) {
return;
}
var slcR = this.resultsPerPageSlc,
slcRSpan = _dom.Dom.id(this.prfxSlcResultsTxt + tf.id);
if (slcR) {
slcR.parentNode.removeChild(slcR);
}
if (slcRSpan) {
slcRSpan.parentNode.removeChild(slcRSpan);
}
this.resultsPerPageSlc = null;
}
}, {
key: 'changePage',
/**
* Change the page asynchronously according to passed index
* @param {Number} index Index of the page (0-n)
*/
value: function changePage(index) {
var tf = this.tf;
var evt = tf.Evt;
tf.EvtManager(evt.name.changepage, { pgIndex: index });
}
}, {
key: 'changeResultsPerPage',
/**
* Change rows asynchronously according to page results
*/
value: function changeResultsPerPage() {
var tf = this.tf;
var evt = tf.Evt;
tf.EvtManager(evt.name.changeresultsperpage);
}
}, {
key: 'resetPage',
/**
* Re-set asynchronously page nb at page re-load
*/
value: function resetPage() {
var tf = this.tf;
var evt = tf.Evt;
tf.EvtManager(evt.name.resetpage);
}
}, {
key: 'resetPageLength',
/**
* Re-set asynchronously page length at page re-load
*/
value: function resetPageLength() {
var tf = this.tf;
var evt = tf.Evt;
tf.EvtManager(evt.name.resetpagelength);
}
}, {
key: '_changePage',
/**
* Change the page according to passed index
* @param {Number} index Index of the page (0-n)
*/
value: function _changePage(index) {
var tf = this.tf;
if (!tf.paging) {
return;
}
if (index === null) {
index = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.options.selectedIndex : this.pagingSlc.value - 1;
}
if (index >= 0 && index <= this.nbPages - 1) {
if (this.onBeforeChangePage) {
this.onBeforeChangePage.call(null, this, index);
}
this.currentPageNb = parseInt(index, 10) + 1;
if (this.pageSelectorType === tf.fltTypeSlc) {
this.pagingSlc.options[index].selected = true;
} else {
this.pagingSlc.value = this.currentPageNb;
}
if (tf.rememberPageNb) {
tf.Cpt.store.savePageNb(tf.pgNbCookie);
}
this.startPagingRow = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.value : index * this.pagingLength;
this.groupByPage();
if (this.onAfterChangePage) {
this.onAfterChangePage.call(null, this, index);
}
}
}
}, {
key: '_changeResultsPerPage',
/**
* Change rows according to page results
*/
value: function _changeResultsPerPage() {
var tf = this.tf;
if (!tf.paging) {
return;
}
var slcR = this.resultsPerPageSlc;
var slcPagesSelIndex = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.selectedIndex : parseInt(this.pagingSlc.value - 1, 10);
this.pagingLength = parseInt(slcR.options[slcR.selectedIndex].value, 10);
this.startPagingRow = this.pagingLength * slcPagesSelIndex;
if (!isNaN(this.pagingLength)) {
if (this.startPagingRow >= tf.nbFilterableRows) {
this.startPagingRow = tf.nbFilterableRows - this.pagingLength;
}
this.setPagingInfo();
if (this.pageSelectorType === tf.fltTypeSlc) {
var slcIndex = this.pagingSlc.options.length - 1 <= slcPagesSelIndex ? this.pagingSlc.options.length - 1 : slcPagesSelIndex;
this.pagingSlc.options[slcIndex].selected = true;
}
if (tf.rememberPageLen) {
tf.Cpt.store.savePageLength(tf.pgLenCookie);
}
}
}
}, {
key: '_resetPage',
/**
* Re-set page nb at page re-load
*/
value: function _resetPage(name) {
var tf = this.tf;
var pgnb = tf.Cpt.store.getPageNb(name);
if (pgnb !== '') {
this.changePage(pgnb - 1);
}
}
}, {
key: '_resetPageLength',
/**
* Re-set page length at page re-load
*/
value: function _resetPageLength(name) {
var tf = this.tf;
if (!tf.paging) {
return;
}
var pglenIndex = tf.Cpt.store.getPageLength(name);
if (pglenIndex !== '') {
this.resultsPerPageSlc.options[pglenIndex].selected = true;
this.changeResultsPerPage();
}
}
}, {
key: 'destroy',
/**
* Remove paging feature
*/
value: function destroy() {
var tf = this.tf;
if (!tf.hasGrid()) {
return;
}
// btns containers
var btnNextSpan, btnPrevSpan, btnLastSpan, btnFirstSpan;
var pgBeforeSpan, pgAfterSpan, pgspan;
btnNextSpan = _dom.Dom.id(this.prfxBtnNextSpan + tf.id);
btnPrevSpan = _dom.Dom.id(this.prfxBtnPrevSpan + tf.id);
btnLastSpan = _dom.Dom.id(this.prfxBtnLastSpan + tf.id);
btnFirstSpan = _dom.Dom.id(this.prfxBtnFirstSpan + tf.id);
//span containing 'Page' text
pgBeforeSpan = _dom.Dom.id(this.prfxPgBeforeSpan + tf.id);
//span containing 'of' text
pgAfterSpan = _dom.Dom.id(this.prfxPgAfterSpan + tf.id);
//span containing nb of pages
pgspan = _dom.Dom.id(this.prfxPgSpan + tf.id);
var evt = this.evt;
if (this.pagingSlc) {
if (this.pageSelectorType === tf.fltTypeSlc) {
_event.Event.remove(this.pagingSlc, 'change', evt.slcPagesChange);
} else if (this.pageSelectorType === tf.fltTypeInp) {
_event.Event.remove(this.pagingSlc, 'keypress', evt._detectKey);
}
this.pagingSlc.parentNode.removeChild(this.pagingSlc);
}
if (btnNextSpan) {
_event.Event.remove(btnNextSpan, 'click', evt.next);
btnNextSpan.parentNode.removeChild(btnNextSpan);
}
if (btnPrevSpan) {
_event.Event.remove(btnPrevSpan, 'click', evt.prev);
btnPrevSpan.parentNode.removeChild(btnPrevSpan);
}
if (btnLastSpan) {
_event.Event.remove(btnLastSpan, 'click', evt.last);
btnLastSpan.parentNode.removeChild(btnLastSpan);
}
if (btnFirstSpan) {
_event.Event.remove(btnFirstSpan, 'click', evt.first);
btnFirstSpan.parentNode.removeChild(btnFirstSpan);
}
if (pgBeforeSpan) {
pgBeforeSpan.parentNode.removeChild(pgBeforeSpan);
}
if (pgAfterSpan) {
pgAfterSpan.parentNode.removeChild(pgAfterSpan);
}
if (pgspan) {
pgspan.parentNode.removeChild(pgspan);
}
if (this.hasResultsPerPage) {
this.removeResultsPerPage();
}
this.pagingSlc = null;
this.nbPages = 0;
this.isPagingRemoved = true;
tf.paging = false;
}
}]);
return Paging;
})();
exports.Paging = Paging;
});
//# sourceMappingURL=paging.js.map

View file

@ -1,255 +0,0 @@
define(['exports', '../types', '../dom', '../event', '../helpers'], function (exports, _types, _dom, _event, _helpers) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var PopupFilter = (function () {
/**
* Pop-up filter component
* @param {Object} tf TableFilter instance
*/
function PopupFilter(tf) {
_classCallCheck(this, PopupFilter);
// Configuration object
var f = tf.config();
// Enable external filters behaviour
tf.isExternalFlt = true;
tf.externalFltTgtIds = [];
//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.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.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.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.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;
//id prefix for pop-up filter span
this.prfxPopUpSpan = 'popUpSpan_';
//id prefix for pop-up div containing filter
this.prfxPopUpDiv = 'popUpDiv_';
this.tf = tf;
}
_createClass(PopupFilter, [{
key: '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.Helpers.isIE()) {
var headerLeft = _dom.Dom.position(header).left;
popUpDiv.style.left = headerLeft + 'px';
}
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
}
_event.Event.cancel(evt);
_event.Event.stop(evt);
}
}, {
key: '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.Dom.create('span', ['id', this.prfxPopUpSpan + tf.id + '_' + i], ['ci', i]);
popUpSpan.innerHTML = this.popUpImgFltHtml;
var header = tf.getHeaderElement(i);
header.appendChild(popUpSpan);
_event.Event.add(popUpSpan, 'click', function (evt) {
_this.onClick(evt);
});
this.popUpFltSpans[i] = popUpSpan;
this.popUpFltImgs[i] = popUpSpan.firstChild;
}
}
}, {
key: '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]);
}
}
}, {
key: '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.Dom.create('div', ['id', this.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.Event.add(popUpDiv, 'click', function (evt) {
_event.Event.stop(evt);
});
this.popUpFltElms[colIndex] = popUpDiv;
}
}, {
key: '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) {
var flt = tf.getFilterElement(colIndex);
if (flt) {
flt.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);
}
}
}
}, {
key: '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';
}
}
}
}, {
key: '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);
}
}
}, {
key: 'buildIcon',
/**
* Build specified icon
* @param {Number} colIndex Column index
* @param {Boolean} active Apply active state
*/
value: function buildIcon(colIndex, active) {
var activeImg = _types.Types.isUndef(active) ? true : active;
if (this.popUpFltImgs[colIndex]) {
this.popUpFltImgs[colIndex].src = active ? this.popUpImgFltActive : this.popUpImgFlt;
}
}
}, {
key: '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 = [];
}
}]);
return PopupFilter;
})();
exports.PopupFilter = PopupFilter;
});
//# sourceMappingURL=popupFilter.js.map

View file

@ -1,158 +0,0 @@
define(['exports', '../dom', '../types', '../helpers'], function (exports, _dom, _types, _helpers) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var RowsCounter = (function () {
/**
* Rows counter
* @param {Object} tf TableFilter instance
*/
function RowsCounter(tf) {
_classCallCheck(this, RowsCounter);
// TableFilter configuration
var f = tf.config();
//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';
//rows counter div
this.prfxCounter = 'counter_';
//nb displayed rows label
this.prfxTotRows = 'totrows_span_';
//label preceding nb rows label
this.prfxTotRowsTxt = 'totRowsTextSpan_';
//callback raised before counter is refreshed
this.onBeforeRefreshCounter = _types.Types.isFn(f.on_before_refresh_counter) ? f.on_before_refresh_counter : null;
//callback raised after counter is refreshed
this.onAfterRefreshCounter = _types.Types.isFn(f.on_after_refresh_counter) ? f.on_after_refresh_counter : null;
this.tf = tf;
}
_createClass(RowsCounter, [{
key: 'init',
value: function init() {
var tf = this.tf;
if (!tf.hasGrid() && !tf.isFirstLoad || this.rowsCounterSpan) {
return;
}
//rows counter container
var countDiv = _dom.Dom.create('div', ['id', this.prfxCounter + tf.id]);
countDiv.className = this.totRowsCssClass;
//rows counter label
var countSpan = _dom.Dom.create('span', ['id', this.prfxTotRows + tf.id]);
var countText = _dom.Dom.create('span', ['id', this.prfxTotRowsTxt + tf.id]);
countText.appendChild(_dom.Dom.text(this.rowsCounterText));
// counter is added to defined element
if (!this.rowsCounterTgtId) {
tf.setToolbar();
}
var targetEl = !this.rowsCounterTgtId ? tf.lDiv : _dom.Dom.id(this.rowsCounterTgtId);
//IE only: clears all for sure
if (this.rowsCounterDiv && _helpers.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();
}
}, {
key: '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);
}
}
}, {
key: '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.Helpers.isIE()) {
this.rowsCounterDiv.outerHTML = '';
} else {
this.rowsCounterDiv.parentNode.removeChild(this.rowsCounterDiv);
}
} else {
_dom.Dom.id(this.rowsCounterTgtId).innerHTML = '';
}
this.rowsCounterSpan = null;
this.rowsCounterDiv = null;
}
}]);
return RowsCounter;
})();
exports.RowsCounter = RowsCounter;
});
//# sourceMappingURL=rowsCounter.js.map

View file

@ -1,145 +0,0 @@
define(['exports', '../dom', '../event', '../types', '../helpers'], function (exports, _dom, _event, _types, _helpers) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var global = window;
var StatusBar = (function () {
/**
* Status bar UI component
* @param {Object} tf TableFilter instance
*/
function StatusBar(tf) {
_classCallCheck(this, StatusBar);
// Configuration object
var f = tf.config();
//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;
//calls function before message is displayed
this.onBeforeShowMsg = _types.Types.isFn(f.on_before_show_msg) ? f.on_before_show_msg : null;
//calls function after message is displayed
this.onAfterShowMsg = _types.Types.isFn(f.on_after_show_msg) ? f.on_after_show_msg : null;
// status bar div
this.prfxStatus = 'status_';
// status bar label
this.prfxStatusSpan = 'statusSpan_';
// text preceding status bar label
this.prfxStatusTxt = 'statusText_';
this.tf = tf;
}
_createClass(StatusBar, [{
key: 'init',
value: function init() {
var tf = this.tf;
if (!tf.hasGrid() && !tf.isFirstLoad) {
return;
}
//status bar container
var statusDiv = _dom.Dom.create('div', ['id', this.prfxStatus + tf.id]);
statusDiv.className = this.statusBarCssClass;
//status bar label
var statusSpan = _dom.Dom.create('span', ['id', this.prfxStatusSpan + tf.id]);
//preceding text
var statusSpanText = _dom.Dom.create('span', ['id', this.prfxStatusTxt + tf.id]);
statusSpanText.appendChild(_dom.Dom.text(this.statusBarText));
// target element container
if (!this.statusBarTgtId) {
tf.setToolbar();
}
var targetEl = !this.statusBarTgtId ? tf.lDiv : _dom.Dom.id(this.statusBarTgtId);
// TODO: use alternative to outerHTML
if (this.statusBarDiv && _helpers.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;
}
}, {
key: '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);
}
}, {
key: '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;
}
}]);
return StatusBar;
})();
exports.StatusBar = StatusBar;
});
//# sourceMappingURL=statusBar.js.map

View file

@ -1,116 +0,0 @@
define(['exports', '../cookie'], function (exports, _cookie) {
'use strict';
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var Store = (function () {
/**
* 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;
}
_createClass(Store, [{
key: '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.Cookie.write(name, fltValues.join(tf.separator), this.duration);
}
}, {
key: 'getFilterValues',
/**
* Retrieve filters' values from cookie
* @param {String} cookie name
* @return {Array}
*/
value: function getFilterValues(name) {
var flts = _cookie.Cookie.read(name);
var rgx = new RegExp(this.tf.separator, 'g');
// filters' values array
return flts.split(rgx);
}
}, {
key: 'savePageNb',
/**
* Store page number in cookie
* @param {String} cookie name
*/
value: function savePageNb(name) {
_cookie.Cookie.write(name, this.tf.Cpt.paging.currentPageNb, this.duration);
}
}, {
key: 'getPageNb',
/**
* Retrieve page number from cookie
* @param {String} cookie name
* @return {String}
*/
value: function getPageNb(name) {
return _cookie.Cookie.read(name);
}
}, {
key: 'savePageLength',
/**
* Store page length in cookie
* @param {String} cookie name
*/
value: function savePageLength(name) {
_cookie.Cookie.write(name, this.tf.Cpt.paging.resultsPerPageSlc.selectedIndex, this.duration);
}
}, {
key: 'getPageLength',
/**
* Retrieve page length from cookie
* @param {String} cookie name
* @return {String}
*/
value: function getPageLength(name) {
return _cookie.Cookie.read(name);
}
}]);
return Store;
})();
exports.Store = Store;
});
//# sourceMappingURL=store.js.map

View file

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

View file

@ -1,51 +0,0 @@
define(['exports'], function (exports) {
/**
* String utilities
*/
'use strict';
var Str = {};
Str.lower = function (text) {
return text.toLowerCase();
};
Str.upper = function (text) {
return text.toUpperCase();
};
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.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;
};
Str.matchCase = function (text, mc) {
if (!mc) {
return this.lower(text);
}
return text;
};
exports.Str = Str;
});
//# sourceMappingURL=string.js.map

File diff suppressed because it is too large Load diff

View file

@ -1,60 +0,0 @@
define(['exports'], function (exports) {
/**
* Types utilities
*/
'use strict';
var Types = {};
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 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;
};
/**
* Determines if passed param is undefined
* @param {Any} o
* @return {Boolean}
*/
Types.isUndef = function (o) {
return o === UNDEFINED;
};
exports.Types = Types;
});
//# sourceMappingURL=types.js.map

1183
dist/1.js vendored

File diff suppressed because one or more lines are too long

7887
dist/tablefilter.js vendored

File diff suppressed because it is too large Load diff

3
dist/tablefilter/1.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
/*====================================================
- HTML Table Filter Generator stylesheet
- do not hesitate to edit classes below to
- do not hesitate to edit classes below to
change filter grid appearance
=====================================================*/
@ -12,7 +12,7 @@ table.TF{
border-bottom:1px solid #ccc; border-right:1px solid #ccc;
}
table.TF th{
background-color:#EBECEE;
background-color:#EBECEE;
border-bottom:1px solid #D0D0D0; border-right:1px solid #D0D0D0;
border-left:1px solid #fff; border-top:1px solid #fff;
padding:5px 5px 5px 5px; color:#333;
@ -26,15 +26,15 @@ table.TF td{ padding:5px 5px 5px 5px; border-bottom:1px solid #D0D0D0; border-ri
height:20px;
background-color:#f4f4f4;
}
.fltrow td, .fltrow th{ padding:2px !important; }
.fltrow td, .fltrow th{ padding:2px !important; }
.btnflt{ /* button appearance */
font-size:11px; vertical-align:middle;
margin:0 2px 0 2px; padding:0 1px 0 1px;
margin:0 2px 0 2px; padding:0 1px 0 1px;
}
.btnflt_icon{ /* button appearance when displayIcons is true */
width:19px; height:19px; cursor:pointer !important;
border:0 !important; vertical-align:middle;
background:transparent url(TF_Themes/btn_filter.png) center center no-repeat !important;
background:transparent url(themes/btn_filter.png) center center no-repeat !important;
}
.flt{ /* filter (input) appearance */
background-color:#fff; font-size:10px;
@ -42,11 +42,11 @@ table.TF td{ padding:5px 5px 5px 5px; border-bottom:1px solid #D0D0D0; border-ri
margin:0; width:97%; vertical-align:middle;
}
select.flt{ /* select filter */
background-color:#fff; border:1px solid #ccc;
background-color:#fff; border:1px solid #ccc;
margin:0 1px 1px 0; width:99%; font-size:9px; vertical-align:middle;
}
select.flt_multi{ /* multiple select filter */
background-color:#fff; border:1px solid #ccc;
background-color:#fff; border:1px solid #ccc;
margin:0 1px 1px 0; width:99%; height:100px;
font-size:9px; vertical-align:middle;
}
@ -95,42 +95,42 @@ select.flt_multi{ /* multiple select filter */
input.reset{
width:19px; height:19px; cursor:pointer !important;
border:0 !important; vertical-align:middle;
background:transparent url(TF_Themes/btn_clear_filters.png) center center no-repeat !important;
background:transparent url(themes/btn_clear_filters.png) center center no-repeat !important;
}
input.reset:hover{ background:#CAD1D6 url(TF_Themes/btn_clear_filters.png) center center no-repeat !important; }
input.reset:hover{ background:#CAD1D6 url(themes/btn_clear_filters.png) center center no-repeat !important; }
/* PAGING ELEMENTS
=====================================================*/
.inf{ /* div containing left, middle and right divs */
clear:both; width:auto; height:25px;
background:#f4f4f4; font-size:12px;
margin:0; padding:1px 3px 1px 3px;
clear:both; width:auto; height:25px;
background:#f4f4f4; font-size:12px;
margin:0; padding:1px 3px 1px 3px;
border:1px solid #ccc; overflow:hidden;
}
.ldiv{ /* left div */
float:left; width:30%; position:inherit;
float:left; width:30%; position:inherit;
}
.mdiv{ /* middle div */
float:left; width:38%; position:inherit; text-align:center;
padding:1px 0;
}
.rdiv{ /* right div */
float:right; width:30%; position:inherit; text-align:right;
float:right; width:30%; position:inherit; text-align:right;
}
select.pgSlc{ height:20px; vertical-align:middle; font-size:10px; }/*paging drop-down list*/
input.pgNbInp{/*paging text-box*/
input.pgNbInp{/*paging text-box*/
width:25px; height:16px; margin:1px;
font-size:11px; vertical-align:middle;
font-size:11px; vertical-align:middle;
}
input.pgInp{ /*paging buttons (Next/Previous)*/
vertical-align: middle;
width:19px; height:19px; cursor:pointer !important;
border:0 !important; font-weight:bold; font-size:11px;
}
.nextPage{ background:transparent url(TF_Themes/btn_next_page.gif) center center no-repeat !important; }
.previousPage{ background:transparent url(TF_Themes/btn_previous_page.gif) center center no-repeat !important; }
.firstPage{ background:transparent url(TF_Themes/btn_first_page.gif) center center no-repeat !important; }
.lastPage{ background:transparent url(TF_Themes/btn_last_page.gif) center center no-repeat !important; }
.nextPage{ background:transparent url(themes/btn_next_page.gif) center center no-repeat !important; }
.previousPage{ background:transparent url(themes/btn_previous_page.gif) center center no-repeat !important; }
.firstPage{ background:transparent url(themes/btn_first_page.gif) center center no-repeat !important; }
.lastPage{ background:transparent url(themes/btn_last_page.gif) center center no-repeat !important; }
.nextPage:hover, .previousPage:hover, .firstPage:hover, .lastPage:hover{ background-color:#CAD1D6 !important; }
span.nbpg{ padding:0 5px 0 0; }/*paging nb pages*/
@ -157,9 +157,9 @@ span.keyword{ background-color: #ffcc00;}/*highlighted word*/
.loader{ /* loader appearance */
position:absolute; padding: 5px 10px 5px 10px;
margin:20px 0 0 20px; width:auto;
margin:20px 0 0 20px; width:auto;
z-index:1000; font-size:12px; font-weight:bold;
border:1px solid #666; background:#f4f4f4;
border:1px solid #666; background:#f4f4f4;
vertical-align:middle;
}
@ -180,11 +180,11 @@ div.head{ width:auto; overflow:hidden; }
/* Help elements */
.helpBtn{ margin:0 5px 0 5px; padding: 2px 4px 2px 4px; border-left:1px solid #ccc; border-right:1px solid #ccc; } /* help button */
div.helpCont{ /* help container */
position:absolute; display:none;
position:absolute; display:none;
max-width:300px; overflow:auto;
padding:7px 7px 7px 7px; margin:15px 0;
border:1px solid #CCC; line-height:19px;
font-size:12px; color:#333;
border:1px solid #CCC; line-height:19px;
font-size:12px; color:#333;
background:#fff; text-align:left;
border-radius:4px;
-moz-border-radius:4px;
@ -200,10 +200,10 @@ div.helpFooter{ margin:10px 0 0 0; }
div.helpFooter h4{ margin:2px 2px 2px 2px; font-size:13px; color:#333; }
/* Pop-up filters elements */
div.popUpFilter{
div.popUpFilter{
position:absolute; display:none; width:100px;
background:#C8E0FB; border:1px solid #e4e4e4;
padding:1px 3px 1px 1px;
padding:1px 3px 1px 1px;
margin:20px auto 0 0px;
}
@ -215,8 +215,8 @@ div.popUpFilter{
div.grd_Cont{ /*Main container*/
width:800px; height:auto;
overflow:hidden;
padding:3px 3px 3px 3px;
background:#C8E0FB;
padding:3px 3px 3px 3px;
background:#C8E0FB;
border:1px solid #99BBE8;
}
div.grd_tblCont{ /*Content table container*/
@ -252,7 +252,7 @@ div.grd_tblCont table th, div.grd_headTblCont table th, div.grd_headTblCont tabl
text-overflow:ellipsis;
}
div.grd_tblCont table td{
padding:2px 2px 2px 2px !important;
padding:2px 2px 2px 2px !important;
border-bottom:1px solid #ccc !important;
overflow:hidden;
/*white-space:nowrap;*/
@ -260,8 +260,8 @@ div.grd_tblCont table td{
}
.grd_inf{ /* div containing left, middle and right divs */
clear:both; width:auto; height:25px;
background:#C8E0FB; font-size:11px;
clear:both; width:auto; height:25px;
background:#C8E0FB; font-size:11px;
margin:0; padding:1px 3px 1px 3px;
border-top:1px solid #99BBE8;
}
@ -277,7 +277,7 @@ div.grd_Cont .odd{ background-color:#DFE8F6; }/*row bg alternating color*/
.ezSelectedRow{ background-color:#316AC5; color:#fff; }
.ezActiveCell{
background-color:#D9E8FB !important;
color:#000 !important; font-weight:bold;
color:#000 !important; font-weight:bold;
}
.ezETSelectedCell{ background-color:#FFDC61 !important; font-weight:bold; color:rgb(0,0,0)!important; }
.ezUnselectable{
@ -296,7 +296,7 @@ div.grd_Cont .odd{ background-color:#DFE8F6; }/*row bg alternating color*/
select[multiple="multiple"].ezSelectEditor{ height:35px; }
/* Command type editor */
.ezCommandEditor{ margin:2px; }
.ezCommandEditor button, .ezCommandEditor input[type="button"] {
.ezCommandEditor button, .ezCommandEditor input[type="button"] {
font-size:11px; min-height:22px;
margin:1px; padding:3px;
border:1px solid #ccc; background:#fff;
@ -324,5 +324,5 @@ select[multiple="multiple"].ezSelectEditor{ height:35px; }
background-position:center center;
background-repeat:no-repeat;
}
.sort-arrow.descending{ background-image:url("TF_Themes/downsimple.png"); }
.sort-arrow.ascending{ background-image:url("TF_Themes/upsimple.png"); }
.sort-arrow.descending{ background-image:url("themes/downsimple.png"); }
.sort-arrow.ascending{ background-image:url("themes/upsimple.png"); }

7
dist/tablefilter/tablefilter.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 303 B

View file

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 326 B

View file

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 356 B

View file

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 332 B

View file

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 331 B

View file

Before

Width:  |  Height:  |  Size: 187 B

After

Width:  |  Height:  |  Size: 187 B

View file

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 440 B

View file

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 640 B

View file

Before

Width:  |  Height:  |  Size: 427 B

After

Width:  |  Height:  |  Size: 427 B

View file

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 393 B

View file

Before

Width:  |  Height:  |  Size: 395 B

After

Width:  |  Height:  |  Size: 395 B

View file

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 290 B

View file

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

Before

Width:  |  Height:  |  Size: 300 B

After

Width:  |  Height:  |  Size: 300 B

View file

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 303 B

View file

Before

Width:  |  Height:  |  Size: 928 B

After

Width:  |  Height:  |  Size: 928 B

View file

Before

Width:  |  Height:  |  Size: 63 B

After

Width:  |  Height:  |  Size: 63 B

View file

Before

Width:  |  Height:  |  Size: 61 B

After

Width:  |  Height:  |  Size: 61 B

View file

Before

Width:  |  Height:  |  Size: 59 B

After

Width:  |  Height:  |  Size: 59 B

View file

Before

Width:  |  Height:  |  Size: 58 B

After

Width:  |  Height:  |  Size: 58 B

View file

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View file

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 554 B

View file

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

View file

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

View file

Before

Width:  |  Height:  |  Size: 97 B

After

Width:  |  Height:  |  Size: 97 B

View file

Before

Width:  |  Height:  |  Size: 97 B

After

Width:  |  Height:  |  Size: 97 B

View file

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 601 B

View file

Before

Width:  |  Height:  |  Size: 847 B

After

Width:  |  Height:  |  Size: 847 B

View file

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View file

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 360 B

View file

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 325 B

View file

Before

Width:  |  Height:  |  Size: 63 B

After

Width:  |  Height:  |  Size: 63 B

View file

Before

Width:  |  Height:  |  Size: 61 B

After

Width:  |  Height:  |  Size: 61 B

View file

Before

Width:  |  Height:  |  Size: 59 B

After

Width:  |  Height:  |  Size: 59 B

View file

Before

Width:  |  Height:  |  Size: 58 B

After

Width:  |  Height:  |  Size: 58 B

View file

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

View file

Before

Width:  |  Height:  |  Size: 68 B

After

Width:  |  Height:  |  Size: 68 B

View file

Before

Width:  |  Height:  |  Size: 78 B

After

Width:  |  Height:  |  Size: 78 B

View file

Before

Width:  |  Height:  |  Size: 201 B

After

Width:  |  Height:  |  Size: 201 B

179
examples/dev-complex.html Normal file
View file

@ -0,0 +1,179 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Table Filter Generator</title>
</head>
<body>
<div style="width: 500px;">
<table id="demo" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>From</th>
<th>Destination</th>
<th>Road Distance (km)</th>
<th>By Air (hrs)</th>
<th>By Rail (hrs)</th>
</tr>
</thead>
<!-- <tfoot>
<tr>
<td>Tot:</td>
<td></td>
<td id="sum1"></td>
<td id="sum2"></td>
<td></td>
</tr>
</tfoot> -->
<tbody>
<tr>
<td><strong>Sydney</strong></td>
<td>Adelaide</td>
<td>1412</td>
<td>1.4</td>
<td>25.3</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Brisbane</td>
<td>982</td>
<td>1.5</td>
<td>16</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Canberra</td>
<td>286</td>
<td>.6</td>
<td>4.3</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Melbourne</td>
<td>872</td>
<td>1.1</td>
<td>10.5</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Perth</td>
<td>2781</td>
<td>3.1</td>
<td>38</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Alice Springs</td>
<td>1533</td>
<td>2</td>
<td>20.25</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Brisbane</td>
<td>2045</td>
<td>2.15</td>
<td>40</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript" src="../build/tablefilter/tablefilter.js"></script>
<script>
// var table = document.getElementById('demo');
// var totRowIndex = table.getElementsByTagName("tr").length;
var tf = new TableFilter("demo", {
col_0: 'select',
col_2: 'multiple',
col_3: 'checklist',
base_path: '../build/tablefilter/',
loader: true,
rows_counter: true,
enable_default_theme: true,
// slc_filling_method: 'innerhtml',
sort: true,
sort_config: {
sort_types: ['string','string','number','number','number']
},
paging: false,
paging_length: 4,
// page_selector_type: 'input',
results_per_page: ['Results per page', [2,4,6]],
remember_grid_values: true,
// remember_page_number: true,
// remember_page_length: true,
fill_slc_on_demand: false,
linked_filters: false,
popup_filters: false,
alternate_rows: true,
highlight_keywords: true,
match_case: false,
btn_reset: true,
status_bar: true,
watermark: [null, 'Filter column...', null, null, 'Helo'],
selectable: false,
editable: false,
ezEditTable_config:{
default_selection: 'both',
loadStylesheet: true
},
grid_layout: true,
grid_width: '600px',
// grid_height: '200px',
on_before_show_msg: function(tf){
// console.log('on_before_show_msg');
},
// rows_always_visible: [totRowIndex],
// col_operation: {
// id: ["sum1", "sum2"],
// col: [2, 3],
// operation: ["sum", "mean"],
// write_method: ["innerhtml", 'innerhtml'],
// exclude_row: [totRowIndex],
// decimal_precision: [0, 2],
// tot_row_index: [totRowIndex, totRowIndex]
// },
extensions: [{
/*** Columns Visibility Manager extension load ***/
name: 'colsVisibility',
description: 'Columns visibility manager',
// manager: true,
tick_to_hide: true,
// headers_table: true,
// container_target_id: 'test_cont',
// headers_text: ['1','2','3','4','5','6'],
// btn_target_id: 'test_cont',
// btn_text: 'Hola',
// btn_html: '<button>Columns</button>',
// btn_css_class: 'test',
// btn_close_text: 'jj',
// btn_close_html: '<button>close</button>',
// btn_close_css_class: 'test',
// stylesheet: 'hola.css',
// cont_css_class: 'test',
// checklist_item_css_class: 'test',
// at_start: [0,1,2,3,4],
// enable_hover: true,
enable_tick_all: true
// ,
// tick_all_text: 'Hola',
// text: 'tutu',
// on_loaded: function(){ console.log(arguments); },
// on_before_open: function(){ console.log('on_before_open', arguments); },
// on_after_open: function(){ console.log('on_after_open',arguments); },
// on_before_close: function(){ console.log('on_before_close',arguments); },
// on_after_close: function(){ console.log('on_after_close',arguments); },
// on_before_col_hidden: function(){ console.log('on_before_col_hidden',arguments); },
// on_after_col_hidden: function(){ console.log('on_after_col_hidden',arguments); },
// on_before_col_displayed: function(){ console.log('on_before_col_displayed',arguments); },
// on_after_col_displayed: function(){ console.log('on_after_col_displayed',arguments); }
}]
});
tf.init();
</script>
<button onclick="javascript:tf.ExtRegistry.colsVisibility.toggleCol(2);">Toggle col 2</button>
</body>
</html>

153
examples/dev.html Normal file
View file

@ -0,0 +1,153 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Table Filter Generator</title>
</head>
<body>
<table id="demo" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>From</th>
<th>Destination</th>
<th>Road Distance (km)</th>
<th>By Air (hrs)</th>
<th width="15%">By Rail (hrs)</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Tot:</td>
<td></td>
<td id="sum1"></td>
<td id="sum2"></td>
<td></td>
</tr>
</tfoot>
<tbody>
<tr>
<td><strong>Sydney</strong></td>
<td>Adelaide</td>
<td>1412</td>
<td>1.4</td>
<td>25.3</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Brisbane</td>
<td>982</td>
<td>1.5</td>
<td>16</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Canberra</td>
<td>286</td>
<td>.6</td>
<td>4.3</td>
</tr>
<tr>
<td><strong>Sydney</strong></td>
<td>Melbourne</td>
<td>872</td>
<td>1.1</td>
<td>10.5</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Perth</td>
<td>2781</td>
<td>3.1</td>
<td>38</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Alice Springs</td>
<td>1533</td>
<td>2</td>
<td>20.25</td>
</tr>
<tr>
<td><strong>Adelaide</strong></td>
<td>Brisbane</td>
<td>2045</td>
<td>2.15</td>
<td>40</td>
</tr>
</tbody>
</table>
<script type="text/javascript" src="../build/tablefilter/tablefilter.js"></script>
<script>
var table = document.getElementById('demo');
var totRowIndex = table.getElementsByTagName("tr").length;
var tf = new TableFilter("demo", {
col_0: 'select',
col_3: 'checklist',
base_path: '../build/tablefilter/',
rows_counter: true,
enable_default_theme: true,
paging: false,
alternate_rows: true,
highlight_keywords: true,
match_case: false,
remember_grid_values: true,
btn_reset: true,
grid_layout: false,
sort: true,
sort_config: {
sort_types: ['string','string','number','number','number']
},
rows_always_visible: [totRowIndex],
col_operation: {
id: ["sum1", "sum2"],
col: [2, 3],
operation: ["sum", "mean"],
write_method: ["innerhtml", 'innerhtml'],
exclude_row: [totRowIndex],
decimal_precision: [0, 2],
tot_row_index: [totRowIndex, totRowIndex]
},
extensions: [{
/*** Columns Visibility Manager extension load ***/
name: 'colsVisibility',
description: 'Columns visibility manager',/*
initialize: function(o){o.SetColsVisibility();}*/
// manager: true,
tick_to_hide: true,
// headers_table: true,
// container_target_id: 'test_cont',
// headers_text: ['1','2','3','4','5','6'],
// btn_target_id: 'test_cont',
// btn_text: 'Hola',
// btn_html: '<button>Columns</button>',
// btn_css_class: 'test',
// btn_close_text: 'jj',
// btn_close_html: '<button>close</button>',
// btn_close_css_class: 'test',
// stylesheet: 'hola.css',
// cont_css_class: 'test',
// checklist_item_css_class: 'test',
// at_start: [0,1,2,3,4],
// enable_hover: true,
enable_tick_all: true
// ,
// tick_all_text: 'Hola',
// text: 'tutu',
// on_loaded: function(){ console.log(arguments); },
// on_before_open: function(){ console.log('on_before_open', arguments); },
// on_after_open: function(){ console.log('on_after_open',arguments); },
// on_before_close: function(){ console.log('on_before_close',arguments); },
// on_after_close: function(){ console.log('on_after_close',arguments); },
// on_before_col_hidden: function(){ console.log('on_before_col_hidden',arguments); },
// on_after_col_hidden: function(){ console.log('on_after_col_hidden',arguments); },
// on_before_col_displayed: function(){ console.log('on_before_col_displayed',arguments); },
// on_after_col_displayed: function(){ console.log('on_after_col_displayed',arguments); }
}]
});
tf.init();
</script>
</body>
</html>

View file

@ -78,7 +78,7 @@
</table>
</div>
<script type="text/javascript" src="../dist/tablefilter.js"></script>
<script type="text/javascript" src="../dist/tablefilter/tablefilter.js"></script>
<script>
// var table = document.getElementById('demo');
// var totRowIndex = table.getElementsByTagName("tr").length;

View file

@ -76,7 +76,7 @@
</tbody>
</table>
<script type="text/javascript" src="../dist/tablefilter.js"></script>
<script type="text/javascript" src="../dist/tablefilter/tablefilter.js"></script>
<script>
var table = document.getElementById('demo');
var totRowIndex = table.getElementsByTagName("tr").length;
@ -84,7 +84,7 @@
var tf = new TableFilter("demo", {
col_0: 'select',
col_3: 'checklist',
base_path: '../dist/',
base_path: '../dist/tablefilter/',
rows_counter: true,
enable_default_theme: true,
paging: false,

View file

@ -100,7 +100,7 @@
col_0: 'select',
col_2: 'multiple',
col_3: 'checklist',
base_path: '../dev/',
base_path: '../build/tablefilter',
loader: false,
rows_counter: true,
enable_default_theme: false,
@ -141,7 +141,7 @@
extensions: [{
/*** Columns Visibility Manager extension load ***/
name: 'colsVisibility',
path: '../dev/extensions/colsVisibility',
path: '../build/extensions/colsVisibility',
description: 'Columns visibility manager',/*
initialize: function(o){o.SetColsVisibility();}*/
// manager: true,

View file

@ -1,11 +1,13 @@
{
"name": "TableFilter",
"version": "3.0.0",
"version": "0.0.1",
"devDependencies": {
"babel-core": "^5.1.13",
"babel-loader": "^5.0.0",
"clean-webpack-plugin": "^0.1.3",
"grunt": "^0.4.5",
"grunt-babel": "^5.0.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-qunit": "^0.7.0",
"grunt-webpack": "^1.0.8",

View file

@ -125,8 +125,10 @@ export default class ColsVisibility{
}
//Loads extension stylesheet
// tf.includeFile(
// f.name+'Style', this.path +'/'+ this.stylesheet, null, 'link');
tf.includeFile(
f.name+'Style', this.path +'/'+ this.stylesheet, null, 'link');
f.name+'Style', tf.basePath + this.stylesheet, null, 'link');
this.tf = tf;
}

View file

@ -4,7 +4,6 @@ import {Arr} from '../../array';
import {Event} from '../../event';
import {DateHelper} from '../../date';
import {Helpers} from '../../helpers';
import 'script!sortabletable';
export default class AdapterSortableTable{

View file

@ -0,0 +1,4 @@
import 'script!sortabletable';
import AdapterSortableTable from './adapterSortabletable';
export default AdapterSortableTable;

View file

@ -1,5 +1,5 @@
/* ------------------------------------------------------------------------
- HTML Table Filter Generator v3.0
- HTML Table Filter Generator v0.0.1
- By Max Guglielmi (tablefilter.free.fr)
- Licensed under the MIT License
---------------------------------------------------------------------------
@ -41,6 +41,8 @@ var global = window,
formatDate = dateHelper.format,
doc = global.document;
// export {Paging, GridLayout};
export class TableFilter{
/**
@ -53,7 +55,7 @@ export class TableFilter{
if(arguments.length === 0){ return; }
this.id = id;
this.version = '3.0';
this.version = '0.0.1';
this.year = new Date().getFullYear();
this.tbl = dom.id(id);
this.startRow = null;
@ -97,7 +99,7 @@ export class TableFilter{
catch(e){ this.nbCells = this.getCellsNb(0); }
//default script base path
this.basePath = f.base_path!==undefined ? f.base_path : '';
this.basePath = f.base_path!==undefined ? f.base_path : 'tablefilter/';
this.extensionsPath = f.extensions_path || this.basePath+'extensions/';
/*** filter types ***/
@ -190,7 +192,7 @@ export class TableFilter{
/*** filters' grid appearance ***/
//stylesheet file
this.stylesheet = f.stylesheet || this.basePath+'filtergrid.css';
this.stylesheet = f.stylesheet || this.basePath+'tablefilter.css';
this.stylesheetId = this.id + '_style';
//defines css class for filters row
this.fltsRowCssClass = f.flts_row_css_class || 'fltrow';
@ -386,12 +388,12 @@ export class TableFilter{
this.sortConfig.name = this.sortConfig['name']!==undefined ?
f.sort_config.name : 'sortabletable';
this.sortConfig.src = this.sortConfig['src']!==undefined ?
f.sort_config.src : this.extensionsPath+'sortabletable/' +
f.sort_config.src : this.extensionsPath+'sort/' +
'sortabletable.js';
this.sortConfig.adapterSrc =
this.sortConfig['adapter_src']!==undefined ?
f.sort_config.adapter_src :
this.extensionsPath+'sortabletable/adapterSortabletable.js';
this.extensionsPath+'sort/adapterSortabletable.js';
this.sortConfig.initialize =
this.sortConfig['initialize']!==undefined ?
f.sort_config.initialize :
@ -553,7 +555,7 @@ export class TableFilter{
(f.themes && types.isObj(f.themes))) ? true : false;
this.themes = this.hasThemes ? f.themes : null;
//themes path
this.themesPath = f.themes_path || this.basePath+'TF_Themes/';
this.themesPath = f.themes_path || this.basePath+'themes/';
// Features registry
this.Cpt = {
@ -1548,8 +1550,8 @@ export class TableFilter{
// });
this.loadExtension({
name: 'adapterSortabletable.js',
path: './extensions/sortabletable'
name: 'sort'/*,
path: './extensions/sort/sort.js'*/
});
}
@ -3380,9 +3382,11 @@ export class TableFilter{
getFilterableRowsNb(){
return this.getRowsNb(false);
}
}
TableFilter.Paging = Paging;
TableFilter.GridLayout = GridLayout;
function removeNbFormat(data, format){
if(!data){
return;
@ -3512,3 +3516,4 @@ function setOuterHtml(){
// }// for i
// }
/*===END removable section===========================*/

1152
src/1.js

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*====================================================
- HTML Table Filter Generator stylesheet
- do not hesitate to edit classes below to
- do not hesitate to edit classes below to
change filter grid appearance
=====================================================*/
@ -12,7 +12,7 @@ table.TF{
border-bottom:1px solid #ccc; border-right:1px solid #ccc;
}
table.TF th{
background-color:#EBECEE;
background-color:#EBECEE;
border-bottom:1px solid #D0D0D0; border-right:1px solid #D0D0D0;
border-left:1px solid #fff; border-top:1px solid #fff;
padding:5px 5px 5px 5px; color:#333;
@ -26,15 +26,15 @@ table.TF td{ padding:5px 5px 5px 5px; border-bottom:1px solid #D0D0D0; border-ri
height:20px;
background-color:#f4f4f4;
}
.fltrow td, .fltrow th{ padding:2px !important; }
.fltrow td, .fltrow th{ padding:2px !important; }
.btnflt{ /* button appearance */
font-size:11px; vertical-align:middle;
margin:0 2px 0 2px; padding:0 1px 0 1px;
margin:0 2px 0 2px; padding:0 1px 0 1px;
}
.btnflt_icon{ /* button appearance when displayIcons is true */
width:19px; height:19px; cursor:pointer !important;
border:0 !important; vertical-align:middle;
background:transparent url(TF_Themes/btn_filter.png) center center no-repeat !important;
background:transparent url(themes/btn_filter.png) center center no-repeat !important;
}
.flt{ /* filter (input) appearance */
background-color:#fff; font-size:10px;
@ -42,11 +42,11 @@ table.TF td{ padding:5px 5px 5px 5px; border-bottom:1px solid #D0D0D0; border-ri
margin:0; width:97%; vertical-align:middle;
}
select.flt{ /* select filter */
background-color:#fff; border:1px solid #ccc;
background-color:#fff; border:1px solid #ccc;
margin:0 1px 1px 0; width:99%; font-size:9px; vertical-align:middle;
}
select.flt_multi{ /* multiple select filter */
background-color:#fff; border:1px solid #ccc;
background-color:#fff; border:1px solid #ccc;
margin:0 1px 1px 0; width:99%; height:100px;
font-size:9px; vertical-align:middle;
}
@ -95,42 +95,42 @@ select.flt_multi{ /* multiple select filter */
input.reset{
width:19px; height:19px; cursor:pointer !important;
border:0 !important; vertical-align:middle;
background:transparent url(TF_Themes/btn_clear_filters.png) center center no-repeat !important;
background:transparent url(themes/btn_clear_filters.png) center center no-repeat !important;
}
input.reset:hover{ background:#CAD1D6 url(TF_Themes/btn_clear_filters.png) center center no-repeat !important; }
input.reset:hover{ background:#CAD1D6 url(themes/btn_clear_filters.png) center center no-repeat !important; }
/* PAGING ELEMENTS
=====================================================*/
.inf{ /* div containing left, middle and right divs */
clear:both; width:auto; height:25px;
background:#f4f4f4; font-size:12px;
margin:0; padding:1px 3px 1px 3px;
clear:both; width:auto; height:25px;
background:#f4f4f4; font-size:12px;
margin:0; padding:1px 3px 1px 3px;
border:1px solid #ccc; overflow:hidden;
}
.ldiv{ /* left div */
float:left; width:30%; position:inherit;
float:left; width:30%; position:inherit;
}
.mdiv{ /* middle div */
float:left; width:38%; position:inherit; text-align:center;
padding:1px 0;
}
.rdiv{ /* right div */
float:right; width:30%; position:inherit; text-align:right;
float:right; width:30%; position:inherit; text-align:right;
}
select.pgSlc{ height:20px; vertical-align:middle; font-size:10px; }/*paging drop-down list*/
input.pgNbInp{/*paging text-box*/
input.pgNbInp{/*paging text-box*/
width:25px; height:16px; margin:1px;
font-size:11px; vertical-align:middle;
font-size:11px; vertical-align:middle;
}
input.pgInp{ /*paging buttons (Next/Previous)*/
vertical-align: middle;
width:19px; height:19px; cursor:pointer !important;
border:0 !important; font-weight:bold; font-size:11px;
}
.nextPage{ background:transparent url(TF_Themes/btn_next_page.gif) center center no-repeat !important; }
.previousPage{ background:transparent url(TF_Themes/btn_previous_page.gif) center center no-repeat !important; }
.firstPage{ background:transparent url(TF_Themes/btn_first_page.gif) center center no-repeat !important; }
.lastPage{ background:transparent url(TF_Themes/btn_last_page.gif) center center no-repeat !important; }
.nextPage{ background:transparent url(themes/btn_next_page.gif) center center no-repeat !important; }
.previousPage{ background:transparent url(themes/btn_previous_page.gif) center center no-repeat !important; }
.firstPage{ background:transparent url(themes/btn_first_page.gif) center center no-repeat !important; }
.lastPage{ background:transparent url(themes/btn_last_page.gif) center center no-repeat !important; }
.nextPage:hover, .previousPage:hover, .firstPage:hover, .lastPage:hover{ background-color:#CAD1D6 !important; }
span.nbpg{ padding:0 5px 0 0; }/*paging nb pages*/
@ -157,9 +157,9 @@ span.keyword{ background-color: #ffcc00;}/*highlighted word*/
.loader{ /* loader appearance */
position:absolute; padding: 5px 10px 5px 10px;
margin:20px 0 0 20px; width:auto;
margin:20px 0 0 20px; width:auto;
z-index:1000; font-size:12px; font-weight:bold;
border:1px solid #666; background:#f4f4f4;
border:1px solid #666; background:#f4f4f4;
vertical-align:middle;
}
@ -180,11 +180,11 @@ div.head{ width:auto; overflow:hidden; }
/* Help elements */
.helpBtn{ margin:0 5px 0 5px; padding: 2px 4px 2px 4px; border-left:1px solid #ccc; border-right:1px solid #ccc; } /* help button */
div.helpCont{ /* help container */
position:absolute; display:none;
position:absolute; display:none;
max-width:300px; overflow:auto;
padding:7px 7px 7px 7px; margin:15px 0;
border:1px solid #CCC; line-height:19px;
font-size:12px; color:#333;
border:1px solid #CCC; line-height:19px;
font-size:12px; color:#333;
background:#fff; text-align:left;
border-radius:4px;
-moz-border-radius:4px;
@ -200,10 +200,10 @@ div.helpFooter{ margin:10px 0 0 0; }
div.helpFooter h4{ margin:2px 2px 2px 2px; font-size:13px; color:#333; }
/* Pop-up filters elements */
div.popUpFilter{
div.popUpFilter{
position:absolute; display:none; width:100px;
background:#C8E0FB; border:1px solid #e4e4e4;
padding:1px 3px 1px 1px;
padding:1px 3px 1px 1px;
margin:20px auto 0 0px;
}
@ -215,8 +215,8 @@ div.popUpFilter{
div.grd_Cont{ /*Main container*/
width:800px; height:auto;
overflow:hidden;
padding:3px 3px 3px 3px;
background:#C8E0FB;
padding:3px 3px 3px 3px;
background:#C8E0FB;
border:1px solid #99BBE8;
}
div.grd_tblCont{ /*Content table container*/
@ -252,7 +252,7 @@ div.grd_tblCont table th, div.grd_headTblCont table th, div.grd_headTblCont tabl
text-overflow:ellipsis;
}
div.grd_tblCont table td{
padding:2px 2px 2px 2px !important;
padding:2px 2px 2px 2px !important;
border-bottom:1px solid #ccc !important;
overflow:hidden;
/*white-space:nowrap;*/
@ -260,8 +260,8 @@ div.grd_tblCont table td{
}
.grd_inf{ /* div containing left, middle and right divs */
clear:both; width:auto; height:25px;
background:#C8E0FB; font-size:11px;
clear:both; width:auto; height:25px;
background:#C8E0FB; font-size:11px;
margin:0; padding:1px 3px 1px 3px;
border-top:1px solid #99BBE8;
}
@ -277,7 +277,7 @@ div.grd_Cont .odd{ background-color:#DFE8F6; }/*row bg alternating color*/
.ezSelectedRow{ background-color:#316AC5; color:#fff; }
.ezActiveCell{
background-color:#D9E8FB !important;
color:#000 !important; font-weight:bold;
color:#000 !important; font-weight:bold;
}
.ezETSelectedCell{ background-color:#FFDC61 !important; font-weight:bold; color:rgb(0,0,0)!important; }
.ezUnselectable{
@ -296,7 +296,7 @@ div.grd_Cont .odd{ background-color:#DFE8F6; }/*row bg alternating color*/
select[multiple="multiple"].ezSelectEditor{ height:35px; }
/* Command type editor */
.ezCommandEditor{ margin:2px; }
.ezCommandEditor button, .ezCommandEditor input[type="button"] {
.ezCommandEditor button, .ezCommandEditor input[type="button"] {
font-size:11px; min-height:22px;
margin:1px; padding:3px;
border:1px solid #ccc; background:#fff;
@ -324,5 +324,5 @@ select[multiple="multiple"].ezSelectEditor{ height:35px; }
background-position:center center;
background-repeat:no-repeat;
}
.sort-arrow.descending{ background-image:url("TF_Themes/downsimple.png"); }
.sort-arrow.ascending{ background-image:url("TF_Themes/upsimple.png"); }
.sort-arrow.descending{ background-image:url("themes/downsimple.png"); }
.sort-arrow.ascending{ background-image:url("themes/upsimple.png"); }

View file

Before

Width:  |  Height:  |  Size: 303 B

After

Width:  |  Height:  |  Size: 303 B

View file

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 326 B

View file

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 356 B

View file

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 332 B

View file

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 331 B

View file

Before

Width:  |  Height:  |  Size: 187 B

After

Width:  |  Height:  |  Size: 187 B

View file

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 440 B

View file

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 640 B

View file

Before

Width:  |  Height:  |  Size: 427 B

After

Width:  |  Height:  |  Size: 427 B

Some files were not shown because too many files have changed in this diff Show more