THDeb​(留言 | 贡献)
小 Add native collapsible sidebar groups
THDeb​(留言 | 贡献)
小 Use language-neutral native sidebar disclosure behavior
第1行: 第1行:
/* Navigation and language selection use the native skin components. */
/* Keep Vector's native sidebar and add accessible disclosure behaviour to custom groups. */
 
/* Add accessible disclosure behaviour to the native Vector sidebar groups. */
( function () {
( function () {
'use strict';
'use strict';


var collapsiblePortlets = [
var excludedPortlets = [ 'p-navigation', 'p-tb', 'p-lang', 'p-search' ];
'p-校园总览',
'p-区域与地点',
'p-课程与教学',
'p-组织与社团',
'p-人物',
'p-活动与赛事',
'p-作品与资料',
'p-待完善内容',
'p-参与编写',
'p-工具与浏览'
];


function isCurrentPortlet( content ) {
function isCurrentPortlet( content ) {
第41行: 第28行:
var contentId;
var contentId;


if ( collapsiblePortlets.indexOf( portlet.id ) === -1 || portlet.dataset.tyzxCollapsible === '1' ) {
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;