小 Add native collapsible sidebar groups |
小 Use language-neutral native sidebar disclosure behavior |
||
| 第1行: | 第1行: | ||
/* | /* Keep Vector's native sidebar and add accessible disclosure behaviour to custom groups. */ | ||
( function () { | ( function () { | ||
'use strict'; | 'use strict'; | ||
var | var excludedPortlets = [ 'p-navigation', 'p-tb', 'p-lang', 'p-search' ]; | ||
function isCurrentPortlet( content ) { | function isCurrentPortlet( content ) { | ||
| 第41行: | 第28行: | ||
var contentId; | var contentId; | ||
if ( | if ( excludedPortlets.indexOf( portlet.id ) !== -1 || | ||
portlet.dataset.tyzxCollapsible === '1' ) { | |||
return; | return; | ||
} | } | ||
| 第47行: | 第35行: | ||
heading = portlet.querySelector( ':scope > .vector-menu-heading' ); | heading = portlet.querySelector( ':scope > .vector-menu-heading' ); | ||
content = portlet.querySelector( ':scope > .vector-menu-content' ); | content = portlet.querySelector( ':scope > .vector-menu-content' ); | ||
if ( !heading || !content ) { | if ( !heading || !content || !content.querySelector( 'li' ) ) { | ||
return; | return; | ||
} | } | ||
label = heading.textContent.trim(); | label = heading.textContent.trim(); | ||
if ( !label ) { | |||
return; | |||
} | |||
contentId = content.id || portlet.id + '-content'; | contentId = content.id || portlet.id + '-content'; | ||
content.id = contentId; | content.id = contentId; | ||