Änderungen

Wechseln zu: Navigation, Suche

MediaWiki:Common.js

6.238 Bytes entfernt, 09:40, 14. Jan. 2015
keine Bearbeitungszusammenfassung
/* Das folgende Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */
/**
importScript("MediaWiki:Common.js/watchlist.js");
}
 
/**
* Load jquery.ui.button if used in content
* for backward-compatibilty
* Should be removed/replaced with mediawiki.ui, when that is loaded on each page
*/
mw.hook( 'wikipage.content' ).add( function ( $content ) {
if ( $content.find( '.ui-button' ).length ) {
mw.loader.load( 'jquery.ui.button' );
}
} );
//=============================================================
mw.user.options.set( 'linkFA_enabled', false );
* star logo for featured articles in other languages,
* see Template:Link_FA / Template:Link_GA and MediaWiki:Common.css / MediaWiki:Cologneblue.css
*/
mw.loader.using( [ 'user', 'mediawiki.user', 'user.options' ], function() { $(function() {
var linkFA_description = "Dieser Artikel wurde als exzellent bewertet.";
var linkGA_description = "Dieser Artikel wurde als lesenswert bewertet.";
 
// linkFA_bullet/linkGA_bullet and linkFA_style/linkGA_Style werden nur für cologneblue, nostalgia and standard verwendet,
// für monobook, modern und simple siehe [[MediaWiki:Common.css]], vector hat in [[MediaWiki:Vector.css] eigene Definitionen
 
/** image to use instead of the standard bullet (for cologneblue, nostalgia and standard */
var linkFA_bullet = "//upload.wikimedia.org/wikipedia/commons/d/d0/Monobook-bullet-star-transparent.png";
var linkGA_bullet = "//upload.wikimedia.org/wikipedia/commons/a/a1/Monobook-bullet-star-gray.png";
 
/** style to use for the linkFA_bullet/LinkGA_bullet img */
var linkFA_style = "margin-right: 0.2em;";
var linkGA_style = "margin-right: 0.2em;";
// early exit when disabled
}
// skins that can be handled the CSS class way
var skin = mw.config.get( 'skin' );
if (skin === "monobook" || skin === "simple" || skin === "modern" || skin === "vector" ) { linkFA_CSS("p-lang", "li");
}
else if (skin === "cologneblue" || skin === "nostalgia" || skin === "standard") { linkFA_decoratelinkFA_CSS("langlinks", "span");
}
/** skin == "monobook" || skin == "simple" || skin="modern" || skin== "vector" */ function linkFA_CSS(rootId, tagName) {
// links are to replaced in p-lang only
var pLang = document.getElementById("p-lang"rootId);
if (!pLang) return;
var lis = pLang.getElementsByTagName("li"tagName);
for (var i = 0; i < lis.length; i++) {
var li = lis[i];
//extract necessary classname
var matches = li.className.match( /(?:^| )(interwiki-[^ ]+)(?: |$)/ );
if ( !matches || matches.length != 2 ) {
continue;
}
var className = matches[1];
// only links with a corresponding Link_FA template are interesting
if (document.getElementById(className + "-fa") && li.className + .indexOf("badge-fafeaturedarticle")=== -1) {
li.className += " FA"; // additional class so the template can be hidden with CSS
li.title = linkFA_description; // change title
continue;
}
if (document.getElementById(className + "-ga") && li.className + .indexOf("badge-gagoodarticle")=== -1) {
li.className += " GA"; // additional class so the template can be hidden with CSS
li.title = linkGA_description; // change title
}
}
}
 
/** skin == "cologneblue" || skin == "nostalgia" || skin == "standard" */
function linkFA_decorate() {
// these root elements can contain FA-/GA-links
var rootIds = new Array("topbar", "footer");
for (var i=0; i<rootIds.length; i++) {
var root = document.getElementById(rootIds[i]);
if (!root) continue;
 
// if the root exists, try to decorate all the links within
var links = root.getElementsByTagName("a");
for (var j=0; j<links.length; j++) {
decorate(links[j], "-fa", linkFA_bullet, linkFA_description, linkFA_style);
decorate(links[j], "-ga", linkGA_bullet, linkGA_description, linkGA_style);
}
}
}
 
/** id necessary, modify a link to show the FA- or GA-star (older) */
function decorate(link, idSuffix, bullet, description, style) {
var lang = link.hostname.split(".")[0];
var fa = document.getElementById("interwiki-" + lang + idSuffix);
if (!fa) return;
 
// build an image-node for the FA-star
var img = document.createElement("img");
img.setAttribute("src", bullet);
img.setAttribute("alt", description);
img.setAttribute("style", style);
// decorate the link with the image
link.appendChild(img);
link.appendChild(link.removeChild(link.firstChild));
link.setAttribute("title", description);
}
})});
siehe auch Feature-Request [[bugzilla:708]]
*/
if( mw.config.get( 'wgNamespaceNumber' ) > 0 ) { mw.loader.using( [ 'mediawiki.util' ], function() { jQuery( document ).ready$(function() { var iProject = document.getElementById$("'#interProject"' ); if(!iProject.length ) { return; } var sistersibling = document.getElementById$("'#p-lang"' ); if(!sistersibling.length ) { sistersibling= document.getElementById$("'#p-tb"' ); } if(!sistersibling.length ) { return; }
//Link auf Parennode des Portletmenues
var sisterparent = sistersibling.parentNodeparent();
//Erzeuge neues Portletmenue
var sisterprojectnav = $( document.createElement("'div"' ) ); sisterprojectnav.attr( 'id = "', 'p-sisterprojects"' ); sisterprojectnav.className = attr( 'class', sistersibling.classNameattr( 'class' ) ); sisterprojectnavvar header = $( document.innerHTML = createElement( '<h3>'+document) ); header.getElementByIdtext( $("'#sisterProjects":first' ).firstChildtext() ); sisterprojectnav.innerHTML+append( header ); var portletDiv = $( document.createElement( '</h3><div><ul></ul></div>') ); var sistersiblingsub = sistersibling.getElementsByTagNamefind("'div":first' )[0]; if(sistersiblingsub.length ) { sisterprojectnavportletDiv.childNodes[1].className = attr( 'class', sistersiblingsub.classNameattr( 'class' ) );
} else {
sisterprojectnavportletDiv.childNodes[1].className = "attr( 'class', 'pBody"' );
}
sisterprojectnav.append( portletDiv );
//Wenn möglich vor den Interwikis einfügen
var sisternext = documentif ( sisterparent.getElementByIdhas("'#p-lang"' ); if ( sisternext && sisternext.parentNode === sisterparent length ) { sisterparentsisterprojectnav.insertBefore( sisterprojectnav, sisternext '#p-lang' );
} else {
sisterparent.appendChildappend(sisterprojectnav);
}
//Schwesterlinks ermitteln und einfügen
var sisterlinks = iProject.getElementsByTagNamefind("'a"' ).each( function();{ for $this = $(var i = 0this ); i < sisterlinks.length; i++) { var sistername = sisterlinks[i]$this.firstChild.nodeValuetext(); mw.util.addPortletLink( 'p-sisterprojects', sisterlinks[i] $this.getAttributeattr("'href"' ) + '?uselang=' + mw.util.rawurlencode( mw.config.get( 'wgUserLanguage' ) ), sistername, " 'sister-"' + sistername, sistername ); }); })});}
/**
mw.util.addPortletLink(
'p-lang',
mw.util.wikiGetlinkgetUrl( 'Wikipedia:Sprachen' ),
'Alle Sprachen',
'interwiki-completelist',
* force the loading of another JavaScript file
* Deprecated function, function alias kept for backward compatibility
* mw.log.deprecate since 08.11.2013
*/
mw.log.deprecate( window., 'includePage', importScript, 'includePage = function( name ) { return ist veraltet, verwende stattdessen importScript( name ' );}
//================================================================================
function toggleNavigationBar(NavToggle, NavFrame)
{
if (!NavFrame || !NavToggle) { return false; }
// if shown now if (NavToggle.firstChild.data === textHide) { for ( var NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) { if (NavChild.className === 'NavPic') { NavChild.style.display = 'none'; } if (|| NavChild.className === 'NavContent') { NavChild.style.display = 'none'; } } if (NavChild.className === ' NavToggle') { NavChild.firstChild.data = textShow; } }
// if hidden now } else if (NavToggle.firstChild.data === textShow) { for ( var NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) { if (NavChild.className === 'NavPic') { NavChild.style.display = 'block'; } if (|| NavChild.className === 'NavContent') { NavChild.style.display = 'block'; } } if (NavChild.className === ' NavToggle') { NavChild.firstChild.data = textHide; } } }
}
// if more Navigation Bars found and not template namespace than Default: hide all
var initiallyToggle = showDefaultCount < NavFrames.length && mw.config.get( 'wgNamespaceNumber' ) !== 10;
for (var i=0; i<NavFrames.length; i++) {
var NavFrame = NavFrames[i];
var NavToggle = document.createElement("a");
if (initiallyToggle) {
toggleNavigationBar(NavToggle, NavFrame);
} else { // make sure that 'display' is always set for every NavFrame
for (
var NavChild = NavFrame.firstChild;
NavChild !== null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className === 'NavPic' || NavChild.className === 'NavContent') {
NavChild.style.display = 'block';
}
}
}
}
}
});
}
 
