app/template/kaiino/Block/category_nav_sp.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% block javascript %}
  9. <script>
  10.     $(function(){
  11.         $(".ec-headerCategoryArea__heading").on("click", function() {
  12.             $(this).next().slideToggle();
  13.             if($(this).hasClass('active')) {
  14.                 $(this).find('img').attr('src','{{ asset("assets/icon/side-arrow-right-gray.svg") }}');
  15.                 $(this).removeClass('active');
  16.             } else {
  17.                 $(this).find('img').attr('src','{{ asset("assets/icon/side-arrow-down-gray.svg") }}');
  18.                 $(this).addClass('active');
  19.             }
  20.         });
  21.         $(".ec-headerCategoryArea .ec-itemNav__nav a").on("click", function() {
  22.             if($(this).hasClass('active')) {
  23.                 $(this).find('img').attr('src','{{ asset("assets/icon/side-arrow-right-gray.svg") }}');
  24.                 $(this).removeClass('active');
  25.             } else {
  26.                 $(this).parent('li').next().find('a').css({
  27.                     'border-top':'1px solid #DDDDDD'
  28.                 });
  29.                 $(this).css({
  30.                     'border':'none'
  31.                 });
  32.                 $(this).find('img').attr('src','{{ asset("assets/icon/side-arrow-down-gray.svg") }}');
  33.                 $(this).addClass('active');
  34.             }
  35.         });
  36.     });
  37. </script>
  38. {% endblock javascript %}
  39. {% set Categories = repository('Eccube\\Entity\\Category').getList() %}
  40. {% macro tree(Category) %}
  41.     {% from _self import tree %}
  42.     <a href="{{ url('product_list') }}?category_id={{ Category.id }}">
  43.         {{ Category.name }}
  44.         <img src="{{ asset('assets/icon/side-arrow-right-gray.svg') }}" alt="">
  45.     </a>
  46.     {% if Category.children|length > 0 %}
  47.         <ul>
  48.             {% for ChildCategory in Category.children %}
  49.                 <li>
  50.                     {{ tree(ChildCategory) }}
  51.                 </li>
  52.             {% endfor %}
  53.         </ul>
  54.     {% endif %}
  55. {% endmacro %}
  56. {# @see https://github.com/bolt/bolt/pull/2388 #}
  57. {% from _self import tree %}
  58. <div class="ec-headerCategoryArea">
  59.     <div class="ec-headerCategoryArea__heading">
  60.         <p>{{ 'Categories'|trans }}<img src="{{ asset('assets/icon/side-arrow-right-gray.svg') }}" alt=""></p>
  61.     </div>
  62.     <div class="ec-itemNav">
  63.         <ul class="ec-itemNav__nav">
  64.             <li class="ec-sideCategoryList__all">
  65.                 <a href="{{ url('product_list') }}?category_id=">全ての商品</a>
  66.             </li>
  67.             {% for Category in Categories %}
  68.                 <li>
  69.                     {{ tree(Category) }}
  70.                 </li>
  71.             {% endfor %}
  72.         </ul>
  73.     </div>
  74. </div>