MediaWiki:Skin/noclick.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
K gklaut von http://www.dhteumeuleu.com/lab/noclick.html (CC-BY-NC)
 
K hm ... könnnte man ja auch hier einfügen
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 26: Zeile 26:
for (var i = 0, o; o = document.body.getElementsByTagName("*")[i]; i++){
for (var i = 0, o; o = document.body.getElementsByTagName("*")[i]; i++){
if (o.className.indexOf('noclick') >= 0) {
if (o.className.indexOf('noclick') >= 0) {
o.style.position = 'relative';
o.style.color    = '#002bb8';
o.l0 = o.style.left;
o.l0 = o.style.left;
o.t0 = o.style.top;
o.t0 = o.style.top;

Aktuelle Version vom 9. Mai 2010, 15:44 Uhr

/* ======================================================================================
                              ===== no click =====
        script by Gerard Ferrandez - ge1doot - April 28, 2007
        http://www.dhteumeuleu.com - CC-BY-NC
   ====================================================================================== */

var xm = 0;
var ym = 0;
document.onmousemove = function(e){
	if (window.event) e=window.event;
	xm = e.clientX;
	ym = e.clientY;
}

var noclick = {
	O : [],
	run : function() {
		for (var i = 0, o; o = noclick.O[i]; i++)
			o.anim();
	},
	resize : function() {
		for (var i = 0, o; o = noclick.O[i]; i++)
			o.resize();
	},
	init : function(){
		for (var i = 0, o; o = document.body.getElementsByTagName("*")[i]; i++){
			if (o.className.indexOf('noclick') >= 0) {
				o.style.position = 'relative';
				o.style.color    = '#002bb8';
				o.l0 = o.style.left;
				o.t0 = o.style.top;
				o.resize = function() {
					this.style.left = this.l0;
					this.style.top = this.t0;
					for (var nx = 0, ny = 0, o = this.offsetParent; o != null; o = o.offsetParent)
						nx += o.offsetLeft, ny += o.offsetTop;
					this.x0 = nx;
					this.y0 = ny;
					this.ox = this.offsetLeft;
					this.oy = this.offsetTop;
					this.rx = (this.style.position == 'absolute') ? 0 : this.ox;
					this.ry = (this.style.position == 'absolute') ? 0 : this.oy;
					this.px = this.ox;
					this.py = this.oy;
					this.nw = this.offsetWidth / 2;
					this.nh = this.offsetHeight / 2;
					this.dp = Math.max(this.offsetWidth, this.offsetHeight);
				}
				o.anim = function() {
					var xmm = xm - this.x0 - this.nw;
					var ymm = ym - this.y0 - this.nh;
					var dx = xmm - this.px;
					var dy = ymm - this.py;
					var d = Math.sqrt(dx * dx + dy * dy);
					this.px += ((this.ox - this.px) * .2);
					this.py += ((this.oy - this.py) * .2);
					if(d < this.dp && d > 0 ){
						this.px = xmm - (this.dp * (xmm - this.px) / d);
						this.py = ymm - (this.dp * (ymm - this.py) / d);
					}
					this.style.left = Math.round(this.px - this.rx) + 'px';
					this.style.top  = Math.round(this.py - this.ry) + 'px';
				}
				o.resize();
				this.O.push(o);
			}
		}
		setInterval(noclick.run, 16);
	}
}

   
addOnloadHook(function() {
	noclick.init();
});

function resize() {
	noclick.resize();
}
onresize = resize;