MediaWiki:Common.js: Difference between revisions

Content deleted Content added
imported>Hendrik Brummermann
from http://de.wikipedia.org/wiki/MediaWiki:Common.js
imported>Hendrik Brummermann
No edit summary
Line 1:
//================================================================================
//*** Dynamic ExpandableigationExpandable Bars
// set up the words in your language
var ExpandableigationBarHideExpandableBarHide = 'Einklappen';
var ExpandableigationBarShowExpandableBarShow = 'Ausklappen';
// set up max count of ExpandableigationExpandable Bars on page,
// if there are more, all will be hidden
// ExpandableigationBarShowDefaultExpandableBarShowDefault = 0; // all bars will be hidden
// ExpandableigationBarShowDefaultExpandableBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
// adds show/hide-button to ExpandableigationExpandable bars
jQuery( document ).ready(function() {
if(!mw.user.options.exists( 'ExpandableigationBarShowDefaultExpandableBarShowDefault' )){
if (typeof ExpandableigationBarShowDefaultExpandableBarShowDefault != 'undefined' ) {
mw.user.options.set( 'ExpandableigationBarShowDefaultExpandableBarShowDefault',ExpandableigationBarShowDefaultExpandableBarShowDefault)
}
}
// shows and hides content and picture (if available) of ExpandableigationExpandable bars
// Parameters:
// indexExpandableigationBarindexExpandableBar: the index of ExpandableigationExpandable bar to be toggled
function toggleExpandableigationBartoggleExpandableBar(ExpandableToggle, ExpandableFrame)
{
if (!ExpandableFrame || !ExpandableToggle) {
Line 29:
// if shown now
if (ExpandableToggle.firstChild.data == ExpandableigationBarHideExpandableBarHide) {
for (
var ExpandableChild = ExpandableFrame.firstChild;
Line 42:
}
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableigationBarShowExpandableBarShow;
}
}
// if hidden now
} else if (ExpandableToggle.firstChild.data == ExpandableigationBarShowExpandableBarShow) {
for (
var ExpandableChild = ExpandableFrame.firstChild;
Line 60:
}
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableigationBarHideExpandableBarHide;
}
}
Line 66:
}
function toggleExpandableigationBarFunctiontoggleExpandableBarFunction(ExpandableToggle, ExpandableFrame) {
return function() {
toggleExpandableigationBartoggleExpandableBar(ExpandableToggle, ExpandableFrame);
return false;
};
Line 75:
var ExpandableFrames = mw.util.$content.find( 'div.ExpandableFrame' );
// if more ExpandableigationExpandable Bars found and not template namespace than Default: hide all
var initiallyToggle = mw.user.options.get( 'ExpandableigationBarShowDefaultExpandableBarShowDefault',1 ) < ExpandableFrames.length && mw.config.get( 'wgNamespaceNumber' ) != 10;
for (var i=0; i<ExpandableFrames.length; i++) {
var ExpandableFrame = ExpandableFrames[i];
Line 83:
ExpandableToggle.setAttribute('href', '#');
var ExpandableToggleText = document.createTextNode(ExpandableigationBarHideExpandableBarHide);
ExpandableToggle.appendChild(ExpandableToggleText);
Line 90:
ExpandableFrame.insertBefore(ExpandableToggle, ExpandableFrame.firstChild);
ExpandableToggle.onclick = toggleExpandableigationBarFunctiontoggleExpandableBarFunction(ExpandableToggle, ExpandableFrame);
if (initiallyToggle) {
toggleExpandableigationBartoggleExpandableBar(ExpandableToggle, ExpandableFrame);
}
}