Filter: cache main loop variables

This commit is contained in:
Mottie 2015-04-07 11:25:40 -05:00
parent c2c4f8d8a0
commit cd98f306bb
8 changed files with 106 additions and 41 deletions

View File

@ -1,4 +1,4 @@
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
/*! tablesorter (FORK) - updated 04-07-2015 (v2.21.4)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {
@ -3297,6 +3297,19 @@ ts.filter = {
$(this).hasClass('filter-parsed');
}).get();
// cache filter variables that use ts.getColumnData in the main loop
wo.filter_indexed = {
functions : [],
excludeFilter : [],
defaultColFilter : [],
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
};
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
wo.filter_indexed.functions[ columnIndex ] = ts.getColumnData( table, wo.filter_functions, columnIndex );
wo.filter_indexed.defaultColFilter[ columnIndex ] = ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
wo.filter_indexed.excludeFilter[ columnIndex ] = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
}
if (c.debug) {
ts.log('Filter: Starting filter widget search', filters);
time = new Date();
@ -3383,8 +3396,8 @@ ts.filter = {
// replace accents
data.anyMatchFilter = ts.replaceAccents(data.anyMatchFilter);
}
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || '')) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) );
if ( wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultAnyFilter ) ) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, wo.filter_indexed.defaultAnyFilter );
// clear search filtered flag because default filters are not saved to the last search
searchFiltered = false;
}
@ -3466,7 +3479,7 @@ ts.filter = {
data.index = columnIndex;
// filter types to exclude, per column
excludeMatch = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
excludeMatch = wo.filter_indexed.excludeFilter[ columnIndex ];
// ignore if filter is empty or disabled
if (data.filter) {
@ -3491,14 +3504,14 @@ ts.filter = {
}
val = true;
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '')) {
data.filter = ts.filter.defaultFilter( data.filter, ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) );
if (wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultColFilter[ columnIndex ] )) {
data.filter = ts.filter.defaultFilter( data.filter, wo.filter_indexed.defaultColFilter[ columnIndex ] );
// val is used to indicate that a filter select is using a default filter; so we override the exact & partial matches
val = false;
}
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
fxn = wo.filter_indexed.functions[ columnIndex ];
$cell = c.$headerIndexed[columnIndex];
hasSelect = $cell.hasClass('filter-select');
if ( fxn || ( hasSelect && val ) ) {

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
/*! tablesorter (FORK) - updated 04-07-2015 (v2.21.4)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {
@ -1168,6 +1168,19 @@ ts.filter = {
$(this).hasClass('filter-parsed');
}).get();
// cache filter variables that use ts.getColumnData in the main loop
wo.filter_indexed = {
functions : [],
excludeFilter : [],
defaultColFilter : [],
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
};
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
wo.filter_indexed.functions[ columnIndex ] = ts.getColumnData( table, wo.filter_functions, columnIndex );
wo.filter_indexed.defaultColFilter[ columnIndex ] = ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
wo.filter_indexed.excludeFilter[ columnIndex ] = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
}
if (c.debug) {
ts.log('Filter: Starting filter widget search', filters);
time = new Date();
@ -1254,8 +1267,8 @@ ts.filter = {
// replace accents
data.anyMatchFilter = ts.replaceAccents(data.anyMatchFilter);
}
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || '')) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) );
if ( wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultAnyFilter ) ) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, wo.filter_indexed.defaultAnyFilter );
// clear search filtered flag because default filters are not saved to the last search
searchFiltered = false;
}
@ -1337,7 +1350,7 @@ ts.filter = {
data.index = columnIndex;
// filter types to exclude, per column
excludeMatch = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
excludeMatch = wo.filter_indexed.excludeFilter[ columnIndex ];
// ignore if filter is empty or disabled
if (data.filter) {
@ -1362,14 +1375,14 @@ ts.filter = {
}
val = true;
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '')) {
data.filter = ts.filter.defaultFilter( data.filter, ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) );
if (wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultColFilter[ columnIndex ] )) {
data.filter = ts.filter.defaultFilter( data.filter, wo.filter_indexed.defaultColFilter[ columnIndex ] );
// val is used to indicate that a filter select is using a default filter; so we override the exact & partial matches
val = false;
}
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
fxn = wo.filter_indexed.functions[ columnIndex ];
$cell = c.$headerIndexed[columnIndex];
hasSelect = $cell.hasClass('filter-select');
if ( fxn || ( hasSelect && val ) ) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*/
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
/*! tablesorter (FORK) - updated 04-07-2015 (v2.21.4)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {
@ -3303,6 +3303,19 @@ ts.filter = {
$(this).hasClass('filter-parsed');
}).get();
// cache filter variables that use ts.getColumnData in the main loop
wo.filter_indexed = {
functions : [],
excludeFilter : [],
defaultColFilter : [],
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
};
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
wo.filter_indexed.functions[ columnIndex ] = ts.getColumnData( table, wo.filter_functions, columnIndex );
wo.filter_indexed.defaultColFilter[ columnIndex ] = ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
wo.filter_indexed.excludeFilter[ columnIndex ] = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
}
if (c.debug) {
ts.log('Filter: Starting filter widget search', filters);
time = new Date();
@ -3389,8 +3402,8 @@ ts.filter = {
// replace accents
data.anyMatchFilter = ts.replaceAccents(data.anyMatchFilter);
}
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || '')) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) );
if ( wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultAnyFilter ) ) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, wo.filter_indexed.defaultAnyFilter );
// clear search filtered flag because default filters are not saved to the last search
searchFiltered = false;
}
@ -3472,7 +3485,7 @@ ts.filter = {
data.index = columnIndex;
// filter types to exclude, per column
excludeMatch = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
excludeMatch = wo.filter_indexed.excludeFilter[ columnIndex ];
// ignore if filter is empty or disabled
if (data.filter) {
@ -3497,14 +3510,14 @@ ts.filter = {
}
val = true;
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '')) {
data.filter = ts.filter.defaultFilter( data.filter, ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) );
if (wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultColFilter[ columnIndex ] )) {
data.filter = ts.filter.defaultFilter( data.filter, wo.filter_indexed.defaultColFilter[ columnIndex ] );
// val is used to indicate that a filter select is using a default filter; so we override the exact & partial matches
val = false;
}
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
fxn = wo.filter_indexed.functions[ columnIndex ];
$cell = c.$headerIndexed[columnIndex];
hasSelect = $cell.hasClass('filter-select');
if ( fxn || ( hasSelect && val ) ) {

View File

@ -4,7 +4,7 @@
*/
/*! tablesorter (FORK) - updated 04-02-2015 (v2.21.4)*/
/*! tablesorter (FORK) - updated 04-07-2015 (v2.21.4)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) {
if (typeof define === 'function' && define.amd) {
@ -1174,6 +1174,19 @@ ts.filter = {
$(this).hasClass('filter-parsed');
}).get();
// cache filter variables that use ts.getColumnData in the main loop
wo.filter_indexed = {
functions : [],
excludeFilter : [],
defaultColFilter : [],
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
};
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
wo.filter_indexed.functions[ columnIndex ] = ts.getColumnData( table, wo.filter_functions, columnIndex );
wo.filter_indexed.defaultColFilter[ columnIndex ] = ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
wo.filter_indexed.excludeFilter[ columnIndex ] = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
}
if (c.debug) {
ts.log('Filter: Starting filter widget search', filters);
time = new Date();
@ -1260,8 +1273,8 @@ ts.filter = {
// replace accents
data.anyMatchFilter = ts.replaceAccents(data.anyMatchFilter);
}
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || '')) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) );
if ( wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultAnyFilter ) ) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, wo.filter_indexed.defaultAnyFilter );
// clear search filtered flag because default filters are not saved to the last search
searchFiltered = false;
}
@ -1343,7 +1356,7 @@ ts.filter = {
data.index = columnIndex;
// filter types to exclude, per column
excludeMatch = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
excludeMatch = wo.filter_indexed.excludeFilter[ columnIndex ];
// ignore if filter is empty or disabled
if (data.filter) {
@ -1368,14 +1381,14 @@ ts.filter = {
}
val = true;
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '')) {
data.filter = ts.filter.defaultFilter( data.filter, ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) );
if (wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultColFilter[ columnIndex ] )) {
data.filter = ts.filter.defaultFilter( data.filter, wo.filter_indexed.defaultColFilter[ columnIndex ] );
// val is used to indicate that a filter select is using a default filter; so we override the exact & partial matches
val = false;
}
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
fxn = wo.filter_indexed.functions[ columnIndex ];
$cell = c.$headerIndexed[columnIndex];
hasSelect = $cell.hasClass('filter-select');
if ( fxn || ( hasSelect && val ) ) {

View File

@ -801,6 +801,19 @@ ts.filter = {
$(this).hasClass('filter-parsed');
}).get();
// cache filter variables that use ts.getColumnData in the main loop
wo.filter_indexed = {
functions : [],
excludeFilter : [],
defaultColFilter : [],
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
};
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
wo.filter_indexed.functions[ columnIndex ] = ts.getColumnData( table, wo.filter_functions, columnIndex );
wo.filter_indexed.defaultColFilter[ columnIndex ] = ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
wo.filter_indexed.excludeFilter[ columnIndex ] = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
}
if (c.debug) {
ts.log('Filter: Starting filter widget search', filters);
time = new Date();
@ -887,8 +900,8 @@ ts.filter = {
// replace accents
data.anyMatchFilter = ts.replaceAccents(data.anyMatchFilter);
}
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || '')) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) );
if ( wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultAnyFilter ) ) {
data.anyMatchFilter = ts.filter.defaultFilter( data.anyMatchFilter, wo.filter_indexed.defaultAnyFilter );
// clear search filtered flag because default filters are not saved to the last search
searchFiltered = false;
}
@ -970,7 +983,7 @@ ts.filter = {
data.index = columnIndex;
// filter types to exclude, per column
excludeMatch = ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split(/\s+/);
excludeMatch = wo.filter_indexed.excludeFilter[ columnIndex ];
// ignore if filter is empty or disabled
if (data.filter) {
@ -995,14 +1008,14 @@ ts.filter = {
}
val = true;
if (wo.filter_defaultFilter && regex.iQuery.test( ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '')) {
data.filter = ts.filter.defaultFilter( data.filter, ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) );
if (wo.filter_defaultFilter && regex.iQuery.test( wo.filter_indexed.defaultColFilter[ columnIndex ] )) {
data.filter = ts.filter.defaultFilter( data.filter, wo.filter_indexed.defaultColFilter[ columnIndex ] );
// val is used to indicate that a filter select is using a default filter; so we override the exact & partial matches
val = false;
}
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
fxn = wo.filter_indexed.functions[ columnIndex ];
$cell = c.$headerIndexed[columnIndex];
hasSelect = $cell.hasClass('filter-select');
if ( fxn || ( hasSelect && val ) ) {