{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% set Categories = repository('Eccube\\Entity\\Category').getList() %}
{% block javascript %}
<script>
$(function() {
$('.ec-headerCategoryArea .ec-itemNav__nav li > a').on('click', function() {
$categoryItem = $(this).parent('.haschild');
$categoryList = $categoryItem.children('.category_child');
$childrenIcon = $(this).children('.only-opend');
if ($categoryList.length > 0){
if ($categoryList.css('display') == 'none') {
$categoryList.slideDown(300);
$childrenIcon.addClass('active');
} else {
$categoryList.slideUp(250);
$childrenIcon.removeClass('active');
}
return false;
}
});
});
</script>
{% endblock %}
{% macro tree(Category) %}
{% from _self import tree %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}#tab-link">
{{ Category.name }}
{% if Category.children|length == 0 %}
<img src="{{ asset('assets/icon/icon_arrow_red.svg') }}" class="ec-itemNav__iconlink" alt="矢印アイコン">
{% else %}
<img src="{{ asset('assets/icon/icon_add.svg') }}" class="ec-itemNav__iconlink only-opend" alt="プラスアイコン">
<img src="{{ asset('assets/icon/icon_minus.svg') }}" class="ec-itemNav__iconlink" alt="マイナスアイコン">
{% endif %}
</a>
{% if Category.children|length > 0 %}
<ul style="display: none;" class="category_child">
<li>
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">
<span>すべて</span>
<img src="{{ asset('assets/icon/icon_arrow_red.svg') }}" class="ec-itemNav__iconlink" alt="矢印アイコン">
</a>
</li>
{% for ChildCategory in Category.children %}
<li>
{{ tree(ChildCategory) }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{# @see https://github.com/bolt/bolt/pull/2388 #}
{% from _self import tree %}
<div class="ec-headerCategoryArea">
<div class="ec-headerCategoryArea__heading">
<p>{{ 'カテゴリから探す'|trans }}</p>
<span class="ec-headerCategoryArea__toggle">すべて開く</span>
</div>
<div class="ec-itemNav">
<ul class="ec-itemNav__nav">
{% for Category in Categories %}
<li>
{{ tree(Category) }}
</li>
{% endfor %}
</ul>
</div>
</div>