無編輯摘要
imported>=海豚= 無編輯摘要 |
imported>=海豚= 無編輯摘要 |
||
第20行: | 第20行: | ||
#moe .mw-cite-backlink> a {color: #36b!important;} | #moe .mw-cite-backlink> a {color: #36b!important;} | ||
#moe pre {display: none!important;} | #moe pre {display: none!important;} | ||
.stickyHeading .section-container { | |||
position: relative; | |||
} | |||
.stickyHeading .section-container h2 { /* 防止误伤目录中的h2 */ | |||
position: sticky; | |||
top: 0; | |||
z-index: 50; | |||
} | |||
.skin-vector .stickyHeading .section-container h2 { | |||
background-color: rgb(246, 246, 246); | |||
} | |||
.skin-minerva .stickyHeading .section-container h2 { | |||
background-color: #fff; | |||
} | |||
.stickyHeading .section-container .documentation h2, | |||
#Wikiplus-Quickedit-Preview-Output .stickyHeading .section-container h2 { | |||
position: static; | |||
background-color: transparent; | |||
} | |||
.collapseHeading .sec-hide { | |||
display: none !important; | |||
} | |||
.collapseHeading .section-container h2 { | |||
cursor: pointer; | |||
} | |||
.collapseHeading .mw-ui-icon { | |||
line-height: 1.5; | |||
margin-left: -0.8em; | |||
} | |||
/* </pre> */ | /* </pre> */ | ||
</style> | </style> | ||
第58行: | 第88行: | ||
.replace(/都会展现这幅表情。/g,'都会展现这幅表情。<br />翻了不下500张图,终于找到这两张没露点的,我容易吗?顺带一提这幅图其实'); | .replace(/都会展现这幅表情。/g,'都会展现这幅表情。<br />翻了不下500张图,终于找到这两张没露点的,我容易吗?顺带一提这幅图其实'); | ||
} | } | ||
if( ( | if( (ns.includes( nsid ) || nsid % 2 === 1) ){ | ||
window.setTimeout(function() { | window.setTimeout(function() { | ||
document.querySelector("#ca-edit a").textContent='编辑本地讨论'; | document.querySelector("#ca-edit a").textContent='编辑本地讨论'; | ||
第64行: | 第94行: | ||
},350); | },350); | ||
} | } | ||
const nsid = mw.config.get( 'wgNamespaceNumber' ), | |||
pagename = mw.config.get('wgPageName'), | |||
contentModel = mw.config.get( 'wgPageContentModel' ), | |||
skin = mw.config.get('skin'), | |||
gadgets = mw.gadgets || {}, | |||
stickyHeading = gadgets.stickyHeading || {}, | |||
ns = stickyHeading.namespace || [], | |||
mode = stickyHeading.mode, | |||
collapse = (stickyHeading.collapse !== false); | |||
if ( contentModel == 'wikitext' && | |||
((skin == 'vector' && mode != 'mobile') || (skin == 'minerva' && mode != 'desktop')) ) { | |||
mw.hook( 'wikipage.content' ).add(function( $content ) { | |||
console.log('Hook: wikipage.content, 开始添加粘性章节标题'); | |||
$content.addClass( 'stickyHeading' ); | |||
const headings = $content.find( '.mw-parser-output > h2' ); | |||
headings.toArray().reverse().forEach(function(ele) { | |||
$('<div>').addClass( 'section-container' ).insertBefore(ele) | |||
.append( $(ele).nextAll( ':not(.section-container, #toc)' ).add(ele) ); | |||
}); | |||
if (!collapse || skin == 'minerva') { return; } | |||
$content.addClass( 'collapseHeading' ); | |||
const icon = $('<i class="mw-ui-icon-before mw-ui-icon-small mw-ui-icon mw-ui-icon-collapse"></i>'); | |||
headings.prepend( icon ).on('click', function(e) { | |||
if ( $(e.target).is('a') ) { return; } | |||
const self = $(this); | |||
self.nextAll().toggleClass( 'sec-hide' ); | |||
self.children().first().toggleClass( 'mw-ui-icon-collapse mw-ui-icon-expand' ); | |||
}); | |||
}); | |||
} | |||
}); | }); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |