1/* 2============= 03. FitVids 1.1 ============= 3* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com 4* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ 5* Released under the WTFPL license - http://sam.zoy.org/wtfpl/ 6* 7*/ 8/*jshint browser:true */ 9;(function( $ ){ 10 11 'use strict'; 12 13 $.fn.fitVids = function( options ) { 14 var settings = { 15 customSelector: null, 16 ignore: null 17 }; 18 19 if(!document.getElementById('fit-vids-style')) { 20 // appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js 21 var head = document.head || document.getElementsByTagName('head')[0]; 22 var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}'; 23 var div = document.createElement("div"); 24 div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>'; 25 head.appendChild(div.childNodes[1]); 26 } 27 28 if ( options ) { 29 $.extend( settings, options ); 30 } 31 32 return this.each(function(){ 33 var selectors = [ 34 'iframe[src*="player.vimeo.com"]', 35 'iframe[src*="youtube.com"]', 36 'iframe[src*="youtube-nocookie.com"]', 37 'iframe[src*="kickstarter.com"][src*="video.html"]', 38 'object', 39 'embed' 40 ]; 41 42 if (settings.customSelector) { 43 selectors.push(settings.customSelector); 44 } 45 46 var ignoreList = '.fitvidsignore'; 47 48 if(settings.ignore) { 49 ignoreList = ignoreList + ', ' + settings.ignore; 50 } 51 52 var $allVideos = $(this).find(selectors.join(',')); 53 $allVideos = $allVideos.not('object object'); // SwfObj conflict patch 54 $allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video. 55 56 $allVideos.each(function(){ 57 var $this = $(this); 58 if($this.parents(ignoreList).length > 0) { 59 return; // Disable FitVids on this video. 60 } 61 if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; } 62 if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width')))) 63 { 64 $this.attr('height', 9); 65 $this.attr('width', 16); 66 } 67 var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(), 68 width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(), 69 aspectRatio = height / width; 70 if(!$this.attr('name')){ 71 var videoName = 'fitvid' + $.fn.fitVids._count; 72 $this.attr('name', videoName); 73 $.fn.fitVids._count++; 74 } 75 $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%'); 76 $this.removeAttr('height').removeAttr('width'); 77 }); 78 }); 79 }; 80 81 // Internal counter for unique video names. 82 $.fn.fitVids._count = 0; 83 84// Works with either jQuery or Zepto 85})( window.jQuery || window.Zepto );
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.