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* Modified by Chris Jean of iThemes.com to be more universal 9* 10* Date: Thu Sept 01 18:00:00 2011 -0500 11*/ 12 13(function( $ ) { 14 $.fn.fitVidsMaxWidthMod = function( options ) { 15 var settings = { 16 customSelector: null 17 } 18 19 var div = document.createElement('div'), 20 ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0]; 21 22 div.className = 'fit-vids-style'; 23 div.innerHTML = '­<style> \ 24 .fluid-width-video-wrapper { \ 25 width: 100%; \ 26 position: relative; \ 27 padding: 0; \ 28 } \ 29 \ 30 .fluid-width-video-wrapper iframe, \ 31 .fluid-width-video-wrapper object, \ 32 .fluid-width-video-wrapper embed { \ 33 position: absolute; \ 34 top: 0; \ 35 left: 0; \ 36 width: 100%; \ 37 height: 100%; \ 38 } \ 39 </style>'; 40 41 ref.parentNode.insertBefore(div,ref); 42 43 if ( options ) { 44 $.extend( settings, options ); 45 } 46 47 return this.each( function() { 48 var selectors = [ 49 "iframe[src*='player.vimeo.com']", 50 "iframe[src*='www.youtube.com']", 51 "iframe[src*='www.kickstarter.com']", 52 "object", 53 "embed" 54 ]; 55 56 if (settings.customSelector) { 57 selectors.push(settings.customSelector); 58 } 59 60 var $allVideos = $(this).find(selectors.join(',')); 61 62 $allVideos.each( function() { 63 var $this = $(this); 64 if ( ( ( 'embed' == this.tagName.toLowerCase() ) && $this.parent('object').length ) || $this.parent('.fluid-width-video-wrapper').length ) { 65 return; 66 } 67 68 var height = ( ( 'object' == this.tagName.toLowerCase() ) || $this.attr( 'height' ) ) ? $this.attr('height') : $this.height(); 69 if ( ( 'undefined' == typeof height ) || String( height ).match(/[^\d]/) || height <= 0 ) { 70 height = 0; 71 72 if ( $this.parent().css('height') ) { 73 height = $this.parent().css('height').replace(/px$/, ''); 74 75 if ( ! height.match(/^\d+/) ) 76 height = 0; 77 } 78 79 if ( height.match(/[^\d]/) || height <= 0 ) 80 height = $this.height(); 81 } 82 83 var width = ( this.tagName.toLowerCase() == 'object' || $this.attr('width') ) ? $this.attr('width') : $this.width(); 84 if ( ( 'undefined' == typeof width ) || String( width ).match(/[^\d]/) || width <= 0 ) { 85 width = 0; 86 87 if ( $this.parent().css('width') ) { 88 width = $this.parent().css('width').replace(/px$/, ''); 89 90 if ( ! width.match(/^\d+/) ) 91 width = 0; 92 } 93 94 if ( width.match(/[^\d]/) || width <= 0 ) 95 width = $this.width(); 96 } 97 var aspectRatio = height / width; 98 99 if ( $this.parent() && $this.parent().attr('id') && $this.parent().attr('id').match(/^jwplayer/) ) { 100 $this.parent().css( { 'height': 'auto', 'width': 'auto', 'max-height': height + 'px', 'max-width': width + 'px' } ); 101 } 102 103 if ( ! $this.attr('id') ) { 104 var videoID = 'fitvid' + Math.floor( Math.random() * 999999 ); 105 $this.attr( 'id', videoID ); 106 } 107 $wrapper = $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%"); 108 $this.removeAttr('height').removeAttr('width'); 109 110 $outer_wrapper = $wrapper.wrap('<div class="fluid-width-video-container"></div>').parent('.fluid-width-video-container').css({'max-width': width + 'px', 'max-height': height + 'px'}); 111 }); 112 }); 113 } 114})( 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.