Skip to content

Commit

Permalink
Fix smart menu mustache linter warnings, solves moodle-an-hochschulen…
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace authored and abias committed Feb 19, 2024
1 parent d1e9c3d commit 1f94941
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 188 deletions.
33 changes: 30 additions & 3 deletions templates/core/moremenu.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,44 @@
<ul id="moremenu-{{moremenuid}}-{{navbarstyle}}" role="{{#istablist}}tablist{{/istablist}}{{^istablist}}menubar{{/istablist}}" class="nav more-nav {{navbarstyle}}">
{{#nodecollection}}
{{#children}}
{{> core/moremenu_children}}
{{#haschildren}}
<li class="dropdown nav-item {{#menuclasses}}{{.}} {{/menuclasses}} " role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> core/moremenu_children}}
</li>
{{/haschildren}}
{{^haschildren}}
<li data-key="{{key}}" class="nav-item {{#menuclasses}}{{.}} {{/menuclasses}}" role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> core/moremenu_children}}
</li>
{{/haschildren}}
{{/children}}
{{/nodecollection}}
{{#nodearray}}
{{!-- Menu with card style --}}
{{#card}}
{{> theme_boost_union/smartmenus-cardmenu-children}}
{{#haschildren}}
<li class="dropdown nav-item {{#card}} card-dropdown {{/card}} {{#menudata.classes}} {{.}} {{/menudata.classes}}" role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> theme_boost_union/smartmenus-cardmenu-children}}
</li>
{{/haschildren}}
{{^haschildren}}
<li data-key="{{key}}" class="nav-item" role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> theme_boost_union/smartmenus-cardmenu-children}}
</li>
{{/haschildren}}
{{/card}}

{{^card}}
{{> core/moremenu_children}}
{{#haschildren}}
<li class="dropdown nav-item {{#menuclasses}}{{.}} {{/menuclasses}} " role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> core/moremenu_children}}
</li>
{{/haschildren}}
{{^haschildren}}
<li data-key="{{key}}" class="nav-item {{#menuclasses}}{{.}} {{/menuclasses}}" role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> core/moremenu_children}}
</li>
{{/haschildren}}
{{/card}}
{{/nodearray}}
{{^drawer}}
Expand Down
219 changes: 113 additions & 106 deletions templates/core/moremenu_children.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"text": "Moodle community",
"children": "",
"title": "Moodle community",
"url": "https://moodle.org"
"url": "https://moodle.org",
"hidemenuitemrole": true
}
}}
{{!
Expand All @@ -38,111 +39,117 @@
* Added smart menu submenu support.
}}
{{#haschildren}}
<li class="dropdown nav-item {{#menuclasses}}{{.}} {{/menuclasses}} " role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
<a class="dropdown-toggle nav-link {{#isactive}}active{{/isactive}} {{#classes}}{{.}} {{/classes}}" id="drop-down-{{moremenuid}}" role="menuitem" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false" href="#" aria-controls="drop-down-menu-{{moremenuid}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
{{#isactive}}aria-current="true"{{/isactive}}
{{^isactive}}tabindex="-1"{{/isactive}}
>
{{{text}}}
</a>
<div class="dropdown-menu" role="menu" id="drop-down-menu-{{moremenuid}}" aria-labelledby="drop-down-{{moremenuid}}">
{{#helpicon}}<div class="menu-helpicon">{{{helpicon}}}</div>{{/helpicon}}
{{#abovehelptext}}<div class="menu-description">{{{helptext}}}</div>{{/abovehelptext}}
{{#children}}
{{^divider}}
{{#haschildren}}
<div class="dropdown-submenu" role="none" >
{{/haschildren}}
{{#is_action_link}}
<a class="dropdown-item {{#itemdata.classes}}{{.}} {{/itemdata.classes}}" role="menuitem" {{#actionattributes}}{{name}}="{{value}}" {{/actionattributes}} href="{{{url}}}{{{action}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
data-disableactive="true" tabindex="-1"
>
{{{text}}}
</a>
{{#action_link_actions}}
{{> core/actions }}
{{/action_link_actions}}
{{/is_action_link}}
{{^is_action_link}}
<a class="dropdown-item {{#itemdata.classes}}{{.}} {{/itemdata.classes}}" role="menuitem" href="{{{url}}}{{{action}}}" {{#isactive}}aria-current="true"{{/isactive}} tabindex="-1"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
>
{{{text}}}
</a>
{{/is_action_link}}
{{#haschildren}}
<ul>
{{#children}}
{{> core/moremenu_children}}
{{/children}}
</ul>
</div>
{{/haschildren}}
{{/divider}}
{{#divider}}
<div class="dropdown-divider"></div>
{{/divider}}
{{/children}}
{{#belowhelptext}}<div class="menu-description">{{{helptext}}}</div>{{/belowhelptext}}
</div>
</li>
<a class="dropdown-toggle nav-link {{#isactive}}active{{/isactive}} {{#classes}}{{.}} {{/classes}}" id="drop-down-{{moremenuid}}" role="menuitem" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false" href="#" aria-controls="drop-down-menu-{{moremenuid}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
{{#isactive}}aria-current="true"{{/isactive}}
{{^isactive}}tabindex="-1"{{/isactive}}
>
{{{text}}}
</a>
<div class="dropdown-menu" role="menu" id="drop-down-menu-{{moremenuid}}" aria-labelledby="drop-down-{{moremenuid}}">
{{#helpicon}}<div class="menu-helpicon">{{{helpicon}}}</div>{{/helpicon}}
{{#abovehelptext}}<div class="menu-description">{{{helptext}}}</div>{{/abovehelptext}}
{{#children}}
{{^divider}}
{{#haschildren}}
<div class="dropdown-submenu" role="none" >
{{/haschildren}}
{{#is_action_link}}
<a class="dropdown-item {{#itemdata.classes}}{{.}} {{/itemdata.classes}}" role="menuitem" {{#actionattributes}}{{name}}="{{value}}" {{/actionattributes}} href="{{{url}}}{{{action}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
data-disableactive="true" tabindex="-1"
>
{{{text}}}
</a>
{{#action_link_actions}}
{{> core/actions }}
{{/action_link_actions}}
{{/is_action_link}}
{{^is_action_link}}
<a class="dropdown-item {{#itemdata.classes}}{{.}} {{/itemdata.classes}}" role="menuitem" href="{{{url}}}{{{action}}}" {{#isactive}}aria-current="true"{{/isactive}} tabindex="-1"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
>
{{{text}}}
</a>
{{/is_action_link}}
{{#haschildren}}
<ul>
{{#children}}
{{#haschildren}}
<li class="dropdown nav-item {{#menuclasses}}{{.}} {{/menuclasses}} " role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> core/moremenu_children}}
</li>
{{/haschildren}}
{{^haschildren}}
<li data-key="{{key}}" class="nav-item {{#menuclasses}}{{.}} {{/menuclasses}}" role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{> core/moremenu_children}}
</li>
{{/haschildren}}
{{/children}}
</ul>
</div>
{{/haschildren}}
{{/divider}}
{{#divider}}
<div class="dropdown-divider"></div>
{{/divider}}
{{/children}}
{{#belowhelptext}}<div class="menu-description">{{{helptext}}}</div>{{/belowhelptext}}
</div>

{{/haschildren}}
{{^haschildren}}
<li data-key="{{key}}" class="nav-item {{#menuclasses}}{{.}} {{/menuclasses}}" role="none" data-forceintomoremenu="{{#forceintomoremenu}}true{{/forceintomoremenu}}{{^forceintomoremenu}}false{{/forceintomoremenu}}">
{{#istablist}}
{{#is_action_link}}
<a role="tab" class="nav-link {{#classes}}{{.}} {{/classes}}" href="{{tab}}" data-toggle="tab" data-text="{{{text}}}" data-disableactive="true" tabindex="-1"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
>
{{{text}}}
</a>
{{#action_link_actions}}
{{> core/actions }}
{{/action_link_actions}}
{{/is_action_link}}
{{^is_action_link}}
<a role="tab" class="nav-link {{#isactive}}active{{/isactive}} {{#classes}}{{.}} {{/classes}}"
href="{{tab}}" data-toggle="tab" data-text="{{{text}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
{{#isactive}}aria-selected="true"{{/isactive}}
{{^isactive}}tabindex="-1"{{/isactive}}
>
{{{text}}}
</a>
{{/is_action_link}}
{{/istablist}}
{{^istablist}}
{{#is_action_link}}
<a role="menuitem" class="nav-link {{#itemdata.classes}}{{.}} {{/itemdata.classes}} {{#classes}}{{.}} {{/classes}}" {{#actionattributes}}{{name}}="{{value}}" {{/actionattributes}} href="{{{url}}}{{{action}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
data-disableactive="true" tabindex="-1"
>
{{{text}}}
</a>
{{#action_link_actions}}
{{> core/actions }}
{{/action_link_actions}}
{{/is_action_link}}
{{^is_action_link}}
<a role="menuitem" class="nav-link {{#itemdata.classes}}{{.}} {{/itemdata.classes}} {{#isactive}}active{{/isactive}} {{#classes}}{{.}} {{/classes}}"
href="{{{url}}}{{{action}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
{{#isactive}}aria-current="true"{{/isactive}}
{{^isactive}}tabindex="-1"{{/isactive}}
>
{{{text}}}
</a>
{{/is_action_link}}
{{/istablist}}
</li>
{{#istablist}}
{{#is_action_link}}
<a role="tab" class="nav-link {{#classes}}{{.}} {{/classes}}" href="{{tab}}" data-toggle="tab" data-text="{{{text}}}" data-disableactive="true" tabindex="-1"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
>
{{{text}}}
</a>
{{#action_link_actions}}
{{> core/actions }}
{{/action_link_actions}}
{{/is_action_link}}
{{^is_action_link}}
<a role="tab" class="nav-link {{#isactive}}active{{/isactive}} {{#classes}}{{.}} {{/classes}}"
href="{{tab}}" data-toggle="tab" data-text="{{{text}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
{{#isactive}}aria-selected="true"{{/isactive}}
{{^isactive}}tabindex="-1"{{/isactive}}
>
{{{text}}}
</a>
{{/is_action_link}}
{{/istablist}}
{{^istablist}}
{{#is_action_link}}
<a {{^hidemenuitemrole}} role="menuitem" {{/hidemenuitemrole}} class="nav-link {{#itemdata.classes}}{{.}} {{/itemdata.classes}} {{#classes}}{{.}} {{/classes}}" {{#actionattributes}}{{name}}="{{value}}" {{/actionattributes}} href="{{{url}}}{{{action}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
data-disableactive="true" tabindex="-1"
>
{{{text}}}
</a>
{{#action_link_actions}}
{{> core/actions }}
{{/action_link_actions}}
{{/is_action_link}}
{{^is_action_link}}
<a {{^hidemenuitemrole}} role="menuitem" {{/hidemenuitemrole}} class="nav-link {{#itemdata.classes}}{{.}} {{/itemdata.classes}} {{#isactive}}active{{/isactive}} {{#classes}}{{.}} {{/classes}}"
href="{{{url}}}{{{action}}}"
{{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}{{^tooltip}}{{#title}}title="{{.}}"{{/title}}{{/tooltip}}
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
{{#isactive}}aria-current="true"{{/isactive}}
{{^isactive}}tabindex="-1"{{/isactive}}
>
{{{text}}}
</a>
{{/is_action_link}}
{{/istablist}}
{{/haschildren}}
12 changes: 8 additions & 4 deletions templates/core/user_action_menu_items.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
* url - The href for the link.
* pixicon - (Optional) The Moodle icon to use
* imgsrc - (Optional) If provided, uses this as source for an image tag. Note: pixicon is preferred.
* hidemenuitemrole - (Not available) Only for example context to fix the CI warnings.
* submenulink - If a submenu link is provided render it.
* submenuid - The id of the targeted submenu.
* title - The text to be shown for the link.
* pixicon - (Optional) The Moodle icon to use.
* imgsrc - (Optional) If provided, uses this as source for an image tag. Note: pixicon is preferred.
* hidemenuitemrole - (Not available) Only for example context to fix the CI warnings on role attribute.
* divider - Whether a divider is to be displayed or not
Example context (json):
Expand All @@ -41,7 +43,8 @@
"title": "Github user",
"url": "https://raw.githubusercontent.com/",
"pixicon": "t/dashboard",
"imgsrc": "https://raw.githubusercontent.com/moodle/moodle/master/pix/t/check.png"
"imgsrc": "https://raw.githubusercontent.com/moodle/moodle/master/pix/t/check.png",
"hidemenuitemrole": true
},
"divider": 1
},
Expand All @@ -50,7 +53,8 @@
"title": "Title",
"submenuid": "86cebd87",
"pixicon": "t/dashboard",
"imgsrc": "https://raw.githubusercontent.com/moodle/moodle/master/pix/t/check.png"
"imgsrc": "https://raw.githubusercontent.com/moodle/moodle/master/pix/t/check.png",
"hidemenuitemrole": true
},
"divider": 1
}
Expand All @@ -69,7 +73,7 @@
}}
{{#items}}
{{#link}}
<a href="{{{url}}}" class="dropdown-item {{#menuclasses}} {{.}} {{/menuclasses}}" role="menuitem" tabindex="-1" {{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}} {{#attributes}}{{#name}}{{name}}="{{value}}"{{/name}} {{/attributes}}>
<a href="{{{url}}}" class="dropdown-item {{#menuclasses}} {{.}} {{/menuclasses}}" {{^hidemenuitemrole}} role="menuitem" {{/hidemenuitemrole}} tabindex="-1" {{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}} {{#attributes}}{{#name}}{{name}}="{{value}}"{{/name}} {{/attributes}}>
{{#pixicon}}
{{#pix}}{{pixicon}}{{/pix}}
{{/pixicon}}
Expand All @@ -80,7 +84,7 @@
</a>
{{/link}}
{{#submenulink}}
<a href="#" class="carousel-navigation-link dropdown-item {{#menuclasses}} {{.}} {{/menuclasses}}" role="menuitem" tabindex="-1" data-carousel-target-id="carousel-item-{{submenuid}}" {{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}
<a href="#" class="carousel-navigation-link dropdown-item {{#menuclasses}} {{.}} {{/menuclasses}}" {{^hidemenuitemrole}} role="menuitem" {{/hidemenuitemrole}} tabindex="-1" data-carousel-target-id="carousel-item-{{submenuid}}" {{#tooltip}}title="{{.}}" data-toggle="tooltip"{{/tooltip}}
{{#attributes}}{{#name}}{{name}}="{{value}}"{{/name}}{{/attributes}}>
{{#pixicon}}
{{#pix}}{{pixicon}}{{/pix}}
Expand Down
Loading

0 comments on commit 1f94941

Please sign in to comment.