MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
from http://de.wikipedia.org/wiki/MediaWiki:Common.js
 
imported>Hendrik Brummermann
No edit summary
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
//================================================================================
//================================================================================
//*** Dynamic Expandableigation Bars
//*** Dynamic Expandable Bars
// set up the words in your language
// set up the words in your language
var ExpandableigationBarHide = 'Einklappen';
var ExpandableBarHide = 'Hide';
var ExpandableigationBarShow = 'Ausklappen';
var ExpandableBarShow = 'Show';
// set up max count of Expandableigation Bars on page,
// if there are more, all will be hidden
// ExpandableigationBarShowDefault = 0; // all bars will be hidden
// ExpandableigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
// adds show/hide-button to Expandableigation bars
// adds show/hide-button to Expandable bars
jQuery( document ).ready(function() {
jQuery( document ).ready(function() {
if(!mw.user.options.exists( 'ExpandableigationBarShowDefault' )){
if (typeof ExpandableigationBarShowDefault != 'undefined' ) {
mw.user.options.set( 'ExpandableigationBarShowDefault',ExpandableigationBarShowDefault)
}
}
// shows and hides content and picture (if available) of Expandableigation bars
// shows and hides content and picture (if available) of Expandable bars
// Parameters:
// Parameters:
// indexExpandableigationBar: the index of Expandableigation bar to be toggled
// indexExpandableBar: the index of Expandable bar to be toggled
function toggleExpandableigationBar(ExpandableToggle, ExpandableFrame)
function toggleExpandableBar(ExpandableToggle, ExpandableFrame)
{
{
if (!ExpandableFrame || !ExpandableToggle) {
if (!ExpandableFrame || !ExpandableToggle) {
Line 29: Line 20:
// if shown now
// if shown now
if (ExpandableToggle.firstChild.data == ExpandableigationBarHide) {
if (ExpandableToggle.firstChild.data == ExpandableBarHide) {
for (
for (
var ExpandableChild = ExpandableFrame.firstChild;
var ExpandableChild = ExpandableFrame.firstChild;
Line 42: Line 33:
}
}
if (ExpandableChild.className == 'ExpandableToggle') {
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableigationBarShow;
ExpandableChild.firstChild.data = ExpandableBarShow;
}
}
}
}
// if hidden now
// if hidden now
} else if (ExpandableToggle.firstChild.data == ExpandableigationBarShow) {
} else if (ExpandableToggle.firstChild.data == ExpandableBarShow) {
for (
for (
var ExpandableChild = ExpandableFrame.firstChild;
var ExpandableChild = ExpandableFrame.firstChild;
Line 60: Line 51:
}
}
if (ExpandableChild.className == 'ExpandableToggle') {
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableigationBarHide;
ExpandableChild.firstChild.data = ExpandableBarHide;
}
}
}
}
Line 66: Line 57:
}
}
function toggleExpandableigationBarFunction(ExpandableToggle, ExpandableFrame) {
function toggleExpandableBarFunction(ExpandableToggle, ExpandableFrame) {
return function() {
return function() {
toggleExpandableigationBar(ExpandableToggle, ExpandableFrame);
toggleExpandableBar(ExpandableToggle, ExpandableFrame);
return false;
return false;
};
};
}
}
// iterate over all ExpandableFrames
// iterate over all ExpandableFrames
var ExpandableFrames = mw.util.$content.find( 'div.ExpandableFrame' );
var ExpandableFrames = jQuery( 'div.ExpandableFrame' );
// if more Expandableigation Bars found and not template namespace than Default: hide all
// if more Expandable Bars found and not template namespace than Default: hide all
var initiallyToggle = true;
var initiallyToggle = mw.user.options.get( 'ExpandableigationBarShowDefault',1 ) < ExpandableFrames.length && mw.config.get( 'wgNamespaceNumber' ) != 10;
for (var i=0; i<ExpandableFrames.length; i++) {
for (var i=0; i<ExpandableFrames.length; i++) {
var ExpandableFrame = ExpandableFrames[i];
var ExpandableFrame = ExpandableFrames[i];
Line 83: Line 74:
ExpandableToggle.setAttribute('href', '#');
ExpandableToggle.setAttribute('href', '#');
var ExpandableToggleText = document.createTextNode(ExpandableigationBarHide);
var ExpandableToggleText = document.createTextNode(ExpandableBarHide);
ExpandableToggle.appendChild(ExpandableToggleText);
ExpandableToggle.appendChild(ExpandableToggleText);
Line 90: Line 81:
ExpandableFrame.insertBefore(ExpandableToggle, ExpandableFrame.firstChild);
ExpandableFrame.insertBefore(ExpandableToggle, ExpandableFrame.firstChild);
ExpandableToggle.onclick = toggleExpandableigationBarFunction(ExpandableToggle, ExpandableFrame);
ExpandableToggle.onclick = toggleExpandableBarFunction(ExpandableToggle, ExpandableFrame);
if (initiallyToggle) {
if (initiallyToggle) {
toggleExpandableigationBar(ExpandableToggle, ExpandableFrame);
toggleExpandableBar(ExpandableToggle, ExpandableFrame);
}
}
}
}
});




//================================================================================
// drop down menus

$(function(){
$("div.dropdownmenu ul li").hover(function(){
$(this).addClass("hover");
$('ul:first',this).css('visibility', 'visible');
}, function(){
$(this).removeClass("hover");
$('ul:first',this).css('visibility', 'hidden');
});
$("div.dropdownmenu ul li ul li:has(ul)").find("a:first").append(" &raquo; ");
});
});