MediaWiki討論:Common.js

由Shizhao在話題編輯請求 2024-07-03上作出的最新留言:2 個月前

編輯請求 2024-07-03

編輯

  請求已處理

/**
 * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse
 *
 * Maintainers: TheDJ
 */
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 (Updated for T333357 2023-04-29)
			if ( $toggle.parent()[ 0 ].style.color ) {
				$toggle.css( 'color', 'inherit' );
				$toggle.find( '.mw-collapsible-text' ).css( 'color', 'inherit' );
			}
		}
	} );
}

mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );

從粵語維基百科引入上述內容並替換現有第223至229行的「展開摺疊按鈕的顏色」,令新版摺疊效果支持autocollapseinnercollapseoutercollapse(對應導航模板的EP)。--Dabao qian 2024年7月3日 (三) 20:19 (UTC)回覆

 完成--百無一用是書生 () 2024年7月11日 (四) 08:53 (UTC)回覆
返回 "Common.js" 頁面。