]> _ Git - ccgm.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Aug 2013 13:19:50 +0000 (13:19 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Aug 2013 13:19:50 +0000 (13:19 +0000)
css/actualites.css [new file with mode: 0644]
css/home.css
framework/application/forms/CMS/Home.php
framework/application/forms/CMS/Sub/Home/Actualite.php [new file with mode: 0644]
framework/application/forms/CMS/Sub/Home/Actualites.php [new file with mode: 0644]
framework/application/views/helpers/Actualites.php [new file with mode: 0644]
framework/application/views/scripts/templates/home.phtml
js/actualites.js [new file with mode: 0644]

diff --git a/css/actualites.css b/css/actualites.css
new file mode 100644 (file)
index 0000000..62795ab
--- /dev/null
@@ -0,0 +1,60 @@
+.updates {
+       background:#f4f1f1;
+       position: relative;
+       font-weight:400;
+       font-style:italic;
+       font-size:14px;
+       line-height:31px;
+}
+.updates .holder{
+       margin:0 auto;
+       width:981px;
+       position:relative;
+       padding: 19px 0 16px;
+       background-image:url(../images/news.svg);
+       background-position: 0 50%;
+}
+.updates .mask {
+       position: relative;
+       overflow: hidden;
+       width: 910px;
+}
+.updates .slideset {
+       position: relative;
+       overflow: hidden;
+       width: 870px;
+       height: 30px;
+       left:39px;
+}
+.updates .slide {
+       width: 870px;
+       display:none;
+       position:absolute;
+       top:0px;
+}
+.updates .btn-prev,
+.updates .btn-next {
+       width: 30px;
+       height: 31px;
+       text-indent: -9999px;
+       overflow: hidden;
+       bottom: 68px;
+       float:left;
+       background-image: url(../images/arrow-news-left.svg);
+       background-size: 30px 30px;
+}
+.updates .btn-next {
+       margin:0 0 0 5px;
+       background-image: url(../images/arrow-news-right.svg);
+}
+.updates .btn-area{
+       position:absolute;
+       right:0;
+       top:20px;
+}
+.updates p{white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
+.updates .date{
+       font-weight:500;
+       margin: 0 5px 0 0;
+       font-style:italic;
+}
\ No newline at end of file
index d93ca671dc3a59c553c6ed3e122b765a13f81a26..796852824b8a7e9b5629c537ce4f3f472e1f94e3 100644 (file)
        padding: 0 0 0 17px;
 }
 .services .col p{margin:0 0 17px;}
-.updates {
-       background:#f4f1f1;
-       position: relative;
-       font-weight:400;
-       font-style:italic;
-       font-size:14px;
-       line-height:31px;
-}
-.updates .holder{
-       margin:0 auto;
-       width:981px;
-       position:relative;
-       padding: 19px 0 16px;
-       background-image:url(../images/news.svg);
-       background-position: 0 50%;
-}
-.updates .mask {
-       position: relative;
-       overflow: hidden;
-       width: 910px;
-}
-.updates .slideset {
-       width: 9999px;
-       float: left;
-}
-.updates .slide {
-       width: 910px;
-       float: left;
-}
-.updates .btn-prev,
-.updates .btn-next {
-       width: 30px;
-       height: 31px;
-       text-indent: -9999px;
-       overflow: hidden;
-       bottom: 68px;
-       float:left;
-       background-image: url(../images/arrow-news-left.svg);
-       background-size: 30px 30px;
-}
-.updates .btn-next {
-       margin:0 0 0 5px;
-       background-image: url(../images/arrow-news-right.svg);
-}
-.updates .btn-area{
-       position:absolute;
-       right:0;
-       top:20px;
-}
-.updates p{margin:0 0 0 39px;}
-.updates .date{
-       font-weight:500;
-       margin: 0 5px 0 0;
-       font-style:italic;
-}
\ No newline at end of file
index 351bb072ee9c4fd058bfc347810c02b35c9b2e3a..332809227efed69f0596598debb2c31a08fc3c2f 100644 (file)
@@ -1,9 +1,14 @@
 <?php
 
-class CCGM_Form_CMS_Home extends CCGM_Form_CMS{
-       public function init(){
+class CCGM_Form_CMS_Home extends CCGM_Form_CMS {
+
+       public function init() {
                parent::init();
+
+               $actualites = new CCGM_Form_CMS_Sub_Home_Actualites();
+               $actualites->setLegend('Actualités');
+               $this->addSubForm($actualites, 'actualites');
        }
+
 }
 
-?>
diff --git a/framework/application/forms/CMS/Sub/Home/Actualite.php b/framework/application/forms/CMS/Sub/Home/Actualite.php
new file mode 100644 (file)
index 0000000..88bb7f5
--- /dev/null
@@ -0,0 +1,24 @@
+<?php\r
+\r
+class CCGM_Form_CMS_Sub_Home_Actualite extends CubeIT_Form_SubForm {\r
+\r
+       public function init() {\r
+               parent::init();\r
+\r
+               $date = new CubeIT_Form_Element_Date('date');\r
+               $date->setLabel('Date');\r
+               $date->setPrecision(CubeIT_Date::DAY);\r
+               $this->addElement($date);\r
+\r
+               $news = new Zend_Form_Element_Textarea('news');\r
+               $news->setLabel('Information');\r
+               $news->setAttrib('rows', 2);\r
+               $this->addElement($news);\r
+\r
+               $lien = new CubeIT_Form_Element_Link();\r
+               $lien->setLabel('Lien');\r
+               $lien->removeElement('label');\r
+               $this->addSubForm($lien, 'lien');\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/framework/application/forms/CMS/Sub/Home/Actualites.php b/framework/application/forms/CMS/Sub/Home/Actualites.php
new file mode 100644 (file)
index 0000000..5d80ab1
--- /dev/null
@@ -0,0 +1,14 @@
+<?php\r
+\r
+class CCGM_Form_CMS_Sub_Home_Actualites extends CubeIT_Form_Multi_SubForm {\r
+\r
+       public function init() {\r
+               parent::init();\r
+\r
+               $actualite = new CCGM_Form_CMS_Sub_Home_Actualite();\r
+               $this->setBaseSubForm($actualite);\r
+               $this->setBaseLegend('Edition de l`actualité « $news »');\r
+               $this->setNewLegend('Nouvelle actualité');\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/framework/application/views/helpers/Actualites.php b/framework/application/views/helpers/Actualites.php
new file mode 100644 (file)
index 0000000..f842242
--- /dev/null
@@ -0,0 +1,59 @@
+<?php\r
+\r
+class CCGM_View_Helper_Actualites extends Zend_View_Helper_Abstract {\r
+\r
+       public function actualites($actus) {\r
+               $actus = $this->_filter($actus);\r
+               if (!count($actus)) {\r
+                       return;\r
+               }\r
+\r
+               $this->view->headScript()->addScriptAndStyle('actualites')\r
+                               ->addGSAP();\r
+               $res = '<div class="updates">';\r
+               $res.='<div class="holder">';\r
+               $res.='<div class="mask">';\r
+               $res.='<div class="slideset">';\r
+               foreach ($actus as $a) {\r
+                       $res.=$this->_actu($a);\r
+               }\r
+               $res.='</div>';\r
+               $res.='</div>';\r
+               $res.='<div class="btn-area">';\r
+               $res.='<a class="btn-prev" title="Actualités plus récente" href="#"></a>';\r
+               $res.='<a class="btn-next" title="Actualités plus ancienne" href="#"></a>';\r
+               $res.='</div>';\r
+               $res.='</div>';\r
+               $res.='</div>';\r
+               return $res;\r
+       }\r
+\r
+       protected function _actu($a) {\r
+               $res = '<div class="slide"><p>';\r
+               $res.=$this->view->dateTime($a['date'], Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR, array('class' => 'date')) . ' ';\r
+               $res.=$a['news'];\r
+               $res.='</p></div>';\r
+               return $res;\r
+       }\r
+\r
+       protected function _filter($actus) {\r
+               $res = array();\r
+               foreach ($actus as $a) {\r
+                       if (trim($a['news']) == '') {\r
+                               continue;\r
+                       }\r
+                       $res[] = $a;\r
+               }\r
+\r
+               usort($res, array($this, '_sort'));\r
+               return $res;\r
+       }\r
+\r
+       protected function _sort($a, $b) {\r
+               $da = new Zend_Date($a['date'], CubeIT_Date::MYSQL);\r
+               $db = new Zend_Date($b['date'], CubeIT_Date::MYSQL);\r
+\r
+               return -1 * $da->compare($db);\r
+       }\r
+\r
+}\r
index f8f0f804db65f07071541318d6e2bc2a8fc4e7c2..0317d15a1de74179065ef8b51a51fef7a9b340a8 100644 (file)
@@ -53,18 +53,7 @@ $this->headScript()->addScriptAndStyle('home');
                </div>\r
        </section>\r
 </div>\r
-<div class="updates">\r
-       <div class="holder">\r
-               <div class="mask">\r
-                       <div class="slideset">\r
-                               <div class="slide"><p><time datetime="2013-02-13" class="date">13/02/2013</time> Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe autem quibusdam et aut officiis debitis </p></div>\r
-                               <div class="slide"><p><time datetime="2013-02-13" class="date">13/02/2013</time> Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe autem quibusdam et aut officiis debitis </p></div>\r
-                               <div class="slide"><p><time datetime="2013-02-13" class="date">13/02/2013</time> Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe autem quibusdam et aut officiis debitis </p></div>\r
-                       </div>\r
-               </div>\r
-               <div class="btn-area">\r
-                       <a class="btn-prev" href="#">Previous</a>\r
-                       <a class="btn-next" href="#">Next</a>\r
-               </div>\r
-       </div>\r
-</div>
\ No newline at end of file
+<?php\r
+\r
+echo $this->actualites($this->actualites);\r
+?>
\ No newline at end of file
diff --git a/js/actualites.js b/js/actualites.js
new file mode 100644 (file)
index 0000000..7ed9c71
--- /dev/null
@@ -0,0 +1,92 @@
+(function($) {\r
+       function JQactualites(element) {\r
+               this.element = element;\r
+               this.currentIndex = -1;\r
+               this.number = this.element.find('.slide').length;\r
+               this.animating = false;\r
+               this.init();\r
+       }\r
+\r
+       JQactualites.prototype = {\r
+               init: function() {\r
+                       var $this = this;\r
+\r
+                       if (this.number < 2) {\r
+                               this.element.find('.btn-area').hide();\r
+                       }\r
+\r
+                       this.element.find('.btn-area a').click(function() {\r
+                               if ($(this).hasClass('btn-next')) {\r
+                                       $this.goNext();\r
+                               } else if ($(this).hasClass('btn-prev')) {\r
+                                       $this.goPrev();\r
+                               }\r
+                               return false;\r
+                       });\r
+\r
+                       this.gotoIndex(0);\r
+               },\r
+               goNext: function() {\r
+                       this.gotoIndex(this.currentIndex + 1);\r
+               },\r
+               goPrev: function() {\r
+                       this.gotoIndex(this.currentIndex - 1);\r
+               },\r
+               gotoIndex: function(index) {\r
+\r
+                       if (this.animating) {\r
+                               return;\r
+                       }\r
+                       var $this = this;\r
+                       this.animating = true;\r
+                       var dir = -1;\r
+                       if (index > this.currentIndex) {\r
+                               dir = 1;\r
+                       }\r
+                       dir *= -1;\r
+                       index = (index + this.number) % this.number;\r
+                       var nextActu = this.getActu(index);\r
+\r
+                       if (this.currentIndex == -1) {\r
+                               $(nextActu).show();\r
+                               this.endTransition(index);\r
+                               return;\r
+                       }\r
+                       var currentActu = this.getActu(this.currentIndex);\r
+                       var w = 870;\r
+\r
+                       $(nextActu).css('left', w * -dir).show();\r
+                       TweenMax.to(nextActu, 0.5, {left: 0});\r
+                       TweenMax.to(currentActu, 0.5, {left: w * dir, onComplete: function() {\r
+                                       $this.endTransition(index);\r
+                               }\r
+                       });\r
+               },\r
+               getActu: function(index) {\r
+                       return this.element.find('.slide:eq(' + index + ')');\r
+               },\r
+               endTransition: function(index) {\r
+                       this.animating = false;\r
+                       this.getActu(this.currentIndex).hide();\r
+                       this.currentIndex = index;\r
+                       if (this.currentIndex == 0) {\r
+                               TweenMax.to(this.element.find('.btn-prev'), 0.5, {opacity: 0});\r
+                       } else {\r
+\r
+                       }\r
+               },\r
+       };\r
+\r
+       jQuery.fn.actualites = function() {\r
+               return this.each(function() {\r
+                       var $this = $(this);\r
+                       $(this).data('actualites', new JQactualites($this));\r
+               })\r
+       };\r
+})(jQuery);\r
+\r
+TO_LOAD_ONCE[TO_LOAD_ONCE.length] = 'load_actualites();';\r
+\r
+function load_actualites() {\r
+       $(".updates").actualites();\r
+}\r