Es de una librería que estoy intentando montarme XD El código es muy largo pero dejo lo importante:
Código Javascript
:
Ver originalvar JSPlus = (function(){
var privado = {
// [...]
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{
if(this.style[estilos[0]]){
return this.style[estilos[0]].match(/\d+(\.\d+)?/)[0]/estilos[1];
}else{
if(SS.find(this.tagName, estilos[0])){
return SS.find(this.tagName, estilos[0]).match(/\d+(\.\d+)?/)[0]/estilos[1];
}else{
if(SS.find('#'+this.id, estilos[0]))
return SS.find('#'+this.id, estilos[0]).match(/\d+(\.\d+)?/)[0]/estilos[1];
else{
for(var i=0, partir=this.className.split(' '); clase=partir[i]; i++){
if(SS.find('.'+clase, estilos[0]))
return SS.find('.'+clase, estilos[0]).match(/\d+(\.\d+)?/)[0]/estilos[1];
}
}
}
}
return 1;
}
return P(this);
},
// [...]
};
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;
}
};
})();
var P = JSPlus.get;
Entonces si por ejemplo tengo un código así:
Funciona en FF y Chrome, pero en IE me dice que se esperaba un objeto (en la línea de this.style[estilos[0]] = valor[0] + (arguments[0] * estilos[1]) + valor[1]; )
Saludos (:
PD: Gracias a
@Panino por la idea del mixin, jamás se me hubiera ocurrido XD