mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-10-08 13:44:18 +00:00
13 lines
916 B
JavaScript
13 lines
916 B
JavaScript
/*! Widget: filter, insideRange filter type - updated 2/23/2015 (v2.21.0) */
|
|
!function(a){"use strict";
|
|
// Add insideRange filter type
|
|
// ============================
|
|
// This allows you to enter a number (e.g. 8) and show the
|
|
// resulting rows that will have that query within it's range
|
|
// demo at http://mottie.github.io/tablesorter/docs/example-widget-filter-custom-search2.html
|
|
var b=a.tablesorter,c=/\d+/,d=/\s+-\s+/,e=function(a){return isNaN(a)?a:parseFloat(a)};b.filter.types.insideRange=function(a,b){if(c.test(b.iFilter)&&d.test(b.iExact)){var f,g,h,i,j=b.iExact.split(d),k=a.parsers[b.index].format;
|
|
// the cell does not contain a range
|
|
// the cell does not contain a range
|
|
// format each side part of the range using the assigned parser
|
|
// swap high & low
|
|
return j&&j.length<2?null:(h=e(k(j[0],a.table)),i=e(k(j[1],a.table)),g=e(k(b.iFilter,a.table)),h>i&&(f=i,i=h,h=f),g>=h&&i>=g)}return null}}(jQuery); |