Readmore.js by @jedfoster packaged for Meteor.
A smooth, responsive jQuery plugin for collapsing and expanding long blocks of text with "Read more" and "Close" links.
The markup Readmore.js requires is so simple, you can probably use it with your existing HTML—there's no need for complicated sets of div's or hardcoded classes, just call .readmore() on the element containing your block of text and Readmore.js takes care of the rest. Readmore.js plays well in a responsive environment, too.
meteor add redspear:readmore
For a block of text like this...
<div class="article">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
</div>Have this run on the page somewhere.
$('.article').readmore();Putting it in onRendered works well.
Template.TEMPLATENAME.onRendered(function () {
$('.article').readmore({collapsedHeight: 60});
});It's that simple. You can change the speed of the animation, the height of the collapsed block, and the open and close elements.
$('.article').readmore({
speed: 75,
lessLink: '<a href="#">Read less</a>'
});speed: 100in millisecondscollapsedHeight: 200in pixelsheightMargin: 16in pixels, avoids collapsing blocks that are only slightly larger thancollapsedHeightmoreLink: '<a href="#">Read more</a>'lessLink: '<a href="#">Close</a>'embedCSS: trueinsert required CSS dynamically, set this tofalseif you include the necessary CSS in a stylesheetblockCSS: 'display: block; width: 100%;'sets the styling of the blocks, ignored ifembedCSSisfalsestartOpen: falsedo not immediately truncate, start in the fully opened positionbeforeToggle: function() {}called after a more or less link is clicked, but before the block is collapsed or expandedafterToggle: function() {}called after the block is collapsed or expanded
If the element has a max-height CSS property, Readmore.js will use that value rather than the value of the collapsedHeight option.
Get more info at the readmore.js github page