MediaWiki:Minerva.js: Difference between revisions
Created page with "→* * Custom mobile navigation for the hamburger menu. * * MinervaNeue does not support custom MediaWiki:Sidebar groups in the * mobile main menu — only the hardcoded Home/Random entries are used. * This is a known upstream limitation (https://phabricator.wikimedia.org/T65459). * This script mirrors the custom sidebar sections into the mobile drawer. * * Keep in sync with MediaWiki:Sidebar.: ( function () { var sections = [ { heading:..." |
No edit summary |
||
| Line 39: | Line 39: | ||
} | } | ||
var sitelinks = menu.querySelector( 'ul.hlist' ); | var sitelinks = menu.querySelector( 'ul.hlist' ); | ||
sections.forEach( function ( section ) { | var firstGroup = menu.querySelector( '#p-navigation' ); | ||
sections.forEach( function ( section ) { | |||
var ul = document.createElement( 'ul' ); | |||
ul.className = 'toggle-list__list'; | |||
section.links.forEach( function ( link ) { | |||
var li = document.createElement( 'li' ); | |||
li.className = 'toggle-list-item'; | |||
var a = document.createElement( 'a' ); | |||
a.className = 'toggle-list-item__anchor'; | |||
a.href = link.href; | |||
var span = document.createElement( 'span' ); | |||
span.className = 'toggle-list-item__label'; | |||
span.textContent = link.label; | |||
a.appendChild( span ); | |||
li.appendChild( a ); | |||
ul.appendChild( li ); | |||
} ); | |||
if ( firstGroup && firstGroup.nextSibling ) { | |||
// Insert right after the navigation group (Home/Random), | |||
// before whatever comes next (Login, Configuration, etc.) | |||
firstGroup.nextSibling.parentNode.insertBefore( ul, firstGroup.nextSibling ); | |||
// Update reference so next section inserts after the one we just added | |||
firstGroup = ul; | |||
} else { | |||
menu.appendChild( ul ); | |||
} | |||
} ); | |||
}() ); | }() ); | ||