custom/plugins/EmovaWbTheme/src/Resources/views/storefront/layout/navigation/offcanvas/item-link.html.twig line 1

Open in your IDE?
  1. {% set isActive = item.category.id == activeId %}
  2. {% set hasChildren = item.category.visibleChildCount > 0 %}
  3. {% set url = category_url(item.category) %}
  4. {% set name = item.category.translated.name %}
  5. <li class="navigation-offcanvas-list-item offcanvas-custom-menu-li">
  6.     {% block layout_navigation_offcanvas_navigation_categories_list_category_item_link %}
  7.     
  8.         <a class="navigation-offcanvas-link nav-item nav-link {% if hasChildren %} js-navigation-offcanvas-link {% else %} js-navigation-offcanvas-link-children {% endif %} {% if parentId == item.category.id %} active {% endif %}"
  9.             {% if hasChildren %} onclick="toggleActiveParent(this)" {% else %} onclick="toggleActiveChildren(this)" {% endif %}
  10.             href="{{ url }}"
  11.             {% if hasChildren %}
  12.                 data-href="{{ path('frontend.menu.offcanvas', {'navigationId': item.category.id}) }}"
  13.             {% endif %}
  14.            itemprop="url"
  15.             {% if category_linknewtab(item.category) %}target="_blank"{% endif %}
  16.            title="{{ name }}">
  17.             {% block layout_navigation_offcanvas_navigation_categories_list_category_item_link_text %}
  18.                 <span itemprop="name">{{ name }}</span>
  19.                 {% if hasChildren %}
  20.                     {% block layout_navigation_offcanvas_navigation_categories_list_category_item_link_icon %}
  21.                         <span
  22.                             class="navigation-offcanvas-link-icon">
  23.                             {% sw_icon 'arrow-right-menu' %}
  24.                         </span>
  25.                     {% endblock %}
  26.                 {% endif %}
  27.             {% endblock %}
  28.         </a>
  29.         <script>
  30.             function toggleActiveParent(link){  
  31.                 if (!link.classList.contains('active')) {
  32.                     var links = document.querySelectorAll('.js-navigation-offcanvas-link');
  33.                     links.forEach(function (el) {
  34.                         el.classList.remove('active');
  35.                     });
  36.                     link.classList.add('active');    
  37.                 }
  38.                 else 
  39.                 {
  40.                     var links = document.querySelectorAll('.js-navigation-offcanvas-link');
  41.                     links.forEach(function (el) {
  42.                         el.classList.remove('active');
  43.                     });
  44.                     setTimeout(function() {
  45.                         var overlayDiv = document.querySelector('.has-transition');
  46.                         if (overlayDiv) {          
  47.                             overlayDiv.parentNode.removeChild(overlayDiv);
  48.                         }
  49.                     }, 500);
  50.                     
  51.                 }                
  52.             }
  53.             function toggleActiveChildren(link){
  54.                 link.classList.toggle('active');
  55.                 var childrenLinks = document.querySelectorAll('.js-navigation-offcanvas-link-children');
  56.                 childrenLinks.forEach(function (el) {
  57.                     el.classList.remove('active');
  58.                 });
  59.             }
  60.         </script>
  61.     {% endblock %}
  62. </li>