Created
December 16, 2015 19:06
-
-
Save emhoracek/2912738029087dbf2fc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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