/*global jquery */ /*! * fitvids 1.0 * * copyright 2011, chris coyier - http://css-tricks.com + dave rupert - http://daverupert.com * credit to thierry koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/ * released under the wtfpl license - http://sam.zoy.org/wtfpl/ * * date: thu sept 01 18:00:00 2011 -0500 */ (function( $ ){ $.fn.fitvids = function( options ) { var settings = { customselector: null } var div = document.createelement('div'), ref = document.getelementsbytagname('base')[0] || document.getelementsbytagname('script')[0]; div.classname = 'fit-vids-style'; div.innerhtml = '­'; ref.parentnode.insertbefore(div,ref); if ( options ) { $.extend( settings, options ); } return this.each(function(){ var selectors = [ "iframe[src*='player.vimeo.com']", "iframe[src*='www.youtube.com']", "iframe[src*='www.kickstarter.com']", "object", "embed" ]; if (settings.customselector) { selectors.push(settings.customselector); } var $allvideos = $(this).find(selectors.join(',')); $allvideos.each(function(){ var $this = $(this); if (this.tagname.tolowercase() == 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; } var height = ( this.tagname.tolowercase() == 'object' || $this.attr('height') ) ? $this.attr('height') : $this.height(), width = $this.attr('width') ? $this.attr('width') : $this.width(), aspectratio = height / width; if(!$this.attr('id')){ var videoid = 'fitvid' + math.floor(math.random()*999999); $this.attr('id', videoid); } $this.wrap('
').parent('.fluid-width-video-wrapper').css('padding-top', (aspectratio * 100)+"%"); $this.removeattr('height').removeattr('width'); }); }); } })( jquery );