trim long words in reports [fixes SCI-105]

This commit is contained in:
zmagod 2016-09-01 15:45:39 +02:00
parent 77f00bf3a7
commit 28fa00c30c
2 changed files with 22 additions and 3 deletions

View file

@ -47,7 +47,7 @@ function initializeHandsonTable(el) {
});
el.handsontable("getInstance").loadData(data);
el.handsontable("getInstance").sort(3, order);
// "Hack" to disable user sorting rows by clicking on
// header elements
el.handsontable("getInstance")
@ -1185,3 +1185,17 @@ initializeAddContentsModal();
initializeSidebarNavigation();
initializeUnsavedWorkDialog();
initializeTutorial();
$(document).change(function(){
setTimeout(function(){
$(".report-nav-link").each( function(){
truncateLongString( $(this), 30);
console.log($(this));
});
}, 1000);
});
$(document).ready(function(){
$(".report-nav-link").each( function(){
truncateLongString( $(this), 30);
});
});

View file

@ -4,15 +4,20 @@
function truncateLongString( el, chars ) {
var input = $.trim(el.text());
var html = "";
if( el.children().hasClass("glyphicon") ){
html = el.children()[0];
}
if( input.length >= chars){
var newText = el.text().slice(0, chars);
for( var i = newText.length; i > 0; i--){
if(newText[i] === ' '){
if(newText[i] === ' ' && i > 10){
newText = newText.slice(0, i);
break;
}
}
el.text(newText + '...');
el.html(html.outerHTML + newText + '...' );
}
}