From: vincent@cubedesigners.com Date: Fri, 1 Dec 2017 17:32:23 +0000 (+0000) Subject: wip #1785 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=38b62eb10d2a63a2562d7c3ea4c4c6d42017b389;p=ccgm.git wip #1785 @1 --- diff --git a/framework/application/views/helpers/News.php b/framework/application/views/helpers/News.php new file mode 100644 index 0000000..62b06eb --- /dev/null +++ b/framework/application/views/helpers/News.php @@ -0,0 +1,30 @@ +order('date DESC')->find(); + + + $res = ''; + + foreach ($allnews as $news) { + $res .= $this->_news($news); + } + + return $this->htmlElement($res, 'section', ['id' => 'news']); + } + + protected function _news($n) { + $res = $this->imageProcess($n->getImage(), '', 200, 200); + $c = $this->dateTime($n->getDate(), CubeIT_Date::DAY . '/' . CubeIT_Date::MONTH . '/' . CubeIT_Date::YEAR); + $c .= $this->htmlElement($n->getTitle(), 'h2'); + $c .= $this->markupDotclear($n->getContent()); + $c .= $this->link('Lire la suite', '#', ['class' => 'more']); + $c .= $this->link('Réduire', '#', ['class' => 'less']); + $res .= $this->htmlElement($c, 'div', ['class' => 'c']); + return $this->htmlElement($res, 'article'); + } +} \ No newline at end of file diff --git a/framework/application/views/scripts/templates/news.phtml b/framework/application/views/scripts/templates/news.phtml index 14fcde2..14fbce1 100644 --- a/framework/application/views/scripts/templates/news.phtml +++ b/framework/application/views/scripts/templates/news.phtml @@ -1,11 +1,13 @@ contentWidth = 980; +$this->headScript()->addScriptAndStyle('news'); ?>
markupDotclear($this->text); + echo $this->news(); ?>
\ No newline at end of file diff --git a/js/news.js b/js/news.js new file mode 100644 index 0000000..6f81869 --- /dev/null +++ b/js/news.js @@ -0,0 +1,47 @@ +(function ($) { + function JQnews(element) { + this.element = element; + this.init(); + } + + JQnews.prototype = { + init: function () { + var $this = this; + + + $(this.element).on('click', '.more', function () { + var c = $(this).closest('.c'); + var d = $(c).find('.dotclear'); + d.css({maxHeight: 999}); + $(this).hide(); + $(c).find('.less').show(); + setTimeout(function () { + d.css({maxHeight: d.outerHeight()}); + }, 600); + return false; + }); + + $(this.element).on('click', '.less', function () { + var c = $(this).closest('.c'); + var d = $(c).find('.dotclear'); + d.css({maxHeight: 72}); + $(this).hide(); + $(c).find('.more').show(); + return false; + }); + } + }; + + jQuery.fn.news = function () { + return this.each(function () { + var $this = $(this); + if ($(this).data('news') === undefined) { + $(this).data('news', new JQnews($this)); + } + }) + }; +})(jQuery); + +$(function () { + $("#news").news(); +}); \ No newline at end of file diff --git a/less/news.less b/less/news.less new file mode 100644 index 0000000..6ed209d --- /dev/null +++ b/less/news.less @@ -0,0 +1,74 @@ +#news { + font-weight: 300; + + article { + border-bottom: 1px solid #dad9d9; + padding-bottom: 48px; + margin-bottom: 48px; + &:last-child{ + border-bottom: none; + margin-bottom: 0; + } + + img { + vertical-align: top; + display: inline-block; + width: 200px; + height: 200px; + border-radius: 100px; + } + + .c { + margin-left: 80px; + vertical-align: top; + display: inline-block; + width: 686px; + time { + font-size: 13px; + } + + h2 { + color: #5e5e5e; + margin: 30px 0 0; + font-size: 26px; + } + + .dotclear { + line-height: 24px; + max-height: 72px; + overflow: hidden; + transition: max-height 450ms; + margin-bottom: 30px; + p:last-child{ + margin-bottom: 0; + } + } + + .more, .less { + color: #25a1da; + font-weight: 500; + font-size: 16px; + display: block; + &:after{ + content:""; + display: inline-block; + margin-left: 10px; + width: 15px; + height: 15px; + position: relative; + top: 3px; + background-image: url("/images/arrow-li.svg"); + background-size: 100% 100%; + transform: rotate(90deg); + } + } + + .less{ + display: none; + &:after{ + transform: rotate(270deg); + } + } + } + } +} \ No newline at end of file