|
21 | 21 | We call a macro which calls itself to render the full tree. |
22 | 22 | @see http://twig.sensiolabs.org/doc/tags/macro.html |
23 | 23 | #} |
24 | | -{{ menus.menu_links(items, attributes, 0, menu_name|clean_class, gcweb_cdn, gcweb_cdn_url, language) }} |
| 24 | +{{ menus.menu_links(menu_type, items, attributes, 0, menu_name|clean_class, gcweb_cdn, gcweb_cdn_url, language) }} |
25 | 25 |
|
26 | | -{% macro menu_links(items, attributes, menu_level, menu_name, gcweb_cdn, gcweb_cdn_url, language) %} |
| 26 | +{% macro menu_links(menu_type, items, attributes, menu_level, menu_name, gcweb_cdn, gcweb_cdn_url, language) %} |
27 | 27 | {% import _self as menus %} |
28 | 28 | {% if items %} |
29 | 29 | {% if menu_level == 0 %} |
30 | 30 | {% if gcweb_cdn and gcweb_cdn_url %} |
31 | 31 | <ul role="menu" aria-orientation="vertical" data-ajax-replace="{{ gcweb_cdn_url }}{{ language }}.html"> |
32 | 32 | {% else %} |
33 | | - <ul role="menu" aria-orientation="vertical"> |
| 33 | + {% if menu_type == 'default' %} |
| 34 | + <ul role="menu" aria-orientation="vertical"> |
| 35 | + {% elseif menu_type == 'horizontal' %} |
| 36 | + <ul role="menubar"{{ attributes.addClass('list-inline', 'menu') }}> |
| 37 | + {% endif %} |
34 | 38 | {% endif %} |
35 | 39 | {% elseif menu_level == 1 %} |
36 | | - <ul role="menu" aria-orientation="vertical"{{ attributes.removeClass('menu', 'list-inline') }}> |
| 40 | + {% if menu_type == 'default' %} |
| 41 | + <ul role="menu" aria-orientation="vertical"{{ attributes.removeClass('menu', 'list-inline') }}> |
| 42 | + {% elseif menu_type == 'horizontal' %} |
| 43 | + <ul role="menu"{{ attributes.addClass('sm', 'list-unstyled').removeClass('menu', 'list-inline') }} aria-expanded="false" aria-hidden="true"> |
| 44 | + {% endif %} |
37 | 45 | {% else %} |
38 | | - <ul role="menu" aria-orientation="vertical"> |
| 46 | + {% if menu_type == 'default' %} |
| 47 | + <ul role="menu" aria-orientation="vertical"> |
| 48 | + {% elseif menu_type == 'horizontal' %} |
| 49 | + <ul role="menu"{{ attributes.addClass('dropdown-menu', menu_name) }}> |
| 50 | + {% endif %} |
39 | 51 | {% endif %} |
40 | 52 | {% for item in items %} |
41 | 53 | {% |
|
46 | 58 | ] |
47 | 59 | %} |
48 | 60 | {% if menu_level == 0 and item.is_expanded %} |
49 | | - <li role="presentation"{{ item.attributes.addClass(item_classes) }}> |
50 | | - <a role="menuitem" href="{{ item.url }}" tabindex="-1" aria-haspopup="true" aria-controls="{{ item.title | clean_id }}" aria-expanded="false">{{ item.title }}</a> |
| 61 | + {% if menu_type == 'default' %} |
| 62 | + <li role="presentation"{{ item.attributes.addClass(item_classes) }}> |
| 63 | + <a role="menuitem" href="{{ item.url }}" tabindex="-1" aria-haspopup="true" aria-controls="{{ item.title | clean_id }}" aria-expanded="false">{{ item.title }}</a> |
| 64 | + {% elseif menu_type == 'horizontal' %} |
| 65 | + <li role="presentation"{{ item.attributes }}> |
| 66 | + <a role="menuitem" class="dropdown-toggle item" href="{{ item.url }}">{{ item.title }}</a> |
| 67 | + {% endif %} |
51 | 68 | {% else %} |
52 | | - <li role="presentation"{{ item.attributes.addClass(item_classes) }}> |
53 | | - {{ link(item.title, item.url, {'role':['menuitem']}) }} |
| 69 | + {% if menu_type == 'default' %} |
| 70 | + <li role="presentation"{{ item.attributes.addClass(item_classes) }}> |
| 71 | + {{ link(item.title, item.url, {'role':['menuitem']}) }} |
| 72 | + {% elseif menu_type == 'horizontal' %} |
| 73 | + <li role="presentation"{{ item.attributes }}> |
| 74 | + {{ link(item.title, item.url, {'role':['menuitem']}) }} |
| 75 | + {% endif %} |
54 | 76 | {% endif %} |
55 | 77 | {% if item.below %} |
56 | | - {{ menus.menu_links(item.below, attributes.removeClass('nav', 'navbar-nav'), menu_level + 1) }} |
| 78 | + {{ menus.menu_links(menu_type, item.below, attributes.removeClass('nav', 'navbar-nav'), menu_level + 1) }} |
57 | 79 | {% endif %} |
58 | 80 | </li> |
59 | 81 | {% endfor %} |
|
0 commit comments