<script src="http://www.nealfletcher.co.uk/js/jquery.ba-hashchange.js"></script>
<script src="http://www.nealfletcher.co.uk/js/jquery.isotope.min.js"></script>
<script src="http://www.nealfletcher.co.uk/js/isotope-center.js"></script>
<script src="http://www.nealfletcher.co.uk/js/jquery.imagesloaded.js"></script>
<div id="main-grid">
<div class="grid-block">
<div class="read-more">Read More</div>
<div class="read-less">Read Less</div>
<div class="grid-block-image"></div>
<div class="grid-block-titles">
<div class="category">Brand</div>
<div class="title">TEST</div>
<div class="date">12 July</div>
</div>
<div class="grid-block-text"><p>this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text</p> <p>this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text</p>
</div>
</div>
<div class="grid-block">
<div class="read-more">Read More</div>
<div class="read-less">Read Less</div>
<div class="grid-block-text">
<p>this is text</p>
</div>
</div>
<div class="grid-block">
<div class="read-more">Read More</div>
<div class="read-less">Read Less</div>
<div class="grid-block-text"><p>this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text this is text...
$(document).ready(function () {
var $elem = $('.grid-block-text p:first-child'); // The element or elements with the text to hide
var $limit = 50; // The number of characters to show
var $str = $elem.html(); // Getting the text
var $strtemp = $str.substr(0, $limit); // Get the visible part of the string
$str = $strtemp + '<span class="hide">' + $str.substr($limit, $str.length) + '</span>'; // Recompose the string with the span tag wrapped around the hidden part of it
$elem.html($str); // Write the string to the DOM
});
$(document).ready(function () {
var $container = $('#main-grid');
$container.imagesLoaded(function () {
$container.isotope({
itemSelector: '.grid-block, .grid-block-long',
animationEngine: 'best-available',
masonry: {
columnWidth: 5
}
});
});
$('.grid-block-text p').hide().filter(":first-child").show();
$('.read-more').click(function () {
var $this = $(this),
$parent = $this.parent('.grid-block');
$this.hide();
$this.nextAll('.grid-block-text')
.children('p').fadeIn('slow');
$this.nextAll('.grid-block-text')
.children().children('.hide').removeClass('hide').addClass('show');
$this.siblings('.read-less').fadeIn('slow');
$parent.css('height','auto');
var newHeight = $parent.height();
newHeight = (Math.floor((newHeight+29)/330)+1)*330-29;
$parent
.css('height',newHeight)
.removeClass('grid-block')
.addClass('grid-block-long');
//$('#main-grid').isotope('reLayout');
$container.isotope('reLayout');
});
$('.read-less').click(function () {
var $this = $(this);
$this.hide();
$this.nextAll('.grid-block-text')
.children("p:not(:first-child)").fadeOut('fast');
$this.nextAll('.grid-block-text')
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.