{% from '@openform_front_templates/_includes/_icons.html.twig' import arrowshow, facebook, instagram, youtube, contrast, magnification, reduction %}
{% macro sectionLink(rootParent, item, loopIndex, depth, class, level = 1) %}
<li class="main-menu-nav__item{{ class is defined and class ? '--' ~ class }} js-main-menu-item {% if item.children|length %}main-menu-nav__item--parent{% endif %}">
<div class="main-menu-nav__item-wrapper{{ class is defined and class ? '--' ~ class }}">
{% set rootParentSlug = app.request.attributes.get('rootParentSlug') ?? 'empty-valueno' %}
{% set currentUrl = toolkit_route_localizer.generate('menu_page', {
makSlug: app.request.attributes.get('makSlug'),
rootParentSlug: rootParentSlug,
slug : app.request.attributes.get('slug')
}, app.request.locale) %}
{% set href = toolkit_route_localizer.generate('menu_page', {
makSlug: app.request.attributes.get('makSlug'),
rootParentSlug: rootParent.Translation[app.request.locale].slug,
slug : item.Translation[app.request.locale].slug
}, app.request.locale) %}
{% set isActive = currentUrl is defined and currentUrl == href %}
<a class="main-menu-nav__url {% if isActive %} active {% endif %}" {{ item.targetBlank ? 'target="_blank"' }} href="{{ item.Translation[app.request.locale].link ?? href }}">
{{ item.Translation[app.request.locale].titleHtml|raw }}
</a>
{% if item.Children|length and item.hasMainMenuVisibleChildren(app.request.locale) %}
<button
class="main-menu-nav__button{{ class is defined and class ? '--' ~ class }}"
type="button"
aria-expanded="false"
data-expanded="js-expanded-submenu-{{ depth ~ '-' ~ loopIndex }}"
data-expandendname="submenu-{{ level }}"
>
{{ arrowshow('OPEN_SUBMENU'|trans({}, 'openform_front', app.request.locale) ~ ' ' ~ item.Translation[app.request.locale].titleHtml|raw) }}
</button>
{% endif %}
</div>
{% if item.Children|length and item.hasMainMenuVisibleChildren(app.request.locale) %}
<ul class="{{ class is defined and class ? 'submenu--' ~ class : 'submenu submenu--parent' }} js-submenu js-expanded-submenu-{{ depth ~ '-' ~ loopIndex }}">
{% for subItem in item.children %}
{% if subItem.isMainMenuVisible(app.request.locale) %}
{{ _self.sectionLink(rootParent, subItem, loop.index, depth + 10, class ? 'sub2' : 'sub', level + 1 ) }}
{% endif %}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}
{% macro pageLink(item, loopIndex, depth, class, level = 1) %}
<li class="main-menu-nav__item{{ class is defined and class ? '--' ~ class }} js-main-menu-item {% if item.children|length %}main-menu-nav__item--parent{% endif %}">
<div class="main-menu-nav__item-wrapper{{ class is defined and class ? '--' ~ class }}">
<a class="main-menu-nav__url" {{ item.blank ? 'target="_blank"'}} title="{{ item.title }}" href="{{ item.link ?? toolkit_route_localizer.generate('page', { slug : item.slug }, app.request.locale) }}">
{{ item.titleHtml|raw }}
</a>
{% if item.children|length %}
<button
class="main-menu-nav__button"
type="button"
aria-expanded="false"
data-expanded="js-expanded-submenu-{{ depth ~ '-' ~ loopIndex }}"
data-expandendname="submenu-{{ level }}"
>
{{ arrowshow('OPEN_SUBMENU'|trans({}, 'openform_front', app.request.locale) ~ ' ' ~ item.titleHtml|raw) }}
</button>
{% endif %}
</div>
{% if item.children|length %}
<ul class="{{ class is defined and class ? 'submenu--' ~ class : 'submenu submenu--parent' }} js-submenu js-expanded-submenu-{{ depth ~ '-' ~ loopIndex }}">
{% for sub2item in item.children %}
{{ _self.pageLink(sub2item, loopIndex, depth + 10, class ? 'sub2' : 'sub', level + 1 ) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}
{% macro socials() %}
{% set config = openform_front_util.getConfig() %}
<ul class="main-menu-nav__socials">
{% if config.linkFacebook %}
<li class="main-menu-nav__social">
<a href="{{ config.linkFacebook }}" target="_blank" rel="noopener noreferrer">
{{ facebook() }}
</a>
</li>
{% endif %}
{% if config.linkYoutube %}
<li class="main-menu-nav__social">
<a href="{{ config.linkYoutube }}" target="_blank" rel="noopener noreferrer">
{{ youtube() }}
</a>
</li>
{% endif %}
{% if config.linkInstagram %}
<li class="main-menu-nav__social">
<a href="{{ config.linkInstagram }}" target="_blank" rel="noopener noreferrer">
{{ instagram() }}
</a>
</li>
{% endif %}
</ul>
<div class="main-menu-nav__controls">
<button class="header__buttons__button header__buttons__accessibility header__expandable__btn js-contrast-change" type="button">
{{ contrast() }}
</button>
<button class="header__buttons__button header__buttons__accessibility header__expandable__btn js-font-resize-plus" type="button">
{{ magnification() }}
</button>
<button class="header__buttons__button header__buttons__accessibility header__expandable__btn js-font-resize-minus" type="button">
{{ reduction() }}
</button>
</div>
{% endmacro %}
{% if rootParent is defined %}
{% set MenuPageItems = openform_front_util.getMenuPageItems(rootParent) %}
{% endif %}
{% if MenuPageItems is defined and MenuPageItems|length > 0 %}
{# encje MenuPage - menu własne muzeum, archiwum, kolekcja prywatna, wystawa #}
<nav class="main-menu-nav main-menu-nav--full js-links js-main-menu-nav {{ class is defined and class ? class : '' }}" style="{{ rootParent.headerHeight ? 'top:' ~ rootParent.headerHeight ~ 'px;' }}{{ style is defined and style ? style }}" role="navigation">
<h3 class="visuallyhidden">{{ 'MAIN_MENU_TITLE'|trans({}, 'openform_front', app.request.locale) }}</h3>
<ul class="main-menu-nav__ul js-links">
{% for item in MenuPageItems %}
{% set depth = 10 %}
{% if item.isMainMenuVisible(app.request.locale) %}
{{ _self.sectionLink(rootParent, item, loop.index, depth) }}
{% endif %}
{% endfor %}
</ul>
<div class="main-menu-nav__bottom">
{{ _self.socials() }}
</div>
</nav>
{% else %}
{# zwykłe menu ze struktury stron #}
{% set navClass = 'main-menu-nav js-links js-main-menu-nav' %}
{% if class is defined and class %}
{% set navClass = 'main-menu-nav js-links js-main-menu-nav ' ~ class %}
{% endif %}
<nav class="{{ navClass }}" role="navigation">
<h3 class="visuallyhidden">{{ 'MAIN_MENU_TITLE'|trans({}, 'openform_front', app.request.locale) }}</h3>
{% set mainMenu = openform_front_util.getFullMenu(app.request.locale) %}
{% if mainMenu|length > 0 %}
<ul class="main-menu-nav__ul js-links">
{% for menuItem in mainMenu %}
{% set depth = 10 %}
{{ _self.pageLink(menuItem, loop.index, depth) }}
{% endfor %}
</ul>
{% endif %}
<div class="main-menu-nav__bottom">
{{ _self.socials() }}
</div>
</nav>
{% endif %}