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($) { 13 14 "use strict"; 15 16 $.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 $.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*='youtu.be/']", 40 "iframe[src*='youtube-nocookie.com']", 41 "iframe[src*='kickstarter.com'][src*='video.html']", 42 "iframe[src*='blip.tv/']", // Problematic, empty space below video 43 "iframe[src*='dailymotion.com/']", 44 "iframe[src*='dai.ly/']", 45 "iframe[src*='flickr.com/']", 46 "iframe[src*='flic.kr/']", 47 "iframe[src*='smugmug.com/']", 48 "iframe[src*='hulu.com/']", 49 "iframe[src*='viddler.com/']", 50 "iframe[src*='revision3.com/']", 51 "iframe[src*='wordpress.tv/']", 52 "iframe[src*='funnyordie.com/']", 53 "iframe[src*='slideshare.net/']", 54 "iframe[src*='instagram.com/p/']", 55 "iframe[src*='instagr.am/p/']", 56 "iframe[src*='scribd.com/']", 57 "object", 58 "embed" 59 ]; 60 61 if (settings.customSelector) { 62 selectors.push(settings.customSelector); 63 } 64 65 var ignoreList = '.fitvidsignore'; 66 67 if (settings.ignore) { 68 ignoreList = ignoreList + ', ' + settings.ignore; 69 } 70 71 var $allVideos = $(this).find(selectors.join(',')); 72 $allVideos = $allVideos.not("object object"); // SwfObj conflict patch 73 $allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video. 74 75 $allVideos.each(function() { 76 var $this = $(this); 77 if ($this.parents(ignoreList).length > 0) { 78 return; // Disable FitVids on this video. 79 } 80 if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { 81 return; 82 } 83 if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width')))) { 84 $this.attr('height', 9); 85 $this.attr('width', 16); 86 } 87 var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(), 88 width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(), 89 aspectRatio = height / width; 90 if (!$this.attr('id')) { 91 var videoID = 'fitvid' + Math.floor(Math.random() * 999999); 92 $this.attr('id', videoID); 93 } 94 $this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100) + "%"); 95 $this.removeAttr('height').removeAttr('width'); 96 }); 97 }); 98 }; 99// Works with either jQuery or Zepto 100})(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.