1function iframeAutoScale() { 2 3 'use strict'; 4 5 var 6 iframes = document.getElementsByTagName('iframe'), 7 index = 0; 8 9 if (iframes.length > 0) { 10 for (index = 0; index < iframes.length; index++) { 11 var 12 iframe = iframes[index], 13 parent = iframe.parentElement, 14 parentPadding = parseInt(window.getComputedStyle(parent, null).getPropertyValue('padding-left')) + parseInt(window.getComputedStyle(parent, null).getPropertyValue('padding-right')), 15 parentWidth = parent.clientWidth - parentPadding, 16 ratio = 0.75, // default ratio (4:3) 17 width = iframe.clientWidth, 18 height = iframe.clientHeight; 19 20 // overwrite default ratio if width and height attributes are not set 21 if (width !== undefined && height !== undefined) { 22 ratio = height / width; 23 } 24 25 iframe.setAttribute('width', parentWidth); 26 iframe.setAttribute('height', parentWidth * ratio); 27 } 28 } 29 } 30 31 // onload 32 document.addEventListener('DOMContentLoaded', function () { 33 iframeAutoScale(); 34 }, false); 35 36 // on window resize 37 window.onresize = function(event) { 38 iframeAutoScale(); 39 };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.