Javascript: show/hide more text
function shortenText (textElement, max) {
var text = textElement.text();
if (text.length > max) {
var shortText = text.substr(0, max);
if (shortText.substr(shortText.length - 1) == ' ') {
shortText = shortText.substr(0, max - 1);
}
shortText += '...';
textElement.after('<div class="fullText is-hidden">' + text + '</div>');
textElement.text(shortText);
}
}
function showFullText(el, fullText) {
el.text(fullText.text());
fullText.remove();
}