reframe.js
Version:
Reframe.js: responsive iframes for embedded content
2 lines (1 loc) • 846 B
JavaScript
!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";var t;"undefined"!=typeof window&&(t=window.$||window.jQuery||window.Zepto)&&(t.fn.noframe=function(t){var e=this,n=t,o="string"==typeof e?document.querySelectorAll(e):e;"length"in o||(o=[o]);for(var i=0;i<o.length;i+=1){var c=o[i],d=void 0!==n&&document.querySelector(n),f=d?document.querySelector(n):c.parentElement,a=c.offsetHeight,r=c.offsetWidth,c=c.style,f=(d?(d=window.getComputedStyle(f,null).getPropertyValue("max-width"),c.width="100%",c.maxHeight="calc(".concat(d," * ").concat(a," / ").concat(r,")")):(c.display="block",c.marginLeft="auto",c.marginRight="auto",d=r>f.offsetWidth?f.offsetWidth:r,f=r>f.offsetWidth?d*a/r:r*(a/r),c.maxHeight="".concat(f,"px"),c.width="".concat(d,"px")),100*a/r);c.height="".concat(f,"vw"),c.maxWidth="100%"}})});