mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-10 10:26:38 +02:00
Added version replacement, made sort an extension
This commit is contained in:
parent
9a9bd2860d
commit
c4ec282b15
41
Gruntfile.js
41
Gruntfile.js
|
@ -1,14 +1,11 @@
|
|||
module.exports = function (grunt) {
|
||||
var webpack = require('webpack');
|
||||
var webpackConfig = require('./webpack.config.js');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var testDir = 'test';
|
||||
var testHost = 'http://localhost:8080/';
|
||||
|
||||
var webpack = require('webpack');
|
||||
var webpackConfig = require('./webpack.config.js');
|
||||
var Clean = require('clean-webpack-plugin');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
// var pkg = grunt.file.readJSON('package.json');
|
||||
// var version = pkg.version;
|
||||
var testDir = 'test';
|
||||
var testHost = 'http://localhost:8080/';
|
||||
module.exports = function (grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
|
||||
|
@ -63,24 +60,8 @@ module.exports = function (grunt) {
|
|||
|
||||
webpack: {
|
||||
options: webpackConfig,
|
||||
build: {
|
||||
plugins: [
|
||||
new Clean(['dist']),
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
new webpack.optimize.MinChunkSizePlugin(
|
||||
{minChunkSize: 10000}),
|
||||
new webpack.optimize.UglifyJsPlugin()
|
||||
]
|
||||
},
|
||||
// build: webpackConfig.build,
|
||||
'build-dev': {
|
||||
devtool: 'sourcemap',
|
||||
debug: true,
|
||||
plugins: [
|
||||
new Clean(['dist']),
|
||||
new webpack.optimize.DedupePlugin()
|
||||
]
|
||||
}
|
||||
build: webpackConfig.build,
|
||||
dev: webpackConfig.dev
|
||||
},
|
||||
|
||||
watch: {
|
||||
|
@ -126,7 +107,7 @@ module.exports = function (grunt) {
|
|||
|
||||
|
||||
grunt.registerTask('dev',
|
||||
['jshint', 'webpack:build-dev', 'copy:dist', 'watch:app']);
|
||||
['jshint', 'webpack:dev', 'copy:dist', 'watch:app']);
|
||||
|
||||
// Production build
|
||||
grunt.registerTask('build',
|
||||
|
@ -177,7 +158,7 @@ module.exports = function (grunt) {
|
|||
return host.concat(relParts.join('/'));
|
||||
}
|
||||
|
||||
// Returns the list of test files from the test folder for QUnit
|
||||
// Returns the list of test files from the test folder for qunit task
|
||||
function getTestFiles(testDir, host) {
|
||||
|
||||
var getFiles = function(dir, host) {
|
||||
|
|
1891
dist/tablefilter/1-d577df757d4add915f61.js
vendored
1891
dist/tablefilter/1-d577df757d4add915f61.js
vendored
File diff suppressed because one or more lines are too long
72
dist/tablefilter/tablefilter.js
vendored
72
dist/tablefilter/tablefilter.js
vendored
|
@ -83,7 +83,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
/******/ script.charset = 'utf-8';
|
||||
/******/ script.async = true;
|
||||
/******/
|
||||
/******/ script.src = __webpack_require__.p + "" + ({}[chunkId]||chunkId) + "-" + {"1":"d577df757d4add915f61"}[chunkId] + ".js";
|
||||
/******/ script.src = __webpack_require__.p + "" + ({}[chunkId]||chunkId) + "-" + {"1":"d57d3ca8ae58d8b3dce2"}[chunkId] + ".js";
|
||||
/******/ head.appendChild(script);
|
||||
/******/ }
|
||||
/******/ };
|
||||
|
@ -227,7 +227,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this._hasGrid = false;
|
||||
this.enableModules = false;
|
||||
|
||||
if (!this.tbl || _Str2['default'].lower(this.tbl.nodeName) !== 'table' || this.getRowsNb() === 0) {
|
||||
if (!this.tbl || this.tbl.nodeName != 'TABLE' || this.getRowsNb() === 0) {
|
||||
throw new Error('Could not instantiate TableFilter class: ' + 'HTML table not found.');
|
||||
}
|
||||
|
||||
|
@ -259,8 +259,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
//default script base path
|
||||
this.basePath = f.base_path || 'tablefilter/';
|
||||
//this.extensionsPath = f.extensions_path ||
|
||||
// this.basePath+'extensions/';
|
||||
|
||||
/*** filter types ***/
|
||||
this.fltTypeInp = 'input';
|
||||
|
@ -504,20 +502,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.nbVisibleRows = 0; //nb visible rows
|
||||
this.nbHiddenRows = 0; //nb hidden rows
|
||||
|
||||
/*** webfx sort adapter ***/
|
||||
//enables/disables default table sorting
|
||||
this.sort = Boolean(f.sort);
|
||||
//indicates if sort is set (used in tfAdapter.sortabletable.js)
|
||||
this.isSortEnabled = false;
|
||||
this.sortConfig = f.sort_config || {};
|
||||
this.sortConfig.name = this.sortConfig.name || 'sort';
|
||||
this.sortConfig.path = this.sortConfig.path || null;
|
||||
this.sortConfig.sortTypes = _Types2['default'].isArray(this.sortConfig.sort_types) ? this.sortConfig.sort_types : [];
|
||||
this.sortConfig.sortCol = this.sortConfig.sort_col || null;
|
||||
this.sortConfig.asyncSort = Boolean(this.sortConfig.async_sort);
|
||||
this.sortConfig.triggerIds = _Types2['default'].isArray(this.sortConfig.sort_trigger_ids) ? this.sortConfig.sort_trigger_ids : [];
|
||||
|
||||
/*** onkeyup event ***/
|
||||
/*** autofilter on typing ***/
|
||||
//enables/disables auto filtering, table is filtered when user stops
|
||||
//typing
|
||||
this.autoFilter = Boolean(f.auto_filter);
|
||||
|
@ -659,7 +644,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
resetvalues: 'ResetValues',
|
||||
resetpage: 'resetPage',
|
||||
resetpagelength: 'resetPageLength',
|
||||
sort: 'Sort',
|
||||
loadextensions: 'LoadExtensions',
|
||||
loadthemes: 'loadThemes'
|
||||
},
|
||||
|
@ -1102,9 +1086,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.Cpt.colOps = new _ColOps.ColOps(this);
|
||||
this.Cpt.colOps.calc();
|
||||
}
|
||||
if (this.sort) {
|
||||
this.importSort();
|
||||
}
|
||||
// if(this.sort){
|
||||
// this.importSort();
|
||||
// }
|
||||
|
||||
this.isFirstLoad = false;
|
||||
this._hasGrid = true;
|
||||
|
@ -1186,8 +1170,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
case ev.resetpagelength:
|
||||
cpt.paging._resetPageLength(this.pgLenCookie);
|
||||
break;
|
||||
case ev.sort:
|
||||
break;
|
||||
case ev.loadextensions:
|
||||
this._loadExtensions();
|
||||
break;
|
||||
|
@ -1510,26 +1492,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'importSort',
|
||||
|
||||
/**
|
||||
* Load sorting module:
|
||||
* - WebFX Sortable Table 1.12 plugin by Erik Arvidsson
|
||||
* - Sortable Table adapter
|
||||
*/
|
||||
value: function importSort() {
|
||||
this.loadExtension({
|
||||
name: this.sortConfig.name,
|
||||
path: this.sortConfig.path
|
||||
// path: './extensions/sort/sort.js'
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'performSort',
|
||||
value: function performSort() {
|
||||
this.EvtManager(this.Evt.name.sort);
|
||||
}
|
||||
}, {
|
||||
key: 'isCustomOptions',
|
||||
|
||||
|
@ -2745,6 +2707,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
for (var i = 0, len = slcIndex.length; i < len; i++) {
|
||||
var curSlc = _Dom2['default'].id(this.fltIds[slcIndex[i]]);
|
||||
slcSelectedValue = this.getFilterValue(slcIndex[i]);
|
||||
|
||||
// Welcome to cyclomatic complexity hell :)
|
||||
// TODO: simplify/refactor if statement
|
||||
if (activeFlt !== slcIndex[i] || this.paging && _Arr2['default'].has(slcA1, slcIndex[i]) && activeFlt === slcIndex[i] || !this.paging && (_Arr2['default'].has(slcA3, slcIndex[i]) || _Arr2['default'].has(slcA2, slcIndex[i])) || slcSelectedValue === this.displayAllText) {
|
||||
|
||||
if (_Arr2['default'].has(slcA3, slcIndex[i])) {
|
||||
|
@ -2805,7 +2770,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
var externalFltEl = this.externalFltEls[ct];
|
||||
extFlt.appendChild(externalFltEl);
|
||||
// let colFltType = this['col'+ct];
|
||||
var colFltType = this.getFilterType(ct);
|
||||
//IE special treatment for gridLayout, appended filters are
|
||||
//empty
|
||||
|
@ -2823,9 +2787,9 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.nbFilterableRows = this.getRowsNb();
|
||||
this.nbVisibleRows = this.nbFilterableRows;
|
||||
this.nbRows = rows.length;
|
||||
if (this.isSortEnabled) {
|
||||
this.sort = true;
|
||||
}
|
||||
// if(this.isSortEnabled){
|
||||
// this.sort = true;
|
||||
// }
|
||||
|
||||
// if(filtersRow.innerHTML === ''){
|
||||
// refreshFilters(this);
|
||||
|
@ -4267,11 +4231,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
// }
|
||||
});
|
||||
|
||||
//Sort is enabled if not specified in config object
|
||||
if (f.sort !== false) {
|
||||
tf.sort = true;
|
||||
tf.sortConfig.asyncSort = true;
|
||||
tf.sortConfig.triggerIds = sortTriggers;
|
||||
//Configure sort extension if any
|
||||
var sort = (f.extensions || []).filter(function (itm) {
|
||||
return itm.name === 'sort';
|
||||
});
|
||||
if (sort.length === 1) {
|
||||
sort[0].async_sort = true;
|
||||
sort[0].trigger_ids = sortTriggers;
|
||||
}
|
||||
|
||||
// if(this.gridEnableColResizer){
|
||||
|
|
|
@ -113,12 +113,7 @@
|
|||
remember_grid_values: true,
|
||||
col_widths: ['150px','150px','150px','200px','150px'],
|
||||
btn_reset: true,
|
||||
grid_layout: false,
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types: ['string','string','number','number','number']
|
||||
},
|
||||
|
||||
grid_layout: true,
|
||||
rows_always_visible: [totRowIndex],
|
||||
custom_options: {
|
||||
cols: [3],
|
||||
|
@ -142,13 +137,20 @@
|
|||
// default_selection: 'both',
|
||||
// auto_save: false
|
||||
// },
|
||||
extensions: [{
|
||||
name: 'advancedGrid',
|
||||
vendor_path: '../libs/ezEditTable/',
|
||||
selectable: true,
|
||||
editable: true,
|
||||
default_selection: 'both',
|
||||
auto_save: false
|
||||
extensions: [
|
||||
{
|
||||
name: 'sort',
|
||||
types: ['string', 'string', 'number', 'number', 'number']
|
||||
// sort_config: {
|
||||
// sort_types: ['string','string','number','number','number']
|
||||
// }
|
||||
},{
|
||||
name: 'advancedGrid',
|
||||
vendor_path: '../libs/ezEditTable/',
|
||||
selectable: true,
|
||||
editable: true,
|
||||
default_selection: 'both',
|
||||
auto_save: false
|
||||
},{
|
||||
name: 'filtersVisibility',
|
||||
// enable_icon: true,
|
||||
|
@ -157,41 +159,42 @@
|
|||
// ,
|
||||
// btn_text: 'Filters',
|
||||
// filters_row_index: 0
|
||||
},{
|
||||
/*** 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); }
|
||||
}]
|
||||
}, {
|
||||
/*** 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();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"grunt-contrib-watch": "^0.6.1",
|
||||
"grunt-webpack": "^1.0.8",
|
||||
"script-loader": "^0.6.1",
|
||||
"string-replace-webpack-plugin": "0.0.1",
|
||||
"webpack": "^1.8.10",
|
||||
"webpack-dev-server": "^1.8.2"
|
||||
},
|
||||
|
|
|
@ -11,24 +11,36 @@ export default class AdapterSortableTable{
|
|||
* SortableTable Adapter module
|
||||
* @param {Object} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf){
|
||||
constructor(tf, opts){
|
||||
// Configuration object
|
||||
var f = tf.config();
|
||||
let f = tf.config();
|
||||
|
||||
this.initialized = false;
|
||||
this.name = opts.name;
|
||||
this.desc = opts.description || 'Sortable table';
|
||||
|
||||
//indicates if paging is enabled
|
||||
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';
|
||||
this.sortTypes = Types.isArray(opts.types) ? opts.types : [];
|
||||
this.sortColAtStart = Types.isArray(opts.sort_col_at_start) ?
|
||||
opts.sort_col_at_start : null;
|
||||
this.asyncSort = Boolean(opts.async_sort);
|
||||
this.triggerIds = Types.isArray(opts.trigger_ids) ?
|
||||
opts.trigger_ids : [];
|
||||
|
||||
// edit .sort-arrow.descending / .sort-arrow.ascending in
|
||||
// tablefilter.css to reflect any path change
|
||||
this.imgPath = opts.images_path || tf.themesPath;
|
||||
this.imgBlank = opts.image_blank || 'blank.png';
|
||||
this.imgClassName = opts.image_class_name || 'sort-arrow';
|
||||
this.imgAscClassName = opts.image_asc_class_name || 'ascending';
|
||||
this.imgDescClassName = opts.image_desc_class_name ||'descending';
|
||||
//cell attribute storing custom key
|
||||
this.sortCustomKey = f.sort_custom_key || 'data-tf-sortKey';
|
||||
this.customKey = opts.sort_custom_key || 'data-tf-sortKey';
|
||||
|
||||
/*** TF additional events ***/
|
||||
//additional paging events for alternating background
|
||||
|
@ -41,21 +53,21 @@ export default class AdapterSortableTable{
|
|||
// o.Evt._OnSlcPagesChangeEvt = o.Evt._Paging.nextEvt;
|
||||
|
||||
// callback invoked after sort is loaded and instanciated
|
||||
this.onSortLoaded = Types.isFn(f.on_sort_loaded) ?
|
||||
f.on_sort_loaded : null;
|
||||
this.onSortLoaded = Types.isFn(opts.on_sort_loaded) ?
|
||||
opts.on_sort_loaded : null;
|
||||
// callback invoked before table is sorted
|
||||
this.onBeforeSort = Types.isFn(f.on_before_sort) ?
|
||||
f.on_before_sort : null;
|
||||
this.onBeforeSort = Types.isFn(opts.on_before_sort) ?
|
||||
opts.on_before_sort : null;
|
||||
// callback invoked after table is sorted
|
||||
this.onAfterSort = Types.isFn(f.on_after_sort) ? f.on_after_sort : null;
|
||||
this.onAfterSort = Types.isFn(opts.on_after_sort) ?
|
||||
f.on_after_sort : null;
|
||||
|
||||
this.tf = tf;
|
||||
}
|
||||
|
||||
init(){
|
||||
var tf = this.tf;
|
||||
var sortConfig = tf.sortConfig;
|
||||
var adpt = this;
|
||||
let tf = this.tf;
|
||||
let adpt = this;
|
||||
|
||||
// SortableTable class sanity check (sortabletable.js)
|
||||
if(Types.isUndef(SortableTable)){
|
||||
|
@ -66,11 +78,11 @@ export default class AdapterSortableTable{
|
|||
this.setSortTypes();
|
||||
|
||||
//Column sort at start
|
||||
if(sortConfig.sortCol){
|
||||
this.stt.sort(sortConfig.sortCol[0], sortConfig.sortCol[1]);
|
||||
let sortColAtStart = adpt.sortColAtStart;
|
||||
if(sortColAtStart){
|
||||
this.stt.sort(sortColAtStart[0], sortColAtStart[1]);
|
||||
}
|
||||
|
||||
tf.isSortEnabled = true;
|
||||
if(this.onSortLoaded){
|
||||
this.onSortLoaded.call(null, tf, this);
|
||||
}
|
||||
|
@ -81,8 +93,6 @@ export default class AdapterSortableTable{
|
|||
this.onBeforeSort.call(null, tf, this.stt.sortColumn);
|
||||
}
|
||||
|
||||
tf.performSort();
|
||||
|
||||
/*** sort behaviour for paging ***/
|
||||
if(tf.paging){
|
||||
adpt.isPaged = true;
|
||||
|
@ -97,13 +107,13 @@ export default class AdapterSortableTable{
|
|||
//rows alternating bg issue
|
||||
// TODO: move into AlternateRows component
|
||||
if(tf.alternateBgs){
|
||||
var rows = tf.tbl.rows, c = 0;
|
||||
let rows = tf.tbl.rows, c = 0;
|
||||
|
||||
var setClass = function(row, i, removeOnly){
|
||||
let setClass = function(row, i, removeOnly){
|
||||
if(Types.isUndef(removeOnly)){
|
||||
removeOnly = false;
|
||||
}
|
||||
var altRows = tf.Cpt.alternateRows,
|
||||
let altRows = tf.Cpt.alternateRows,
|
||||
oddCls = altRows.oddCss,
|
||||
evenCls = altRows.evenCss;
|
||||
Dom.removeClass(row, oddCls);
|
||||
|
@ -114,8 +124,8 @@ export default class AdapterSortableTable{
|
|||
}
|
||||
};
|
||||
|
||||
for (var i = tf.refRow; i < tf.nbRows; i++){
|
||||
var isRowValid = rows[i].getAttribute('validRow');
|
||||
for (let i = tf.refRow; i < tf.nbRows; i++){
|
||||
let isRowValid = rows[i].getAttribute('validRow');
|
||||
if(tf.paging && rows[i].style.display === ''){
|
||||
setClass(rows[i], c);
|
||||
c++;
|
||||
|
@ -132,10 +142,10 @@ export default class AdapterSortableTable{
|
|||
}
|
||||
//sort behaviour for paging
|
||||
if(adpt.isPaged){
|
||||
var paginator = tf.Cpt.paging,
|
||||
let paginator = tf.Cpt.paging,
|
||||
config = tf.config();
|
||||
if(paginator.hasResultsPerPage){
|
||||
var slc = paginator.resultsPerPageSlc;
|
||||
let slc = paginator.resultsPerPageSlc;
|
||||
config.paging_length = slc.options[slc.selectedIndex].value;
|
||||
}
|
||||
paginator.addPaging(false);
|
||||
|
@ -147,6 +157,8 @@ export default class AdapterSortableTable{
|
|||
adpt.onAfterSort.call(null, tf, tf.stt.sortColumn);
|
||||
}
|
||||
};
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,7 +170,7 @@ export default class AdapterSortableTable{
|
|||
}
|
||||
|
||||
overrideSortableTable(){
|
||||
var adpt = this,
|
||||
let adpt = this,
|
||||
tf = this.tf;
|
||||
|
||||
/**
|
||||
|
@ -166,11 +178,12 @@ export default class AdapterSortableTable{
|
|||
* @param {Object} e [description]
|
||||
*/
|
||||
SortableTable.prototype.headerOnclick = function(evt){
|
||||
if(!tf.sort){
|
||||
if(!adpt.initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
// find Header element
|
||||
var el = evt.target || evt.srcElement;
|
||||
let el = evt.target || evt.srcElement;
|
||||
|
||||
while(el.tagName !== 'TD' && el.tagName !== 'TH'){
|
||||
el = el.parentNode;
|
||||
|
@ -189,7 +202,7 @@ export default class AdapterSortableTable{
|
|||
* @return {Number} Cell index
|
||||
*/
|
||||
SortableTable.getCellIndex = function(oTd){
|
||||
var cells = oTd.parentNode.cells,
|
||||
let cells = oTd.parentNode.cells,
|
||||
l = cells.length, i;
|
||||
for (i = 0; cells[i] != oTd && i < l; i++){}
|
||||
return i;
|
||||
|
@ -200,22 +213,27 @@ export default class AdapterSortableTable{
|
|||
* @param {Array} oSortTypes
|
||||
*/
|
||||
SortableTable.prototype.initHeader = function(oSortTypes){
|
||||
var stt = this;
|
||||
let stt = this;
|
||||
if (!stt.tHead){
|
||||
// throw new Error('Sorting feature requires a THEAD element');
|
||||
return;
|
||||
if(tf.gridLayout){
|
||||
stt.tHead = tf.Cpt.gridLayout.headTbl.tHead;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
stt.headersRow = tf.headersRow;
|
||||
var cells = stt.tHead.rows[stt.headersRow].cells;
|
||||
let cells = stt.tHead.rows[stt.headersRow].cells;
|
||||
stt.sortTypes = oSortTypes || [];
|
||||
var l = cells.length;
|
||||
var img, c;
|
||||
for (var i = 0; i < l; i++) {
|
||||
let l = cells.length;
|
||||
let img, c;
|
||||
|
||||
for (let i = 0; i < l; i++) {
|
||||
c = cells[i];
|
||||
if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None'){
|
||||
c.style.cursor = 'pointer';
|
||||
img = Dom.create('img',
|
||||
['src', adpt.sortImgPath + adpt.sortImgBlank]);
|
||||
['src', adpt.imgPath + adpt.imgBlank]);
|
||||
c.appendChild(img);
|
||||
if (stt.sortTypes[i] !== null){
|
||||
c.setAttribute( '_sortType', stt.sortTypes[i]);
|
||||
|
@ -233,14 +251,15 @@ export default class AdapterSortableTable{
|
|||
* Overrides updateHeaderArrows in order to handle arrows indicators
|
||||
*/
|
||||
SortableTable.prototype.updateHeaderArrows = function(){
|
||||
var stt = this;
|
||||
var cells, l, img;
|
||||
let stt = this;
|
||||
let cells, l, img;
|
||||
|
||||
// external headers
|
||||
if(tf.sortConfig.asyncSort && tf.sortConfig.triggerIds !== null){
|
||||
var triggers = tf.sortConfig.triggerIds;
|
||||
if(adpt.asyncSort && adpt.triggerIds.length > 0){
|
||||
let triggers = adpt.triggerIds;
|
||||
cells = [];
|
||||
l = triggers.length;
|
||||
for(var j=0; j<triggers.length; j++){
|
||||
for(let j=0; j<triggers.length; j++){
|
||||
cells.push(Dom.id(triggers[j]));
|
||||
}
|
||||
} else {
|
||||
|
@ -250,22 +269,22 @@ export default class AdapterSortableTable{
|
|||
cells = stt.tHead.rows[stt.headersRow].cells;
|
||||
l = cells.length;
|
||||
}
|
||||
for(var i = 0; i < l; i++){
|
||||
var cellAttr = cells[i].getAttribute('_sortType');
|
||||
for(let i = 0; i < l; i++){
|
||||
let cellAttr = cells[i].getAttribute('_sortType');
|
||||
if(cellAttr !== null && cellAttr !== 'None'){
|
||||
img = cells[i].lastChild || cells[i];
|
||||
if(img.nodeName.toLowerCase() !== 'img'){
|
||||
img = Dom.create('img',
|
||||
['src', adpt.sortImgPath + adpt.sortImgBlank]);
|
||||
['src', adpt.imgPath + adpt.imgBlank]);
|
||||
cells[i].appendChild(img);
|
||||
}
|
||||
if (i === stt.sortColumn){
|
||||
img.className = adpt.sortImgClassName +' '+
|
||||
img.className = adpt.imgClassName +' '+
|
||||
(this.descending ?
|
||||
adpt.sortImgDescClassName :
|
||||
adpt.sortImgAscClassName);
|
||||
adpt.imgDescClassName :
|
||||
adpt.imgAscClassName);
|
||||
} else{
|
||||
img.className = adpt.sortImgClassName;
|
||||
img.className = adpt.imgClassName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,14 +298,14 @@ export default class AdapterSortableTable{
|
|||
* @return {String}
|
||||
*/
|
||||
SortableTable.prototype.getRowValue = function(oRow, sType, nColumn){
|
||||
var stt = this;
|
||||
let stt = this;
|
||||
// if we have defined a custom getRowValue use that
|
||||
var sortTypeInfo = stt._sortTypeInfo[sType];
|
||||
let sortTypeInfo = stt._sortTypeInfo[sType];
|
||||
if (sortTypeInfo && sortTypeInfo.getRowValue){
|
||||
return sortTypeInfo.getRowValue(oRow, nColumn);
|
||||
}
|
||||
var c = oRow.cells[nColumn];
|
||||
var s = SortableTable.getInnerText(c);
|
||||
let c = oRow.cells[nColumn];
|
||||
let s = SortableTable.getInnerText(c);
|
||||
return stt.getValueFromString(s, sType);
|
||||
};
|
||||
|
||||
|
@ -300,8 +319,8 @@ export default class AdapterSortableTable{
|
|||
if(!oNode){
|
||||
return;
|
||||
}
|
||||
if(oNode.getAttribute(adpt.sortCustomKey)){
|
||||
return oNode.getAttribute(adpt.sortCustomKey);
|
||||
if(oNode.getAttribute(adpt.customKey)){
|
||||
return oNode.getAttribute(adpt.customKey);
|
||||
} else {
|
||||
return Dom.getText(oNode);
|
||||
}
|
||||
|
@ -314,16 +333,15 @@ export default class AdapterSortableTable{
|
|||
}
|
||||
|
||||
setSortTypes(){
|
||||
var tf = this.tf,
|
||||
configSort = tf.sortConfig,
|
||||
configSortTypes = configSort.sortTypes,
|
||||
sortTypes = [];
|
||||
let tf = this.tf,
|
||||
sortTypes = this.sortTypes,
|
||||
_sortTypes = [];
|
||||
|
||||
for(var i=0; i<tf.nbCells; i++){
|
||||
var colType;
|
||||
for(let i=0; i<tf.nbCells; i++){
|
||||
let colType;
|
||||
|
||||
if(configSortTypes !== null && configSortTypes[i] != null){
|
||||
colType = configSortTypes[i].toLowerCase();
|
||||
if(sortTypes[i] !== null){
|
||||
colType = sortTypes[i].toLowerCase();
|
||||
if(colType === 'none'){
|
||||
colType = 'None';
|
||||
}
|
||||
|
@ -336,7 +354,7 @@ export default class AdapterSortableTable{
|
|||
colType = 'String';
|
||||
}
|
||||
}
|
||||
sortTypes.push(colType);
|
||||
_sortTypes.push(colType);
|
||||
}
|
||||
|
||||
//Public TF method to add sort type
|
||||
|
@ -354,21 +372,21 @@ export default class AdapterSortableTable{
|
|||
this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter);
|
||||
this.addSortType('ipaddress', ipAddress, sortIP);
|
||||
|
||||
this.stt = new SortableTable(tf.tbl, sortTypes);
|
||||
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(this.asyncSort && this.triggerIds.length > 0){
|
||||
let triggers = this.triggerIds;
|
||||
for(let j=0; j<triggers.length; j++){
|
||||
if(triggers[j] === null){
|
||||
continue;
|
||||
}
|
||||
var trigger = Dom.id(triggers[j]);
|
||||
let trigger = Dom.id(triggers[j]);
|
||||
if(trigger){
|
||||
trigger.style.cursor = 'pointer';
|
||||
|
||||
Event.add(trigger, 'click', (evt) => {
|
||||
var elm = evt.target;
|
||||
let elm = evt.target;
|
||||
if(!this.tf.sort){
|
||||
return;
|
||||
}
|
||||
|
@ -376,7 +394,7 @@ export default class AdapterSortableTable{
|
|||
Arr.indexByValue(triggers, elm.id, true)
|
||||
);
|
||||
});
|
||||
trigger.setAttribute('_sortType', sortTypes[j]);
|
||||
trigger.setAttribute('_sortType', _sortTypes[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -386,15 +404,15 @@ export default class AdapterSortableTable{
|
|||
* Destroy sort
|
||||
*/
|
||||
destroy(){
|
||||
var tf = this.tf;
|
||||
tf.sort = false;
|
||||
let tf = this.tf;
|
||||
this.sorted = false;
|
||||
this.initialized = false;
|
||||
this.stt.destroy();
|
||||
|
||||
var ids = tf.getFiltersId();
|
||||
for (var idx = 0; idx < ids.length; idx++){
|
||||
var header = tf.getHeaderElement(idx);
|
||||
var img = Dom.tag(header, 'img');
|
||||
let ids = tf.getFiltersId();
|
||||
for (let idx = 0; idx < ids.length; idx++){
|
||||
let header = tf.getHeaderElement(idx);
|
||||
let img = Dom.tag(header, 'img');
|
||||
|
||||
if(img.length === 1){
|
||||
header.removeChild(img[0]);
|
||||
|
@ -428,9 +446,9 @@ function ddmmmyyyyDateConverter(s){
|
|||
}
|
||||
|
||||
function ipAddress(value){
|
||||
var vals = value.split('.');
|
||||
for (var x in vals) {
|
||||
var val = vals[x];
|
||||
let vals = value.split('.');
|
||||
for (let x in vals) {
|
||||
let val = vals[x];
|
||||
while (3 > val.length){
|
||||
val = '0'+val;
|
||||
}
|
||||
|
@ -440,8 +458,8 @@ function ipAddress(value){
|
|||
}
|
||||
|
||||
function sortIP(a,b){
|
||||
var aa = ipAddress(a.value.toLowerCase());
|
||||
var bb = ipAddress(b.value.toLowerCase());
|
||||
let aa = ipAddress(a.value.toLowerCase());
|
||||
let bb = ipAddress(b.value.toLowerCase());
|
||||
if (aa==bb){
|
||||
return 0;
|
||||
} else if (aa<bb){
|
||||
|
|
|
@ -230,11 +230,13 @@ export class GridLayout{
|
|||
// }
|
||||
});
|
||||
|
||||
//Sort is enabled if not specified in config object
|
||||
if(f.sort !== false){
|
||||
tf.sort = true;
|
||||
tf.sortConfig.asyncSort = true;
|
||||
tf.sortConfig.triggerIds = sortTriggers;
|
||||
//Configure sort extension if any
|
||||
var sort = (f.extensions || []).filter(function(itm){
|
||||
return itm.name === 'sort';
|
||||
});
|
||||
if(sort.length === 1){
|
||||
sort[0].async_sort = true;
|
||||
sort[0].trigger_ids = sortTriggers;
|
||||
}
|
||||
|
||||
// if(this.gridEnableColResizer){
|
||||
|
|
|
@ -54,7 +54,7 @@ export class TableFilter{
|
|||
if(arguments.length === 0){ return; }
|
||||
|
||||
this.id = id;
|
||||
this.version = '0.0.1';
|
||||
this.version = '{VERSION}';
|
||||
this.year = new Date().getFullYear();
|
||||
this.tbl = Dom.id(id);
|
||||
this.startRow = null;
|
||||
|
@ -67,8 +67,7 @@ export class TableFilter{
|
|||
this._hasGrid = false;
|
||||
this.enableModules = false;
|
||||
|
||||
if(!this.tbl || Str.lower(this.tbl.nodeName) !== 'table' ||
|
||||
this.getRowsNb() === 0){
|
||||
if(!this.tbl || this.tbl.nodeName != 'TABLE' || this.getRowsNb() === 0){
|
||||
throw new Error(
|
||||
'Could not instantiate TableFilter class: ' +
|
||||
'HTML table not found.');
|
||||
|
@ -99,8 +98,6 @@ export class TableFilter{
|
|||
|
||||
//default script base path
|
||||
this.basePath = f.base_path || 'tablefilter/';
|
||||
//this.extensionsPath = f.extensions_path ||
|
||||
// this.basePath+'extensions/';
|
||||
|
||||
/*** filter types ***/
|
||||
this.fltTypeInp = 'input';
|
||||
|
@ -359,23 +356,7 @@ export class TableFilter{
|
|||
this.nbVisibleRows = 0; //nb visible rows
|
||||
this.nbHiddenRows = 0; //nb hidden rows
|
||||
|
||||
/*** webfx sort adapter ***/
|
||||
//enables/disables default table sorting
|
||||
this.sort = Boolean(f.sort);
|
||||
//indicates if sort is set (used in tfAdapter.sortabletable.js)
|
||||
this.isSortEnabled = false;
|
||||
this.sortConfig = f.sort_config || {};
|
||||
this.sortConfig.name = this.sortConfig.name || 'sort';
|
||||
this.sortConfig.path = this.sortConfig.path || null;
|
||||
this.sortConfig.sortTypes = Types.isArray(this.sortConfig.sort_types) ?
|
||||
this.sortConfig.sort_types : [];
|
||||
this.sortConfig.sortCol = this.sortConfig.sort_col || null;
|
||||
this.sortConfig.asyncSort = Boolean(this.sortConfig.async_sort);
|
||||
this.sortConfig.triggerIds =
|
||||
Types.isArray(this.sortConfig.sort_trigger_ids) ?
|
||||
this.sortConfig.sort_trigger_ids : [];
|
||||
|
||||
/*** onkeyup event ***/
|
||||
/*** autofilter on typing ***/
|
||||
//enables/disables auto filtering, table is filtered when user stops
|
||||
//typing
|
||||
this.autoFilter = Boolean(f.auto_filter);
|
||||
|
@ -524,7 +505,6 @@ export class TableFilter{
|
|||
resetvalues: 'ResetValues',
|
||||
resetpage: 'resetPage',
|
||||
resetpagelength: 'resetPageLength',
|
||||
sort: 'Sort',
|
||||
loadextensions: 'LoadExtensions',
|
||||
loadthemes: 'loadThemes'
|
||||
},
|
||||
|
@ -987,9 +967,9 @@ export class TableFilter{
|
|||
this.Cpt.colOps = new ColOps(this);
|
||||
this.Cpt.colOps.calc();
|
||||
}
|
||||
if(this.sort){
|
||||
this.importSort();
|
||||
}
|
||||
// if(this.sort){
|
||||
// this.importSort();
|
||||
// }
|
||||
|
||||
this.isFirstLoad = false;
|
||||
this._hasGrid = true;
|
||||
|
@ -1071,8 +1051,6 @@ export class TableFilter{
|
|||
case ev.resetpagelength:
|
||||
cpt.paging._resetPageLength(this.pgLenCookie);
|
||||
break;
|
||||
case ev.sort:
|
||||
break;
|
||||
case ev.loadextensions:
|
||||
this._loadExtensions();
|
||||
break;
|
||||
|
@ -1384,23 +1362,6 @@ export class TableFilter{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load sorting module:
|
||||
* - WebFX Sortable Table 1.12 plugin by Erik Arvidsson
|
||||
* - Sortable Table adapter
|
||||
*/
|
||||
importSort(){
|
||||
this.loadExtension({
|
||||
name: this.sortConfig.name,
|
||||
path: this.sortConfig.path
|
||||
// path: './extensions/sort/sort.js'
|
||||
});
|
||||
}
|
||||
|
||||
performSort(){
|
||||
this.EvtManager(this.Evt.name.sort);
|
||||
}
|
||||
|
||||
/*====================================================
|
||||
- IE bug: it seems there is no way to make
|
||||
multiple selections programatically, only last
|
||||
|
@ -1868,7 +1829,7 @@ export class TableFilter{
|
|||
let sA = this.searchArgs[this.singleSearchFlt ? 0 : j];
|
||||
var dtType = this.hasColDateType ?
|
||||
this.colDateType[j] : this.defaultDateType;
|
||||
if(sA===''){
|
||||
if(sA === ''){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2585,6 +2546,9 @@ export class TableFilter{
|
|||
for(let i=0, len=slcIndex.length; i<len; i++){
|
||||
let curSlc = Dom.id(this.fltIds[slcIndex[i]]);
|
||||
slcSelectedValue = this.getFilterValue(slcIndex[i]);
|
||||
|
||||
// Welcome to cyclomatic complexity hell :)
|
||||
// TODO: simplify/refactor if statement
|
||||
if(activeFlt!==slcIndex[i] ||
|
||||
(this.paging && Arr.has(slcA1, slcIndex[i]) &&
|
||||
activeFlt === slcIndex[i] ) ||
|
||||
|
@ -2646,7 +2610,6 @@ export class TableFilter{
|
|||
|
||||
let externalFltEl = this.externalFltEls[ct];
|
||||
extFlt.appendChild(externalFltEl);
|
||||
// let colFltType = this['col'+ct];
|
||||
let colFltType = this.getFilterType(ct);
|
||||
//IE special treatment for gridLayout, appended filters are
|
||||
//empty
|
||||
|
@ -2667,17 +2630,17 @@ export class TableFilter{
|
|||
this.nbFilterableRows = this.getRowsNb();
|
||||
this.nbVisibleRows = this.nbFilterableRows;
|
||||
this.nbRows = rows.length;
|
||||
if(this.isSortEnabled){
|
||||
this.sort = true;
|
||||
}
|
||||
// if(this.isSortEnabled){
|
||||
// this.sort = true;
|
||||
// }
|
||||
|
||||
// if(filtersRow.innerHTML === ''){
|
||||
// refreshFilters(this);
|
||||
// } else {
|
||||
if(this.popUpFilters){
|
||||
this.headersRow++;
|
||||
Cpt.popupFilter.buildAll();
|
||||
}
|
||||
if(this.popUpFilters){
|
||||
this.headersRow++;
|
||||
Cpt.popupFilter.buildAll();
|
||||
}
|
||||
// }
|
||||
|
||||
/*** ie bug work-around, filters need to be re-generated since row
|
||||
|
|
|
@ -3,9 +3,9 @@ var tag = function (elm, tag){ return elm.getElementsByTagName(tag); };
|
|||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types:[
|
||||
extensions:[{
|
||||
name: 'sort',
|
||||
types:[
|
||||
'String',
|
||||
'enforceinteger',
|
||||
'String',
|
||||
|
@ -15,12 +15,12 @@ var tf = new TableFilter('demo', {
|
|||
'String',
|
||||
'dmydate',
|
||||
'mdydate'
|
||||
]
|
||||
},
|
||||
on_sort_loaded: function(tf, sort){
|
||||
sort.addSortType('enforceinteger', customIntegerSorter);
|
||||
startTest(tf, sort);
|
||||
}
|
||||
],
|
||||
on_sort_loaded: function(tf, sort){
|
||||
sort.addSortType('enforceinteger', customIntegerSorter);
|
||||
startTest(tf, sort);
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
||||
//Custom sorter function
|
||||
|
@ -36,6 +36,7 @@ function startTest(tf, sort){
|
|||
test('Sort extension', function() {
|
||||
notEqual(sort, null, 'Sort instanciated');
|
||||
deepEqual(sort.sorted, false, 'Table not sorted');
|
||||
deepEqual(sort.initialized, true, 'Sort initialized');
|
||||
});
|
||||
|
||||
module('UI elements');
|
||||
|
@ -52,8 +53,7 @@ function startTest(tf, sort){
|
|||
});
|
||||
|
||||
test('Sort behaviour', function() {
|
||||
var th = tf.getHeaderElement(1),
|
||||
validRows = tf.getValidRows();
|
||||
var validRows = tf.getValidRows(true);
|
||||
sort.sortByColumnIndex(1);
|
||||
|
||||
deepEqual(sort.sorted, true, 'Table column sorted');
|
||||
|
@ -68,7 +68,7 @@ function startTest(tf, sort){
|
|||
sort.destroy();
|
||||
var th = tf.getHeaderElement(0),
|
||||
indicator = tag(th, 'img');
|
||||
deepEqual(tf.sort, false, 'Sort is removed');
|
||||
deepEqual(sort.initialized, false, 'Sort is removed');
|
||||
deepEqual(indicator.length, 0, 'Sort indicator is removed');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,24 +3,24 @@ var tag = function (elm, tag){ return elm.getElementsByTagName(tag); };
|
|||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types: ['string','string','number','number','number']
|
||||
},
|
||||
grid_layout: true,
|
||||
on_sort_loaded: startSimple
|
||||
extensions:[{
|
||||
name: 'sort',
|
||||
types: ['string','string','number','number','number'],
|
||||
on_sort_loaded: startSimple
|
||||
}]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var tf1 = new TableFilter('demo2', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
paging: true,
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types: ['string','string','number','number','number']
|
||||
},
|
||||
grid_layout: true,
|
||||
on_sort_loaded: startPaging
|
||||
extensions:[{
|
||||
name: 'sort',
|
||||
types: ['string','string','number','number','number'],
|
||||
on_sort_loaded: startPaging
|
||||
}]
|
||||
});
|
||||
tf1.init();
|
||||
|
||||
|
@ -30,10 +30,10 @@ function startSimple(tf, sort){
|
|||
notEqual(sort, null, 'Sort instanciated');
|
||||
deepEqual(sort.stt instanceof SortableTable, true, 'Sort type');
|
||||
deepEqual(sort.sorted, false, 'Table not sorted');
|
||||
deepEqual(sort.initialized, true, 'Sort initialized');
|
||||
});
|
||||
|
||||
test('Sort behaviour', function() {
|
||||
var th = tf.getHeaderElement(0);
|
||||
sort.sortByColumnIndex(0);
|
||||
|
||||
deepEqual(sort.sorted, true, 'Table column sorted');
|
||||
|
@ -45,20 +45,20 @@ function startSimple(tf, sort){
|
|||
sort.destroy();
|
||||
var th = tf.getHeaderElement(0),
|
||||
indicator = tag(th, 'img');
|
||||
deepEqual(tf.sort, false, 'Sort is removed');
|
||||
deepEqual(sort.initialized, false, 'Sort is removed');
|
||||
deepEqual(indicator.length, 0, 'Sort indicator is removed');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function startPaging(tf, sort){
|
||||
// var sort = tf.ExtRegistry.sort;
|
||||
|
||||
module('Sanity checks');
|
||||
test('Sort extension', function() {
|
||||
notEqual(sort, null, 'Sort instanciated');
|
||||
deepEqual(sort.stt instanceof SortableTable, true, 'Sort type');
|
||||
deepEqual(sort.sorted, false, 'Table not sorted');
|
||||
deepEqual(sort.initialized, true, 'Sort initialized');
|
||||
});
|
||||
|
||||
module('UI elements');
|
||||
|
@ -70,7 +70,6 @@ function startPaging(tf, sort){
|
|||
});
|
||||
|
||||
test('Sort behaviour', function() {
|
||||
var th = tf.getHeaderElement(0);
|
||||
sort.sortByColumnIndex(0);
|
||||
|
||||
deepEqual(sort.sorted, true, 'Table column sorted');
|
||||
|
@ -82,7 +81,7 @@ function startPaging(tf, sort){
|
|||
sort.destroy();
|
||||
var th = tf.getHeaderElement(0),
|
||||
indicator = tag(th, 'img');
|
||||
deepEqual(tf.sort, false, 'Sort is removed');
|
||||
deepEqual(sort.initialized, false, 'Sort is removed');
|
||||
deepEqual(indicator.length, 0, 'Sort indicator is removed');
|
||||
});
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ var tag = function (elm, tag){ return elm.getElementsByTagName(tag); };
|
|||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types:[
|
||||
extensions:[{
|
||||
name: 'sort',
|
||||
types:[
|
||||
'String',
|
||||
'Number',
|
||||
'String',
|
||||
|
@ -15,9 +15,9 @@ var tf = new TableFilter('demo', {
|
|||
'String',
|
||||
'dmydate',
|
||||
'mdydate'
|
||||
]
|
||||
},
|
||||
on_sort_loaded: start
|
||||
],
|
||||
on_sort_loaded: start
|
||||
}]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
|
@ -28,6 +28,7 @@ function start(tf, sort){
|
|||
notEqual(sort, null, 'Sort instanciated');
|
||||
deepEqual(sort.stt instanceof SortableTable, true, 'Sort type');
|
||||
deepEqual(sort.sorted, false, 'Table not sorted');
|
||||
deepEqual(sort.initialized, true, 'Sort initialized');
|
||||
});
|
||||
|
||||
module('UI elements');
|
||||
|
@ -44,7 +45,6 @@ function start(tf, sort){
|
|||
});
|
||||
|
||||
test('Sort behaviour', function() {
|
||||
var th = tf.getHeaderElement(1),
|
||||
validRows = tf.getValidRows();
|
||||
sort.sortByColumnIndex(1);
|
||||
|
||||
|
@ -60,7 +60,7 @@ function start(tf, sort){
|
|||
sort.destroy();
|
||||
var th = tf.getHeaderElement(0),
|
||||
indicator = tag(th, 'img');
|
||||
deepEqual(tf.sort, false, 'Sort is removed');
|
||||
deepEqual(sort.initialized, false, 'Sort is removed');
|
||||
deepEqual(indicator.length, 0, 'Sort indicator is removed');
|
||||
});
|
||||
|
||||
|
|
|
@ -3,33 +3,33 @@ var tag = function (elm, tag){ return elm.getElementsByTagName(tag); };
|
|||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types: ['string','string','number','number','number']
|
||||
},
|
||||
on_sort_loaded: startSimple
|
||||
extensions:[{
|
||||
name: 'sort',
|
||||
types: ['string','string','number','number','number'],
|
||||
on_sort_loaded: startSimple
|
||||
}]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
var tf1 = new TableFilter('demo2', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
paging: true,
|
||||
sort: true,
|
||||
sort_config: {
|
||||
sort_types: ['string','string','number','number','number']
|
||||
},
|
||||
on_sort_loaded: startPaging
|
||||
extensions:[{
|
||||
name: 'sort',
|
||||
types: ['string','string','number','number','number'],
|
||||
on_sort_loaded: startPaging
|
||||
}]
|
||||
});
|
||||
tf1.init();
|
||||
|
||||
function startSimple(tf, sort){
|
||||
// var sort = tf.ExtRegistry.sort;
|
||||
|
||||
module('Sanity checks');
|
||||
test('Sort extension', function() {
|
||||
notEqual(sort, null, 'Sort instanciated');
|
||||
deepEqual(sort.stt instanceof SortableTable, true, 'Sort type');
|
||||
deepEqual(sort.sorted, false, 'Table not sorted');
|
||||
deepEqual(sort.initialized, true, 'Sort initialized');
|
||||
});
|
||||
|
||||
module('UI elements');
|
||||
|
@ -41,7 +41,6 @@ function startSimple(tf, sort){
|
|||
});
|
||||
|
||||
test('Sort behaviour', function() {
|
||||
var th = tf.getHeaderElement(0);
|
||||
sort.sortByColumnIndex(0);
|
||||
|
||||
deepEqual(sort.sorted, true, 'Table column sorted');
|
||||
|
@ -53,20 +52,20 @@ function startSimple(tf, sort){
|
|||
sort.destroy();
|
||||
var th = tf.getHeaderElement(0),
|
||||
indicator = tag(th, 'img');
|
||||
deepEqual(tf.sort, false, 'Sort is removed');
|
||||
deepEqual(sort.initialized, false, 'Sort is removed');
|
||||
deepEqual(indicator.length, 0, 'Sort indicator is removed');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function startPaging(tf, sort){
|
||||
// var sort = tf.ExtRegistry.sort;
|
||||
|
||||
module('Sanity checks');
|
||||
test('Sort extension', function() {
|
||||
notEqual(sort, null, 'Sort instanciated');
|
||||
deepEqual(sort.stt instanceof SortableTable, true, 'Sort type');
|
||||
deepEqual(sort.sorted, false, 'Table not sorted');
|
||||
deepEqual(sort.initialized, true, 'Sort initialized');
|
||||
});
|
||||
|
||||
module('UI elements');
|
||||
|
@ -78,7 +77,6 @@ function startPaging(tf, sort){
|
|||
});
|
||||
|
||||
test('Sort behaviour', function() {
|
||||
var th = tf.getHeaderElement(0);
|
||||
sort.sortByColumnIndex(0);
|
||||
|
||||
deepEqual(sort.sorted, true, 'Table column sorted');
|
||||
|
@ -90,7 +88,7 @@ function startPaging(tf, sort){
|
|||
sort.destroy();
|
||||
var th = tf.getHeaderElement(0),
|
||||
indicator = tag(th, 'img');
|
||||
deepEqual(tf.sort, false, 'Sort is removed');
|
||||
deepEqual(sort.initialized, false, 'Sort is removed');
|
||||
deepEqual(indicator.length, 0, 'Sort indicator is removed');
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
var webpack = require('webpack');
|
||||
var path = require('path');
|
||||
var Clean = require('clean-webpack-plugin');
|
||||
var StringReplacePlugin = require("string-replace-webpack-plugin");
|
||||
var fs = require('fs');
|
||||
var pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||
|
||||
module.exports = {
|
||||
cache: true,
|
||||
|
@ -20,14 +25,53 @@ module.exports = {
|
|||
module: {
|
||||
// exprContextRegExp: /$^/,
|
||||
// exprContextCritical: true,
|
||||
loaders: [{
|
||||
test: path.join(__dirname, 'src'),
|
||||
exclude: /node_modules/,
|
||||
query: {
|
||||
compact: false
|
||||
loaders: [
|
||||
{
|
||||
test: path.join(__dirname, 'src'),
|
||||
exclude: /node_modules/,
|
||||
query: {
|
||||
compact: false
|
||||
},
|
||||
loader: 'babel-loader'
|
||||
},
|
||||
loader: 'babel-loader'
|
||||
}]
|
||||
{
|
||||
test: path.join(__dirname, 'src'),
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [{
|
||||
pattern: /{VERSION}/ig,
|
||||
replacement: function (/*match, p1, offset, string*/) {
|
||||
return pkg.version;
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
]
|
||||
},
|
||||
build: {
|
||||
plugins: [
|
||||
new Clean(['dist']),
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
new StringReplacePlugin(),
|
||||
new webpack.optimize.MinChunkSizePlugin({ minChunkSize: 10000 }),
|
||||
new webpack.optimize.UglifyJsPlugin(),
|
||||
new webpack.BannerPlugin(
|
||||
'/** \n' +
|
||||
' *\t '+ pkg.name +' v'+ pkg.version +' by Max Guglielmi \n' +
|
||||
' *\t build date: '+ new Date().toISOString() +' \n' +
|
||||
' *\t MIT License \n' +
|
||||
' */ \n',
|
||||
{ raw: true }
|
||||
)
|
||||
]
|
||||
},
|
||||
dev: {
|
||||
devtool: 'sourcemap',
|
||||
debug: true,
|
||||
plugins: [
|
||||
new Clean(['dist']),
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
new StringReplacePlugin()
|
||||
]
|
||||
}
|
||||
// ,
|
||||
// plugins: [
|
||||
|
|
Loading…
Reference in a new issue