//-- Handle show/hide link clicks
$(document).on('click', 'a.read-more', function() {
- var content = $(this).siblings('.news-content');
+ var content = $(this).siblings('.news-content-wrapper');
- if (content.hasClass('open')) {
- content.removeClass('open');
+ if ($(this).hasClass('open')) {
+ content.attr('style', ''); // Reset height
$(this).text($(this).data('closed'));
} else {
- content.addClass('open');
+ var h = content.find('.news-content').height();
+ content.css('height', h);
$(this).text($(this).data('open'));
}
+ $(this).toggleClass('open');
+
return false;
});
}
// If we don't have a full window of content, the scroll
// trigger won't fire, so load more content until it can
if ($(document).height() <= $(window).height()) {
- console.info('fillpage ' + currentPage);
+ fb('fillpage ' + currentPage);
loadMoreContent(fillPage);
}
}
res += '<div class="news-body">';
res += '<time class="news-date">' + data.date + '</time>';
res += '<h3 class="news-headline">' + data.headline + '</h3>';
- res += data.content; // MarkupDotClear view helper already wraps content in a div
+ res += '<div class="news-content-wrapper">' + data.content + '</div>';
// Add the open/close link
res += '<a href="#" class="read-more" data-closed="'+ readMoreClosed +'" data-open="'+ readMoreOpen +'">'+ readMoreClosed +'</a>';
// Add new items to container and update Masonry
$container.append(elems);
+ // Now that elements have been added, check to see
+ // if any are too short to need a "read more" link
+ $('.news-content').each(function() {
+ if ($(this).height() <= 48) {
+ $(this).parent().siblings('.read-more').hide();
+ }
+ });
+
currentPage++;
if (typeof callback === "function") {
.page-heading {
- margin-bottom: 110px;
+ margin: 60px 0 110px;
}
.news-item {
margin: 15px 0 25px;
}
-.news-content {
+.news-content-wrapper {
overflow: hidden;
- max-height: 3em; // Line height is 1.5 so 3em = 2 lines visible
-
- &.open {
- max-height: none;
- }
+ height: 3em; // Line height is 1.5 so 3em = 2 lines visible
+ transition: height 0.3s ease-in;
+}
+.news-content {
p {
&:first-of-type {
padding-top: 0;
}
+ &:last-of-type {
+ padding-bottom: 0;
+ }
}
}
font-size: 16px;
font-weight: 600;
color: #000;
- display: block;
+ display: inline-block;
margin-top: 1em;
+
+ &.open:after {
+ transform: rotate(180deg);
+ }
+
+ &:after {
+ content: '';
+ width: 15px;
+ height: 14px;
+ display: inline-block;
+ background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAOCAYAAADwikbvAAABQElEQVQoU6WTsVKDQBCG/1WwThm7pKC3dMJl5lLGSt8geQBxbOmldcSepDaFqaSUGSC1PUV8hMxIZdB1Dj1UcMQZt4E79v9272ePUAshhARezwCSADrMeCTiB2DnKkmS6Gs66YWUsrPdbi+JMKkDP9e8NIy9aRRFG7VXiYWw7wGoai3ByyRZnVTi4XAwYaZZm0x/J+JpHK/mZWXbttdE6Kl3y7KQZVmD0+3uI8+fkOc5lA9pmvZJysNeUeyudXYcJ/A8D2F4VwEU0Pev4TinFdgwXvr07i6r85YxHh/Bdd0KoIW+738DAjRqiDXAcRwogXouFjcIgqB2FBo12q53EIYhPO+i4UHZdt2wvzheGaaS//WrFECIwS1Ax+2Va0OiBGo8i+J59huAGXPTNM8b46kr6ovBTAcfg7MBOPrpYrwBbS+Up/n+Zr4AAAAASUVORK5CYII=');
+ margin-left: 5px;
+ }
}