diff --git a/app/assets/javascripts/reports/new.js b/app/assets/javascripts/reports/new.js index a0111bb82..9d090e868 100644 --- a/app/assets/javascripts/reports/new.js +++ b/app/assets/javascripts/reports/new.js @@ -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); + }); +}); diff --git a/app/assets/javascripts/sitewide/string_utils.js b/app/assets/javascripts/sitewide/string_utils.js index f36e29311..5b63fb1fb 100644 --- a/app/assets/javascripts/sitewide/string_utils.js +++ b/app/assets/javascripts/sitewide/string_utils.js @@ -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 + '...' ); } }