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
 
(29 intermediate revisions by the same user not shown)
Line 1:
//================================================================================
//*** Dynamic ExpandableigationExpandable Bars
// set up the words in your language
var ExpandableigationBarHideExpandableBarHide = 'EinklappenHide';
var ExpandableigationBarShowExpandableBarShow = 'AusklappenShow';
// 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 ExpandableigationExpandable bars
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 ExpandableigationExpandable bars
// Parameters:
// indexExpandableigationBarindexExpandableBar: the index of ExpandableigationExpandable bar to be toggled
function toggleExpandableigationBartoggleExpandableBar(ExpandableToggle, ExpandableFrame)
{
if (!ExpandableFrame || !ExpandableToggle) {
Line 29 ⟶ 20:
// if shown now
if (ExpandableToggle.firstChild.data == ExpandableigationBarHideExpandableBarHide) {
for (
var ExpandableChild = ExpandableFrame.firstChild;
Line 42 ⟶ 33:
}
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableigationBarShowExpandableBarShow;
}
}
// if hidden now
} else if (ExpandableToggle.firstChild.data == ExpandableigationBarShowExpandableBarShow) {
for (
var ExpandableChild = ExpandableFrame.firstChild;
Line 60 ⟶ 51:
}
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableigationBarHideExpandableBarHide;
}
}
Line 66 ⟶ 57:
}
function toggleExpandableigationBarFunctiontoggleExpandableBarFunction(ExpandableToggle, ExpandableFrame) {
return function() {
toggleExpandableigationBartoggleExpandableBar(ExpandableToggle, ExpandableFrame);
return false;
};
}
// iterate over all ExpandableFrames
var ExpandableFrames = mw.util.$content.findjQuery( 'div.ExpandableFrame' );
// if more ExpandableigationExpandable 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++) {
var ExpandableFrame = ExpandableFrames[i];
Line 83 ⟶ 74:
ExpandableToggle.setAttribute('href', '#');
var ExpandableToggleText = document.createTextNode(ExpandableigationBarHideExpandableBarHide);
ExpandableToggle.appendChild(ExpandableToggleText);
Line 90 ⟶ 81:
ExpandableFrame.insertBefore(ExpandableToggle, ExpandableFrame.firstChild);
ExpandableToggle.onclick = toggleExpandableigationBarFunctiontoggleExpandableBarFunction(ExpandableToggle, ExpandableFrame);
if (initiallyToggle) {
toggleExpandableigationBartoggleExpandableBar(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; ");
});