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* Modified by ElegantThemes to exclude fancybox videos ( line: 68 ) 10* 11* Date: Thu Sept 01 18:00:00 2011 -0500 12*/ 13 14(function( $ ){ 15 16 $.fn.fitVids = function( options ) { 17 var settings = { 18 customSelector: null 19 } 20 21 var div = document.createElement('div'), 22 ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0]; 23 24 div.className = 'fit-vids-style'; 25 div.innerHTML = '­<style> \ 26 .fluid-width-video-wrapper { \ 27 width: 100%; \ 28 position: relative; \ 29 padding: 0; \ 30 } \ 31 \ 32 .fluid-width-video-wrapper iframe, \ 33 .fluid-width-video-wrapper object, \ 34 .fluid-width-video-wrapper embed { \ 35 position: absolute; \ 36 top: 0; \ 37 left: 0; \ 38 width: 100%; \ 39 height: 100%; \ 40 } \ 41 </style>'; 42 43 ref.parentNode.insertBefore(div,ref); 44 45 if ( options ) { 46 $.extend( settings, options ); 47 } 48 49 return this.each(function(){ 50 var selectors = [ 51 "iframe[src^='http://player.vimeo.com']", 52 "iframe[src^='http://www.youtube.com']", 53 "iframe[src^='http://www.kickstarter.com']", 54 "object", 55 "embed" 56 ]; 57 58 if (settings.customSelector) { 59 selectors.push(settings.customSelector); 60 } 61 62 var $allVideos = $(this).find(selectors.join(',')); 63 64 $allVideos.each(function(){ 65 var $this = $(this); 66 67 // don't apply fluid width to fancybox videos 68 if ( $this.closest('.et_embedded_videos').length ) return; 69 70 if (this.tagName.toLowerCase() == 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; } 71 var height = this.tagName.toLowerCase() == 'object' ? $this.attr('height') : $this.height(), 72 aspectRatio = height / $this.width(); 73 $this.wrap('<div class="fluid-width-video-wrapper" />').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%"); 74 $this.removeAttr('height').removeAttr('width'); 75 }); 76 }); 77 78 } 79})( 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.