Sha256: 13139f1a0790e4d50e3b7f8d22eaff1343ecaa0b6dc3b312daea60e52ca8d3a4

Contents?: true

Size: 1.53 KB

Versions: 11

Compression:

Stored size: 1.53 KB

Contents

/*! Widget: filter, insideRange filter type - updated 12/10/2015 (v2.25.0) */
;(function($) {
	'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 ts = $.tablesorter,
		isDigit = /\d+/,
		range = /\s+-\s+/,
		parseNumber = function(num) {
			return isNaN(num) ? num : parseFloat(num);
		};

	ts.filter.types.insideRange = function( c, data ) {
		// don't look for an inside range if "any" match is enabled... multiple "-" really screw things up
		if ( !data.anyMatch && isDigit.test( data.iFilter ) && range.test( data.iExact ) ) {
			var t, val, low, high,
				index = data.index,
				cell = data.$cells[ index ],
				parts = data.iExact.split( range ),
				format = c.parsers[data.index] && c.parsers[data.index].format;
			// the cell does not contain a range or the parser isn't defined
			if ( parts && parts.length < 2 || typeof format !== 'function' ) {
				return null;
			}
			// format each side part of the range using the assigned parser
			low = parseNumber( format( parts[0], c.table, cell, index ) );
			high = parseNumber( format( parts[1], c.table, cell, index ) );
			val = parseNumber( format( data.iFilter, c.table, cell, index ) );
			if ( high < low ) {
				// swap high & low
				t = high; high = low; low = t;
			}
			return low <= val && val <= high;
		}
		return null;
	};

})(jQuery);

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
jquery-tablesorter-1.27.2 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.27.1 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.27.0 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.26.1 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.26.0 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.25.5 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.25.4 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.25.3 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.25.2 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.25.1 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js
jquery-tablesorter-1.25.0 vendor/assets/javascripts/jquery-tablesorter/widgets/widget-filter-type-insideRange.js