1/*global jQuery */ 2/*! 3* FitVids 1.0 4* 5* Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com 6* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ 7* Released under the WTFPL license - http://sam.zoy.org/wtfpl/ 8* 9* Date: Thu Sept 01 18:00:00 2011 -0500 10*/ 11 12/*global jQuery */ 13/*! 14* FitVids 1.0 15* 16* Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com 17* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ 18* Released under the WTFPL license - http://sam.zoy.org/wtfpl/ 19* 20* Date: Thu Sept 01 18:00:00 2011 -0500 21*/ 22 23(function( $ ){ 24 25 $.fn.fitVids = function( options ) { 26 var settings = { 27 customSelector: null 28 } 29 30 var div = document.createElement('div'), 31 ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0]; 32 33 div.className = 'fit-vids-style'; 34 div.innerHTML = '­<style> \ 35.fluid-width-video-wrapper { \ 36width: 100%; \ 37position: relative; \ 38padding: 0; \ 39} \ 40\ 41.fluid-width-video-wrapper iframe, \ 42.fluid-width-video-wrapper object, \ 43.fluid-width-video-wrapper embed { \ 44position: absolute; \ 45top: 0; \ 46left: 0; \ 47width: 100%; \ 48height: 100%; \ 49} \ 50</style>'; 51 52 ref.parentNode.insertBefore(div,ref); 53 54 if ( options ) { 55 $.extend( settings, options ); 56 } 57 58 return this.each(function(){ 59 var selectors = [ 60 "iframe[src*='player.vimeo.com']", 61 "iframe[src*='www.youtube.com']", 62 "iframe[src*='www.kickstarter.com']", 63 "object", 64 "embed" 65 ]; 66 67 if (settings.customSelector) { 68 selectors.push(settings.customSelector); 69 } 70 71 var $allVideos = $(this).find(selectors.join(',')); 72 73 $allVideos.each(function(){ 74 var $this = $(this); 75 if (this.tagName.toLowerCase() == 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; } 76 var height = this.tagName.toLowerCase() == 'object' ? $this.attr('height') : $this.height(), 77 aspectRatio = height / $this.width(); 78if(!$this.attr('id')){ 79var videoID = 'fitvid' + Math.floor(Math.random()*999999); 80$this.attr('id', videoID); 81} 82 $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%"); 83 $this.removeAttr('height').removeAttr('width'); 84 }); 85 }); 86 87 } 88})( jQuery );
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.