/**
* <noscript>-Emulation via <div class="noscript"></div>
*/
mw.loader.using( [ 'mediawiki.util' ], function() {
mw.util.addCSS( '.noscript { display:none; }' );
});
 
/**
* Verwendung von OpenStreetMap in Wikipedia.
* (c) 2008 by Magnus Manske, Released under GPL
*/
//mediawiki.util is used by openStreetMapToggle
mw.loader.using( [ 'mediawiki.util' ], function() { $( function() {
var c = $( '#coordinates' );
if ( !c.length ) {
return;
}
 
var a = c.find( 'a' );
var geohack = false;
for (var i = 0; i < a.length; i++) {
var h = a[i].href;
if (!h.match(/geohack/)) continue;
if (h.match(/skyhack/)) continue;
if (h.match(/_globe:/)) continue; // no OSM for moon, mars, etc
geohack = true;
break;
}
if ( !geohack ) {
return;
}
 
var separator = $( document.createElement( 'span' ) );
separator.text( ' | ' );
separator.attr( 'class', 'noprint coordinates-separator' );
c.append( separator );
var img = $( document.createElement( 'img' ) );
img.attr( {
'src': '//upload.wikimedia.org/wikipedia/commons/thumb/c/c9/OpenStreetMapLogo.png/17px-OpenStreetMapLogo.png',
'width': '17px',
'height': '17px'
} );
var a = $( document.createElement( 'a' ) );
a.attr( {
'href': '#',
'title': 'Zeige Koordinaten auf einer Karte von OpenStreetMap',
'class': 'noprint osm-icon-coordinates'
} );
a.click( openStreetMapToggle );
a.append( img );
c.append( a );
})});
// The function to toggle
function openStreetMapToggle() {
var c = $( '#coordinates' );
if ( !c.length) {
return;
}
var cs = $( '#contentSub' );
var osm = $( '#openstreetmap' );
 
if ( cs.length && osm.length ) {
if ( osm.css( 'display' ) === 'none' ) {
osm.css( 'display', 'block' );
} else {
osm.css( 'display', 'none' );
}
return false;
}
 
var found_link = false;
var a = c.find( 'a' );
var h;
for (var i = 0; i < a.length; i++) {
h = a[i].href;
if (!h.match(/geohack/)) continue;
found_link = true;
break;
}
if ( !found_link ) {
return; // No geohack link found
}
 
h = h.split('params=')[1];
 
var url = '//toolserver.org/~kolossos/openlayers/kml-on-ol.php?lang=de&uselang='
+ mw.util.rawurlencode( mw.config.get( 'wgUserLanguage' ) )
+ '&params=' + h
+ '&title=' + mw.util.wikiUrlencode( mw.config.get( 'wgTitle' ) );
 
var iframe = $( document.createElement( 'iframe' ) );
iframe.attr( 'id', 'openstreetmap' );
iframe.css({
'width': '100%',
'height': '350px',
'clear': 'both'
});
iframe.attr( 'src', url );
cs.append( iframe );
return false;
}
} );
//add it within the brackets
var lastEditsectionLink = $( 'span.mw-editsection:last a:last' );
lastEditsectionLink.after( link );
lastEditsectionLink.after( ' | ' ); //see [[MediaWiki:Pipe-separator]]
});
}
 
