MediaWiki:Common.js

Aus Freiheit statt Angst!

Wechseln zu: Navigation, Suche

Hinweis: Leere nach dem Speichern den Browser-Cache, um die Änderungen zu sehen: Mozilla/Firefox: Shift-Strg-R, Internet Explorer: Strg-F5, Opera: F5, Safari: ⌘-R, Konqueror: Strg-R.

/* Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */

// ============================================================
// BEGIN Toggling Boxes
// Source: http://de.wikipedia.org/wiki/Benutzer:Navigation/monobook.js
//
// set up the words in your language
var TogglingBoxHide = 'Einklappen';
var TogglingBoxShow = 'Ausklappen';
 
var TogglingBoxShowDefault = 1; // 0: hide bars after loading
                                  // 1: show bars after loading
 
// shows and hides content and picture (if available) of navigation bars
// Parameters:
//     indexNavigationBar: the index of navigation bar to be toggled
function toggleTogglingBox(indexNavigationBar)
{
    var BoxToggle = document.getElementById("BoxToggle" + indexNavigationBar);
    var BoxFrame = document.getElementById("BoxFrame" + indexNavigationBar);
 
    if (!BoxFrame || !BoxToggle) {
        return false;
    }
 
    // if shown now
    if (BoxToggle.firstChild.data == TogglingBoxHide) {
        for (
                var BoxChild = BoxFrame.firstChild;
                BoxChild != null;
                BoxChild = BoxChild.nextSibling
            ) {
            if (BoxChild.className == 'BoxPic') {
                BoxChild.style.display = 'none';
            }
            if (BoxChild.className == 'BoxContent') {
                BoxChild.style.display = 'none';
            }
            if (BoxChild.className == 'BoxToggle') {
                BoxChild.firstChild.data = TogglingBoxShow;
            }
        }
 
    // if hidden now
    } else if (BoxToggle.firstChild.data == TogglingBoxShow) {
        for (
                var BoxChild = BoxFrame.firstChild;
                BoxChild != null;
                BoxChild = BoxChild.nextSibling
            ) {
            if (BoxChild.className == 'BoxPic') {
                BoxChild.style.display = 'block';
            }
            if (BoxChild.className == 'BoxContent') {
                BoxChild.style.display = 'block';
            }
            if (BoxChild.className == 'BoxToggle') {
                BoxChild.firstChild.data = TogglingBoxHide;
            }
        }
    }
}
 
// adds show/hide-button to navigation bars
function createTogglingBoxToggleButton()
{
    var indexTogglingBox = 0;
    // iterate over all <div>-elements
    for(
            var i=0; 
            BoxFrame = document.getElementsByTagName("div")[i]; 
            i++
        ) {
        // if found a navigation bar
        if (BoxFrame.className == "BoxFrame") {
 
            indexTogglingBox++;
            var BoxToggle = document.createElement("a");
            BoxToggle.className = 'BoxToggle';
            BoxToggle.setAttribute('id', 'BoxToggle' + indexNavigationBar);
            BoxToggle.setAttribute('href', 'javascript:toggleTogglingBox(' + indexTogglingBox + ');');
 
            var BoxToggleText = document.createTextNode(TogglingBoxHide);
            BoxToggle.appendChild(BoxToggleText);
 
            // add BoxToggle-Button as first div-element 
            // in <div class="BoxFrame">
            BoxFrame.insertBefore(
                BoxToggle,
                BoxFrame.firstChild
            );
            BoxFrame.setAttribute('id', 'BoxFrame' + indexTogglingBox);
        }
    }
    if (TogglingBoxShowDefault) {
        for(
                var i=1; 
                i<=indexTogglingBox; 
                i++
        ) {
            toggleTogglingBox(i);
        }
    }
 
}
 
onload = createTogglingBoxToggleButton();
 
// END Toggling Boxes
// ============================================================
Persönliche Werkzeuge
Werkzeuge