Theme Inspinia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

responsible-video.js 714B

123456789101112131415161718192021
  1. $(function() {
  2. var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], object, embed"),
  3. $fluidEl = $("figure");
  4. $allVideos.each(function() {
  5. $(this)
  6. // jQuery .data does not work on object/embed elements
  7. .attr('data-aspectRatio', this.height / this.width)
  8. .removeAttr('height')
  9. .removeAttr('width');
  10. });
  11. $(window).resize(function() {
  12. var newWidth = $fluidEl.width();
  13. $allVideos.each(function() {
  14. var $el = $(this);
  15. $el
  16. .width(newWidth)
  17. .height(newWidth * $el.attr('data-aspectRatio'));
  18. });
  19. }).resize();
  20. });