diff --git a/dataRender/ellipsis.js b/dataRender/ellipsis.js index 7abfa0d..f56ee4b 100644 --- a/dataRender/ellipsis.js +++ b/dataRender/ellipsis.js @@ -47,7 +47,7 @@ * } ); */ -jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) { +jQuery.fn.dataTable.render.ellipsis = function ( cutoff, maxLength, wordbreak, escapeHtml ) { var esc = function ( t ) { return t .replace( /&/g, '&' ) @@ -55,7 +55,7 @@ jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) .replace( />/g, '>' ) .replace( /"/g, '"' ); }; - + return function ( d, type, row ) { // Order, search and type get the original data if ( type !== 'display' ) { @@ -68,36 +68,38 @@ jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml ) d = d.toString(); // cast numbers - if ( d.length <= cutoff * 1.5) { + if ( d.length <= maxLength) { return d; } - var shortened = d.substr(0, cutoff-1); - + // Find the last white space character in the string if ( wordbreak ) { shortened = shortened.replace(/\s([^\s]*)$/, ''); } - + var remainder = d.substr(shortened.length); // Protect against uncontrolled HTML input if ( escapeHtml ) { shortened = esc( shortened ); + remainder = esc(remainder); } - var myID = row[0]; - return ''+ shortened + ' …more