From 1f4a6638a5f90875ae0a57ae88097e42f6f96789 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Mon, 9 May 2016 10:01:34 +0000 Subject: [PATCH] #simeox Finalise news page, improve "read more" link and animations. #372 @1h30 --- framework/application/Simeox/News.php | 2 +- js/news.js | 23 ++++++++++++++------ less/navigation.less | 2 +- less/news.less | 31 ++++++++++++++++++++------- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/framework/application/Simeox/News.php b/framework/application/Simeox/News.php index 5b54c57..b5f20ea 100644 --- a/framework/application/Simeox/News.php +++ b/framework/application/Simeox/News.php @@ -7,7 +7,7 @@ class Simeox_News { public static function getNews($page = 1, $perPage = 3) { //###TEMPORARY! Produce endless stream of data for testing infinite scroll - //$page = ($page > 1) ? 1 : $page; + $page = ($page > 1) ? 1 : $page; //fb('Fetching page #'. $page); diff --git a/js/news.js b/js/news.js index fb19d31..825837d 100644 --- a/js/news.js +++ b/js/news.js @@ -33,16 +33,19 @@ function load_newsfeed() { //-- 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; }); } @@ -52,7 +55,7 @@ function fillPage() { // 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); } } @@ -90,7 +93,7 @@ function loadMoreContent(callback) { res += '
'; res += ''; res += '

' + data.headline + '

'; - res += data.content; // MarkupDotClear view helper already wraps content in a div + res += '
' + data.content + '
'; // Add the open/close link res += ''+ readMoreClosed +''; @@ -107,6 +110,14 @@ function loadMoreContent(callback) { // 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") { diff --git a/less/navigation.less b/less/navigation.less index 4cd7aef..8faa1df 100644 --- a/less/navigation.less +++ b/less/navigation.less @@ -40,7 +40,7 @@ nav.locale { right: 0; top: 15px; opacity: 1; - transition: opacity 0.1s ease-in; + transition: all 0.1s ease-in 0s; backface-visibility: hidden; .small & { diff --git a/less/news.less b/less/news.less index bc4e5e6..362d911 100644 --- a/less/news.less +++ b/less/news.less @@ -1,5 +1,5 @@ .page-heading { - margin-bottom: 110px; + margin: 60px 0 110px; } .news-item { @@ -32,18 +32,20 @@ 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; + } } } @@ -51,8 +53,21 @@ 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; + } } -- 2.39.5