codice:
if(!e) return;
if(e.constructor==Array){
for(var i=0; i<e.length; ++i) calcP(e[i]);
return;
}
_imgBgInURL=rzGetStyle(e,'background-image');
if(_imgBgInURL&&_imgBgInURL=='none') _imgBgInURL=null;
if(_imgBgInURL){
_imgBgInRepeat=rzGetStyle(e,'background-repeat');
}
_coBgIn=rzS2C(rzGetBg(e));
_coBgOut=rzS2C(rzGetBg(e.parentNode));
var borderCSS='border-'+(_isT?'top-':'bottom-');
var bs=rzGetStyle(e,borderCSS+'style','none');
if(bs && bs!='' && bs!='none' && bs!='hidden'){
_coBorder=rzS2C(rzGetStyle(e,borderCSS+'color','black'));
_wBorder=rzPX2I(rzGetStyle(e,borderCSS+'width','1px'));
}else{
_coBorder=_coBgIn;
_wBorder=0;
}
_coShadow=_coShadowS=='.fade'?_coBorder:rzS2C(_coShadowS);
_cacheID=
rzC2S(_coBgIn)+'.'+rzC2S(_coBgOut)+'.'+
rzC2S(_coBorder)+'.'+rzC2S(_coShadow)+'.'+
_wBorder+'.'+_isL+_isR+_isT+_isB+'.'+
_cornerRadius+'.'+_shadowRadius+'.'+
_shadowPadding+'.'+this.shadowShift+'.'+
_imgBgInURL+'.'+_imgBgInRepeat;
var eb=crDiv();
var elOb=crDiv();
var elO=crDiv();
var elI=crDiv();
var elCw=crDiv();
var elCb=crDiv();
var elC=crDiv();
eb.style.position=elC.style.position=elCw.style.position='relative';
elC.style.zIndex=2;
eb.appendChild(elOb);
elOb.appendChild(crDiv(null,'1px'));
elOb.appendChild(elO);
elOb.appendChild(crDiv(null,'1px'));
elI.appendChild(elCw);
elCw.appendChild(elCb);
elCb.appendChild(elC);
elO.appendChild(crTB(true));
var elTB=crLR(elI);
elO.appendChild(elTB);
elO.appendChild(crTB(false));
var psLR=_shadowRadius-_shadowPadding+_wBorder;
var psL=_isL?psLR:0;
var psR=_isR?psLR:0;
var isTB=_isT&&_isB;
var psT=_psT;
var psB=_psB;
var bgImgY=_psT;
setBgImg(elI,psL,bgImgY);
elI.style.backgroundColor=rzC2S(_coBgIn);
var end=crDiv('1px','1px');
elI.insertBefore(end,elCw);
elI.appendChild(end.cloneNode(true));
psT++; psB++;
if(_height){
elC.style.height=_height+'px';
}
var update=function(l,ps){
var padL='padding-'+l; var padCC=rzCC(padL);
var marL='margin-'+l; var marCC=rzCC(marL);
var borL='border-'+l+'-width'; var borCC=rzCC(borL);
var pad=rzGetStyle(e,padL);
var borPx=rzPX2I(rzGetStyle(e,borL));
var borPxNeg=(l=='top'||l=='bottom')?-borPx-1:-borPx;
if(!_isB && l=='bottom') borPx-=2;
if(!_isT && l=='top') borPx-=2;
eb.style[marCC]=borPx+'px';
elO.style[marCC]='-'+pad;
elOb.style[marCC]=borPxNeg+'px';
elCw.style[marCC]=(-ps)+'px';
elC.style[marCC]=pad;
elCb.style[marCC]=borPx+'px';
return function(){
if(RUZEE.isIE){
if(l=='top') elOb.style[marCC]='-1px';
if(l=='bottom') e.style[padCC]='1px';
}
};
};
var funcs=[update('top',psT),update('bottom',psB),
update('left',psL),update('right',psR)];
RUZEE.Borders.addCalc(function(){
for(var i=0; i<funcs.length; ++i) funcs[i]();
e.style.border='none';
e.style.background='transparent';
e.style.backgroundImage='none';
if(RUZEE.isIE){
e.style.height='1%';
}
e.style.position='relative';
e.appendChild(eb);
while (e.childNodes.length>1){
elC.appendChild(e.removeChild(e.childNodes[0]));
}
});
};
var pub={
init:function(d){
var rad=d.cornerRadius||8;
_height=d.height||0;
_shadowShift=0;
setEdges(d.edges||'lrtb');
switch(d.borderType){
case 'simple':
_cornerRadius=_shadowRadius=_shadowPadding=rad;
_coShadowS='000';
break;
case 'shadow':
var sw=d.shadowWidth||8;
_cornerRadius=rad;
_shadowRadius=rad+sw*2;
_shadowPadding=rad+sw;
_shadowShift=Math.round(sw/2);
_coShadowS=d.shadowColor||'000';
break;
case 'fade':
_cornerRadius=_shadowPadding=1;
_shadowRadius=rad;
_coShadowS='.fade';
break;
case 'glow':
_cornerRadius=_shadowPadding=rad;
_shadowRadius=rad+(d.glowWidth||rad);
_coShadowS=d.glowColor||'fff';
break;
default:
alert('Unknown borderType: '+d.borderType);
}
},
calc:calcP,
render:function(e){
t.calc(e);
RUZEE.Borders.renderCalcs();
},
draw:function(e,edges){
setEdges(edges?edges.toLowerCase():'lrtb');
if(typeof e=='string'){
if(e.charAt(0)!='.') e='#'+e;
e=RUZEE.Borders.cssQuery(e);
}
t.render(e);
}
};
pub.init(d);
delete pub.init;
for(m in pub) t[m]=pub[m];
};
if(RUZEE.Events){
RUZEE.Events.add(window,'domload',function(){
if(RUZEE.Borders.autoRender) RUZEE.Borders.render();
});
}
Math.sqr=function(x){
return x*x;
};
function rzCC(s){
for(var exp=/-([a-z])/; exp.test(s); s=s.replace(exp,RegExp.$1.toUpperCase()));
return s;
};
function rzGetStyle(e,a,d){
if(e==null) return d;
var v=null;
if(document.defaultView && document.defaultView.getComputedStyle){
var cs=document.defaultView.getComputedStyle(e,null);
if(cs && cs.getPropertyValue) v=cs.getPropertyValue(a);
}
if(!v && e.currentStyle) v=e.currentStyle[rzCC(a)];
return v?v:d?d:null;
};
function rzGetBg(e){
var v=rzGetStyle(e,'background-color');
while (!v || v=='transparent' || v=='#000000' || v=='rgba(0, 0, 0, 0)'){
if(e==document.body) v='fff'; else {
e=e.parentNode;
v=rzGetStyle(e,'background-color');
}
}
return v;
};
function rzPX2I(px){
if(!px) return 0;
var p=/\s*(\d\d*)px/.exec(px);
if(p) return parseInt(p[1]);
return 0;
};
function rzS2C(s,d){
if (!s) return d?rzS2C(d):[0,0,0,0];
if (s.charAt(0)=='#') s=s.substr(1,6);
s=s.replace(/ /g,'').toLowerCase();
var COLORS = {
aqua:'00ffff', black:'000000', blue:'0000ff', fuchsia:'ff00ff',
gray:'808080', green:'008000', lime:'00ff00', maroon:'800000',
navy:'000080', olive:'808000', orange:'ffa500', purple:'800080',
red:'ff0000', silver:'c0c0c0', teal:'008080', white:'ffffff',
yellow:'ffff00'
};
for (var key in COLORS) if (s==key) s=COLORS[key];
var p=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s);
if(p) return [parseInt(p[1]),parseInt(p[2]),parseInt(p[3]),parseInt(p[4])];
var p=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(s);
if(p) return [parseInt(p[1]),parseInt(p[2]),parseInt(p[3]),255];
p=/^(\w{2})(\w{2})(\w{2})$/.exec(s);
if(p) return [parseInt(p[1],16),parseInt(p[2],16),parseInt(p[3],16),255];
p=/^(\w{1})(\w{1})(\w{1})$/.exec(s);
if(p) return [parseInt(p[1]+p[1],16),parseInt(p[2]+p[2],16),parseInt(p[3]+p[3],16),255];
return d?rzS2C(d):[0,0,0,0];
};
function rzC2S(c){
if(typeof c=='string') return c;
r='0'+c[0].toString(16);
g='0'+c[1].toString(16);
b='0'+c[2].toString(16);
return '#'
+r.substring(r.length-2)
+g.substring(g.length-2)
+b.substring(b.length-2);
};
function rzBlend(a,b,w){
return Array(
Math.round(a[0]+(b[0]-a[0])*w),
Math.round(a[1]+(b[1]-a[1])*w),
Math.round(a[2]+(b[2]-a[2])*w),
Math.round(a[3]+(b[3]-a[3])*w));
};
function rzCrSimpleBorder(rad){
return new RUZEE.Borders.Border({ borderType:'simple', cornerRadius:rad });
};
function rzCrShadowBorder(rad,smar,coShadowS){
return new RUZEE.Borders.Border({
borderType:'shadow', cornerRadius:rad, shadowWidth:smar, shadowColor:coShadowS });
};
function rzCrFadeBorder(rad){
return new RUZEE.Borders.Border({ borderType:'fade', cornerRadius:rad });
};
function rzCrGlowBorder(rad,gmar,coGlowS){
return new RUZEE.Borders.Border({ borderType:'glow', cornerRadius:rad, glowWidth:gmar, glowColor:coGlowS });
};
purtroppo è lunghissimo...vedi un po se riesci..mmm!!!