1(function ( window, document, undefined ) { 2 3 /* 4 * Grab all iframes on the page or return 5 */ 6 var iframes = document.getElementsByTagName( 'iframe' ); 7 8 /* 9 * Loop through the iframes array 10 */ 11 for ( var i = 0; i < iframes.length; i++ ) { 12 13 var iframe = iframes[i], 14 15 /* 16 * RegExp, extend this if you need more players 17 */ 18 players = /www.youtube.com|player.vimeo.com/; 19 20 /* 21 * If the RegExp pattern exists within the current iframe 22 */ 23 if ( iframe.src.search( players ) > 0 ) { 24 25 /* 26 * Calculate the video ratio based on the iframe's w/h dimensions 27 */ 28 var videoRatio = ( iframe.height / iframe.width ) * 100; 29 30 /* 31 * Replace the iframe's dimensions and position 32 * the iframe absolute, this is the trick to emulate 33 * the video ratio 34 */ 35 iframe.style.position = 'absolute'; 36 iframe.style.top = '0'; 37 iframe.style.left = '0'; 38 iframe.width = '100%'; 39 iframe.height = '100%'; 40 41 /* 42 * Wrap the iframe in a new <div> which uses a 43 * dynamically fetched padding-top property based 44 * on the video's w/h dimensions 45 */ 46 var wrap = document.createElement( 'div' ); 47 wrap.className = 'fluid-vids'; 48 wrap.style.width = '100%'; 49 wrap.style.position = 'relative'; 50 wrap.style.paddingTop = videoRatio + '%'; 51 52 /* 53 * Add the iframe inside our newly created <div> 54 */ 55 var iframeParent = iframe.parentNode; 56 iframeParent.insertBefore( wrap, iframe ); 57 wrap.appendChild( iframe ); 58 59 } 60 61 } 62 63})( window, document );
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.