{#- Main navigation: one row on every screen, no JavaScript. Up to 6 sections: all of them in the bar. More than 6: the bar keeps - the first section of each kind feed, periodic, page, people, in menu order (news, the menu or schedule, the first page such as «Ученикам», the administration); documents sections stay in the panel, where they are grouped; - «Контакты» (the mandatory section whose slug is fixed by its section type: url ends in /contacts/); - the current section, wherever it is in the menu; - when that gives fewer than 5, the next sections in menu order up to 5; and every section is listed in the «Все разделы» panel (
), grouped by kind. The panel opens in the page flow under the bar (it pushes the content down, never covers it). The bar scrolls sideways below 64rem; the panel button keeps its place at the end of the row. -#} {% if menu %} {% set nav_bar_kinds = ['feed', 'periodic', 'page', 'people'] %} {% set nav_all = menu|length > 6 %} {% set ns_nav = namespace(bar=[], picked=[], seen=[]) %} {% if nav_all %} {% for m in menu %} {% set nav_is_contacts = m.url[-10:] == '/contacts/' %} {% if m.current or nav_is_contacts or (m.kind in nav_bar_kinds and m.kind not in ns_nav.seen) %}{% set ns_nav.picked = ns_nav.picked + [m.url] %}{% endif %} {% if not nav_is_contacts and m.kind not in ns_nav.seen %}{% set ns_nav.seen = ns_nav.seen + [m.kind] %}{% endif %} {% endfor %} {#- top up to 5 in menu order when the kinds above give fewer (a kindergarten with mostly documents) -#} {% for m in menu %}{% if ns_nav.picked|length < 5 and m.url not in ns_nav.picked %}{% set ns_nav.picked = ns_nav.picked + [m.url] %}{% endif %}{% endfor %} {% for m in menu %}{% if m.url in ns_nav.picked %}{% set ns_nav.bar = ns_nav.bar + [m] %}{% endif %}{% endfor %} {% else %} {% set ns_nav.bar = menu %} {% endif %} {% endif %}