Este es el código entero:
Código Javascript
:
Ver originalfunction addEvent(tipo, toDo, obj){
if(obj.attachEvent){
var thix = obj, fn = function(){ toDo.call(thix, window.event); };
obj.attachEvent('on'+tipo, fn);
this[toDo.toString()+tipo]=fn;
}else{
if(obj.addEventListener)
obj.addEventListener(tipo, toDo, false);
else
obj['on'+tipo]=toDo;
}
}
var JSPlus = (function(){
var privado = {
evento : function(tipo, toDo){
return addEvent(tipo, toDo, this);
},
quitaEvento : function(tipo, fn){
if(this.detachEvent)
this.detachEvent('on'+tipo, this[fn.toString()+tipo]);
else{
if(this.removeEventListener)
this.removeEventListener(tipo, fn, false);
else
this['on'+tipo]=null;
}
return P(this);
},
getStyle : function(style){
var computedStyle;
if (typeof this.currentStyle != 'undefined')
computedStyle = this.currentStyle;
else
computedStyle = document.defaultView.getComputedStyle(this, null);
return computedStyle[style];
},
atrb : function(att){ return this.getAttribute(att); },
set : function(att, valor){ this.setAttribute(att,valor); return P(this); },
css : function(estilo, valor){
var propi = !(/-/.test(estilo)) ? estilo : (function(s){var str=s.split('-');
for(i=0;i<str.length;i++){
str[i]=str[i].charAt(0).toUpperCase()+str[i].substr(1);
}
return str.join('');
})(estilo);
this.style[propi] = valor;
return P(this);
},
opacity : function(){
var isIE = document.all, estilos = isIE ? ['filter', 100] : ['opacity', 1], valor = isIE ? ['alpha(opacity=', ')'] : ['', ''];
if(arguments.length)
this.style[estilos[0]] = valor[0] + (arguments[0] * estilos[1]) + valor[1];
else
return P(this).getStyle('opacity');
return 1;
},
entrada : function(t){
var tempo = { 'lento' : 800, 'medio' : 500, 'rapido' : 200};
var tiempo = isFinite(t)?t:tempo[t], thix = P(this), incr = 20/tiempo;
thix.opacity(0);
var timer = setInterval(function(){
if(thix.opacity()>=1) timer = clearInterval(timer);
else{
thix.opacity(thix.opacity()+incr);
}
}, 20);
return P(this);
},
salida : function(t){
var tempo = { 'lento' : 800, 'medio' : 500, 'rapido' : 200};
var tiempo = isFinite(t)?t:tempo[t], thix = P(this), incr = 20/tiempo;
thix.opacity(1);
var timer = setInterval(function(){
if(thix.opacity()<=0) timer = clearInterval(timer);
else{
thix.opacity(thix.opacity()-incr);
}
}, 20);
return P(this);
},
hover : function(toDo){
addEvent('mouseover', toDo, this);
return P(this);
},
out : function(toDo){
addEvent('mouseout', toDo, this);
return P(this);
},
nodo : function(elem){ this.appendChild(elem); return P(this); },
extendido : true
};
return {
extender : function(elem, obj){
if(elem.extendido && elem != privado) return elem;
for(var i in obj){
elem[i] = obj[i];
}
return elem;
},
get : function(obj){
switch(typeof obj){
case 'object':
return JSPlus.extender(obj, privado);
break;
case 'string':
return JSPlus.extender(document.querySelector(obj), privado);
break;
}
return null;
},
metodos : function(obj){
JSPlus.extender(privado, obj);
}
};
})();
var P = JSPlus.get;
Saludos y gracias ;D