}
}
- $res.=$this->view->tags($tags);
-
-
-
+ $res.=$this->view->tags($tags, array('data-perline' => 3));
return $res;
}
class Cubedesigners_View_Helper_CategoriesList extends Zend_View_Helper_Abstract {
- public function CategoriesList($rubrique) {
+ public function CategoriesList($rubrique, $listId) {
$acl = Bootstrap::getInstance()->isAllowed("edition");
$tags[$r->id] = $r->name;
}
}
- $res.=$this->view->tags($tags);
+ $res.=$this->view->tags($tags, array('data-perline' => 3, 'data-list' => '#' . $listId));
return $res;
+++ /dev/null
-<?php
-
-class Cubedesigners_View_Helper_TagList extends CubeIT_View_Helper_Abstract {
-
- public function tagList() {
- $res = '';
-
- return $res;
- }
-
-}
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 {
$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);
}
<div id="casestudies-tagslist">
<?php
- echo $this->CategoriesList('casestudies');
+ echo $this->CategoriesList('casestudies', 'casestudies-list');
?>
</div>
--- /dev/null
+(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
--- /dev/null
+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
color:#545454;
margin-bottom: 20px;
}
- &:nth-child(3n){
+ &.last{
margin-right: 0;
}
}