]> _ Git - cubedesigners-v7.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 19 Nov 2014 09:46:20 +0000 (09:46 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 19 Nov 2014 09:46:20 +0000 (09:46 +0000)
framework/application/views/helpers/CasestudiesTagsList.php
framework/application/views/helpers/CategoriesList.php
framework/application/views/helpers/RealisationsList.php
framework/application/views/helpers/TagList.php [deleted file]
framework/application/views/helpers/Tags.php
framework/application/views/scripts/templates/casestudies.phtml
js/taglist.js [new file with mode: 0644]
js/taglist_.js [new file with mode: 0644]
less/casestudies.less

index 64ff070e5ac80665fcae25a23275dbc717e18552..c557ca49d69e034df91d50629d5cce05cc62b5b6 100644 (file)
@@ -34,10 +34,7 @@ class Cubedesigners_View_Helper_CasestudiesTagsList extends CubeIT_View_Helper_A
                        }
                }
 
-               $res.=$this->view->tags($tags);
-
-
-
+               $res.=$this->view->tags($tags, array('data-perline' => 3));
                return $res;
        }
 
index 664ec924475559ef546cbff77b155540d5e4064f..01d35a84cc865c63376e5127d465c54a9e1f7547 100644 (file)
@@ -2,7 +2,7 @@
 
 class Cubedesigners_View_Helper_CategoriesList extends Zend_View_Helper_Abstract {
 
-       public function CategoriesList($rubrique) {
+       public function CategoriesList($rubrique, $listId) {
 
                $acl = Bootstrap::getInstance()->isAllowed("edition");
 
@@ -36,7 +36,7 @@ class Cubedesigners_View_Helper_CategoriesList extends Zend_View_Helper_Abstract
                                $tags[$r->id] = $r->name;
                        }
                }
-               $res.=$this->view->tags($tags);
+               $res.=$this->view->tags($tags, array('data-perline' => 3, 'data-list' => '#' . $listId));
 
 
                return $res;
index 66a63213e1965d4679fa076f4b4e6f693064a045..688692c5a684a88c6b5eeba72e72069cdab00ad9 100644 (file)
@@ -51,5 +51,3 @@ class Cubedesigners_View_Helper_RealisationsList extends CubeIT_View_Helper_Abst
        }
 
 }
-
-?>
diff --git a/framework/application/views/helpers/TagList.php b/framework/application/views/helpers/TagList.php
deleted file mode 100644 (file)
index ecd9886..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-class Cubedesigners_View_Helper_TagList extends CubeIT_View_Helper_Abstract {
-
-       public function tagList() {
-               $res = '';
-
-               return $res;
-       }
-
-}
index 16d5016f5496aacdd3beb739d5926336b55799b1..d6c3e1cf88590b2e518f750446a20e9e6a79b4cd 100644 (file)
@@ -3,9 +3,10 @@
 class Cubedesigners_View_Helper_Tags extends CubeIT_View_Helper_ListUnordered {
 
        function tags($tags, $attrs = array()) {
+               fb($attrs);
                $tags = CubeIT_Util_Cms::unserialize($tags);
 
-               $this->view->headLink()->appendStylesheet('/less/taglist.less');
+               $this->addScriptAndStyle('taglist');
                if (isset($attrs['class'])) {
                        $attrs['class'].=" tags";
                } else {
@@ -14,10 +15,10 @@ class Cubedesigners_View_Helper_Tags extends CubeIT_View_Helper_ListUnordered {
                $items[] = array('content' => __('TOUT VOIR'), 'class' => 'active', 'data-id' => 0);
 
                foreach ($tags as $id => $name) {
-
-
                        $items[] = array('content' => $name, 'data-id' => $id);
                }
+               fb($items);
+               fb($attrs);
                return $this->listUnordered($items, $attrs);
        }
 
index 95b8739eda678247498be1437842cc9eac915fd7..d49ede2753f0f86c6bf0103bd690216084d52f37 100644 (file)
@@ -7,7 +7,7 @@ $this->headScript()->addScriptAndStyle('casestudies');
 
        <div id="casestudies-tagslist">
                <?php
-               echo $this->CategoriesList('casestudies');
+               echo $this->CategoriesList('casestudies', 'casestudies-list');
                ?>
        </div>
 
diff --git a/js/taglist.js b/js/taglist.js
new file mode 100644 (file)
index 0000000..9d24339
--- /dev/null
@@ -0,0 +1,57 @@
+(function ($) {
+       function JQtaglist(element) {
+               this.element = element;
+               this.perline = parseInt(this.element.data('perline'));
+               this.list = $(this.element.data('list'));
+               this.init();
+       }
+
+       JQtaglist.prototype = {
+               init: function () {
+                       var $this = this;
+                       this.element.on('click', "li[data-id]", function () {
+                               fb(this);
+                               if ($(this).hasClass('active')) {
+                                       return false;
+                               }
+
+                               var id = $(this).data('id');
+
+                               $this.filter(id);
+
+                               $(this).siblings().removeClass('active');
+                               $(this).addClass('active');
+                               return false;
+                       });
+                       $this.filter(0);
+               },
+               filter: function (id) {
+                       var $this = this;
+                       this.list.find('[data-cat]:hidden').show().removeClass('last');
+                       if (id != 0) {
+                               this.list.find('[data-cat][data-cat!="' + id + '"]').hide();
+                       }
+                       var i = 1;
+                       this.list.find('[data-cat]:visible').each(function () {
+                               if (i % $this.perline == 0) {
+                                       $(this).addClass('last');
+                               }
+                               i++;
+                       });
+               }
+       };
+
+       jQuery.fn.taglist = function () {
+               return this.each(function () {
+                       var $this = $(this);
+                       $(this).data('taglist', new JQtaglist($this));
+               });
+       };
+})(jQuery);
+
+
+registerLoader(load_taglist);
+
+function load_taglist() {
+       $('ul.tags').taglist();
+}
\ No newline at end of file
diff --git a/js/taglist_.js b/js/taglist_.js
new file mode 100644 (file)
index 0000000..f406ac1
--- /dev/null
@@ -0,0 +1,22 @@
+registerLoader(load_taglist, true);
+
+function load_taglist() {
+       var t = $('ul.tags');
+       var perline = $(t).data('perline');
+       $(document).on('click', "ul.tags li[data-id]", function () {
+               if ($(this).hasClass('active')) {
+                       return false;
+               }
+
+               var id = $(this).data('id');
+
+               $('[data-cat]:hidden').show().removeClass('last');
+               if (id != 0) {
+                       $('[data-cat][data-cat!="' + id + '"]').hide();
+               }
+               $('[data-cat]:visible:nth-child(3n)').addClass('last');
+
+               $(this).siblings().removeClass('active');
+               $(this).addClass('active');
+       });
+}
\ No newline at end of file
index 89b654dffaa3adf7b6da4de406ca4e07795668f1..1e0287ae561dde260b7d08f32b2a05e7589de2d9 100644 (file)
@@ -33,7 +33,7 @@
                        color:#545454;
                        margin-bottom: 20px;
                }
-               &:nth-child(3n){
+               &.last{
                        margin-right: 0;
                }
     }