Last active
August 29, 2015 14:20
-
-
Save tinchoz49/5a9c0437adfeb982bc87 to your computer and use it in GitHub Desktop.
ellipsis for wordpress
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
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