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 |
||
| (27 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
//================================================================================ |
//================================================================================ |
||
//*** Dynamic |
//*** Dynamic Expandable Bars |
||
// set up the words in your language |
// set up the words in your language |
||
var |
var ExpandableBarHide = 'Hide'; |
||
var |
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 |
// 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 |
// shows and hides content and picture (if available) of Expandable bars |
||
// Parameters: |
// Parameters: |
||
// |
// indexExpandableBar: the index of Expandable bar to be toggled |
||
function |
function toggleExpandableBar(ExpandableToggle, ExpandableFrame) |
||
{ |
{ |
||
if (!ExpandableFrame || !ExpandableToggle) { |
if (!ExpandableFrame || !ExpandableToggle) { |
||
| Line 29: | Line 20: | ||
// if shown now |
// if shown now |
||
if (ExpandableToggle.firstChild.data == |
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 = |
ExpandableChild.firstChild.data = ExpandableBarShow; |
||
} |
} |
||
} |
} |
||
// if hidden now |
// if hidden now |
||
} else if (ExpandableToggle.firstChild.data == |
} 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 = |
ExpandableChild.firstChild.data = ExpandableBarHide; |
||
} |
} |
||
} |
} |
||
| Line 66: | Line 57: | ||
} |
} |
||
function |
function toggleExpandableBarFunction(ExpandableToggle, ExpandableFrame) { |
||
return function() { |
return function() { |
||
toggleExpandableBar(ExpandableToggle, ExpandableFrame); |
|||
return false; |
return false; |
||
}; |
}; |
||
} |
} |
||
// iterate over all ExpandableFrames |
// iterate over all ExpandableFrames |
||
var ExpandableFrames = |
var ExpandableFrames = jQuery( 'div.ExpandableFrame' ); |
||
// if more |
// 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( |
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 = |
ExpandableToggle.onclick = toggleExpandableBarFunction(ExpandableToggle, ExpandableFrame); |
||
if (initiallyToggle) { |
if (initiallyToggle) { |
||
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(" » "); |
|||
}); |
}); |
||