MediaWiki core provides a method mw.util.addPortletLink for adding menu items. However it makes a lot of assumption about the HTML structure of the menu and what needs to be added. It is used widely by gadget developers. In Minerva it doesn't work as the selectors passed don't match anything, and menu items are more complicated than a single li item - they can contain icons for example.
Minerva (the mobile skin) doesn't support this, meaning editors often use hacks to add things to menus with undesired results.
Examples:
Map gadget Wikipedia:
Wikisource:
Instead of passing a jQuery object and selector to mw.util.addPortletLink a new method is needed that replaces mw.util.addPortletLink and uses models, leaving presentation up to the skin.
Something like:
mw.menus.addItem( new mw.menu.Item( label, href, groupOfMenu, iconNameWhichDefaultsToSomePlaceholderIcon ) ); // addItem might throw an exception or warning if the group doesn't exist in the skin. mw.hookSubscribe( 'menu-changed', function ( menu ) { // skin decides how to render menu. } ); // if nothing has subscribed to hook gadget developer gets a warning telling them to ask skin to implement it.
Acceptance criteria
- A method is available to gadgets that manipulates a model that corresponds to all menu contents
- When the menu contents change, a signal is sent to the skin to render it
- A skin must register how to add new items to menus.
Developer notes
Menus in mobile