Filter formatter: set datepicker to null. See #512

Needed for older versions of jQuery UI
This commit is contained in:
Mottie 2014-04-26 17:12:31 -05:00
parent 1b3016da74
commit a502cc6411

View File

@ -1,4 +1,4 @@
/*! Filter widget formatter functions - updated 4/23/2014 (v2.16.0) /*! Filter widget formatter functions - updated 4/26/2014 (v2.16.0)
* requires: tableSorter 2.15+ and jQuery 1.4.3+ * requires: tableSorter 2.15+ and jQuery 1.4.3+
* *
* uiSpinner (jQuery UI spinner) * uiSpinner (jQuery UI spinner)
@ -517,7 +517,7 @@ tsff = ts.filterFormatter = {
getdate = $date.datepicker('getDate') || '', getdate = $date.datepicker('getDate') || '',
compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '', compare = ($.isArray(o.compare) ? $cell.find(compareSelect).val() || o.compare[ o.selected || 0] : o.compare) || '',
searchType = c.$table[0].hasInitialized ? o.delayed || '': true; searchType = c.$table[0].hasInitialized ? o.delayed || '': true;
$date.datepicker('setDate', getdate === '' ? '' : getdate); $date.datepicker('setDate', (getdate === '' ? '' : getdate) || null);
if (getdate === '') { notrigger = false; } if (getdate === '') { notrigger = false; }
date = $date.datepicker('getDate'); date = $date.datepicker('getDate');
query = date ? ( o.endOfDay && /<=/.test(compare) ? date.setHours(23, 59, 59) : date.getTime() ) || '' : ''; query = date ? ( o.endOfDay && /<=/.test(compare) ? date.setHours(23, 59, 59) : date.getTime() ) || '' : '';
@ -557,7 +557,7 @@ tsff = ts.filterFormatter = {
if ($.isArray(o.compare)) { if ($.isArray(o.compare)) {
$cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] ); $cell.add($shcell).find(compareSelect).val( o.compare[ o.selected || 0 ] );
} }
$cell.add($shcell).find('.date').val(o.defaultDate).datepicker('setDate', o.defaultDate); $cell.add($shcell).find('.date').val(o.defaultDate).datepicker('setDate', o.defaultDate || null);
setTimeout(function(){ setTimeout(function(){
date1Compare(); date1Compare();
}, 0); }, 0);
@ -570,13 +570,13 @@ tsff = ts.filterFormatter = {
// date range found; assume an exact match on one day // date range found; assume an exact match on one day
$cell.find(compareSelect).val('='); $cell.find(compareSelect).val('=');
num = v.split(/\s+-\s+/)[0]; num = v.split(/\s+-\s+/)[0];
$date.datepicker( 'setDate', num ); $date.datepicker( 'setDate', num || null );
} else { } else {
num = (tsff.updateCompare($cell, $input, o)[1]).toString() || ''; num = (tsff.updateCompare($cell, $input, o)[1]).toString() || '';
// differeniate 1388556000000 from 1/1/2014 using \d{5} regex // differeniate 1388556000000 from 1/1/2014 using \d{5} regex
num = num !== '' ? /\d{5}/g.test(num) ? Number(num) : num || '' : ''; num = num !== '' ? /\d{5}/g.test(num) ? Number(num) : num || '' : '';
} }
$cell.add($shcell).find('.date').datepicker( 'setDate', num ); $cell.add($shcell).find('.date').datepicker( 'setDate', num || null );
setTimeout(function(){ setTimeout(function(){
date1Compare(true); date1Compare(true);
}, 0); }, 0);
@ -681,16 +681,16 @@ tsff = ts.filterFormatter = {
if (/<=/.test(range)) { if (/<=/.test(range)) {
$cell.add( $shcell ) $cell.add( $shcell )
.find('.dateFrom').datepicker('option', 'maxDate', to ).end() .find('.dateFrom').datepicker('option', 'maxDate', to || null ).end()
.find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to); .find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to || null);
} else if (/>=/.test(range)) { } else if (/>=/.test(range)) {
$cell.add( $shcell ) $cell.add( $shcell )
.find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from).end() .find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from || null).end()
.find('.dateTo').datepicker('option', 'minDate', from ); .find('.dateTo').datepicker('option', 'minDate', from || null );
} else { } else {
$cell.add( $shcell ) $cell.add( $shcell )
.find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from ).end() .find('.dateFrom').datepicker('option', 'maxDate', null).datepicker('setDate', from || null ).end()
.find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to); .find('.dateTo').datepicker('option', 'minDate', null).datepicker('setDate', to || null);
} }
if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); } if (typeof o.oldonClose === 'function') { o.oldonClose(selectedDate, ui); }
@ -718,8 +718,8 @@ tsff = ts.filterFormatter = {
// less than date (from date empty) // less than date (from date empty)
to = val.replace(/<=/, '') || ''; to = val.replace(/<=/, '') || '';
} }
$cell.add($shcell).find('.dateFrom').datepicker('setDate', from); $cell.add($shcell).find('.dateFrom').datepicker('setDate', from || null);
$cell.add($shcell).find('.dateTo').datepicker('setDate', to); $cell.add($shcell).find('.dateTo').datepicker('setDate', to || null);
// give datepicker time to process // give datepicker time to process
setTimeout(function(){ setTimeout(function(){
closeDate(); closeDate();
@ -742,8 +742,8 @@ tsff = ts.filterFormatter = {
// on reset // on reset
$cell.closest('table').bind('filterReset', function(){ $cell.closest('table').bind('filterReset', function(){
$cell.add($shcell).find('.dateFrom').val('').datepicker('setDate', o.from ); $cell.add($shcell).find('.dateFrom').val('').datepicker('setDate', o.from || null );
$cell.add($shcell).find('.dateTo').val('').datepicker('setDate', o.to ); $cell.add($shcell).find('.dateTo').val('').datepicker('setDate', o.to || null );
setTimeout(function(){ setTimeout(function(){
closeDate(); closeDate();
}, 0); }, 0);