(function () { window.foundEe = window.foundEe || {}; window.foundEe.embedsResizer = window.foundEe.embedsResizer || new EmbedsResizer(); var resizer = window.foundEe.embedsResizer; resizer.registerEmbed(document.getElementById("iframe-0dEQe93")); function EmbedsResizer(){ var self = this; this.embeds = []; this.registerEmbed= function (frame) { this.embeds.push(frame) }; window.onresize = function(event) { doResize(); }; window.onload = function(event) { doResize(); }; function getAvailableWidth(unit, frame) { //get current font size for em calculations var fontSize = parseInt(window.getComputedStyle(frame.parentElement).fontSize); var width = unit === 'px' ? frame.parentElement.clientWidth : frame.parentElement.clientWidth / fontSize; return Math.floor(width); } function doResize() { self.embeds.forEach(function (embed) { var referenceWidth = embed.getAttribute("data-original-width"); var referenceWidthValue = parseInt(referenceWidth); var referenceWidthType = referenceWidth.indexOf('px') !== -1 ? 'px' : (referenceWidth.indexOf('em') !== -1 ? 'em' : '%'); var availableWidth = getAvailableWidth(referenceWidthType, embed); //for % we always use reference width if(availableWidth <= referenceWidthValue && referenceWidthType !== '%') { embed.style.width = '100%'; } else { embed.style.width = referenceWidthValue + referenceWidthType; } }) } } })();