Skip to content

Instantly share code, notes, and snippets.

@emhoracek
Created December 16, 2015 19:06
Show Gist options
  • Save emhoracek/2912738029087dbf2fc5 to your computer and use it in GitHub Desktop.
Save emhoracek/2912738029087dbf2fc5 to your computer and use it in GitHub Desktop.
var excerpts=document.getElementsByClassName('excerpt-container');
var ellipsisify = function() {
for (var i=0; i < excerpts.length; i++) {
var p=$(excerpts[i]).find('p');
var divh=$(excerpts[i]).height();
while ($(p).outerHeight()>divh) {
$(p).text(function (index, text) {
return text.replace(/\W*\s(\S)*$/, '...');
});
}
}
};
ellipsisify();
$(window).resize(function() {
ellipsisify();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment