2015-06-30 17:21:45 -04:00
|
|
|
function containElement(e){function t(){var o=l.parentElement.offsetWidth,a=l.parentElement.offsetHeight;if(o&&a){if(n=o>a/(s*n)*i*n?o/i:a/s,l.style.width=i*n+"px",l.style.height=s*n+"px",i*n>o)switch(e.halign){case"left":l.style.left="0px";break;case"right":l.style.left=0-(i*n-o)+"px";break;default:l.style.left=0-(i*n-o)/2+"px"}else l.style.left="0px";if(s*n>a)switch(e.valign){case"top":l.style.top="0px";break;case"bottom":l.style.top=0-(s*n-a)+"px";break;default:l.style.top=0-(s*n-a)/2+"px"}else l.style.top="0px"}else window.setTimeout(t,30)}var n=1,l=document.getElementById(e.id),i=e.width||l.offsetWidth,s=e.height||l.offsetHeight;"absolute"!=l.style.position&&(l.style.position="absolute"),"hidden"!=l.parentElement.style.overflow&&(l.parentElement.style.overflow="hidden"),"relative"!=l.parentElement.style.position&&"absolute"!=l.parentElement.style.position&&"fixed"!=l.parentElement.style.position&&(l.parentElement.style.position="relative"),t(),window.onresize=function(e){t()},screen.addEventListener("orientationchange",function(){t()})}
|