General code cleanup

Also replace instances of tagName with nodeName
This commit is contained in:
Mottie 2015-03-23 16:08:07 -05:00
parent 799ede9199
commit 7f37b90ebd
9 changed files with 56 additions and 52 deletions

View File

@ -204,7 +204,7 @@
p.$goto.html(t).val( p.page + 1 ); p.$goto.html(t).val( p.page + 1 );
} }
if ($out.length) { if ($out.length) {
$out[ ($out[0].tagName === 'INPUT') ? 'val' : 'html' ](s); $out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
// rebind startRow/page inputs // rebind startRow/page inputs
$out.find('.ts-startRow, .ts-page').unbind('change.pager').bind('change.pager', function(){ $out.find('.ts-startRow, .ts-page').unbind('change.pager').bind('change.pager', function(){
var v = $(this).val(), var v = $(this).val(),

View File

@ -88,7 +88,7 @@ $.tablesorter.customPagerControls = function(settings) {
if (options.addKeyboard) { if (options.addKeyboard) {
$(document).on('keydown', function(events){ $(document).on('keydown', function(events){
// ignore arrows inside form elements // ignore arrows inside form elements
if (/input|select|textarea/i.test(events.target.tagName)) { return; } if (/input|select|textarea/i.test(events.target.nodeName)) { return; }
if (events.which === 37) { if (events.which === 37) {
// left // left
$pager.find(options.currentPage).filter('.' + options.currentClass).prevAll(':not(span):first').click(); $pager.find(options.currentPage).filter('.' + options.currentClass).prevAll(':not(span):first').click();

View File

@ -169,7 +169,7 @@
h = window.location.hash; h = window.location.hash;
if (h) { if (h) {
prop = $(h); prop = $(h);
if (prop.length && !/h3|a|table/i.test(prop[0].tagName)) { if (prop.length && !/h3|a|table/i.test(prop[0].nodeName)) {
prop.find('.collapsible').show(); prop.find('.collapsible').show();
if (h === '#csschildrow') { if (h === '#csschildrow') {
$('#root .tablesorter-childRow').show(); $('#root .tablesorter-childRow').show();

View File

@ -4,7 +4,7 @@
*/ */
/*! tablesorter (FORK) widgets - updated 03-13-2015 (v2.21.2)*/ /*! tablesorter (FORK) widgets - updated 03-23-2015 (v2.21.2)*/
/* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */ /* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */
(function(factory) { (function(factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -361,11 +361,13 @@ ts.addWidget({
*/ */
;(function ($) { ;(function ($) {
'use strict'; 'use strict';
var ts = $.tablesorter = $.tablesorter || {}; var ts = $.tablesorter = $.tablesorter || {},
tscss = ts.css;
$.extend(ts.css, { $.extend(tscss, {
filterRow : 'tablesorter-filter-row', filterRow : 'tablesorter-filter-row',
filter : 'tablesorter-filter' filter : 'tablesorter-filter',
filterRowHide : 'hideme'
}); });
ts.addWidget({ ts.addWidget({
@ -415,7 +417,7 @@ ts.addWidget({
// add .tsfilter namespace to all BUT search // add .tsfilter namespace to all BUT search
.unbind( events.replace(/\s+/g, ' ') ) .unbind( events.replace(/\s+/g, ' ') )
// remove the filter row even if refreshing, because the column might have been moved // remove the filter row even if refreshing, because the column might have been moved
.find('.' + ts.css.filterRow).remove(); .find('.' + tscss.filterRow).remove();
if (refreshing) { return; } if (refreshing) { return; }
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) { for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
@ -643,13 +645,13 @@ ts.filter = {
c.$table.bind( txt, function(event, filter) { c.$table.bind( txt, function(event, filter) {
val = (wo.filter_hideEmpty && $.isEmptyObject(c.cache) && !(c.delayInit && event.type === 'appendCache')); val = (wo.filter_hideEmpty && $.isEmptyObject(c.cache) && !(c.delayInit && event.type === 'appendCache'));
// hide filter row using the "filtered" class name // hide filter row using the "filtered" class name
c.$table.find('.' + ts.css.filterRow).toggleClass(wo.filter_filteredRow, val ); // fixes #450 c.$table.find('.' + tscss.filterRow).toggleClass(wo.filter_filteredRow, val ); // fixes #450
if ( !/(search|filter)/.test(event.type) ) { if ( !/(search|filter)/.test(event.type) ) {
event.stopPropagation(); event.stopPropagation();
ts.filter.buildDefault(table, true); ts.filter.buildDefault(table, true);
} }
if (event.type === 'filterReset') { if (event.type === 'filterReset') {
c.$table.find('.' + ts.css.filter).add(wo.filter_$externalFilters).val(''); c.$table.find('.' + tscss.filter).add(wo.filter_$externalFilters).val('');
ts.filter.searching(table, []); ts.filter.searching(table, []);
} else if (event.type === 'filterEnd') { } else if (event.type === 'filterEnd') {
ts.filter.buildDefault(table, true); ts.filter.buildDefault(table, true);
@ -712,7 +714,7 @@ ts.filter = {
options += '<option ' + (txt === val ? '' : 'data-function-name="' + string + '" ') + 'value="' + val + '">' + txt + '</option>'; options += '<option ' + (txt === val ? '' : 'data-function-name="' + string + '" ') + 'value="' + val + '">' + txt + '</option>';
} }
} }
c.$table.find('thead').find('select.' + ts.css.filter + '[data-column="' + column + '"]').append(options); c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').append(options);
} }
} }
} }
@ -721,7 +723,7 @@ ts.filter = {
// it would append the same options twice. // it would append the same options twice.
ts.filter.buildDefault(table, true); ts.filter.buildDefault(table, true);
ts.filter.bindSearch( table, c.$table.find('.' + ts.css.filter), true ); ts.filter.bindSearch( table, c.$table.find('.' + tscss.filter), true );
if (wo.filter_external) { if (wo.filter_external) {
ts.filter.bindSearch( table, wo.filter_external ); ts.filter.bindSearch( table, wo.filter_external );
} }
@ -736,7 +738,7 @@ ts.filter = {
.unbind( ('filterStart filterEnd '.split(' ').join(c.namespace + 'filter ')).replace(/\s+/g, ' ') ) .unbind( ('filterStart filterEnd '.split(' ').join(c.namespace + 'filter ')).replace(/\s+/g, ' ') )
.bind( 'filterStart filterEnd '.split(' ').join(c.namespace + 'filter '), function(event, columns) { .bind( 'filterStart filterEnd '.split(' ').join(c.namespace + 'filter '), function(event, columns) {
// only add processing to certain columns to all columns // only add processing to certain columns to all columns
$header = (columns) ? c.$table.find('.' + ts.css.header).filter('[data-column]').filter(function() { $header = (columns) ? c.$table.find('.' + tscss.header).filter('[data-column]').filter(function() {
return columns[$(this).data('column')] !== ''; return columns[$(this).data('column')] !== '';
}) : ''; }) : '';
ts.isProcessing(table, event.type === 'filterStart', columns ? $header : ''); ts.isProcessing(table, event.type === 'filterStart', columns ? $header : '');
@ -850,7 +852,7 @@ ts.filter = {
// c.columns defined in computeThIndexes() // c.columns defined in computeThIndexes()
columns = c.columns, columns = c.columns,
arry = $.isArray(wo.filter_cellFilter), arry = $.isArray(wo.filter_cellFilter),
buildFilter = '<tr role="row" class="' + ts.css.filterRow + '">'; buildFilter = '<tr role="row" class="' + tscss.filterRow + ' ' + c.cssIgnoreRow + '">';
for (column = 0; column < columns; column++) { for (column = 0; column < columns; column++) {
if (arry) { if (arry) {
buildFilter += '<td' + ( wo.filter_cellFilter[column] ? ' class="' + wo.filter_cellFilter[column] + '"' : '' ) + '></td>'; buildFilter += '<td' + ( wo.filter_cellFilter[column] ? ' class="' + wo.filter_cellFilter[column] + '"' : '' ) + '></td>';
@ -899,7 +901,7 @@ ts.filter = {
name = ( $.isArray(wo.filter_cssFilter) ? name = ( $.isArray(wo.filter_cssFilter) ?
(typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '') : (typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '') :
wo.filter_cssFilter ) || ''; wo.filter_cssFilter ) || '';
buildFilter.addClass( ts.css.filter + ' ' + name ).attr('data-column', column); buildFilter.addClass( tscss.filter + ' ' + name ).attr('data-column', column);
if (disabled) { if (disabled) {
buildFilter.attr('placeholder', '').addClass('disabled')[0].disabled = true; // disabled! buildFilter.attr('placeholder', '').addClass('disabled')[0].disabled = true; // disabled!
} }
@ -995,7 +997,7 @@ ts.filter = {
} }
if (wo.filter_hideFilters) { if (wo.filter_hideFilters) {
// show/hide filter row as needed // show/hide filter row as needed
c.$table.find('.' + ts.css.filterRow).trigger( combinedFilters === '' ? 'mouseleave' : 'mouseenter' ); c.$table.find('.' + tscss.filterRow).trigger( combinedFilters === '' ? 'mouseleave' : 'mouseenter' );
} }
// return if the last search is the same; but filter === false when updating the search // return if the last search is the same; but filter === false when updating the search
// see example-widget-filter.html filter toggle buttons // see example-widget-filter.html filter toggle buttons
@ -1021,8 +1023,8 @@ ts.filter = {
hideFilters: function(table, c) { hideFilters: function(table, c) {
var $filterRow, $filterRow2, timer; var $filterRow, $filterRow2, timer;
$(table) $(table)
.find('.' + ts.css.filterRow) .find('.' + tscss.filterRow)
.addClass('hideme') .addClass(tscss.filterRowHide)
.bind('mouseenter mouseleave', function(e) { .bind('mouseenter mouseleave', function(e) {
// save event object - http://bugs.jquery.com/ticket/12140 // save event object - http://bugs.jquery.com/ticket/12140
var event = e; var event = e;
@ -1030,14 +1032,14 @@ ts.filter = {
clearTimeout(timer); clearTimeout(timer);
timer = setTimeout(function() { timer = setTimeout(function() {
if ( /enter|over/.test(event.type) ) { if ( /enter|over/.test(event.type) ) {
$filterRow.removeClass('hideme'); $filterRow.removeClass(tscss.filterRowHide);
} else { } else {
// don't hide if input has focus // don't hide if input has focus
// $(':focus') needs jQuery 1.6+ // $(':focus') needs jQuery 1.6+
if ( $(document.activeElement).closest('tr')[0] !== $filterRow[0] ) { if ( $(document.activeElement).closest('tr')[0] !== $filterRow[0] ) {
// don't hide row if any filter has a value // don't hide row if any filter has a value
if (c.lastCombinedFilter === '') { if (c.lastCombinedFilter === '') {
$filterRow.addClass('hideme'); $filterRow.addClass(tscss.filterRowHide);
} }
} }
} }
@ -1050,7 +1052,7 @@ ts.filter = {
timer = setTimeout(function() { timer = setTimeout(function() {
// don't hide row if any filter has a value // don't hide row if any filter has a value
if (ts.getFilters(c.$table).join('') === '') { if (ts.getFilters(c.$table).join('') === '') {
$filterRow2[ event.type === 'focus' ? 'removeClass' : 'addClass']('hideme'); $filterRow2[ event.type === 'focus' ? 'removeClass' : 'addClass'](tscss.filterRowHide);
} }
}, 200); }, 200);
}); });
@ -1538,7 +1540,7 @@ ts.filter = {
// t.data('placeholder') won't work in jQuery older than 1.4.3 // t.data('placeholder') won't work in jQuery older than 1.4.3
options = '<option value="">' + ( node.data('placeholder') || node.attr('data-placeholder') || wo.filter_placeholder.select || '' ) + '</option>', options = '<option value="">' + ( node.data('placeholder') || node.attr('data-placeholder') || wo.filter_placeholder.select || '' ) + '</option>',
// Get curent filter value // Get curent filter value
currentValue = c.$table.find('thead').find('select.' + ts.css.filter + '[data-column="' + column + '"]').val(); currentValue = c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').val();
// nothing included in arry (external source), so get the options from filter_selectSource or column data // nothing included in arry (external source), so get the options from filter_selectSource or column data
if (typeof arry === 'undefined' || arry === '') { if (typeof arry === 'undefined' || arry === '') {
arry = ts.filter.getOptionSource(table, column, onlyAvail); arry = ts.filter.getOptionSource(table, column, onlyAvail);
@ -1565,7 +1567,7 @@ ts.filter = {
} }
// update all selects in the same column (clone thead in sticky headers & any external selects) - fixes 473 // update all selects in the same column (clone thead in sticky headers & any external selects) - fixes 473
$filters = ( c.$filters ? c.$filters : c.$table.children('thead') ).find('.' + ts.css.filter); $filters = ( c.$filters ? c.$filters : c.$table.children('thead') ).find('.' + tscss.filter);
if (wo.filter_$externalFilters) { if (wo.filter_$externalFilters) {
$filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters; $filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters;
} }
@ -1609,7 +1611,7 @@ ts.getFilters = function(table, getRaw, setFilters, skipFirst) {
} }
if (c) { if (c) {
if (c.$filters) { if (c.$filters) {
$filters = c.$filters.find('.' + ts.css.filter); $filters = c.$filters.find('.' + tscss.filter);
} }
if (wo.filter_$externalFilters) { if (wo.filter_$externalFilters) {
$filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters; $filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters;
@ -1856,7 +1858,7 @@ ts.addWidget({
resizeHeader(); resizeHeader();
}); });
ts.bindEvents(table, $stickyThead.children().children('.tablesorter-header')); ts.bindEvents(table, $stickyThead.children().children('.' + ts.css.header));
// add stickyheaders AFTER the table. If the table is selected by ID, the original one (first) will be returned. // add stickyheaders AFTER the table. If the table is selected by ID, the original one (first) will be returned.
$table.after( $stickyWrap ); $table.after( $stickyWrap );

View File

@ -111,7 +111,7 @@
// bind to .tablesorter (default class name) // bind to .tablesorter (default class name)
$(this).children('tbody') $(this).children('tbody')
.on('mouseleave', function(e){ .on('mouseleave', function(e){
restoreValue(e.target.tagName === 'TBODY'); restoreValue(e.target.nodeName === 'TBODY');
}) })
.on('focus', 'select, input, textarea', function(){ .on('focus', 'select, input, textarea', function(){
$(this).data('ts-original-value', this.value); $(this).data('ts-original-value', this.value);
@ -129,7 +129,7 @@
} }
// Update cell cache using... select: change, input: enter or textarea: alt + enter // Update cell cache using... select: change, input: enter or textarea: alt + enter
if ( ( e.type === 'change' ) || if ( ( e.type === 'change' ) ||
( e.type === 'keyup' && e.which === 13 && ( e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' && e.altKey ) ) ) { ( e.type === 'keyup' && e.which === 13 && ( e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' && e.altKey ) ) ) {
var undef, var undef,
$tar = $(e.target), $tar = $(e.target),
$cell = $tar.closest('td'), $cell = $tar.closest('td'),

View File

@ -12,7 +12,7 @@ var ts = $.tablesorter = $.tablesorter || {},
// data.rows contains an array of rows which contains an array of cells // data.rows contains an array of rows which contains an array of cells
bt = ts.buildTable = function(tar, c){ bt = ts.buildTable = function(tar, c){
// add table if one doesn't exist // add table if one doesn't exist
var $tbl = tar.tagName === 'TABLE' ? $(tar) : $('<table>').appendTo(tar), var $tbl = tar.nodeName === 'TABLE' ? $(tar) : $('<table>').appendTo(tar),
table = $tbl[0], table = $tbl[0],
wo = c.widgetOptions = $.extend( true, {}, bt.defaults, c.widgetOptions ), wo = c.widgetOptions = $.extend( true, {}, bt.defaults, c.widgetOptions ),
p = wo.build_processing, p = wo.build_processing,

View File

@ -4,11 +4,13 @@
*/ */
;(function ($) { ;(function ($) {
'use strict'; 'use strict';
var ts = $.tablesorter = $.tablesorter || {}; var ts = $.tablesorter = $.tablesorter || {},
tscss = ts.css;
$.extend(ts.css, { $.extend(tscss, {
filterRow : 'tablesorter-filter-row', filterRow : 'tablesorter-filter-row',
filter : 'tablesorter-filter' filter : 'tablesorter-filter',
filterRowHide : 'hideme'
}); });
ts.addWidget({ ts.addWidget({
@ -58,7 +60,7 @@ ts.addWidget({
// add .tsfilter namespace to all BUT search // add .tsfilter namespace to all BUT search
.unbind( events.replace(/\s+/g, ' ') ) .unbind( events.replace(/\s+/g, ' ') )
// remove the filter row even if refreshing, because the column might have been moved // remove the filter row even if refreshing, because the column might have been moved
.find('.' + ts.css.filterRow).remove(); .find('.' + tscss.filterRow).remove();
if (refreshing) { return; } if (refreshing) { return; }
for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) { for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
$tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
@ -286,13 +288,13 @@ ts.filter = {
c.$table.bind( txt, function(event, filter) { c.$table.bind( txt, function(event, filter) {
val = (wo.filter_hideEmpty && $.isEmptyObject(c.cache) && !(c.delayInit && event.type === 'appendCache')); val = (wo.filter_hideEmpty && $.isEmptyObject(c.cache) && !(c.delayInit && event.type === 'appendCache'));
// hide filter row using the "filtered" class name // hide filter row using the "filtered" class name
c.$table.find('.' + ts.css.filterRow).toggleClass(wo.filter_filteredRow, val ); // fixes #450 c.$table.find('.' + tscss.filterRow).toggleClass(wo.filter_filteredRow, val ); // fixes #450
if ( !/(search|filter)/.test(event.type) ) { if ( !/(search|filter)/.test(event.type) ) {
event.stopPropagation(); event.stopPropagation();
ts.filter.buildDefault(table, true); ts.filter.buildDefault(table, true);
} }
if (event.type === 'filterReset') { if (event.type === 'filterReset') {
c.$table.find('.' + ts.css.filter).add(wo.filter_$externalFilters).val(''); c.$table.find('.' + tscss.filter).add(wo.filter_$externalFilters).val('');
ts.filter.searching(table, []); ts.filter.searching(table, []);
} else if (event.type === 'filterEnd') { } else if (event.type === 'filterEnd') {
ts.filter.buildDefault(table, true); ts.filter.buildDefault(table, true);
@ -355,7 +357,7 @@ ts.filter = {
options += '<option ' + (txt === val ? '' : 'data-function-name="' + string + '" ') + 'value="' + val + '">' + txt + '</option>'; options += '<option ' + (txt === val ? '' : 'data-function-name="' + string + '" ') + 'value="' + val + '">' + txt + '</option>';
} }
} }
c.$table.find('thead').find('select.' + ts.css.filter + '[data-column="' + column + '"]').append(options); c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').append(options);
} }
} }
} }
@ -364,7 +366,7 @@ ts.filter = {
// it would append the same options twice. // it would append the same options twice.
ts.filter.buildDefault(table, true); ts.filter.buildDefault(table, true);
ts.filter.bindSearch( table, c.$table.find('.' + ts.css.filter), true ); ts.filter.bindSearch( table, c.$table.find('.' + tscss.filter), true );
if (wo.filter_external) { if (wo.filter_external) {
ts.filter.bindSearch( table, wo.filter_external ); ts.filter.bindSearch( table, wo.filter_external );
} }
@ -379,7 +381,7 @@ ts.filter = {
.unbind( ('filterStart filterEnd '.split(' ').join(c.namespace + 'filter ')).replace(/\s+/g, ' ') ) .unbind( ('filterStart filterEnd '.split(' ').join(c.namespace + 'filter ')).replace(/\s+/g, ' ') )
.bind( 'filterStart filterEnd '.split(' ').join(c.namespace + 'filter '), function(event, columns) { .bind( 'filterStart filterEnd '.split(' ').join(c.namespace + 'filter '), function(event, columns) {
// only add processing to certain columns to all columns // only add processing to certain columns to all columns
$header = (columns) ? c.$table.find('.' + ts.css.header).filter('[data-column]').filter(function() { $header = (columns) ? c.$table.find('.' + tscss.header).filter('[data-column]').filter(function() {
return columns[$(this).data('column')] !== ''; return columns[$(this).data('column')] !== '';
}) : ''; }) : '';
ts.isProcessing(table, event.type === 'filterStart', columns ? $header : ''); ts.isProcessing(table, event.type === 'filterStart', columns ? $header : '');
@ -493,7 +495,7 @@ ts.filter = {
// c.columns defined in computeThIndexes() // c.columns defined in computeThIndexes()
columns = c.columns, columns = c.columns,
arry = $.isArray(wo.filter_cellFilter), arry = $.isArray(wo.filter_cellFilter),
buildFilter = '<tr role="row" class="' + ts.css.filterRow + '">'; buildFilter = '<tr role="row" class="' + tscss.filterRow + ' ' + c.cssIgnoreRow + '">';
for (column = 0; column < columns; column++) { for (column = 0; column < columns; column++) {
if (arry) { if (arry) {
buildFilter += '<td' + ( wo.filter_cellFilter[column] ? ' class="' + wo.filter_cellFilter[column] + '"' : '' ) + '></td>'; buildFilter += '<td' + ( wo.filter_cellFilter[column] ? ' class="' + wo.filter_cellFilter[column] + '"' : '' ) + '></td>';
@ -542,7 +544,7 @@ ts.filter = {
name = ( $.isArray(wo.filter_cssFilter) ? name = ( $.isArray(wo.filter_cssFilter) ?
(typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '') : (typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '') :
wo.filter_cssFilter ) || ''; wo.filter_cssFilter ) || '';
buildFilter.addClass( ts.css.filter + ' ' + name ).attr('data-column', column); buildFilter.addClass( tscss.filter + ' ' + name ).attr('data-column', column);
if (disabled) { if (disabled) {
buildFilter.attr('placeholder', '').addClass('disabled')[0].disabled = true; // disabled! buildFilter.attr('placeholder', '').addClass('disabled')[0].disabled = true; // disabled!
} }
@ -638,7 +640,7 @@ ts.filter = {
} }
if (wo.filter_hideFilters) { if (wo.filter_hideFilters) {
// show/hide filter row as needed // show/hide filter row as needed
c.$table.find('.' + ts.css.filterRow).trigger( combinedFilters === '' ? 'mouseleave' : 'mouseenter' ); c.$table.find('.' + tscss.filterRow).trigger( combinedFilters === '' ? 'mouseleave' : 'mouseenter' );
} }
// return if the last search is the same; but filter === false when updating the search // return if the last search is the same; but filter === false when updating the search
// see example-widget-filter.html filter toggle buttons // see example-widget-filter.html filter toggle buttons
@ -664,8 +666,8 @@ ts.filter = {
hideFilters: function(table, c) { hideFilters: function(table, c) {
var $filterRow, $filterRow2, timer; var $filterRow, $filterRow2, timer;
$(table) $(table)
.find('.' + ts.css.filterRow) .find('.' + tscss.filterRow)
.addClass('hideme') .addClass(tscss.filterRowHide)
.bind('mouseenter mouseleave', function(e) { .bind('mouseenter mouseleave', function(e) {
// save event object - http://bugs.jquery.com/ticket/12140 // save event object - http://bugs.jquery.com/ticket/12140
var event = e; var event = e;
@ -673,14 +675,14 @@ ts.filter = {
clearTimeout(timer); clearTimeout(timer);
timer = setTimeout(function() { timer = setTimeout(function() {
if ( /enter|over/.test(event.type) ) { if ( /enter|over/.test(event.type) ) {
$filterRow.removeClass('hideme'); $filterRow.removeClass(tscss.filterRowHide);
} else { } else {
// don't hide if input has focus // don't hide if input has focus
// $(':focus') needs jQuery 1.6+ // $(':focus') needs jQuery 1.6+
if ( $(document.activeElement).closest('tr')[0] !== $filterRow[0] ) { if ( $(document.activeElement).closest('tr')[0] !== $filterRow[0] ) {
// don't hide row if any filter has a value // don't hide row if any filter has a value
if (c.lastCombinedFilter === '') { if (c.lastCombinedFilter === '') {
$filterRow.addClass('hideme'); $filterRow.addClass(tscss.filterRowHide);
} }
} }
} }
@ -693,7 +695,7 @@ ts.filter = {
timer = setTimeout(function() { timer = setTimeout(function() {
// don't hide row if any filter has a value // don't hide row if any filter has a value
if (ts.getFilters(c.$table).join('') === '') { if (ts.getFilters(c.$table).join('') === '') {
$filterRow2[ event.type === 'focus' ? 'removeClass' : 'addClass']('hideme'); $filterRow2[ event.type === 'focus' ? 'removeClass' : 'addClass'](tscss.filterRowHide);
} }
}, 200); }, 200);
}); });
@ -1181,7 +1183,7 @@ ts.filter = {
// t.data('placeholder') won't work in jQuery older than 1.4.3 // t.data('placeholder') won't work in jQuery older than 1.4.3
options = '<option value="">' + ( node.data('placeholder') || node.attr('data-placeholder') || wo.filter_placeholder.select || '' ) + '</option>', options = '<option value="">' + ( node.data('placeholder') || node.attr('data-placeholder') || wo.filter_placeholder.select || '' ) + '</option>',
// Get curent filter value // Get curent filter value
currentValue = c.$table.find('thead').find('select.' + ts.css.filter + '[data-column="' + column + '"]').val(); currentValue = c.$table.find('thead').find('select.' + tscss.filter + '[data-column="' + column + '"]').val();
// nothing included in arry (external source), so get the options from filter_selectSource or column data // nothing included in arry (external source), so get the options from filter_selectSource or column data
if (typeof arry === 'undefined' || arry === '') { if (typeof arry === 'undefined' || arry === '') {
arry = ts.filter.getOptionSource(table, column, onlyAvail); arry = ts.filter.getOptionSource(table, column, onlyAvail);
@ -1208,7 +1210,7 @@ ts.filter = {
} }
// update all selects in the same column (clone thead in sticky headers & any external selects) - fixes 473 // update all selects in the same column (clone thead in sticky headers & any external selects) - fixes 473
$filters = ( c.$filters ? c.$filters : c.$table.children('thead') ).find('.' + ts.css.filter); $filters = ( c.$filters ? c.$filters : c.$table.children('thead') ).find('.' + tscss.filter);
if (wo.filter_$externalFilters) { if (wo.filter_$externalFilters) {
$filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters; $filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters;
} }
@ -1252,7 +1254,7 @@ ts.getFilters = function(table, getRaw, setFilters, skipFirst) {
} }
if (c) { if (c) {
if (c.$filters) { if (c.$filters) {
$filters = c.$filters.find('.' + ts.css.filter); $filters = c.$filters.find('.' + tscss.filter);
} }
if (wo.filter_$externalFilters) { if (wo.filter_$externalFilters) {
$filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters; $filters = $filters && $filters.length ? $filters.add(wo.filter_$externalFilters) : wo.filter_$externalFilters;

View File

@ -454,7 +454,7 @@ tsp = ts.pager = {
p.$goto.html(t).val( p.page + 1 ); p.$goto.html(t).val( p.page + 1 );
} }
if ($out.length) { if ($out.length) {
$out[ ($out[0].tagName === 'INPUT') ? 'val' : 'html' ](s); $out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
// rebind startRow/page inputs // rebind startRow/page inputs
$out.find('.ts-startRow, .ts-page').off('change.pager').on('change.pager', function(){ $out.find('.ts-startRow, .ts-page').off('change.pager').on('change.pager', function(){
var v = $(this).val(), var v = $(this).val(),

View File

@ -179,7 +179,7 @@ ts.addWidget({
resizeHeader(); resizeHeader();
}); });
ts.bindEvents(table, $stickyThead.children().children('.tablesorter-header')); ts.bindEvents(table, $stickyThead.children().children('.' + ts.css.header));
// add stickyheaders AFTER the table. If the table is selected by ID, the original one (first) will be returned. // add stickyheaders AFTER the table. If the table is selected by ID, the original one (first) will be returned.
$table.after( $stickyWrap ); $table.after( $stickyWrap );