Skip to content

Instantly share code, notes, and snippets.

@tinchoz49
Last active August 29, 2015 14:20
Show Gist options
  • Save tinchoz49/5a9c0437adfeb982bc87 to your computer and use it in GitHub Desktop.
Save tinchoz49/5a9c0437adfeb982bc87 to your computer and use it in GitHub Desktop.
ellipsis for wordpress
function ellip( item ) {
var wrap = item,
header = $(item.find('.ellip-header')),
content = $(item.find('.ellip-content')),
footer = $(item.find('.ellip-footer'));
var height = wrap.height(),
margin = 40,
p = $(content.find('p'));
height = height - header.outerHeight(true) - footer.outerHeight(true);
// mantengo al footer final
wrap.css({
position: 'relative'
});
footer.css({
bottom: 0,
position: 'absolute',
width: '100%'
});
content.height(height);
while ( p.outerHeight() > height ) {
p.text(function (index, text) {
return text.replace(/\W*\s(\S)*$/, '...');
});
}
}
$(function() {
$('.ellip').each(function (index,value) {
ellip($(value));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment