MediaWiki:Common.js: Unterschied zwischen den Versionen
(Click Event für NavHead hinzugefügt) |
|||
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
Zeile 14: | Zeile 14: | ||
/* Begin of mw.loader.using callback */ | /* Begin of mw.loader.using callback */ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
/** | /** | ||
* Load scripts specific to Internet Explorer | * Load scripts specific to Internet Explorer | ||
Zeile 64: | Zeile 57: | ||
} ); | } ); | ||
} )(); | } )(); | ||
− | + | ||
/** | /** | ||
− | * | + | * NavFrame click events |
− | + | * @author Gaddezwerch | |
− | |||
− | |||
− | * | ||
*/ | */ | ||
− | + | jQuery(".NavHead").css('cursor', 'pointer'); | |
− | + | jQuery(".NavHead").click(function() { | |
− | + | jQuery(this).parent().find('.NavContent').toggle(); | |
− | + | }); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
/** | /** | ||
Zeile 169: | Zeile 73: | ||
* Maintainers: UNMAINTAINED | * Maintainers: UNMAINTAINED | ||
*/ | */ | ||
− | + | var NavigationBarHide = '[verstecken]'; | |
− | + | var NavigationBarShow = '[anzeigen]'; | |
− | var NavigationBarHide = '[ | ||
− | var NavigationBarShow = '[ | ||
/** | /** | ||
Zeile 226: | Zeile 128: | ||
NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar ); | NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar ); | ||
NavToggle.setAttribute( 'href', '#' ); | NavToggle.setAttribute( 'href', '#' ); | ||
− | jQuery( NavToggle ).on( 'click', jQuery.proxy( window.toggleNavigationBar, window, indexNavigationBar ) ); | + | //jQuery( NavToggle ).on( 'click', jQuery.proxy( window.toggleNavigationBar, window, indexNavigationBar ) ); |
var isCollapsed = jQuery( NavFrame ).hasClass( 'collapsed' ); | var isCollapsed = jQuery( NavFrame ).hasClass( 'collapsed' ); | ||
Zeile 266: | Zeile 168: | ||
jQuery( createNavigationBarToggleButton ); | jQuery( createNavigationBarToggleButton ); | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
/** | /** |
Aktuelle Version vom 30. Mai 2013, 11:39 Uhr
/**
* Keep code in MediaWiki:Common.js to a minimum as it is unconditionally
* loaded for all users on every wiki page. If possible create a gadget that is
* enabled by default instead of adding it here (since gadgets are fully
* optimized ResourceLoader modules with possibility to add dependencies etc.)
*
* Since Common.js isn't a gadget, there is no place to declare its
* dependencies, so we have to lazy load them with mw.loader.using on demand and
* then execute the rest in the callback. In most cases these dependencies will
* be loaded (or loading) already and the callback will not be delayed. In case a
* dependency hasn't arrived yet it'll make sure those are loaded before this.
*/
mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
/* Begin of mw.loader.using callback */
/**
* Load scripts specific to Internet Explorer
*/
if ( jQuery.client.profile().name === 'msie' ) {
importScript( 'MediaWiki:Common.js/IEFixes.js' );
}
/**
* Fix for Windows XP Unicode font rendering
*/
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' +
'.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
}
/**
* 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.
* Maintainers: [[User:Dschwen]]
*/
( function () {
var require_wikiminiatlas = false;
var coord_filter = /geohack/;
jQuery( document ).ready( function() {
jQuery( 'a.external.text' ).each( function( key, link ) {
if ( link.href && coord_filter.exec( link.href ) ) {
require_wikiminiatlas = true;
// break from loop
return false;
}
} );
if ( jQuery( 'div.kmldata' ).length ) {
require_wikiminiatlas = true;
}
if ( require_wikiminiatlas ) {
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
}
} );
} )();
/**
* NavFrame click events
* @author Gaddezwerch
*/
jQuery(".NavHead").css('cursor', 'pointer');
jQuery(".NavHead").click(function() {
jQuery(this).parent().find('.NavContent').toggle();
});
/**
* Dynamic Navigation Bars (experimental)
*
* Description: See [[Wikipedia:NavFrame]].
* Maintainers: UNMAINTAINED
*/
var NavigationBarHide = '[verstecken]';
var NavigationBarShow = '[anzeigen]';
/**
* Shows and hides content and picture (if available) of navigation bars
* Parameters:
* indexNavigationBar: the index of navigation bar to be toggled
**/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
var NavChild;
if ( !NavFrame || !NavToggle ) {
return false;
}
/* if shown now */
if ( NavToggle.firstChild.data === NavigationBarHide ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( jQuery( NavChild ).hasClass( 'NavContent' ) || jQuery( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'none';
}
}
NavToggle.firstChild.data = NavigationBarShow;
/* if hidden now */
} else if ( NavToggle.firstChild.data === NavigationBarShow ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( jQuery( NavChild ).hasClass( 'NavContent' ) || jQuery( NavChild ).hasClass( 'NavPic' ) ) {
NavChild.style.display = 'block';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
event.preventDefault();
};
/* 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 ( jQuery( NavFrame ).hasClass( 'NavFrame' ) ) {
indexNavigationBar++;
var NavToggle = document.createElement( 'a' );
NavToggle.className = 'NavToggle';
NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
NavToggle.setAttribute( 'href', '#' );
//jQuery( NavToggle ).on( 'click', jQuery.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
var isCollapsed = jQuery( 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 ( jQuery( NavChild ).hasClass( 'NavPic' ) || jQuery( NavChild ).hasClass( 'NavContent' ) ) {
if ( NavChild.style.display === 'none' ) {
isCollapsed = true;
}
}
}
if ( isCollapsed ) {
for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
if ( jQuery( NavChild ).hasClass( 'NavPic' ) || jQuery( 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 ( jQuery( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
NavToggle.style.color = NavFrame.childNodes[j].style.color;
NavFrame.childNodes[j].appendChild( NavToggle );
}
}
NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
}
}
}
jQuery( createNavigationBarToggleButton );
/**
* Magic editintros ****************************************************
*
* Description: Adds editintros on disambiguation pages and BLP pages.
* Maintainers: [[User:RockMFR]]
*/
function addEditIntro( name ) {
jQuery( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
el.href = jQuery( this ).attr( 'href' ) + '&editintro=' + name;
} );
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
jQuery( function () {
if ( document.getElementById( 'disambigbox' ) ) {
addEditIntro( 'Template:Disambig_editintro' );
}
} );
jQuery( function () {
var cats = document.getElementById( 'mw-normal-catlinks' );
if ( !cats ) {
return;
}
cats = cats.getElementsByTagName( 'a' );
for ( var i = 0; i < cats.length; i++ ) {
if ( cats[i].title === 'Category:Living people' || cats[i].title === 'Category:Possibly living people' ) {
addEditIntro( 'Template:BLP_editintro' );
break;
}
}
} );
}
/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */