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