|
|
@ -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 ) {
|
|
|
|
var esc = function ( t ) {
|
|
|
|
return t
|
|
|
|
return t
|
|
|
|
.replace( /&/g, '&' )
|
|
|
|
.replace( /&/g, '&' )
|
|
|
@ -68,36 +68,38 @@ jQuery.fn.dataTable.render.ellipsis = function ( cutoff, wordbreak, escapeHtml )
|
|
|
|
|
|
|
|
|
|
|
|
d = d.toString(); // cast numbers
|
|
|
|
d = d.toString(); // cast numbers
|
|
|
|
|
|
|
|
|
|
|
|
if ( d.length <= cutoff * 1.5) {
|
|
|
|
if ( d.length <= maxLength) {
|
|
|
|
return d;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var shortened = d.substr(0, cutoff-1);
|
|
|
|
var shortened = d.substr(0, cutoff-1);
|
|
|
|
|
|
|
|
|
|
|
|
// Find the last white space character in the string
|
|
|
|
// Find the last white space character in the string
|
|
|
|
if ( wordbreak ) {
|
|
|
|
if ( wordbreak ) {
|
|
|
|
shortened = shortened.replace(/\s([^\s]*)$/, '');
|
|
|
|
shortened = shortened.replace(/\s([^\s]*)$/, '');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var remainder = d.substr(shortened.length);
|
|
|
|
// Protect against uncontrolled HTML input
|
|
|
|
// Protect against uncontrolled HTML input
|
|
|
|
if ( escapeHtml ) {
|
|
|
|
if ( escapeHtml ) {
|
|
|
|
shortened = esc( shortened );
|
|
|
|
shortened = esc( shortened );
|
|
|
|
|
|
|
|
remainder = esc(remainder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var myID = row[0];
|
|
|
|
|
|
|
|
return '<span class="ellipsis" title="'+esc(d)+'">'+ shortened + '</span><a id="ellipsis_' + myID + '" onclick=toggleVisibility(' + myID + ') class="ellipsis" style="font-style: italic"> …more</a><span id="truncatedItem_' + myID + '" style="display:none">' +d.substr(shortened.length, d.length)+'<span>';
|
|
|
|
return '<span class="ellipsis" title="'+esc(d)+'">' +
|
|
|
|
|
|
|
|
shortened +
|
|
|
|
|
|
|
|
'</span><a onclick="toggleVisibility(this)" class="ellipsis" style="font-style: italic"> …more</a><span style="display:none">' +
|
|
|
|
|
|
|
|
remainder + '</span></span>';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function toggleVisibility(myId){
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
var truncatedText = document.getElementById("truncatedItem_"+myId);
|
|
|
|
function toggleVisibility(thisElement){
|
|
|
|
var ellipsis = document.getElementById("ellipsis_" + myId);
|
|
|
|
if(thisElement.innerText === " …more") {
|
|
|
|
if(ellipsis.innerText === truncatedText.innerText) {
|
|
|
|
thisElement.style = "font-style: inherit";
|
|
|
|
ellipsis.innerText = " …more";
|
|
|
|
thisElement.innerText = thisElement.nextSibling.innerText;
|
|
|
|
ellipsis.style = "font-style: italic";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
ellipsis.innerText = truncatedText.innerText;
|
|
|
|
thisElement.innerText = " …more";
|
|
|
|
ellipsis.style = "";
|
|
|
|
thisElement.style = "font-style: italic";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|