/**
* A recent update for AFTv5 is not behaving properly when
* cache page output is served & a non-cached JS is loaded.
* The default value of 'permissionLevel' will now be false,
* instead of an actual value. Cached pages will still have
* the default value set though (instead of false), so the
* new JavaScript will interpret that as that the permission
* level has been set specifically, instead of falling back
* to the real (disabled) default value.
* This code will basically detect if the page output is old,
* and if so, re-calculate and correct what the values for
* permissionLevel & defaultPermissionLevel.
*
* This section can be removed after July 7, because than the cache for all pages should be fine
*/
(function() { //avoid globals
var article = mw.config.get( 'aftv5Article' );
if (
article &&
// check if new data is not yet exposed
typeof article['defaultPermissionLevel'] === 'undefined' &&
// make sure no specific protection was set (aft-reader was default)
article['permissionLevel'] === 'aft-reader'
) {
// check if lottery results in AFT enabled/disabled for this article
var odds = mw.config.get( 'wgArticleFeedbackv5LotteryOdds', 0 );
if ( typeof odds === 'object' ) {
if ( article.namespace in odds ) {
odds = odds[article.namespace];
} else {
odds = 0;
}
}
var enable = ( Number( article.id ) % 1000 ) >= ( 1000 - ( Number( odds ) * 10 ) );
 
// pretend no permission level is set
mw.config.get( 'aftv5Article' )['permissionLevel'] = false;
 
// fake the default level based on lottery
mw.config.get( 'aftv5Article' )['defaultPermissionLevel'] = ( enable ? 'aft-reader' : 'aft-noone' );
 
// now that data is corrected, check if AFT should be enabled;
// if not, we should make sure that any form being added is
// removed again
// if verify function does not exist, we need not worry,
// AFT data is corrected now already so nothing wrong
// will be added
if ( typeof $.aftUtils.verify === 'function' && !$.aftUtils.verify( 'article' ) ) {
var remove, interval;
 
remove = function() {
var $aft = $( '#mw-articlefeedbackv5' );
 
if ( $aft.length > 0 ) {
$aft.remove();
clearInterval( interval );
}
};
interval = setInterval( remove, 100 );
}
}
})();
Bürokrat, fachreferenten, leitung, Administrator
1.428
Bearbeitungen

Navigationsmenü