MediaWiki:Common.js

A Wikiszótárból, a nyitott szótárból

Megjegyzés: közzététel után frissítened kell a böngésződ gyorsítótárát, hogy lásd a változásokat.

  • Firefox / Safari: tartsd lenyomva a Shift gombot és kattints a Frissítés gombra a címsorban, vagy használd a Ctrl–F5 vagy Ctrl–R (Macen ⌘–R) billentyűkombinációt
  • Google Chrome: használd a Ctrl–Shift–R (Macen ⌘–Shift–R) billentyűkombinációt
  • Internet Explorer / Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
  • Opera: Nyomj Ctrl–F5-öt
/**
 * Autocollapse for mw-collapsible class
 */
var autoCollapseThreshold = 2;
function mwCollapsibleSetup( $collapsibleContent ) {
	var autoCollapse = $collapsibleContent.length >= autoCollapseThreshold;
	$collapsibleContent.each( function () {
		var $this = $( this );
		if ( autoCollapse && $this.hasClass( 'mw-autocollapse' ) ) {
			$this.data( 'mw-collapsible' ).collapse();
		}
	} );
}
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );

/**
 * Add a dropdown list for selecting character insert types
 * @see [[MediaWiki:Edittools]]
 */
function addCharSubsetMenu( forceAll ) {
	var $specialchars = $( '#specialchars' );
	if ( !$specialchars.length ) return;
	var $menu = $( '#charSubsetMenu' );
	if ( !$menu.length ) {
		$menu = $( '<select>' )
			.attr( 'id', 'charSubsetMenu' )
			.css( 'display', 'inline' )
			.change( chooseCharSubset );
	} else { // menu already built
		return;
	}
	
	$specialchars.find( 'p' ).each( function( i ) {
		$( '<option>' )
			.text( this.title )
			.attr( 'value', i )
			.appendTo( $menu );
	} );

	// activate first character set
	chooseCharSubset( null, $menu.find( 'option:first' ).val() );

	$specialchars.prepend( $menu );
}
function chooseCharSubset( e, val ) {
	if ( !val ) {
		val = $( this ).val();
	}
	$( '#specialchars p' )
		.hide()
		.eq( val ).css( 'display', 'inline' );
}
$( addCharSubsetMenu );