MediaWiki:Common.js:修订间差异
MediaWiki界面页面
更多操作
搬些脚本 |
翻译一些注释 |
||
| 第14行: | 第14行: | ||
/** | /** | ||
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse | * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse. | ||
* 向 mw-collapsible 添加对 autocollapse, innercollapse 和 outercollapse 的支持。 | |||
* Source: https://en.wikipedia.org/wiki/MediaWiki:Common.js | * Source: https://en.wikipedia.org/wiki/MediaWiki:Common.js | ||
* | * | ||
| 第37行: | 第38行: | ||
// because of colored backgrounds, style the link in the text color | // because of colored backgrounds, style the link in the text color | ||
// to ensure accessible contrast | // to ensure accessible contrast | ||
// 如果改过背景颜色, 就将链接颜色变为普通文本颜色, 以获得更好的对比度 | |||
$toggle = $element.find( '.mw-collapsible-toggle' ); | $toggle = $element.find( '.mw-collapsible-toggle' ); | ||
if ( $toggle.length ) { | if ( $toggle.length ) { | ||
2022年5月27日 (五) 21:30的最新版本
/*
* 全wiki通用Javascript
*
* 这里放置的Javascript将在用户使用桌面版每次载入页面时加载, 不分皮肤。
** [[MediaWiki:Gadget-site-javascript.js]] — 全站通用Javascript;
** [[MediaWiki:Mobile.js]] — 仅在移动版生效的Javascript;
** [[MediaWiki:<皮肤名>.js]] — 作用于特定皮肤的Javascript。
*/
/* global mw, $ */
mw.loader.using( [ 'mediawiki.util' ] ).done( function () {
/* Begin of mw.loader.using callback */
/**
* Add support to mw-collapsible for autocollapse, innercollapse and outercollapse.
* 向 mw-collapsible 添加对 autocollapse, innercollapse 和 outercollapse 的支持。
* Source: https://en.wikipedia.org/wiki/MediaWiki:Common.js
*
* @author TheDJ (Maintainer)
*/
function mwCollapsibleSetup( $collapsibleContent ) {
var $element,
$toggle,
autoCollapseThreshold = 2;
$.each( $collapsibleContent, function ( index, element ) {
$element = $( element );
if ( $element.hasClass( 'collapsible' ) ) {
$element.find( 'tr:first > th:first' ).prepend( $element.find( 'tr:first > * > .mw-collapsible-toggle' ) );
}
if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) {
$element.data( 'mw-collapsible' ).collapse();
} else if ( $element.hasClass( 'innercollapse' ) ) {
if ( $element.parents( '.outercollapse' ).length > 0 ) {
$element.data( 'mw-collapsible' ).collapse();
}
}
// because of colored backgrounds, style the link in the text color
// to ensure accessible contrast
// 如果改过背景颜色, 就将链接颜色变为普通文本颜色, 以获得更好的对比度
$toggle = $element.find( '.mw-collapsible-toggle' );
if ( $toggle.length ) {
// Make the toggle inherit text color
if ( $toggle.parent()[ 0 ].style.color ) {
$toggle.find( 'a' ).css( 'color', 'inherit' );
}
}
} );
}
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
/* End of mw.loader.using callback */
} );
/* 不要在这行下面添加代码! */