MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann No edit summary |
imported>Hendrik Brummermann No edit summary |
||
| (12 intermediate revisions by the same user not shown) | |||
| Line 64: | Line 64: | ||
} |
} |
||
// iterate over all ExpandableFrames |
// iterate over all ExpandableFrames |
||
var ExpandableFrames = |
var ExpandableFrames = jQuery( 'div.ExpandableFrame' ); |
||
// if more Expandable Bars found and not template namespace than Default: hide all |
// if more Expandable Bars found and not template namespace than Default: hide all |
||
| Line 86: | Line 86: | ||
} |
} |
||
} |
} |
||
}); |
|||
//================================================================================ |
|||
// 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(" » "); |
|||
}); |
}); |
||
Latest revision as of 21:12, 27 July 2011
//================================================================================
//*** Dynamic Expandable Bars
// set up the words in your language
var ExpandableBarHide = 'Hide';
var ExpandableBarShow = 'Show';
// adds show/hide-button to Expandable bars
jQuery( document ).ready(function() {
// shows and hides content and picture (if available) of Expandable bars
// Parameters:
// indexExpandableBar: the index of Expandable bar to be toggled
function toggleExpandableBar(ExpandableToggle, ExpandableFrame)
{
if (!ExpandableFrame || !ExpandableToggle) {
return false;
}
// if shown now
if (ExpandableToggle.firstChild.data == ExpandableBarHide) {
for (
var ExpandableChild = ExpandableFrame.firstChild;
ExpandableChild != null;
ExpandableChild = ExpandableChild.nextSibling
) {
if (ExpandableChild.className == 'ExpandablePic') {
ExpandableChild.style.display = 'none';
}
if (ExpandableChild.className == 'ExpandableContent') {
ExpandableChild.style.display = 'none';
}
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableBarShow;
}
}
// if hidden now
} else if (ExpandableToggle.firstChild.data == ExpandableBarShow) {
for (
var ExpandableChild = ExpandableFrame.firstChild;
ExpandableChild != null;
ExpandableChild = ExpandableChild.nextSibling
) {
if (ExpandableChild.className == 'ExpandablePic') {
ExpandableChild.style.display = 'block';
}
if (ExpandableChild.className == 'ExpandableContent') {
ExpandableChild.style.display = 'block';
}
if (ExpandableChild.className == 'ExpandableToggle') {
ExpandableChild.firstChild.data = ExpandableBarHide;
}
}
}
}
function toggleExpandableBarFunction(ExpandableToggle, ExpandableFrame) {
return function() {
toggleExpandableBar(ExpandableToggle, ExpandableFrame);
return false;
};
}
// iterate over all ExpandableFrames
var ExpandableFrames = jQuery( 'div.ExpandableFrame' );
// if more Expandable Bars found and not template namespace than Default: hide all
var initiallyToggle = true;
for (var i=0; i<ExpandableFrames.length; i++) {
var ExpandableFrame = ExpandableFrames[i];
var ExpandableToggle = document.createElement("a");
ExpandableToggle.className = 'ExpandableToggle';
ExpandableToggle.setAttribute('href', '#');
var ExpandableToggleText = document.createTextNode(ExpandableBarHide);
ExpandableToggle.appendChild(ExpandableToggleText);
// add ExpandableToggle-Button as first div-element
// in < div class="ExpandableFrame" >
ExpandableFrame.insertBefore(ExpandableToggle, ExpandableFrame.firstChild);
ExpandableToggle.onclick = toggleExpandableBarFunction(ExpandableToggle, ExpandableFrame);
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(" » ");
});