Sha256: b309f8ad01c0b2402a10033d6f7f544ecd3d8593ebe450bf04175558b1c54f50

Contents?: true

Size: 704 Bytes

Versions: 3

Compression:

Stored size: 704 Bytes

Contents

/**
 * Detect file size type columns automatically. Commonly used for computer
 * file sizes, this can allow sorting to take the order of magnitude indicated
 * by the label (GB etc) into account.
 *
 *  @name File size
 *  @summary Detect abbreviated file size data (8MB, 4KB, 3B, etc)
 *  @author Allan Jardine - datatables.net
 */

jQuery.fn.dataTable.ext.type.detect.unshift( function ( data ) {
	if ( typeof data !== 'string' ) {
		return null;
	}

	var matches = data.match( /^(\d+(?:\.\d+)?)\s*([a-z]+)/i );
	var units = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
	var is_file_size = ( matches && jQuery.inArray(matches[2].toLowerCase(), units) !== -1 );
	return is_file_size ? 'file-size' : null;
} );

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jquery-datatables-1.10.19.1 app/assets/javascripts/datatables/plugins/type-detection/file-size.js
jquery-datatables-1.10.19 app/assets/javascripts/datatables/plugins/type-detection/file-size.js
jquery-datatables-1.10.18 app/assets/javascripts/datatables/plugins/type-detection/file-size.js