From 17ebc25fbbff92180f60c9300059088d134c44cc Mon Sep 17 00:00:00 2001 From: Mottie Date: Fri, 24 May 2013 17:42:15 -0500 Subject: [PATCH] filter placeholder text can now be obtained from jQuery data --- ...ry.tablesorter.widgets-filter-formatter.js | 19 ++++++++++--------- js/jquery.tablesorter.widgets.js | 8 +++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/js/jquery.tablesorter.widgets-filter-formatter.js b/js/jquery.tablesorter.widgets-filter-formatter.js index 74a4c048..0d9ff1da 100644 --- a/js/jquery.tablesorter.widgets-filter-formatter.js +++ b/js/jquery.tablesorter.widgets-filter-formatter.js @@ -1,13 +1,14 @@ -/*! Filter widget formatter functions - updated 5/8/2013 +/*! Filter widget formatter functions - updated 5/24/2013 * requires: tableSorter 2.7.7+ and jQuery 1.4.3+ * - * jQuery UI spinner - * jQuery UI slider - * jQuery UI range slider - * jQuery UI datepicker (range) - * HTML5 number (spinner) - * HTML5 range slider - * HTML5 color selector + * uiSpinner (jQuery UI spinner) + * uiSlider (jQuery UI slider) + * uiRange (jQuery UI range slider) + * uiDateCompare (jQuery UI datepicker; 1 input) + * uiDatepicker (jQuery UI datepicker; 2 inputs, filter range) + * html5Number (spinner) + * html5Range (slider) + * html5Color (color) */ /*jshint browser:true, jquery:true, unused:false */ /*global jQuery: false */ @@ -248,7 +249,7 @@ $.tablesorter.filterFormatter = { // make sure we're using parsed dates in the search $hdr.addClass('filter-parsed'); // Add date range picker - $('' + o.cellText + '').appendTo($cell); + $('' + o.cellText + '').appendTo($cell); // add callbacks; preserve added callbacks o.oldonClose = o.onClose; diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index a79d42b5..013e0983 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -547,7 +547,9 @@ ts.addWidget({ buildSelect = function(i, updating, onlyavail){ var o, t, arry = [], currentVal; i = parseInt(i, 10); - o = ''; + t = $ths.filter('[data-column="' + i + '"]:last'); + // t.data('placeholder') won't work in jQuery older than 1.4.3 + o = ''; for (k = 0; k < b.length; k++ ){ l = c.cache[k].row.length; // loop through the rows @@ -651,7 +653,7 @@ ts.addWidget({ t = $('').appendTo( c.$filters.eq(i) ); } if (t) { - t.attr('placeholder', $th.attr('data-placeholder') || ''); + t.attr('placeholder', $th.data('placeholder') || $th.attr('data-placeholder') || ''); } } if (t) { @@ -715,7 +717,7 @@ ts.addWidget({ // add custom drop down list for (str in wo.filter_functions[col]){ if (typeof str === 'string'){ - ff += ff === '' ? '' : ''; + ff += ff === '' ? '' : ''; ff += ''; } }