Hopp til innhold

MediaWiki:Common.js

Fra Wikipedia, den frie encyklopedi

Merk: Etter publisering vil det kanskje være nødvendig å slette mellomlageret i nettleseren din for å se endringene.

  • Firefox / Safari: Hold Shift mens du klikker på Oppdater, eller trykk enten Ctrl+F5 eller Ctrl+R (⌘+R på Mac)
  • Google Chrome: Trykk Ctrl+Shift+R (⌘+Shift+R på Mac)
  • Edge: Hold Ctrl mens du trykker på Oppdater eller trykk Ctrl+F5
/* JavaScript i denne fila vil bli lastet for alle brukere på hver side. */
/**
 * Description: Vis/skjul definerte seksjoner i linjekart
 * Maintainer: BjørnN
 */
if ( $( '.BStable, .filterGroup' ).length ) {
	mw.loader.load(
		mw.config.get( 'wgServer' ) +
		mw.config.get( 'wgScript' ) +
		'?title=MediaWiki:Gadget-linjekart.js&action=raw&ctype=text/javascript'
	);
}

/**
 * Description: OpenStreetMap embedded inside articles
 * Maintainers: [[User:Haros]]
 * Note: this script uses text strings that must be passed as global variables
 */
mw.config.set( 'osm_proj_map', 'kart' ); //"map" in project language
mw.config.set( 'osm_proj_lang', 'no' );  //project language
mw.loader.load( 'https://meta.wikimedia.org/w/index.php?title=MediaWiki:OSM.js&action=raw&ctype=text/javascript' );

/**
 * Description: Move the set of links from a box at the bottom of the page to the siteSub at the top
 * Maintainers:
 */
( function() {
    var portlinks = $( '#portlinks' ).html();
    if ( portlinks && portlinks.length ) {
        if ( !window.matchMedia( 'print' ).matches ) {
            portlinks = portlinks.replace( /(?: | |\u00a0|\u000d|\x0d|\r|\u000a|\x0a|\n)*(?:·|·|\|)(?: | |\u00a0|\u000d|\x0d|\r|\u000a|\x0a|\n)*/g, ', ' );
            $( '#siteSub' ).html( portlinks );
        }
        $( '#portlinks' ).remove();
    }
} )();

/**
 * Fra https://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=961296730 (2021-03-17)
 * 
 * Collapsible tables; reimplemented with mw-collapsible
 * Styling is also in place to avoid FOUC
 *
 * Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]].
 * @version 3.0.0 (2018-05-20)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @author [[User:TheDJ]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core. Shimmable since MediaWiki 1.32
 *
 * @param {jQuery} $content
 */
mw.loader.using( [ 'mediawiki.util' ] ).done( function () {
	function makeCollapsibleMwCollapsible( $content ) {
		var $tables = $content
			.find( 'table.collapsible:not(.mw-collapsible)' )
			.addClass( 'mw-collapsible' );
	
		$.each( $tables, function ( index, table ) {
			// mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.');
			if ( $( table ).hasClass( 'collapsed' ) ) {
				$( table ).addClass( 'mw-collapsed' );
				// mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.');
			}
		} );
		if ( $tables.length > 0 ) {
			mw.loader.using( 'jquery.makeCollapsible' ).then( function () {
				$tables.makeCollapsible();
			} );
		}
	}
	mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible );
	
	/**
	 * 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
				if ( $toggle.parent()[ 0 ].style.color ) {
					$toggle.find( 'a' ).css( 'color', 'inherit' );
				}
			}
		} );
	}
	mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );
} );
OSZAR »