MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus WiiDatabase Wiki
Zur Navigation springenZur Suche springen
ICON (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
ICON (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
/* | /* Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */ | ||
// Imports Edittools functions | |||
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) { | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:Edittools.js&action=raw&ctype=text/javascript' ); | |||
} | |||
// Select containers with tabs | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:TabsSelection.js&action=raw&ctype=text/javascript' ); | |||
// Image / scroll galleries | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:ScrollGallery.js&action=raw&ctype=text/javascript' ); | |||
// Adding Skype links in VCards | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:VCard.js&action=raw&ctype=text/javascript' ); | |||
// Image Upload | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:Upload.js&action=raw&ctype=text/javascript' ); | |||
// Adding Wikidata search results | |||
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' || ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) { | |||
mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript' ); | |||
} | |||
// Wrapping li/dd/p/div containers which contain vCard templates for maintenance | |||
// See also MediaWiki:Gadget-vCards-Notes.css | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:CheckWrappedVCards.js&action=raw&ctype=text/javascript' ); | |||
// Adding GPX download | |||
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:Poi2gpx.js&action=raw&ctype=text/javascript" ); | |||
// Adding vCard Editor (ListingEditor) | |||
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:ListingEditor.js&action=raw&ctype=text/javascript" ); | |||
// Adding vCard/Listing popup information dialog | |||
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:ListingInfo.js&action=raw&ctype=text/javascript" ); | |||
// Adding marker tooltips | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:MarkerTooltip.js&action=raw&ctype=text/javascript' ); | |||
// Adding several map features | |||
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:MapTools.js&action=raw&ctype=text/javascript' ); | |||
// Adding Feature for Requests for Deletion | |||
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:DeleteRequests.js&action=raw&ctype=text/javascript" ); | |||
/** | /** | ||
* Collapsible tables ********************************************************* | * Collapsible tables ********************************************************* | ||
Zeile 156: | Zeile 201: | ||
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton ); | mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton ); | ||
/** | |||
* For Template:Button | |||
* 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' ); | |||
} | |||
} ); | |||
/** | |||
* some general changes on the site after loading | |||
* author: DerFussi | |||
************************************************* */ | |||
( function ( $ ) { | |||
// 1. removing empty brackets in the infoboxes (e.g. empty year statements in population entries) | |||
$('.qbItemSmall').each(function(){ | |||
if ( $(this).text() == '()' ) { | |||
$(this).remove(); | |||
} | |||
}); | |||
} ( jQuery ) ); |
Version vom 26. März 2018, 18:18 Uhr
/* Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */
// Imports Edittools functions
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:Edittools.js&action=raw&ctype=text/javascript' );
}
// Select containers with tabs
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:TabsSelection.js&action=raw&ctype=text/javascript' );
// Image / scroll galleries
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:ScrollGallery.js&action=raw&ctype=text/javascript' );
// Adding Skype links in VCards
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:VCard.js&action=raw&ctype=text/javascript' );
// Image Upload
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:Upload.js&action=raw&ctype=text/javascript' );
// Adding Wikidata search results
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' || ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript' );
}
// Wrapping li/dd/p/div containers which contain vCard templates for maintenance
// See also MediaWiki:Gadget-vCards-Notes.css
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:CheckWrappedVCards.js&action=raw&ctype=text/javascript' );
// Adding GPX download
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:Poi2gpx.js&action=raw&ctype=text/javascript" );
// Adding vCard Editor (ListingEditor)
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:ListingEditor.js&action=raw&ctype=text/javascript" );
// Adding vCard/Listing popup information dialog
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:ListingInfo.js&action=raw&ctype=text/javascript" );
// Adding marker tooltips
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:MarkerTooltip.js&action=raw&ctype=text/javascript' );
// Adding several map features
mw.loader.load( '//de.wikivoyage.org/w/index.php?title=MediaWiki:MapTools.js&action=raw&ctype=text/javascript' );
// Adding Feature for Requests for Deletion
mw.loader.load( "//de.wikivoyage.org/w/index.php?title=MediaWiki:DeleteRequests.js&action=raw&ctype=text/javascript" );
/**
* Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* [[Wikipedia:NavFrame]].
* Maintainers: [[User:R. Koot]]
*/
var autoCollapse = 2;
var collapseCaption = 'Einkl.';
var expandCaption = 'Auskl.';
window.collapseTable = function ( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.rows;
var i;
if ( Button.firstChild.data === collapseCaption ) {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
};
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = {};
var Tables = document.getElementsByTagName( 'table' );
var i;
function handleButtonLink( index, e ) {
window.collapseTable( index );
e.preventDefault();
}
for ( i = 0; i < Tables.length; i++ ) {
if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
/* only add button and increment count if there is a header row to work with */
var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
if ( !HeaderRow ) continue;
var Header = HeaderRow.getElementsByTagName( 'th' )[0];
if ( !Header ) continue;
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
var Button = document.createElement( 'span' );
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
Button.className = 'collapseButton'; /* Styles are declared in Common.css */
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
ButtonLink.setAttribute( 'href', '#' );
$( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( '[' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
Header.insertBefore( Button, Header.firstChild );
tableIndex++;
}
}
for ( i = 0; i < tableIndex; i++ ) {
if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
window.collapseTable( i );
}
else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
var element = NavigationBoxes[i];
while ((element = element.parentNode)) {
if ( $( element ).hasClass( 'outercollapse' ) ) {
window.collapseTable ( i );
break;
}
}
}
}
}
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton() {
var indexNavigationBar = 0;
var NavFrame;
var NavChild;
/* iterate over all < div >-elements */
var divs = document.getElementsByTagName( 'div' );
for ( var i = 0; (NavFrame = divs[i]); i++ ) {
/* if found a navigation bar */
if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
indexNavigationBar++;
var NavToggle = document.createElement( 'a' );
NavToggle.className = 'NavToggle';
NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
NavToggle.setAttribute( 'href', '#' );
$( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
/**
* Check if any children are already hidden. This loop is here for backwards compatibility:
* the old way of making NavFrames start out collapsed was to manually add style="display:none"
* to all the NavPic/NavContent elements. Since this was bad for accessibility (no way to make
* the content visible without JavaScript support), the new recommended way is to add the class
* "collapsed" to the NavFrame itself, just like with collapsible tables.
*/
for ( NavChild = NavFrame.firstChild; NavChild !== null && !isCollapsed; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
if ( NavChild.style.display === 'none' ) {
isCollapsed = true;
}
}
}
if ( isCollapsed ) {
for ( NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) {
if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
NavChild.style.display = 'none';
}
}
}
var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
NavToggle.appendChild( NavToggleText );
/* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
NavToggle.style.color = NavFrame.childNodes[j].style.color;
NavFrame.childNodes[j].appendChild( NavToggle );
}
}
NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
}
}
}
mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
/**
* For Template:Button
* 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' );
}
} );
/**
* some general changes on the site after loading
* author: DerFussi
************************************************* */
( function ( $ ) {
// 1. removing empty brackets in the infoboxes (e.g. empty year statements in population entries)
$('.qbItemSmall').each(function(){
if ( $(this).text() == '()' ) {
$(this).remove();
}
});
} ( jQuery ) );