Hopp til innhald

MediaWiki:Common.js

Frå Wikipedia – det frie oppslagsverket

Merk: Etter lagring vil det kanskje vera naudsynt at nettlesaren slettar mellomlageret sitt for at endringane skal tre i kraft.

  • Firefox og Safari: Haldt nede Shift medan du klikkar på Oppdater, eller trykk anten Ctrl-F5 eller Ctrl-R (⌘-R på Mac)
  • Google Chrome: Trykk Ctrl-Shift-R (⌘-Shift-R på Mac)
  • Internet Explorer og Edge: Haldt nede Ctrl medan du klikkar Oppdater, eller trykk Ctrl-F5
  • Opera: Tøm mellomlageret i Verktøy → Innstillingar
/* JavaScript i denne fila vil verta lasta for alle brukarar på kvar side. */

/** WikiMiniAtlas *******************************************************
   *
   *  Description: WikiMiniAtlas is a popup click and drag world map.
   *               This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
   *               The script itself is located on meta because it is used by many projects.
   *               See [[Meta:WikiMiniAtlas]] for more information. 
   *  Created by: [[User:Dschwen]]
   */
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript');

/* Force preview for anons */
/* by Marc Mongenet, 2006, fr.wikipedia */
 
function forcePreview() {
  if (mw.config.get('wgUserName') != null || mw.config.get('wgAction') != "edit") return;
  saveButton = document.getElementById("wpSave");
  if (!saveButton) return;
  saveButton.disabled = true;
  saveButton.value = "Publiser (førehandsvis fyrst)";
  saveButton.style.fontWeight = "normal";
  document.getElementById("wpPreview").style.fontWeight = "bold";
}
$(forcePreview);

/**
 * 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
 */
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 );

/** Linjekart: Vis/skjul definerte seksjonar ***** */
 
importScript('MediaWiki:Linjekart.js');

/** Multibilete: Biletseriar ein kan klikka seg gjennom***** */

importScript('MediaWiki:Multibilete.js');

/** OpenStreetMap for artiklar som inneheld koordinatar ***** */

mw.config.set( 'osm_proj_map', 'kart' ); //"map" in project language
mw.config.set( 'osm_proj_lang', 'nn' );  //project language
 
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:OSM.js&action=raw&ctype=text/javascript');

/**
 * Collation sequence for Norwegian.
 * Note that æ, ø, and å are reordered.
 * For jquery.tablesorter.js
 */
mw.config.set( 'tableSorterCollation', {
 	'Æ'  : 'Å',
 	'Ø'  : 'Æ',
 	'Å'  : 'Ø',
 	'Ä'  : 'Å',
 	'Ö'  : 'Æ',
 	'Ü'  : 'Y',
 	'Þ'  : 'Th',
 	'æ'  : 'å',
 	'ø'  : 'æ',
 	'å'  : 'ø',
 	'ä'  : 'å',
 	'ö'  : 'æ',
 	'ü'  : 'y',
 	'þ'  : 'th'
} );