//# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // //# RESPONSIVEVIDEO (function($) { $.fn.responsiveVideo = function(config) { //: var defaults = {}; //: var options = $.extend({}, defaults, config); //: return this.each(function() { var $node = $(this); var $video = $node.find('video'); if ( $video.length > 0 ) { var containerWidth = $node.width(); var containerHeight = $node.height(); var wideoWidth = $video.attr('width'); var wideoHeight = $video.attr('height'); $video.attr('width', '').attr('height', ''); var newWidth = containerWidth; var newHeight = Math.round( newWidth * (wideoHeight / wideoWidth) ); $video.attr('width', '100%').attr('height', newHeight); $video.css( { width: '100%', height: newHeight+'px' } ); $(window).on('resize', function(e) { var newWidth = $node.width(); var newHeight = Math.round( newWidth * (wideoHeight / wideoWidth) ); $video.attr('width', '100%').attr('height', newHeight); $video.css( { width: '100%', height: newHeight+'px' } ); }); // consoleLog( $video, ' | ', $node ); //: Test } }); }; })(jQuery);