mediawiki-skins-Vector/includes/templates/LegacyMenu.mustache
Jon Robson cb8a500e7a Vector legacy: Support dropdown creation via addPortlet
Vector:
    mw.util.addPortlet('p-twinkle', 'TW', '#p-cactions');
    mw.util.addPortletLink('p-twinkle','#', 'Hello world');

Additional changes:
* Add aria labels to gadget created menus

Additional changes to template
* Remove self closing tag on input[checkbox] in template
* Rearrange vector-menu and vector-menu-dropdown classes
for consistency between two approaches

Bug: T342815
Change-Id: I938928c3625099ad49bec8aafb11f91190a9f494
2023-10-25 10:39:30 +02:00

35 lines
1.2 KiB
Plaintext

{{!
See @typedef MenuDefinition
}}
{{! `role` is unnecessary but kept to support selectors in any gadgets or user styles. }}
{{! DO NOT REMOVE vector-menu class. It is used for click tracking in Extension:WikimediaEvents }}
<nav id="{{id}}" class="{{#class}}{{.}}{{/class}} vector-menu" aria-labelledby="{{id}}-label" role="navigation" {{{html-tooltip}}} {{{html-user-language-attributes}}}>
{{#is-dropdown}}
<input type="checkbox"
id="{{id}}-checkbox"
role="button"
aria-haspopup="true"
data-event-name="ui.dropdown-{{id}}"
class="vector-menu-checkbox{{#checkbox-class}} {{.}}{{/checkbox-class}}"
aria-labelledby="{{id}}-label"
>
<label
id="{{id}}-label"
{{#aria-label}} aria-label="{{.}}"{{/aria-label}}
class="vector-menu-heading{{#heading-class}} {{.}}{{/heading-class}}"
>
{{{html-vector-heading-icon}}}<span class="vector-menu-heading-label">{{label}}</span>
</label>
{{/is-dropdown}}
{{^is-dropdown}}
<h3
id="{{id}}-label"
{{#aria-label}} aria-label="{{.}}"{{/aria-label}}
class="vector-menu-heading{{#heading-class}} {{.}}{{/heading-class}}"
>
{{{html-vector-heading-icon}}}<span class="vector-menu-heading-label">{{label}}</span>
</h3>
{{/is-dropdown}}
{{>MenuContents}}
</nav>