MediaWiki:Skin/Test zirkelklapp.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
K
K (jQuery(document).ready)
 
Zeile 43: Zeile 43:
 
}
 
}
  
addOnloadHook(zirkelklapp);
+
jQuery(document).ready(zirkelklapp);

Aktuelle Version vom 25. April 2011, 16:29 Uhr

/* Neues Zirkel-Klapp-script mit prototype-Gedöhnse */

function zirkelklapp() {
	alldivs = document.getElementsByTagName('div');
	for(var i = 0; i < alldivs.length; i++) {
		if(alldivs[i].className == "tooltipsource zirkel") {
			if(typeof zirkel == 'undefined') {
				zirkel = new Array();
				}
			zirkel.push(alldivs[i]);
			}
		}
	if(typeof zirkel != 'undefined') {
		for(var i = 0; i < zirkel.length; i++) {
			zirkel[i].getElementsByTagName('table')[0].style.display = 'none';
			}
		alllinks = document.getElementsByTagName('a');
		for(var i = 0; i < alllinks.length; i++) {
			Event.observe(alllinks[i], 'mouseover', function(event) {
				Event.stopObserving(document.getElementsByTagName('body')[0], 'mousedown');
				});
			Event.observe(alllinks[i], 'mouseout', function(event) {
				Event.observe(document.getElementsByTagName('body')[0], 'mousedown', function(event) {
					for(var i = 0; i < zirkel.length; i++) {
						zirkel[i].getElementsByTagName('table')[0].style.display = 'none';
						}
					Event.stopObserving(document.getElementsByTagName('body')[0], 'mousedown');
					});
				});
			};
		for(var i = 0; i < zirkel.length; i++) {
			Event.observe(zirkel[i].getElementsByTagName('span')[0], 'click', function(event) {
				this.parentNode.getElementsByTagName('table')[0].style.display = 'block';
				Event.observe(document.getElementsByTagName('body')[0], 'mousedown', function(event) {
					for(var i = 0; i < zirkel.length; i++) {
						zirkel[i].getElementsByTagName('table')[0].style.display = 'none';
						}
					Event.stopObserving(document.getElementsByTagName('body')[0], 'mousedown');
					});			
				});
			}
		}
	}

jQuery(document).ready(zirkelklapp);