diff --git a/filtering/type-based/accent-neutralise.js b/filtering/type-based/accent-neutralise.js index 79732d2..e917dae 100644 --- a/filtering/type-based/accent-neutralise.js +++ b/filtering/type-based/accent-neutralise.js @@ -34,33 +34,51 @@ * } ); */ -jQuery.fn.DataTable.ext.type.search.string = function ( data ) { +(function(){ + +function removeAccents ( data ) { + return data + .replace( /έ/g, 'ε' ) + .replace( /[ύϋΰ]/g, 'υ' ) + .replace( /ό/g, 'ο' ) + .replace( /ώ/g, 'ω' ) + .replace( /ά/g, 'α' ) + .replace( /[ίϊΐ]/g, 'ι' ) + .replace( /ή/g, 'η' ) + .replace( /\n/g, ' ' ) + .replace( /á/g, 'a' ) + .replace( /é/g, 'e' ) + .replace( /í/g, 'i' ) + .replace( /ó/g, 'o' ) + .replace( /ú/g, 'u' ) + .replace( /ê/g, 'e' ) + .replace( /î/g, 'i' ) + .replace( /ô/g, 'o' ) + .replace( /è/g, 'e' ) + .replace( /ï/g, 'i' ) + .replace( /ü/g, 'u' ) + .replace( /ã/g, 'a' ) + .replace( /õ/g, 'o' ) + .replace( /ç/g, 'c' ) + .replace( /ì/g, 'i' ); +} + +var searchType = jQuery.fn.DataTable.ext.type.search; + +searchType.string = function ( data ) { + return ! data ? + '' : + typeof data === 'string' ? + removeAccents( data ) : + data; +}; + +searchType.html = function ( data ) { return ! data ? '' : typeof data === 'string' ? - data - .replace( /έ/g, 'ε' ) - .replace( /[ύϋΰ]/g, 'υ' ) - .replace( /ό/g, 'ο' ) - .replace( /ώ/g, 'ω' ) - .replace( /ά/g, 'α' ) - .replace( /[ίϊΐ]/g, 'ι' ) - .replace( /ή/g, 'η' ) - .replace( /\n/g, ' ' ) - .replace( /á/g, 'a' ) - .replace( /é/g, 'e' ) - .replace( /í/g, 'i' ) - .replace( /ó/g, 'o' ) - .replace( /ú/g, 'u' ) - .replace( /ê/g, 'e' ) - .replace( /î/g, 'i' ) - .replace( /ô/g, 'o' ) - .replace( /è/g, 'e' ) - .replace( /ï/g, 'i' ) - .replace( /ü/g, 'u' ) - .replace( /ã/g, 'a' ) - .replace( /õ/g, 'o' ) - .replace( /ç/g, 'c' ) - .replace( /ì/g, 'i' ) : + removeAccents( data.replace( /<.*?>/g, '' ) ) : data; }; + +}()); \ No newline at end of file